[devscripts] 02/02: debsign: Determine related filenames from .changes/.buildinfo

James McCoy jamessan at debian.org
Mon Mar 13 03:57:08 UTC 2017


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit 4a4238dbf1e789e998cf047ea0f006e982fba56b
Author: James McCoy <jamessan at debian.org>
Date:   Sun Mar 12 23:53:42 2017 -0400

    debsign: Determine related filenames from .changes/.buildinfo
    
    Rather than trying to guess at the filenames by munging the name of the
    file we were given, just inspect its contents.  This ensures we're
    signing the correct files, instead of unrelated files that happen to
    match the munging we're doing, as well as fixing are broken guessing for
    buildinfo filenames.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog   |  2 ++
 scripts/debsign.sh | 27 ++++++++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index bcd139c..38cc63a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ devscripts (2.17.3) UNRELEASED; urgency=medium
   * debsign:
     + Fix auto-detection of the signer.  Regression introduced in 2.17.2.
       (Closes: #857537)
+    + Determine the names of related files from the file listings in
+      .changes/.buildinfo.  (Closes: #857536)
 
  -- James McCoy <jamessan at debian.org>  Sun, 12 Mar 2017 22:19:34 -0400
 
diff --git a/scripts/debsign.sh b/scripts/debsign.sh
index fccbbef..12c8909 100755
--- a/scripts/debsign.sh
+++ b/scripts/debsign.sh
@@ -626,9 +626,8 @@ dosigning() {
 	    for changes in $changes
 	    do
 		printf "\n"
-		buildinfo="${remotedir+$remotedir/}${changes%.changes}.buildinfo"
-		dsc=`echo "${remotedir+$remotedir/}$changes" | \
-		    perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+		derive_childfile "$changes" buildinfo
+		derive_childfile "$changes" dsc
 		dosigning;
 	    done
 	    exit 0;
@@ -731,6 +730,15 @@ for valid format" >&2;
     fi
 }
 
+derive_childfile() {
+    local base="$1"
+    local ext="$2"
+
+    mustsetvar "$ext" \
+      "$(sed -n '/^\(Checksum\|Files\)/,/^\(Checksum\|Files\)/s/.*[ 	]\([^ ]*\.'"$ext"'\)$/\1/p' "$base" | head -n1)" \
+      "$ext filename from $base"
+}
+
 # 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
@@ -769,10 +777,7 @@ case $# in
 	fi
 
 	sversion=`echo "$version" | perl -pe 's/^\d+://'`
-	pv="${package}_${sversion}"
 	pva="${package}_${sversion}_${arch}"
-	dsc="$debsdir/$pv.dsc"
-	buildinfo="$debsdir/$pva.buildinfo"
 	changes="$debsdir/$pva.changes"
 	if [ -n "$multiarch" -o ! -r $changes ]; then
 	    changes=$(ls "$debsdir/${package}_${sversion}_*+*.changes" "$debsdir/${package}_${sversion}_multi.changes" 2>/dev/null | head -1)
@@ -792,6 +797,8 @@ case $# in
 		exit 1
 	    fi
 	fi
+	derive_childinfo "$changes" dsc
+	derive_childfile "$changes" buildinfo
 	dosigning;
 	;;
 
@@ -806,15 +813,13 @@ case $# in
 	        *.buildinfo)
 		    changes=
 		    buildinfo=$1
-		    dsc=`echo $buildinfo | \
-			perl -pe 's/\.buildinfo$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+		    derive_childfile "$buildinfo" dsc
 		    commands=
 		    ;;
 	        *.changes)
 		    changes=$1
-		    buildinfo="${changes%.changes}.buildinfo"
-		    dsc=`echo $changes | \
-			perl -pe 's/\.changes$/.dsc/; s/(.*)_(.*)_(.*)\.dsc/\1_\2.dsc/'`
+		    derive_childfile "$changes" buildinfo
+		    derive_childfile "$changes" dsc
 		    commands=
 		    ;;
 		*.commands)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list