From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.62) (envelope-from ) id 1H1UDG-0002Uf-MQ for garchives@archives.gentoo.org; Mon, 01 Jan 2007 20:56:55 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.8/8.13.8) with SMTP id l01KsfFp026605; Mon, 1 Jan 2007 20:54:41 GMT Received: from psmtp13.wxs.nl (psmtp13.wxs.nl [195.121.247.25]) by robin.gentoo.org (8.13.8/8.13.8) with ESMTP id l01Kqbqw011178 for ; Mon, 1 Jan 2007 20:52:38 GMT Received: from graskamp (ip51cfa1ef.direct-adsl.nl [81.207.161.239]) by psmtp13.wxs.nl (iPlanet Messaging Server 5.2 HotFix 2.15 (built Nov 14 2006)) with ESMTP id <0JB7002JFJBP7J@psmtp13.wxs.nl> for gentoo-user@lists.gentoo.org; Mon, 01 Jan 2007 21:52:37 +0100 (MET) Date: Mon, 01 Jan 2007 21:52:21 +0100 From: Benno Schulenberg Subject: Re: [gentoo-user] working with overlays In-reply-to: <200701011831.36066.bo.andresen@zlin.dk> To: gentoo-user@lists.gentoo.org Message-id: <200701012152.21114.benno.schulenberg@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-disposition: inline User-Agent: KMail/1.9.5 References: <49bf44f10612180647g6ac243ebm9cfa8b79a5aeb3b5@mail.gmail.com> <200612222009.56010.benno.schulenberg@gmail.com> <200701011831.36066.bo.andresen@zlin.dk> Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by robin.gentoo.org id l01KsfGK026605 X-Archives-Salt: 8af3daf7-3c6f-4332-979e-01b28ebaba58 X-Archives-Hash: bcf6e9cf7df6eab59a560a90fe07bdbb Bo =C3=98rsted 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. =C2=A0If so, Bo, please post the script. > > You may be referring to this post: > > http://thread.gmane.org/gmane.linux.gentoo.user/164432/focus=3D164437 Ah, yes. Thanks. Meanwhile my own script evolved a little further: -----8<------------------------------------------ #!/bin/bash # ovlay.sh version 0.2 OVERLAY=3D/usr/local/portage unset BUMP DELETE EDIT HELP NEWVERSION RENUMBER REST if [[ -z $EDITOR ]]; then EDITOR=3D"vim" fi for ARGUMENT in $*; do if [[ "$BUMP" =3D=3D "take" ]]; then NEWVERSION=3D"$ARGUMENT" BUMP=3D"yes" continue fi case "$ARGUMENT" in "-b"|"--bump") BUMP=3D"take";; "-d"|"--delete") DELETE=3D"yes";; "-e"|"--edit") EDIT=3D"yes";; "-h"|"--help") HELP=3D"yes";; "-r"|"--renumber") RENUMBER=3D"yes";; *) REST=3D"$REST $ARGUMENT";; esac done # Redefine positional arguments: set -- $REST if [[ $HELP || -z "$1" ]]; then PROGRAM=3D${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] p= ackage_name" echo "" echo "Copies the latest ebuild of the specified package to the local ove= rlay," echo "and optionally allows you to bump it, insert patches, and edit it.= " exit 0 elif [[ "$BUMP" =3D=3D "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=09 ##shopt -s -o xtrace EMERGEOUT=3D"$(emerge -qOp $1 2>/dev/null)" if [[ $? !=3D 0 ]]; then EMERGEOUT=3D"$(emerge -qOp =3D$1 2>/dev/null)" if [[ $? !=3D 0 ]]; then echo "Package '$1' not found." exit 2 fi fi NAMENUMBER=3D$(echo $EMERGEOUT | sed -e 's:^[^/]*\]::' -e 's:\[.*$::' -e = 's: ::g') CATPACK=3D${NAMENUMBER%%-[0-9]*} PACKAGE=3D${NAMENUMBER##[a-z]*/} FULLPATH=3D${OVERLAY}/${CATPACK} NAME=3D${PACKAGE%%-[0-9]*} VERSION=3D${PACKAGE##[a-z]*-} if [[ $NAME !=3D $1 && $PACKAGE !=3D $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 furt= her # 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 =3D${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}.ebu= ild if [[ $RENUMBER ]]; then # Renumber versioned patches: rename "${VERSION}" "${NEWVERSION}" /${FULLPATH}/files/*${VERSION}* fi PACKAGE=3D${NAME}-${NEWVERSION} fi # Insert any trailing arguments as patches: if [[ "$2" ]]; then echo -e '\n\npost_src_unpack() { cd ${S}' >>/${FULLPATH}/${PACKAGE}.ebui= ld 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 =3D${PACKAGE} -----8<------------------------------------------ Benno --=20 Cetere mi opinias ke ne =C4=89io tradukenda estas. --=20 gentoo-user@gentoo.org mailing list