#!/bin/bash MESSAGE="Version bump." ROOT="/home/donnie/src/gentoo-x86" CATEGORY="${PWD##*/}" DEBUG=0 COMMIT=0 if [[ $# -eq 0 ]]; then echo "Usage: ${0##*/} [-c] [-b] [-m MESSAGE] [-d ROOT] [-p PACKAGE] [-p PACKAGE] [...]" echo echo "Will bump any number of packages in PWD, which should be a category." echo "Assumes that the ebuild in PWD has already been bumped to the new version." echo "By default, bumps all packages in a category." echo echo "-c Required for committing; otherwise, does a dry run" echo "-b Debugging; dry run" echo "-m MESSAGE Use this for a commit message" echo "-d ROOT Use this CVS root" echo "-p PACKAGE Bump these packages" echo echo "Default settings:" echo " MESSAGE='${MESSAGE}'" echo " ROOT=${ROOT}" echo " PACKAGES=${PACKAGES}" exit 1 fi while getopts m:d:p:bc OPT; do case ${OPT} in m) MESSAGE=${OPTARG} ;; d) [[ -d ${OPTARG} ]] && ROOT=${OPTARG} ;; p) [[ -d ${OPTARG} ]] && PACKAGES="${PACKAGES} ${OPTARG%/}" ;; b) DEBUG=1 ;; c) COMMIT=1 ;; esac done shift $((OPTIND - 1)) # Default to all packages in category if [[ -z ${PACKAGES} ]]; then for i in *; do [[ -d ${i} ]] && PACKAGES="${PACKAGES} ${i%/}" done fi # Tag on trailing slashes if needed if [[ ${ROOT:$((${#ROOT}-1)):1} != / ]]; then ROOT="${ROOT}/" fi if [[ ${CATEGORY:$((${#CATEGORY}-1)):1} != / ]]; then CATEGORY="${CATEGORY}/" fi debug() { if [[ ${DEBUG} -eq 1 ]]; then echo "Variable settings:" echo " MESSAGE='${MESSAGE}'" echo " ROOT=${ROOT}" echo " PACKAGES=${PACKAGES}" fi } run() { [[ ${DEBUG} -eq 1 ]] && echo "$*" [[ ${COMMIT} -eq 1 ]] && eval "$*" } commit() { for PACKAGE in ${PACKAGES}; do for EBUILD_PATH in ${PACKAGE}/*.ebuild; do EBUILD=${EBUILD_PATH#*/} run cp ${EBUILD_PATH} ${ROOT}${CATEGORY}${PACKAGE} run pushd ${ROOT}${CATEGORY}${PACKAGE} run cvs up run cvs add ${EBUILD} if [[ $? -eq 0 ]]; then run ekeyword ~all ${EBUILD} fi run popd done run pushd ${ROOT}${CATEGORY}${PACKAGE} run ebuild ${EBUILD} digest run echangelog "'${MESSAGE}'" run repoman ci -m "'${MESSAGE}'" run popd done } debug commit