Author: adam-guest
Date: 2008-02-23 22:29:27 +0000 (Sat, 23 Feb 2008)
New Revision: 1047
Modified:
trunk/debian/changelog
trunk/scripts/debsign.sh
Log:
debsign: Allow multiple files to be signed in a single invocation
(Closes: #457355)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-02-23 21:38:57 UTC (rev 1046)
+++ trunk/debian/changelog 2008-02-23 22:29:27 UTC (rev 1047)
@@ -48,6 +48,8 @@
confirmation (Closes: #467134)
- Allow the use of --{force-,}interactive to be specified in the
configuration file (Closes: #467131)
+ * debsign: Allow multiple files to be signed in a single invocation
+ (Closes: #457355)
[ Christoph Berg ]
* dget:
Modified: trunk/scripts/debsign.sh
===================================================================
--- trunk/scripts/debsign.sh 2008-02-23 21:38:57 UTC (rev 1046)
+++ trunk/scripts/debsign.sh 2008-02-23 22:29:27 UTC (rev 1047)
@@ -305,195 +305,120 @@
exit 1
fi
-# If there is a command-line parameter, it is the name of a .changes file
-# If not, we must be at the top level of a source tree and will figure
-# out its name from debian/changelog
-case $# in
- 1) case "$1" in
- *.dsc)
- changes=
- dsc=$1
- commands=
- ;;
- *.changes)
- changes=$1
- dsc=`echo $changes | \
- perl -pe 's/\.changes$/.dsc/;
s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
- commands=
- ;;
- *.commands)
- changes=
- dsc=
- commands=$1
- ;;
- *) echo "$PROGNAME: Only a .changes, .dsc or .commands file is
allowed as argument!" >&2
- exit 1 ;;
- esac
- ;;
+dosigning() {
+ # Do we have to download the changes file?
+ if [ -n "$remotehost" ]
+ then
+ cd ${TMPDIR:-/tmp}
+ mkdir debsign.$$ || { echo "$PROGNAME: Can't mkdir!" >&2; exit 1; }
+ trap "cleanup_tmpdir" 0 1 2 3 7 10 13 15
+ cd debsign.$$
- 0) # We have to parse debian/changelog to find the current version
- if [ -n "$remotehost" ]; then
- echo "$PROGNAME: Need to specify a .changes, .dsc or .commands file
location with -r!" >&2
- exit 1
+ remotechanges=$changes
+ remotedsc=$dsc
+ remotecommands=$commands
+ remotedir="`perl -e 'chomp($_="'"$dsc"'"); m%/% && s%/[^/]*$%% &&
print'`"
+ changes=`basename "$changes"`
+ dsc=`basename "$dsc"`
+ commands=`basename "$commands"`
+
+ if [ -n "$changes" ]
+ then withecho scp "$remotehost:$remotechanges" "$changes"
+ elif [ -n "$dsc" ]
+ then withecho scp "$remotehost:$remotedsc" "$dsc"
+ else withecho scp "$remotehost:$remotecommands" "$commands"
fi
- if [ ! -r debian/changelog ]; then
- echo "$PROGNAME: Must be run from top of source dir or a .changes
file given as arg" >&2
- exit 1
- fi
+ fi
- mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
- "source package"
- mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
- "source version"
-
- if [ "x$sourceonly" = x ]
+ if [ -n "$changes" ]
+ then
+ if [ ! -f "$changes" -o ! -r "$changes" ]
then
- mustsetvar arch "`dpkg-architecture -a${targetarch}
-t${targetgnusystem} -qDEB_HOST_ARCH`" "build architecture"
- else
- arch=source
+ echo "$PROGNAME: Can't find or can't read changes file $changes!"
>&2
+ exit 1
fi
- sversion=`echo "$version" | perl -pe 's/^\d+://'`
- pv="${package}_${sversion}"
- pva="${package}_${sversion}_${arch}"
- dsc="../$pv.dsc"
- changes="../$pva.changes"
- if [ -n "$multiarch" -o ! -r $changes ]; then
- changes=$(ls "../${package}_${sversion}_*+*.changes"
"../${package}_${sversion}_multi.changes" 2>/dev/null | head -1)
- if [ -z "$multiarch" ]; then
- if [ -n "$changes" ]; then
- echo "$PROGNAME: could not find normal .changes file but
found multiarch file:" >&2
- echo " $changes" >&2
- echo "Using this changes file instead." >&2
- else
- echo "$PROGNAME: Can't find or can't read changes file
$changes!" >&2
- exit 1
- fi
- elif [ -n "$multiarch" -a -z "$changes" ]; then
- echo "$PROGNAME: could not find any multiarch .changes file
with name" >&2
- echo "../${package}_${sversion}_*.changes" >&2
- exit 1
- fi
+ check_already_signed "$changes" "changes" && {
+ echo "Leaving current signature unchanged." >&2
+ exit 0
+ }
+ if [ -n "$maint" ]
+ then maintainer="$maint"
+ # Try the "Changed-By:" field first
+ else maintainer=`sed -n 's/^Changed-By: //p' $changes`
fi
- ;;
+ if [ -z "$maintainer" ]
+ then maintainer=`sed -n 's/^Maintainer: //p' $changes`
+ fi
- *) echo "$PROGNAME: Only a single .changes, .dsc or .commands file is
allowed as argument!" >&2
- exit 1 ;;
-esac
+ signas="${signkey:-$maintainer}"
-# Do we have to download the changes file?
-if [ -n "$remotehost" ]
-then
- cd ${TMPDIR:-/tmp}
- mkdir debsign.$$ || { echo "$PROGNAME: Can't mkdir!" >&2; exit 1; }
- trap "cleanup_tmpdir" 0 1 2 3 7 10 13 15
- cd debsign.$$
-
- remotechanges=$changes
- remotedsc=$dsc
- remotecommands=$commands
- remotedir="`perl -e 'chomp($_="'"$dsc"'"); m%/% && s%/[^/]*$%% && print'`"
- changes=`basename "$changes"`
- dsc=`basename "$dsc"`
- commands=`basename "$commands"`
-
- if [ -n "$changes" ]
- then withecho scp "$remotehost:$remotechanges" "$changes"
- elif [ -n "$dsc" ]
- then withecho scp "$remotehost:$remotedsc" "$dsc"
- else withecho scp "$remotehost:$remotecommands" "$commands"
- fi
-fi
-
-if [ -n "$changes" ]
-then
- if [ ! -f "$changes" -o ! -r "$changes" ]
- then
- echo "$PROGNAME: Can't find or can't read changes file $changes!" >&2
- exit 1
- fi
-
- check_already_signed "$changes" "changes" && {
- echo "Leaving current signature unchanged." >&2
- exit 0
- }
- if [ -n "$maint" ]
- then maintainer="$maint"
- # Try the "Changed-By:" field first
- else maintainer=`sed -n 's/^Changed-By: //p' $changes`
- fi
- if [ -z "$maintainer" ]
- then maintainer=`sed -n 's/^Maintainer: //p' $changes`
- fi
-
- signas="${signkey:-$maintainer}"
-
- # Is there a dsc file listed in the changes file?
- if grep -q `basename "$dsc"` "$changes"
- then
- if [ -n "$remotehost" ]
+ # Is there a dsc file listed in the changes file?
+ if grep -q `basename "$dsc"` "$changes"
then
- withecho scp "$remotehost:$remotedsc" "$dsc"
- fi
+ if [ -n "$remotehost" ]
+ then
+ withecho scp "$remotehost:$remotedsc" "$dsc"
+ fi
- if [ ! -f "$dsc" -o ! -r "$dsc" ]
- then
- echo "$PROGNAME: Can't find or can't read dsc file $dsc!" >&2
- exit 1
- fi
- check_already_signed "$dsc" "dsc" || withecho signfile "$dsc" "$signas"
- dsc_md5=`md5sum $dsc | cut -d' ' -f1`
+ if [ ! -f "$dsc" -o ! -r "$dsc" ]
+ then
+ echo "$PROGNAME: Can't find or can't read dsc file $dsc!" >&2
+ exit 1
+ fi
+ check_already_signed "$dsc" "dsc" || withecho signfile "$dsc"
"$signas"
+ dsc_md5=`md5sum $dsc | cut -d' ' -f1`
- perl -i -pe 'BEGIN {
- '" \$dsc_file=\"$dsc\"; \$dsc_md5=\"$dsc_md5\"; "'
- $dsc_size=(-s $dsc_file); ($dsc_base=$dsc_file) =~ s|.*/||;
- $infiles=0;
- }
- /^Files:/ && ($infiles=1);
- /^\s*$/ && ($infiles=0);
- if ($infiles &&
- /^ (\S+) (\d+) (\S+) (\S+) \Q$dsc_base\E\s*$/) {
- $_ = " $dsc_md5 $dsc_size $3 $4 $dsc_base\n";
+ perl -i -pe 'BEGIN {
+ '" \$dsc_file=\"$dsc\"; \$dsc_md5=\"$dsc_md5\"; "'
+ $dsc_size=(-s $dsc_file); ($dsc_base=$dsc_file) =~ s|.*/||;
$infiles=0;
- }' "$changes"
+ }
+ /^Files:/ && ($infiles=1);
+ /^\s*$/ && ($infiles=0);
+ if ($infiles &&
+ /^ (\S+) (\d+) (\S+) (\S+) \Q$dsc_base\E\s*$/) {
+ $_ = " $dsc_md5 $dsc_size $3 $4 $dsc_base\n";
+ $infiles=0;
+ }' "$changes"
- withecho signfile "$changes" "$signas"
+ withecho signfile "$changes" "$signas"
- if [ -n "$remotehost" ]
- then
- withecho scp "$changes" "$dsc" "$remotehost:$remotedir"
- PRECIOUS_FILES=$(($PRECIOUS_FILES - 2))
- fi
+ if [ -n "$remotehost" ]
+ then
+ withecho scp "$changes" "$dsc" "$remotehost:$remotedir"
+ PRECIOUS_FILES=$(($PRECIOUS_FILES - 2))
+ fi
- echo "Successfully signed dsc and changes files"
- else
- withecho signfile "$changes" "$signas"
+ echo "Successfully signed dsc and changes files"
+ else
+ withecho signfile "$changes" "$signas"
- if [ -n "$remotehost" ]
+ if [ -n "$remotehost" ]
+ then
+ withecho scp "$changes" "$remotehost:$remotechanges"
+ PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
+ fi
+
+ echo "Successfully signed changes file"
+ fi
+ elif [ -n "$commands" ] # sign .commands file
+ then
+ if [ ! -f "$commands" -o ! -r "$commands" ]
then
- withecho scp "$changes" "$remotehost:$remotechanges"
- PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
+ echo "$PROGNAME: Can't find or can't read commands file $commands!"
>&2
+ exit 1
fi
- echo "Successfully signed changes file"
- fi
-elif [ -n "$commands" ] # sign .commands file
-then
- if [ ! -f "$commands" -o ! -r "$commands" ]
- then
- echo "$PROGNAME: Can't find or can't read commands file $commands!" >&2
- exit 1
- fi
-
- check_already_signed "$commands" commands && {
- echo "Leaving current signature unchanged." >&2
- exit 0
- }
+ check_already_signed "$commands" commands && {
+ echo "Leaving current signature unchanged." >&2
+ exit 0
+ }
- # simple validator for .commands files, see
- # ftp://ftp-master.debian.org/pub/UploadQueue/README
- perl -ne 'BEGIN { $uploader = 0; $incommands = 0; }
+ # simple validator for .commands files, see
+ # ftp://ftp-master.debian.org/pub/UploadQueue/README
+ perl -ne 'BEGIN { $uploader = 0; $incommands = 0; }
END { exit $? if $?;
if ($uploader && $incommands) { exit 0; }
else { die ".commands file missing Uploader or Commands
field\n"; }
@@ -523,59 +448,138 @@
for valid format" >&2;
exit 1; }
- if [ -n "$maint" ]
- then maintainer="$maint"
- else
- maintainer=`sed -n 's/^Uploader: //p' $commands`
- if [ -z "$maintainer" ]
- then
- echo "Unable to parse Uploader, .commands file invalid."
- exit 1
- fi
- fi
+ if [ -n "$maint" ]
+ then maintainer="$maint"
+ else
+ maintainer=`sed -n 's/^Uploader: //p' $commands`
+ if [ -z "$maintainer" ]
+ then
+ echo "Unable to parse Uploader, .commands file invalid."
+ exit 1
+ fi
+ fi
- signas="${signkey:-$maintainer}"
+ signas="${signkey:-$maintainer}"
- withecho signfile "$commands" "$signas"
+ withecho signfile "$commands" "$signas"
- if [ -n "$remotehost" ]
- then
- withecho scp "$commands" "$remotehost:$remotecommands"
- PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
- fi
+ if [ -n "$remotehost" ]
+ then
+ withecho scp "$commands" "$remotehost:$remotecommands"
+ PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
+ fi
- echo "Successfully signed commands file"
-else # only a dsc file to sign; much easier
- if [ ! -f "$dsc" -o ! -r "$dsc" ]
- then
- echo "$PROGNAME: Can't find or can't read dsc file $dsc!" >&2
- exit 1
- fi
+ echo "Successfully signed commands file"
+ else # only a dsc file to sign; much easier
+ if [ ! -f "$dsc" -o ! -r "$dsc" ]
+ then
+ echo "$PROGNAME: Can't find or can't read dsc file $dsc!" >&2
+ exit 1
+ fi
- check_already_signed "$dsc" dsc && {
- echo "Leaving current signature unchanged." >&2
- exit 0
- }
- if [ -n "$maint" ]
- then maintainer="$maint"
- # Try the new "Changed-By:" field first
- else maintainer=`sed -n 's/^Changed-By: //p' $dsc`
- fi
- if [ -z "$maint" ]
- then maintainer=`sed -n 's/^Maintainer: //p' $dsc`
- fi
+ check_already_signed "$dsc" dsc && {
+ echo "Leaving current signature unchanged." >&2
+ exit 0
+ }
+ if [ -n "$maint" ]
+ then maintainer="$maint"
+ # Try the new "Changed-By:" field first
+ else maintainer=`sed -n 's/^Changed-By: //p' $dsc`
+ fi
+ if [ -z "$maint" ]
+ then maintainer=`sed -n 's/^Maintainer: //p' $dsc`
+ fi
- signas="${signkey:-$maintainer}"
+ signas="${signkey:-$maintainer}"
- withecho signfile "$dsc" "$signas"
+ withecho signfile "$dsc" "$signas"
- if [ -n "$remotehost" ]
- then
- withecho scp "$dsc" "$remotehost:$remotedsc"
- PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
+ if [ -n "$remotehost" ]
+ then
+ withecho scp "$dsc" "$remotehost:$remotedsc"
+ PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
+ fi
+
+ echo "Successfully signed dsc file"
fi
+}
- echo "Successfully signed dsc file"
-fi
+# If there is a command-line parameter, it is the name of a .changes file
+# If not, we must be at the top level of a source tree and will figure
+# out its name from debian/changelog
+case $# in
+ 0) # We have to parse debian/changelog to find the current version
+ if [ -n "$remotehost" ]; then
+ echo "$PROGNAME: Need to specify a .changes, .dsc or .commands file
location with -r!" >&2
+ exit 1
+ fi
+ if [ ! -r debian/changelog ]; then
+ echo "$PROGNAME: Must be run from top of source dir or a .changes
file given as arg" >&2
+ exit 1
+ fi
+ mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
+ "source package"
+ mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+ "source version"
+
+ if [ "x$sourceonly" = x ]
+ then
+ mustsetvar arch "`dpkg-architecture -a${targetarch}
-t${targetgnusystem} -qDEB_HOST_ARCH`" "build architecture"
+ else
+ arch=source
+ fi
+
+ sversion=`echo "$version" | perl -pe 's/^\d+://'`
+ pv="${package}_${sversion}"
+ pva="${package}_${sversion}_${arch}"
+ dsc="../$pv.dsc"
+ changes="../$pva.changes"
+ if [ -n "$multiarch" -o ! -r $changes ]; then
+ changes=$(ls "../${package}_${sversion}_*+*.changes"
"../${package}_${sversion}_multi.changes" 2>/dev/null | head -1)
+ if [ -z "$multiarch" ]; then
+ if [ -n "$changes" ]; then
+ echo "$PROGNAME: could not find normal .changes file but
found multiarch file:" >&2
+ echo " $changes" >&2
+ echo "Using this changes file instead." >&2
+ else
+ echo "$PROGNAME: Can't find or can't read changes file
$changes!" >&2
+ exit 1
+ fi
+ elif [ -n "$multiarch" -a -z "$changes" ]; then
+ echo "$PROGNAME: could not find any multiarch .changes file
with name" >&2
+ echo "../${package}_${sversion}_*.changes" >&2
+ exit 1
+ fi
+ fi
+ ;;
+
+ *) while [ $# -gt 0 ]; do
+ case "$1" in
+ *.dsc)
+ changes=
+ dsc=$1
+ commands=
+ ;;
+ *.changes)
+ changes=$1
+ dsc=`echo $changes | \
+ perl -pe 's/\.changes$/.dsc/;
s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+ commands=
+ ;;
+ *.commands)
+ changes=
+ dsc=
+ commands=$1
+ ;;
+ *)
+ echo "$PROGNAME: Only a .changes, .dsc or .commands file is
allowed as argument!" >&2
+ exit 1 ;;
+ esac
+ dosigning
+ shift
+ done
+ ;;
+esac
+
exit 0
--
To unsubscribe, send mail to [EMAIL PROTECTED]