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