3 # cvs-debrelease: Call dupload/dput to upload package built with
4 # cvs-buildpackage or cvs-debuild
6 # Based on debrelease; see it for copyright information
7 # Based on cvs-buildpackage, copyright 1997 Manoj Srivastava
8 # (CVS Id: cvs-buildpackage,v 1.58 2003/08/22 17:24:29 srivasta Exp)
9 # This code is copyright 2003, Julian Gilbey <jdg@debian.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 PROGNAME=`basename $0 .sh` # .sh for debugging purposes
28 "Usage: $PROGNAME [cvs-debrelease options] [--dopts [dupload/dput options]]
29 Upload the .changes file(s) just created by cvs-buildpackage or
30 cvs-debuild, as listed in the .changes file generated on that run.
32 Note that unlike cvs-buildpackage, the only way to specify the
33 source package name is with the -P option; you cannot simply have it
34 as the last parameter.
36 Also uses the cvs-buildpackage configuration files to determine the
37 location of the build tree, as described in its manpage.
39 Available cvs-debrelease options:
40 -M<module> CVS module name
41 -P<package> Package name
42 -V<version> Package version
43 -T<tag> CVS tag to use
44 -R<root dir> Root directory
45 -W<work dir> Working directory
46 -x<prefix> CVS default module prefix
47 -a<arch> Search for .changes file made for Debian build <arch>
48 -t<target> Search for .changes file made for GNU <target> arch
49 --dupload Use dupload to upload files (default)
50 --dput Use dput to upload files
52 Don't read devscripts config files;
53 must be the first option given
54 --dopts The remaining options are for dupload/dput
55 --help Show this message
56 --version Show version and copyright information
57 Other cvs-buildpackage options will be silently ignored.
59 Default settings modified by devscripts configuration files:
60 (no configuration files are read by $PROGNAME)
61 For information on default debrelease settings modified by the
62 configuration files, run: debrelease --help"
67 "This is $PROGNAME, from the Debian devscripts package, version ###VERSION###
68 This code is copyright 2003, Julian Gilbey <jdg@debian.org>,
70 Based on original code by Christoph Lameter and Manoj Srivastava.
71 This program comes with ABSOLUTELY NO WARRANTY.
72 You are free to redistribute this code under the terms of
73 the GNU General Public License, version 2 or later."
77 # Variable Value Doc string
78 if [ "x$2" = "x" ]; then
79 echo >&2 "$progname: Unable to determine $3"
82 if [ ! "x$Verbose" = "x" ]; then
83 echo "$progname: $3 is $2";
89 # Is cvs-buildpackage installed?
90 if ! command -v cvs-buildpackage >/dev/null 2>&1; then
91 echo "$PROGNAME: need the cvs-buildpackage package installed to run this" >&2
95 # Long term variables, which may be set in the cvsdeb config file or the
97 # rootdir workdir (if all original sources are kept in one dir)
99 TEMPDIR=$(mktemp -dt cvs-debrelease.XXXXXXXX) || {
100 echo "$PROGNAME: Unable to create temporary directory" >&2
101 echo "Aborting...." >&2
104 TEMPFILE=$TEMPDIR/cl-tmp
105 trap "rm -f $TEMPFILE; rmdir $TEMPDIR" 0 1 2 3 7 10 13 15
110 # Start by pulling off all options up to --dopts
111 declare -a cvsopts debreleaseopts
112 if [ "$1" = --no-conf -o "$1" = --noconf ]; then
113 debreleaseopts=("$1")
117 debreleaseopts=("${debreleaseopts[@]}" "--check-dirname-level=0")
119 while [ $# -gt 0 ]; do
120 if [ "$1" = "--dopts" ]; then
124 cvsopts=("${cvsopts[@]}" "$1")
128 # This will bomb out if there is an unrecognised option
129 TEMP=$(getopt -a -s bash \
130 -o hC:EH:G:M:P:R:T:U:V:W:Ff:dcnr:x:Bp:Dk:a:Sv:m:e:i:I:t: \
131 --long help,version,ctp,tC,sgpg,spgp,us,uc,op \
132 --long si,sa,sd,ap,sp,su,sk,sr,sA,sP,sU,sK,sR,ss,sn \
133 --long dupload,dput,no-conf,noconf \
134 --long check-dirname-level:,check-dirname-regex: \
135 -n "$PROGNAME" -- "${cvsopts[@]}")
141 -h|--help) usage; exit 0 ; shift ;;
142 --version) version; exit 0 ; shift ;;
143 -M) opt_cvsmodule="$2" ; shift 2 ;;
144 -P) opt_package="$2" ; shift 2 ;;
145 -R) opt_rootdir="$2" ; shift 2 ;;
146 -T) opt_tag="$2" ; shift 2 ;;
147 -V) opt_version="$2" ; shift 2 ;;
148 -W) opt_workdir="$2" ; shift 2 ;;
149 -x) opt_prefix="$2" ; shift 2 ;;
150 -a) debreleaseopts=("${debreleaseopts[@]}" "$1" "$2")
151 targetarch="$2" ; shift 2 ;;
152 -t) if [ "$2" != "C" ]; then
153 debreleaseopts=("${debreleaseopts[@]}" "$1" "$2")
158 debreleaseopts=("${debreleaseopts[@]}" "$1"); shift ;;
160 echo "$PROGNAME: $1 is only acceptable as the first command-line option!" >&2
162 --check-dirname-level|--check-dirname-regex)
163 debreleaseopts=("${debreleaseopts[@]}" "$1" "$2"); shift 2 ;;
165 # everything else is silently ignored
166 -[CHfGUr]) shift 2 ;;
168 --ctp|--op|--tC) shift ;;
171 --us|--uc|--sgpg|--spgp) shift ;;
172 --s[idapukrAPUKRns]) shift ;;
174 -[kvmeiI]) shift 2 ;;
177 *) echo >&2 "Internal error! ($1)"
182 if [ "x$opt_cvsmodule" = "x" -a "x$opt_package" = "x" -a \
183 ! -e 'debian/changelog' ] ; then
184 echo >&2 "$progname should be run in the top working directory of"
185 echo >&2 "a Debian Package, or an explicit package (or CVS module) name"
186 echo >&2 "should be given."
190 if [ "x$opt_tag" != "x" ]; then
194 # Command line, env variable, config file, or default
195 # This anomalous position is in case we need to check out the changelog
196 # below (anaomalous since we ahve not loaded the config file yet)
197 if [ ! "x$opt_prefix" = "x" ]; then
199 elif [ ! "x$CVSDEB_PREFIX" = "x" ]; then
200 prefix="$CVSDEB_PREFIX"
201 elif [ ! "x$conf_prefix" = "x" ]; then
202 prefix="$conf_prefix"
207 # put a slash at the end of the prefix
208 if [ "X$prefix" != "X" ]; then
210 prefix=`echo $prefix | sed 's://:/:g'`;
213 if [ ! -f CVS/Root ]; then
214 if [ "X$CVSROOT" = "X" ]; then
215 echo "no CVS/Root file found, and CVSROOT var is empty" >&2
219 CVSROOT=$(cat CVS/Root)
223 if [ "x$opt_package" = "x" ]; then
224 # Get the official package name and version.
225 if [ -f debian/changelog ]; then
226 # Ok, changelog exists
228 "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
231 "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
233 elif [ "x$opt_cvsmodule" != "x" ]; then
234 # Hmm. Well, see if we can checkout the changelog file
236 cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
238 "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Source: //p'`" \
241 "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
245 # Well. We don't know what this package is.
246 echo >&2 " This does not appear be a Debian source tree, since"
247 echo >&2 " theres is no debian/changelog, and there was no"
248 echo >&2 " package name or cvs module given on the comand line"
249 echo >&2 " it is hard to figure out what the package name "
250 echo >&2 " should be. I give up."
254 # The user knows best; package name is provided
255 setq "package" "$opt_package" "source package"
257 # Now, the version number
258 if [ "x$opt_version" != "x" ]; then
259 # All hail the user provided value
260 setq "version" "$opt_version" "source package"
261 elif [ -f debian/changelog ]; then
262 # Fine, see what the changelog says
264 "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
266 elif [ "x$opt_cvsmodule" != "x" ]; then
267 # Hmm. The CVS module name is known, so lets us try exporting changelog
269 cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
271 "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
275 # Ok, try exporting the package name
277 cvsmodule="${prefix}$package"
278 cvs -q co -p $TAGOPT $cvsmodule/debian/changelog > $TEMPFILE
280 "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
288 trap "" 0 1 2 3 7 10 13 15
291 non_epoch_version=$(echo -n "$version" | perl -pe 's/^\d+://')
292 upstream_version=$(echo -n "$non_epoch_version" | sed -e 's/-[^-]*$//')
293 debian_version=$(echo -n $non_epoch_version | perl -nle 'm/-([^-]*)$/ && print $1')
296 if [ "X$opt_rootdir" != "X" ]; then
297 rootdir="$opt_rootdir"
299 rootdir='/usr/local/src/Packages'
302 if [ "X$opt_workdir" != "X" ]; then
303 workdir="$opt_workdir"
305 workdir="$rootdir/$package"
308 # Load site defaults and over rides.
309 if [ -f /etc/cvsdeb.conf ]; then
313 # Load user defaults and over rides.
314 if [ -f ~/.cvsdeb.conf ]; then
318 # Command line, env variable, config file, or default
319 if [ ! "x$opt_rootdir" = "x" ]; then
320 rootdir="$opt_rootdir"
321 elif [ ! "x$CVSDEB_ROOTDIR" = "x" ]; then
322 rootdir="$CVSDEB_ROOTDIR"
323 elif [ ! "x$conf_rootdir" = "x" ]; then
324 rootdir="$conf_rootdir"
327 # Command line, env variable, config file, or default
328 if [ ! "x$opt_workdir" = "x" ]; then
329 workdir="$opt_workdir"
330 elif [ ! "x$CVSDEB_WORKDIR" = "x" ]; then
331 workdir="$CVSDEB_WORKDIR"
332 elif [ ! "x$conf_workdir" = "x" ]; then
333 workdir="$conf_workdir"
335 workdir="$rootdir/$package"
338 if [ ! -d "$workdir" ]; then
339 echo >&2 "The working directory, $workdir, does not exist. Aborting"
340 if [ ! -d "$rootdir" ]; then
341 echo >&2 "The root directory, $rootdir, does not exist either."
346 pkgdir="$workdir/$package-$upstream_version"
348 if [ ! -d "$pkgdir" ]; then
349 echo "The build directory $pkgdir does not exist!" >&2
350 echo "Have you built the package yet?" >&2
354 setq arch "`dpkg-architecture -a${targetarch} -t${targetgnusystem} -qDEB_HOST_ARCH`" "build architecture"
356 pva="${package}_${non_epoch_version}_${arch}"
357 changes="$pva.changes"
359 if [ ! -f "$workdir/$changes" ]; then
360 echo "Can't find $workdir/$changes!" >&2
361 echo "Have you built the package yet?" >&2
367 echo "Couldn't cd $pkgdir. Aborting" >&2
371 # Just call debrelease, now that we are in the correct directory
373 SUBPROG=${PROGNAME#cvs-}
375 exec $SUBPROG "${debreleaseopts[@]}" "$@"