Re: [gentoo-user] working with overlays
On Friday 22 December 2006 20:09, Benno Schulenberg wrote: Bo once said (or was it someone else?) he had such a script. If so, Bo, please post the script. You may be referring to this post: http://thread.gmane.org/gmane.linux.gentoo.user/164432/focus=164437 -- Bo Andresen pgp0VEvG6aAi5.pgp Description: PGP signature
Re: [gentoo-user] working with overlays
Bo Ørsted Andresen wrote: On Friday 22 December 2006 20:09, Benno Schulenberg wrote: Bo once said (or was it someone else?) he had such a script. If so, Bo, please post the script. You may be referring to this post: http://thread.gmane.org/gmane.linux.gentoo.user/164432/focus=164437 Ah, yes. Thanks. Meanwhile my own script evolved a little further: -8-- #!/bin/bash # ovlay.sh version 0.2 OVERLAY=/usr/local/portage unset BUMP DELETE EDIT HELP NEWVERSION RENUMBER REST if [[ -z $EDITOR ]]; then EDITOR=vim fi for ARGUMENT in $*; do if [[ $BUMP == take ]]; then NEWVERSION=$ARGUMENT BUMP=yes continue fi case $ARGUMENT in -b|--bump) BUMP=take;; -d|--delete)DELETE=yes;; -e|--edit) EDIT=yes;; -h|--help) HELP=yes;; -r|--renumber) RENUMBER=yes;; *) REST=$REST $ARGUMENT;; esac done # Redefine positional arguments: set -- $REST if [[ $HELP || -z $1 ]]; then PROGRAM=${0##/[a-z]*/} echo Usage: $PROGRAM [-e|--edit] package_name [patch_name...] echo $PROGRAM -d|--delete package_name... echo $PROGRAM -b|--bump new_version_number [-r|--renumber] package_name echo echo Copies the latest ebuild of the specified package to the local overlay, echo and optionally allows you to bump it, insert patches, and edit it. exit 0 elif [[ $BUMP == take ]]; then echo Specify a new version number. exit 2 elif [[ $RENUMBER -z $BUMP ]]; then echo Renumbering is only possible with version bumping. exit 2 fi if [[ $DELETE ]]; then if [[ $BUMP || $EDIT || $RENUMBER ]]; then echo Deletion does not go together with other options. exit 2 fi while [[ $1 ]]; do if ls -d /${OVERLAY}/*/$1 /dev/null; then rm -r /${OVERLAY}/*/$1 else echo There is no overlay for '$1'. exit 2 fi shift done # Remove empty dirs (there must be a better way): ls -dl /${OVERLAY}/* | grep x 2 root | sed 's/.* //' | while read dir; do rmdir $dir; done exit 0 fi ##shopt -s -o xtrace EMERGEOUT=$(emerge -qOp $1 2/dev/null) if [[ $? != 0 ]]; then EMERGEOUT=$(emerge -qOp =$1 2/dev/null) if [[ $? != 0 ]]; then echo Package '$1' not found. exit 2 fi fi NAMENUMBER=$(echo $EMERGEOUT | sed -e 's:^[^/]*\]::' -e 's:\[.*$::' -e 's: ::g') CATPACK=${NAMENUMBER%%-[0-9]*} PACKAGE=${NAMENUMBER##[a-z]*/} FULLPATH=${OVERLAY}/${CATPACK} NAME=${PACKAGE%%-[0-9]*} VERSION=${PACKAGE##[a-z]*-} if [[ $NAME != $1 $PACKAGE != $1 ]]; then echo *Internal error*: determination of package name is wrong. exit 4 fi # When wanting to edit an already existing ebuild and not giving any further # arguments, do not first recreate the ebuild, but just allow editting it: if [[ $EDIT -f /$FULLPATH/${PACKAGE}.ebuild -z $2 ]]; then vim /$FULLPATH/${PACKAGE}.ebuild ebuild ${FULLPATH}/${PACKAGE}.ebuild digest /dev/null emerge -pqv =${PACKAGE} exit 0 fi mkdir -p /${FULLPATH} cp /usr/portage/${CATPACK}/${PACKAGE}.ebuild /${FULLPATH}/ cp -a /usr/portage/${CATPACK}/files /${FULLPATH}/ if [[ $BUMP ]]; then mv /${FULLPATH}/${PACKAGE}.ebuild /${FULLPATH}/${NAME}-${NEWVERSION}.ebuild if [[ $RENUMBER ]]; then # Renumber versioned patches: rename ${VERSION} ${NEWVERSION} /${FULLPATH}/files/*${VERSION}* fi PACKAGE=${NAME}-${NEWVERSION} fi # Insert any trailing arguments as patches: if [[ $2 ]]; then echo -e '\n\npost_src_unpack() { cd ${S}' /${FULLPATH}/${PACKAGE}.ebuild while [[ $2 ]]; do if [[ ! -f $2 ]]; then echo Patch file '$2' not found. exit 2 fi cp $2 /${FULLPATH}/files/ echo -e '\tepatch ${FILESDIR}/'$2 /${FULLPATH}/${PACKAGE}.ebuild shift done echo -e }\n /${FULLPATH}/${PACKAGE}.ebuild fi if [[ $EDIT ]]; then vim /$FULLPATH/${PACKAGE}.ebuild fi rm /$FULLPATH/files/digest-* # Strangely this does not allow a double leading slash: ebuild ${FULLPATH}/${PACKAGE}.ebuild digest /dev/null emerge -pqv =${PACKAGE} -8-- Benno -- Cetere mi opinias ke ne ĉio tradukenda estas. -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] working with overlays
Neil Bothwick wrote: On Fri, 22 Dec 2006 20:09:55 +0100, Benno Schulenberg wrote: mkdir -p /usr/local/portage/category/package ## Dont't copy all ebuilds, just the one to be tweaked: Unless you are really short of disk space, what's wrong with copying the complete package directory - it makes life much simpler. There's nothing wrong with it, but it makes life harder: now I must remember which of the ebuilds in /usr/local/portage/*/* I have patched and which not. It's much easier to have only ebuilds in there that I've actually changed. If you just want to add a patch, you can do it with bashrc, no need to mess with overlays: http://forums.gentoo.org/viewtopic-t-339019.html (Or http://dev.gentoo.org/~solar/portage_misc/bashrc.autopatch for the original.) Well, yes, that is one way. But mostly I do not want things to be autopatched: I just want to change this one version and not any newer one. And I do not want to have to remember to remove /usr/portage/local/patches/category/package afterwards; patch, emerge and forget is easier. Also, when using overlays 'emerge -pev world' will immediately show which packages have been patched (because coming from my overlay). When autopatching, one has to check /usr/portage/local/patches/ separately. There's a script floating around that will copy an ebuild to your overlay and bump its version. Found it here: http://forums.gentoo.org/viewtopic.php?p=445501 Since this script is a bit too verbose for my taste, I've continued working on my own. Using the post_src_unpack() function mentioned by Bo, the inserting of patches becomes pretty easy. See the attached file. Suggestions and improvements are welcome. But neither of these are related to the original question, which was about preserving old versions. Yes, sorry for changing focus; I was reacting to this: Overlays are there specifically for people who need something different from the standard portage tree. Benno ovlay.sh Description: application/shellscript
Re: [gentoo-user] working with overlays
Neil Bothwick wrote: Overlays are there specifically for people who need something different from the standard portage tree. They are hardly difficult to use, Not difficult, but it is clumsy: mkdir -p /usr/local/portage/category/package ## Dont't copy all ebuilds, just the one to be tweaked: cp /usr/portage/category/package/packag-x.y.z.ebuild /usr/local/portage/category/package/ ## Copy all possible patches: cp -a /usr/portage/category/package/files /usr/local/portage/category/package/ ## Copy the new patch too: cp package-foo-bar.patch /usr/local/portage/category/package/files/ ## Edit the ebuild and insert an 'epatch ${FILESDIR}/package-foo-bar.patch' command: vim /usr/local/portage/category/package/package-x.y.z.ebuild [search for src_unpack(), insert extra command at end, :wq] ## Recreate digest: ebuild /usr/local/portage/category/package/package-x.y.z.ebuild digest ## Finally, emerge the thing: emerge -1 package How hard is that? Not hard, but a nuisance. Of course one could write a script that automates all those seven steps into a single command, but it has proven a bit beyond my skills (the finding of the category when just saying 'ovlay.sh package', not to mention the insertion of an epatch command). Bo once said (or was it someone else?) he had such a script. If so, Bo, please post the script. Or better yet, push it upstream. Portage knows about overlays, but doesn't have any commands to make working with them easy. It really should include a command that copies the latest ebuild of a given package to an overlay, and inserts epatch commands for all the additional arguments. Benno -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] working with overlays
On Fri, 22 Dec 2006 20:09:55 +0100, Benno Schulenberg wrote: Overlays are there specifically for people who need something different from the standard portage tree. They are hardly difficult to use, Not difficult, but it is clumsy: mkdir -p /usr/local/portage/category/package ## Dont't copy all ebuilds, just the one to be tweaked: Unless you are really short of disk space, what's wrong with copying the complete package directory - it makes life much simpler. cp /usr/portage/category/package/packag-x.y.z.ebuild /usr/local/portage/category/package/ ## Copy all possible patches: cp -a /usr/portage/category/package/files /usr/local/portage/category/package/ ## Copy the new patch too: cp package-foo-bar.patch /usr/local/portage/category/package/files/ ## Edit the ebuild and insert an 'epatch ${FILESDIR}/package-foo-bar.patch' command: vim /usr/local/portage/category/package/package-x.y.z.ebuild [search for src_unpack(), insert extra command at end, :wq] ## Recreate digest: ebuild /usr/local/portage/category/package/package-x.y.z.ebuild digest ## Finally, emerge the thing: emerge -1 package If you just want to add a patch, you can do it with bashrc, no need to mess with overlays: http://forums.gentoo.org/viewtopic-t-339019.html Not hard, but a nuisance. Of course one could write a script that automates all those seven steps into a single command, but it has proven a bit beyond my skills (the finding of the category when just saying 'ovlay.sh package', not to mention the insertion of an epatch command). Bo once said (or was it someone else?) he had such a script. There's a script floating around that will copy an ebuild to your overlay and bump its version. Adding patches is easier with bashrc. But neither of these are related to the original question, which was about preserving old versions. for that you only need at most one mkdir and exactly one cp. -- Neil Bothwick Bookmark - A means of returning to where you got lost last time. signature.asc Description: PGP signature