From 86eaf5e03289e45a95514b4f6011157972016e9d Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Thu, 30 Apr 2009 21:52:45 +0000 Subject: Tagging the gentoolkit-0.2.4 release svn path=/tags/gentoolkit-0.2.4/; revision=564 --- src/ebump/AUTHORS | 5 + src/ebump/ChangeLog | 8 ++ src/ebump/Makefile | 20 +++ src/ebump/README | 18 +++ src/ebump/TODO | 0 src/ebump/ebump | 356 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ebump/ebump.1 | 110 ++++++++++++++++ 7 files changed, 517 insertions(+) create mode 100644 src/ebump/AUTHORS create mode 100644 src/ebump/ChangeLog create mode 100644 src/ebump/Makefile create mode 100644 src/ebump/README create mode 100644 src/ebump/TODO create mode 100755 src/ebump/ebump create mode 100644 src/ebump/ebump.1 (limited to 'src/ebump') diff --git a/src/ebump/AUTHORS b/src/ebump/AUTHORS new file mode 100644 index 0000000..2432e06 --- /dev/null +++ b/src/ebump/AUTHORS @@ -0,0 +1,5 @@ +Maintainer: +Karl Trygve Kalleberg + +Original author: +Karl Trygve Kalleberg diff --git a/src/ebump/ChangeLog b/src/ebump/ChangeLog new file mode 100644 index 0000000..4434b94 --- /dev/null +++ b/src/ebump/ChangeLog @@ -0,0 +1,8 @@ +2004-06-21 Karl Trygve Kalleberg + * Fixed handling of deletion. + +2004-03-11 Karl Trygve Kalleberg + * Fixed incorrect cut'ing of wc -l output when updating ChangeLog + +2004-02-08 Karl Trygve Kalleberg + * Initial import diff --git a/src/ebump/Makefile b/src/ebump/Makefile new file mode 100644 index 0000000..aa1d347 --- /dev/null +++ b/src/ebump/Makefile @@ -0,0 +1,20 @@ +# Copyright 2004 Karl Trygve Kalleberg +# Copyright 2004 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# +# $Header$ + +include ../../makedefs.mak + +.PHONY: all +all: + +dist: + mkdir -p ../../$(distdir)/src/ebump/ + cp Makefile AUTHORS README TODO ChangeLog ebump ebump.1 ../../$(distdir)/src/ebump/ + +install: all + install -m 0755 ebump $(bindir)/ + install -d $(docdir)/ebump + install -m 0644 AUTHORS README TODO ChangeLog $(docdir)/ebump/ + install -m 0644 ebump.1 $(mandir)/ diff --git a/src/ebump/README b/src/ebump/README new file mode 100644 index 0000000..c81835c --- /dev/null +++ b/src/ebump/README @@ -0,0 +1,18 @@ + +Package : ebump +Version : 0.1.0 +Author : See AUTHORS + +MOTIVATION + +The ebump utility is a Gentoo-specific tool for bumping the revision of +a given ebuild and auxiliary files in the Portage tree. It is only +useful for Gentoo developers with CVS commit access. + +MECHANICS + +N/A + +IMPROVEMENTS + +N/A diff --git a/src/ebump/TODO b/src/ebump/TODO new file mode 100644 index 0000000..e69de29 diff --git a/src/ebump/ebump b/src/ebump/ebump new file mode 100755 index 0000000..2623a28 --- /dev/null +++ b/src/ebump/ebump @@ -0,0 +1,356 @@ +#! /bin/sh +# +# Copyright (c) 2004 Karl Trygve Kalleberg +# Copyright (c) Gentoo Technologies, Inc. +# Licensed under the GNU General Public License, version 2 +# +# Maintainer: Karl Trygve Kalleberg + +__version__="0.1.0" +__author__="Karl Trygve Kalleberg" +__email__="" +__description__="Ebuild version bumping tool" + + + +die() { + echo $1 > /dev/stderr + exit -1 +} + +einfo() { + if [ ${opt_verbosity} -gt 2 ] ; then + echo $* + fi +} + +print_version() { + echo "${__description__}, v${__version__}" + echo "Copyright (c) 2004 ${__author__} ${__email__}" + echo "Copyright (c) 2004 Gentoo Technologies, Inc." + echo "Licensed under the GNU General Public License, version 2" +} + +print_usage() { + echo "Usage: ebump foo<.ebuild>" + echo "Ebuild version bumping tool, v${__version__}" + echo " -V|--version show version info" + echo " -v|--verbose increase verbosity" + echo " -q|--quiet turn off output" + echo " -C|--no-cvs do not add to CVS" + echo " -m|--message append message to ChangeLog" + echo " -d|--delete-old delete previous revision from CVS (DANGEROUS!)" +} + +# +# Load options from /etc/gentoolkit/ebump.conf and ${HOME}/.gentoo/ebump.conf +# Home directory file takes precedence. +# +load_options() { + + # FIXME: Sourcing config files like this is really a bad idea; users may + # easily override any function in this program inside his config files. + + if [ -f /etc/gentoolkit/ebump.conf ] ; then + . /etc/gentoolkit/ebump.conf + fi + if [ -f ${HOME}/.gentoo/gentool-env ] ; then + . ${HOME}/.gentoo/gentool-env + fi + if [ -f ${HOME}/.gentoo/ebump.conf ] ; then + . ${HOME}/.gentoo/ebump.conf + fi +} + +# +# Find closes ebuild to ${1}, if any +# +find_ebuild() { + f=${1} + + if [ -f ${1} ] ; then + echo ${1} + fi + + if [ -f ${1}.ebuild ] ; then + echo ${1} + fi +} + +# +# splitname (version|name|revision) package-name-version-revision +# +splitname() { + case $1 in + version) + echo ${2} | sed -r "s/.*-([0-9].*)/\1/" + ;; + name) + name=$(echo ${2} | sed -r "s/(.*)-[0-9].*/\1/") + if [ ${name} == ${2} ] ; then + if [ $(echo ${2} | grep "^[0-9].*") ] ; then + # The filename starts with a version number, thus it has no + # name + name="" + else + # The filename doesn't have a recognizeable version number; + # everything is a name + name=${2} + fi + fi + echo ${name} + ;; + revision) + rev=$(echo ${2} | sed -r "s/.*-r([0-9][0-9]*)/\1/") + if [ ${rev} == ${2} ] ; then + rev=0 + fi + echo ${rev} + ;; + vernorev) + ver=$(echo ${2} | sed -r "s/.*-([0-9].*)-r[0-9]+/\1/") + if [ ${ver} == ${2} ] ; then + ver=$(echo ${2} | sed -r "s/.*-([0-9].*)/\1/") + fi + echo ${ver} + ;; + *) + echo + esac +} + +process_ebuild() { + ebuild_arg=${1} + + # Files to add to CVS + addfiles="" + # Files to remove from CVS + delfiles="" + + if [ -z ${ebuild_arg} ] ; then + print_usage + exit + fi + + # + # Try to find a matching ebuild + # + + ebuild_name=$(find_ebuild ${ebuild_arg}) + if [ -z ${ebuild_name} ] ; then + die "Could not find ${ebuild_arg}" + fi + einfo "Processing ebuild ${ebuild_name}" + + # + # Bump revision suffix (or add one) + # + + PF=$(basename ${ebuild_name} .ebuild) + PN=$(splitname name ${PF}) + PV=$(splitname version ${PF}) + rev=$(splitname revision ${PF}) + PV_norev=$(splitname vernorev ${PF}) + newPF=${PN}-${PV_norev}-r$[rev+1] + +# echo $PF / $PN / $PV / $rev / $PV_norev / $newPF + + einfo "Bumped ${PF}.ebuild to ${newPF}.ebuild" + + cp ${PF}.ebuild ${newPF}.ebuild + + addfiles="${addfiles} ${newPF}.ebuild" + delfiles="${delfiles} ${PF}.ebuild" + + # + # (Optional) Bump relevant files in files/ + # + + if [ "${opt_bump_auxfiles}" == "y" ] ; then + + # Gather list of auxiliary files in files/ that has a versioned + # filename, where the version matches our current version. + + bumplist="" + for x in $(echo files/*) ; do + if [ ! -z $(echo $x | grep "${PV}$") ] ; then + bumplist="${bumplist} ${x}" + fi + done + + # Bump version of all matches + + for x in ${bumplist} ; do + + bn=$(basename ${x}) + dn=$(dirname ${x}) + + PN=$(splitname name ${bn}) + PV=$(splitname version ${bn}) + rev=$(splitname revision ${bn}) + PV_norev=$(splitname vernorev ${bn}) + +# echo $PN / ${PV_norev} / ${rev} + + # Special case for when we have no name part; filename + # is just a version number + if [ -z "${PN}" ] ; then + newbn=${PV_norev}-r$[rev+1] + else + newbn=${PN}-${PV_norev}-r$[rev+1] + fi + + if [ -d ${dn}/${bn} ] ; then + if [ -e ${dn}/${newbn} ] ; then + echo "Directory ${dn}/${newbn} exists, not copying" > /dev/stderr + else + cp -a ${dn}/${bn} ${dn}/${newbn} + find ${dn}/${newbn} -name CVS | xargs rm -rf + fi + else + cp ${dn}/${bn} ${dn}/${newbn} + fi + + addfiles="${addfiles} ${dn}/${newbn}" + delfiles="${delfiles} ${dn}/${bn}" + + einfo "Bumped ${dn}/${bn} to ${dn}/${newbn}" + done + fi + +# echo "addfiles ${addfiles}" +# echo "delfiles ${delfiles}" + + filelist="${addfiles}" + # + # (Optional) Add ChangeLog entry + # + + if [ "${opt_add_changelog}" == "y" ] && + [ -f ChangeLog ] ; then + + # Add ChangeLog entry + + curdate=$(LC_TIME="us" date +"%02d %b %Y") + cp ChangeLog ChangeLog.old + ( + # Use header (four first lines) of the old ChangeLog + head -n 4 ChangeLog.old + + # Write new entry + + echo "*${newPF} (${curdate})" + echo + echo " ${curdate}; ${AUTHORNAME} <${AUTHOREMAIL}> ${filelist}" + + # If we don't have a commit message, add comment + if [ -z "${opt_commitmessage}" ] ; then + echo " # INSERT ENTRY HERE" + if [ "${opt_delete_old}" == "y" ] && [ ! -z "${delfiles}" ] ; then + echo " Removed ${delfiles}." + fi + echo + else + echo " ${opt_commitmessage}" + echo + fi + + # Write tail of old ChangeLog + nl=$(wc -l ChangeLog.old | sed -r "s/^([0-9]+).*/\1/") + tail -n $[nl - 4] ChangeLog.old + ) > ChangeLog + rm ChangeLog.old + + einfo "Added ChangeLog entry" + fi + + # + # (Optional) Add CVS entry for all new files + # + + if [ "${opt_add_cvs}" == "y" ] ; then + + # Add all new files to CVS + for x in ${addfiles} ; do + if [ -d ${x} ] ; then + find ${x} | xargs echo cvs add + else + cvs add ${x} + fi + done + einfo "Added ${addfiles} to CVS" + fi + + + # + # (Optional) Delete previous entry + # + + if [ "${opt_delete_old}" == "y" ] ; then + + for x in ${delfiles} ; do + cvs remove -f ${x} + done + einfo "Removed ${delfiles} from CVS" + fi + +} + +original_params=${#} + +# +# Global options +# +opt_verbosity=1 +opt_warn_on_delete=y +opt_add_changelog=y +opt_add_cvs=y +opt_bump_auxfiles=y +opt_delete_old=n +opt_commitmessage="" + +load_options + +skip=0 +while [ ${#} -gt 0 ] ; do + arg=${1} + shift + if [ ${skip} -gt 0 ] ; then + skip=$[skip-1] + else + case ${arg} in + -h|--help) + print_usage + exit 0 + ;; + -m|--message) + opt_commitmessage="${1}" + skip=1 + ;; + -C|--no-cvs) + opt_add_cvs=n + ;; + -V|--version) + print_version + exit + ;; + -v|--verbose) + opt_verbosity=$[opt_verbosity + 1] + ;; + -q|--quiet) + opt_verbosity=0 + ;; + -d|--delete-old) + opt_delete_old=y + ;; + *) + ebuild_arg=${arg} + ;; + esac + fi +done + +process_ebuild ${ebuild_arg} + +# TODO: +# - put cli parser into separate functions diff --git a/src/ebump/ebump.1 b/src/ebump/ebump.1 new file mode 100644 index 0000000..6a64a0a --- /dev/null +++ b/src/ebump/ebump.1 @@ -0,0 +1,110 @@ +.TH "ebump" "1" "0.1.0" "Gentoolkit" "Gentoo Administration" +.SH "NAME" +.LP +ebump \- Gentoo: Ebuild revision bumper +.SH "SYNTAX" +.LP +ebump [\fIoption\fP] <\fIpackage-name[-version]\fP> + +.SH "DESCRIPTION" + +.LP +\fIebump\fR bumps the revision of a particular ebuild, and all auxiliary +files in the files/ directory that have a matching version suffix. + +.LP +By default, the all new revision files will be added to CVS, and a +dummy ChangeLog entry will be made. + +.LP +You must stand in the directory of the ebuild to be bumped. + +.SH "OPTIONS" +.LP +\fB\-C\fR +.br +\fB--no-cvs\fB +.IP +Do not add new files to CVS. + +.LP +\fB\-V\fR +.br +\fB--version\fB +.IP +Display version information and exit. + +.LP +\fB\-v\fR +.br +\fB--verbose\fB +.IP +Increase verbosity level. May be used more than once. + +.LP +\fB\-q\fR +.br +\fB--quiet\fB +.IP +Do not output any non-essential information. + +.LP +\fB\-m\fR <\fIChangeLog text\fR> +.br +\fB\--message\fR <\fIChangeLog text\fR> +.IP +Specifies the message to add to the ChangeLog, instead of the standard +placeholder. + +.LP +\fB\-d\fR +.br +\fB\--delete-old\fR +.IP +Delete old revision and old auxiliary files from CVS. This is +\fIdangerous\fR and should only be used if you know exactly what you are +doing, because +.br +1) the old revision may be stable on a different architecture than the one you +are working on. +.br +2) the auxiliary files may be required by other versions of the ebuild. +.br +3) the new revision should usually undergo a period of testing before being marked stable. + +.SH "CONFIGURATION" + +.LP +\fB/etc/gentoolkit/ebump.conf\fR +.br +\fB~/.gentoo/ebump.conf\fR +.IP +From these files, \fIebump\fR will load the settings +.br +\fBopt_verbosity\fR (default \fI1\fR) - verbosity level 0-10 +.br +\fBopt_add_changelog\fR (default \fIy\fR) - add entry in ChangeLog +.br +\fBopt_add_cvs\fR (default \fIy\fR) - add new files to CVS +.br +\fBopt_bump_auxfiles\fR (default \fIy\fR) - bump auxiliary files in files/ +.br +\fBopt_delete_old\fR (default \fIn\fR) - delete old revision (DANGEROUS!) +.br +\fBopt_commitmessage\fR (default \fI""\fR) - default ChangeLog message + +.LP +\fB~/.gentoo/gentool-env\fR +.IR +From this file, \fIebump\fR will load the env vars \fBAUTHORNAME\fR and +\fBAUTHOREMAIL\fR, which are used to generate proper ChangeLog entries. + +.SH "SEE ALSO" +.LP +The rest of the utilities in \fIapp-portage/gentoolkit-dev\fR, such as +\fIechangelog\fR and \fIego\fR. + +.SH "AUTHORS" +.LP +Karl Trygve Kalleberg + -- cgit v1.2.3