Author: adsb
Date: 2008-12-02 22:00:03 +0000 (Tue, 02 Dec 2008)
New Revision: 1749

Modified:
   trunk/debian/changelog
   trunk/scripts/debsign.sh
Log:
* debsign:
  + Use mktemp rather than a temporary directory name based on the
    process ID. (Closes: #507482)
  + Use temporary files rather than redirecting gpg's stdin and stdout,
    enabling the use of pinentry-gtk2. (Closes: #507479)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-12-02 19:50:38 UTC (rev 1748)
+++ trunk/debian/changelog      2008-12-02 22:00:03 UTC (rev 1749)
@@ -9,6 +9,11 @@
     already installed on the system should be installed, rather than
     all packages listed in the .changes file. Thanks, Colin Watson.
     (Closes: #506663)
+  * debsign:
+    + Use mktemp rather than a temporary directory name based on the
+      process ID. (Closes: #507482)
+    + Use temporary files rather than redirecting gpg's stdin and stdout,
+      enabling the use of pinentry-gtk2. (Closes: #507479)
   * uscan: Remove the downloads.sourceforge.net example from the manpage.
     It no longer works due to changes in the website structure. Thanks,
     Alexander Block.

Modified: trunk/scripts/debsign.sh
===================================================================
--- trunk/scripts/debsign.sh    2008-12-02 19:50:38 UTC (rev 1748)
+++ trunk/scripts/debsign.sh    2008-12-02 22:00:03 UTC (rev 1749)
@@ -41,8 +41,34 @@
 PROGNAME=`basename $0`
 MODIFIED_CONF_MSG='Default settings modified by devscripts configuration 
files:'
 
+# Temporary directories
+signingdir=""
+remotefilesdir=""
+
+trap "cleanup_tmpdir" 0 1 2 3 9 11 13 15
+
 # --- Functions
 
+mksigningdir () {
+    if [ -z "$signingdir" ]; then
+       signingdir=$(mktemp -dt debsign.XXXXXXXX) || {
+           echo "$PROGNAME: Can't create temporary directory" >&2
+           echo "Aborting..." >&2
+           exit 1
+       }
+    fi
+}
+
+mkremotefilesdir () {
+    if [ -z "$remotefilesdir" ]; then
+       remotefilesdir=$(mktemp -dt debsign.XXXXXXXX) || {
+           echo "$PROGNAME: Can't create temporary directory" >&2
+           echo "Aborting..." >&2
+           exit 1
+       }
+    fi
+}
+
 usage () {
     echo \
 "Usage: debsign [options] [changes, dsc or commands file]
@@ -111,11 +137,20 @@
 }
 
 cleanup_tmpdir () {
-    if [ "$PRECIOUS_FILES" -gt 0 ]; then
-        echo "$PROGNAME: aborting with $PRECIOUS_FILES signed files in `pwd`" 
>&2
-    else
-        cd ..; rm -rf debsign.$$
+    if [ -n "$remotefilesdir" ] && [ -d "$remotefilesdir" ]; then
+       if [ "$PRECIOUS_FILES" -gt 0 ]; then
+           echo "$PROGNAME: aborting with $PRECIOUS_FILES signed files in 
$remotefilesdir" >&2
+           # Only produce the warning once...
+           PRECIOUS_FILES=0
+       else
+           cd ..
+           rm -rf "$remotefilesdir"
+       fi
     fi
+
+    if [ -n "$signingdir" ] && [ -d "$signingdir" ]; then
+       rm -rf "$signingdir"
+    fi
 }
 
 mustsetvar () {
@@ -137,27 +172,32 @@
     local savestty=$(stty -g 2>/dev/null) || true
     if [ $signinterface = gpg ]
     then
-       ASCII_SIGNED_FILE="$(temp_filename "$1" "asc")"
+       mksigningdir
+       UNSIGNED_FILE="$signingdir/$(basename "$1")"
+       ASCII_SIGNED_FILE="${UNSIGNED_FILE}.asc"
 
        gpgversion=`gpg --version | head -n 1 | cut -d' ' -f3`
        gpgmajorversion=`echo $gpgversion | cut -d. -f1`
        gpgminorversion=`echo $gpgversion | cut -d. -f2`
+
        if [ $gpgmajorversion -gt 1 -o $gpgminorversion -ge 4 ]
        then
-               (cat "$1" ; echo "") | \
-                   $signcommand --local-user "$2" --clearsign \
+               (cat "$1" ; echo "") > "$UNSIGNED_FILE"
+               $signcommand --local-user "$2" --clearsign \
                    --list-options no-show-policy-urls \
-                   --armor --textmode --output - - > "$ASCII_SIGNED_FILE" || \
+                   --armor --textmode --output "$ASCII_SIGNED_FILE"\
+                   "$UNSIGNED_FILE" || \
                { SAVESTAT=$?
                  echo "$PROGNAME: gpg error occurred!  Aborting...." >&2
                  stty $savestty 2>/dev/null || true
                  exit $SAVESTAT
                }
        else
-               (cat "$1" ; echo "") | \
-                   $signcommand --local-user "$2" --clearsign \
-                       --no-show-policy-url \
-                       --armor --textmode --output - - > "$ASCII_SIGNED_FILE" 
|| \
+               (cat "$1" ; echo "") > "$UNSIGNED_FILE"
+               $signcommand --local-user "$2" --clearsign \
+                   --no-show-policy-url \
+                   --armor --textmode --output "$ASCII_SIGNED_FILE" \
+                   "$UNSIGNED_FILE" || \
                { SAVESTAT=$?
                  echo "$PROGNAME: gpg error occurred!  Aborting...." >&2
                  stty $savestty 2>/dev/null || true
@@ -372,13 +412,8 @@
     # Do we have to download the changes file?
     if [ -n "$remotehost" ]
     then
-       cd ${TMPDIR:-/tmp}
-       if [ ! -d "debsign.$$" ]
-       then
-           mkdir debsign.$$ || { echo "$PROGNAME: Can't mkdir!" >&2; exit 1; }
-       fi
-       trap "cleanup_tmpdir" 0 1 2 3 7 10 13 15
-       cd debsign.$$
+       mkremotefilesdir
+       cd $remotefilesdir
 
        remotechanges=$changes
        remotedsc=$dsc



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to