Signed-off-by: Carsten Hey <cars...@debian.org>
---
 debian/changelog   |    7 +++++++
 scripts/debsign.1  |    6 ++++++
 scripts/debsign.sh |   32 ++++++++++++++++++++++----------
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5e49b00..6b39609 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+devscripts (2.10.66) UNRELEASED; urgency=low
+
+  * debsign: Add options --re-sign and --no-re-sign to let the user choose
+    whether an already signed file should be resigned.  (Closes: #580821)
+
+ -- Carsten Hey <cars...@debian.org>  Sun, 18 Jul 2010 17:32:38 +0200
+
 devscripts (2.10.65.1) unstable; urgency=low
 
   * debc:
diff --git a/scripts/debsign.1 b/scripts/debsign.1
index 824e689..39c5c21 100644
--- a/scripts/debsign.1
+++ b/scripts/debsign.1
@@ -87,6 +87,12 @@ use the most recent file with the name pattern
 \fIpackage_version_*+*.changes\fR as the changes file, allowing for the
 changes files produced by \fBdpkg-cross\fR.
 .TP
+\fB\-\-re\-sign\fR, \fB\-\-no\-re\-sign\fR
+Recreate signature, respectively use the existing signature, if the
+file has been signed already.  If neither option is given and an already
+signed file is found the user is asked if he or she likes to use the
+current signature.
+.TP
 \fB\-\-debs\-dir\fR \fIDIR\fR
 Look for the \fI.changes\fR and \fI.dsc\fR files in directory
 \fIDIR\fR instead of the parent of the source directory.  This should
diff --git a/scripts/debsign.sh b/scripts/debsign.sh
index 60f15f5..1625112 100755
--- a/scripts/debsign.sh
+++ b/scripts/debsign.sh
@@ -88,6 +88,8 @@ usage () {
     -a<arch>        Use changes file made for Debian target architecture <arch>
     -t<target>      Use changes file made for GNU target architecture <target>
     --multi         Use most recent multiarch .changes file found
+    --re-sign       Re-sign if the file is already signed.
+    --no-re-sign    Don't re-sign if the file is already signed.
     --debs-dir <directory>
                     The location of the .changes / .dsc files when called from
                     within a source tree (default "..")
@@ -224,23 +226,31 @@ withecho () {
 # and failure if the file needs signing.  Parameters: $1=filename,
 # $2=file description for message (dsc or changes)
 check_already_signed () {
-    if [ "`head -n 1 \"$1\"`" != "-----BEGIN PGP SIGNED MESSAGE-----" ]
-    then
+    [ "`head -n 1 \"$1\"`" = "-----BEGIN PGP SIGNED MESSAGE-----" ] || \
        return 1
+
+    local resign
+    if [ "$opt_re_sign" = "true" ]; then
+       resign="true"
+    elif [ "$opt_re_sign" = "false" ]; then
+       resign="false"
     else
        printf "The .$2 file is already signed.\nWould you like to use the 
current signature? [Yn]"
        read response
        case $response in
-       [Nn]*)
-           UNSIGNED_FILE="$(temp_filename "$1" "unsigned")"
-
-           sed -e '1,/^$/d; /^$/,$d' "$1" > "$UNSIGNED_FILE"
-           movefile "$UNSIGNED_FILE" "$1"
-           return 1
-           ;;
-       *) return 0;;
+       [Nn]*) resign="true" ;;
+       *)     resign="false" ;;
        esac
     fi
+
+    [ "$resign" = "true" ] || \
+       return 0
+
+    UNSIGNED_FILE="$(temp_filename "$1" "unsigned")"
+
+    sed -e '1,/^$/d; /^$/,$d' "$1" > "$UNSIGNED_FILE"
+    movefile "$UNSIGNED_FILE" "$1"
+    return 1
 }
 
 # --- main script
@@ -345,6 +355,8 @@ do
        -a*)    targetarch="$value" ;;
        -t*)    targetgnusystem="$value" ;;
        --multi) multiarch="true" ;;
+       --re-sign)    opt_re_sign="true" ;;
+       --no-re-sign) opt_re_sign="false" ;;
        -r*)    if [ -n "$value" ]; then remotehost=$value;
                elif [ $# -lt 1 ]; then
                    echo "$PROGNAME: -r option missing argument!" >&2
-- 
1.7.1




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to