3 # Copyright (c) 2004 Karl Trygve Kalleberg <karltk@gentoo.org>
4 # Copyright (c) Gentoo Technologies, Inc.
5 # Licensed under the GNU General Public License, version 2
7 # Maintainer: Karl Trygve Kalleberg <karltk@gentoo.org>
10 __author__="Karl Trygve Kalleberg"
11 __email__="<karltk@gentoo.org>"
12 __description__="Ebuild version bumping tool"
22 if [ ${opt_verbosity:-0} -eq 1 ] ; then
28 echo "${__description__}, v${__version__}"
29 echo "Copyright (c) 2004 ${__author__} ${__email__}"
30 echo "Copyright (c) 2004 Gentoo Technologies, Inc."
31 echo "Licensed under the GNU General Public License, version 2"
35 echo "Usage: ebump <options> foo<.ebuild>"
36 echo "Ebuild version bumping tool, v${__version__}"
37 echo " -V|--version show version info"
38 echo " -v|--verbose increase verbosity"
39 echo " -q|--quiet turn off output"
40 echo " -a|--no-auxfiles don't bump auxfiles (files/*)"
41 echo " -c|--no-changelog do not update ChangeLog (via echangelog)"
42 echo " -C|--no-vcs do not add to VCS"
43 echo " -m|--message append message to ChangeLog"
44 echo " -d|--delete-old delete previous revision from VCS (DANGEROUS!)"
48 # Load options from /etc/gentoolkit/ebump.conf and ${HOME}/.gentoo/ebump.conf
49 # Home directory file takes precedence.
52 # FIXME: Sourcing config files like this is really a bad idea; users may
53 # easily override any function in this program inside his config files.
54 if [ -f "/etc/gentoolkit/ebump.conf" ] ; then
55 . /etc/gentoolkit/ebump.conf
57 if [ -f "${HOME}/.gentoo/gentool-env" ] ; then
58 . ${HOME}/.gentoo/gentool-env
60 if [ -f "${HOME}/.gentoo/ebump.conf" ] ; then
61 . ${HOME}/.gentoo/ebump.conf
64 # FIXME: remove this warning in 2-3 releases.
65 if [ -n "${opt_add_cvs}" ]; then
66 echo "Warning: opt_add_cvs is deprecated, please use opt_add_vcs from now on!" >&2
71 # Find closes ebuild to ${1}, if any
76 if [ -f "${f}" ] ; then
80 if [ -f "${f}.ebuild" ] ; then
86 # splitname (version|name|revision) package-name-version-revision
91 echo ${2} | sed -r "s/.*-([0-9].*)/\1/"
94 name=$(echo ${2} | sed -r "s/(.*)-[0-9].*/\1/")
95 if [ ${name} == ${2} ] ; then
96 if [ $(echo ${2} | grep "^[0-9].*") ] ; then
97 # The filename starts with a version number, thus it has no
101 # The filename doesn't have a recognizeable version number;
102 # everything is a name
109 rev=$(echo ${2} | sed -r "s/.*-r([0-9][0-9]*)/\1/")
110 if [ ${rev} == ${2} ] ; then
116 ver=$(echo ${2} | sed -r "s/.*-([0-9].*)-r[0-9]+/\1/")
117 if [ ${ver} == ${2} ] ; then
118 ver=$(echo ${2} | sed -r "s/.*-([0-9].*)/\1/")
133 # Files to add to VCS
135 # Files to remove from VCS
138 if [ -z "${ebuild_arg}" ] ; then
144 # Try to find a matching ebuild
146 local ebuild_name=$(find_ebuild ${ebuild_arg})
147 if [ -z "${ebuild_name}" ] ; then
148 die "Could not find ${ebuild_arg}"
150 einfo "Processing ebuild ${ebuild_name}"
153 # Bump revision suffix (or add one)
155 local PF=$(basename ${ebuild_name} .ebuild)
156 local PN=$(splitname name ${PF})
157 local PV=$(splitname version ${PF})
158 local rev=$(splitname revision ${PF})
159 local PV_norev=$(splitname vernorev ${PF})
160 local newPF=${PN}-${PV_norev}-r$[rev+1]
162 # echo $PF / $PN / $PV / $rev / $PV_norev / $newPF
164 einfo "Bumped ${PF}.ebuild to ${newPF}.ebuild"
166 if [ "${vcs}" == "svn" ]; then
167 svn cp ${PF}.ebuild ${newPF}.ebuild
169 cp ${PF}.ebuild ${newPF}.ebuild
172 einfo "Reset keywords to ~arch"
174 ekeyword '~all' "${newPF}.ebuild"
176 addfiles="${addfiles} ${newPF}.ebuild"
177 delfiles="${delfiles} ${PF}.ebuild"
180 # (Optional) Bump relevant files in files/
182 if [ "${opt_bump_auxfiles}" == "y" ] ; then
183 # Gather list of auxiliary files in files/ that has a versioned
184 # filename, where the version matches our current version.
187 for x in $(echo files/*) ; do
188 if [ ! -z "$(echo $x | grep "${PV}$")" ] ; then
189 bumplist="${bumplist} ${x}"
193 # Bump version of all matches
194 for x in ${bumplist} ; do
195 local bn=$(basename ${x})
196 local dn=$(dirname ${x})
199 PN=$(splitname name ${bn})
200 PV=$(splitname version ${bn})
201 rev=$(splitname revision ${bn})
202 PV_norev=$(splitname vernorev ${bn})
204 # echo $PN / ${PV_norev} / ${rev}
206 # Special case for when we have no name part; filename
207 # is just a version number
208 if [ -z "${PN}" ] ; then
209 newbn=${PV_norev}-r$[rev+1]
211 newbn=${PN}-${PV_norev}-r$[rev+1]
214 if [ -d ${dn}/${bn} ] ; then
215 if [ -e ${dn}/${newbn} ] ; then
216 echo "Directory ${dn}/${newbn} exists, not copying" >&2
218 cp -a ${dn}/${bn} ${dn}/${newbn}
219 # uhm, is that necessary?
220 # find ${dn}/${newbn} -name CVS | xargs rm -rf
223 cp ${dn}/${bn} ${dn}/${newbn}
226 addfiles="${addfiles} ${dn}/${newbn}"
227 delfiles="${delfiles} ${dn}/${bn}"
229 einfo "Bumped ${dn}/${bn} to ${dn}/${newbn}"
233 # echo "addfiles ${addfiles}"
234 # echo "delfiles ${delfiles}"
237 # (Optional) Add VCS entry for all new files
239 if [ "${opt_add_vcs}" == "y" ] ; then
240 for x in ${addfiles} ; do
241 if [ -d ${x} ] ; then
242 find ${x} -exec ${vcs} add {} ';'
247 einfo "Added ${addfiles} to VCS"
252 # (Optional) Delete previous entry
254 # Could we use 'rm' instead of remove for all vcs?
255 if [ "${opt_delete_old}" == "y" ] ; then
256 for x in ${delfiles} ; do
257 if [ "${vcs}" == "cvs" ]; then
258 ${vcs} remove -f ${x}
259 elif [ "${vcs}" == "git" ]; then
265 einfo "Removed ${delfiles} from VCS"
269 # (Optional) Add ChangeLog entry
271 if [ "${opt_add_changelog}" == "y" ] && [ "${opt_add_vcs}" == "y" ]; then
272 # FIXME: remove this warning in 2-3 releases
273 if [ -n "${AUTHORNAME}" ] || [ -n "${AUTHOREMAIL}" ]; then
274 echo "Warning: AUTHORNAME and AUTHOREMAIL is deprecated!" >&2
275 echo "Please take a look at echangelog(1)." >&2
276 echo "To avoid this warning unset AUTHORNAME and AUTHOREMAIL." >&2
279 echangelog "${opt_commitmessage}" || set $?
281 if [ ${1:-0} -ne 0 ]; then
282 einfo "Modifying ChangeLog failed!"
284 einfo "Added ChangeLog entry"
290 if [ -d "CVS" ]; then
293 elif [ -d ".svn" ]; then
297 if [ -x "$(which git)" ]; then
298 if [ -n "$(git rev-parse --git-dir 2>/dev/null)" ]; then
323 while [ ${#} -gt 0 ] ; do
333 opt_commitmessage="${1}"
373 if [ -z "${vcs}" ]; then
374 echo "Warning: no cvs, git or svn repository found!" >&2
375 echo "Changes can't be added to the VCS" >&2
379 process_ebuild "${vcs}" ${ebuild_arg}
382 # - put cli parser into separate functions