[devscripts] 01/02: debsign: Refactor remote file handling
James McCoy
jamessan at debian.org
Thu Mar 16 03:35:07 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 799809881e1dcb6926818f71f3ab3477a7df74df
Author: James McCoy <jamessan at debian.org>
Date: Wed Mar 15 23:03:49 2017 -0400
debsign: Refactor remote file handling
Restore use of $remotedir to specify where to copy files on the remote
host. This is needed to allow glob patterns for the remote changes
file.
This also allows removing all the extra "$remote*" arguments to the
maybesign_* functions. All that's required is the host and directory.
Finally, lift the ensure_local_copy calls out of maybesign_* functions,
since the file needs to be local in order to derive the child filenames.
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 2 +
scripts/debsign.sh | 134 +++++++++++++++++++++++++++++------------------------
2 files changed, 76 insertions(+), 60 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 38cc63a..de4990b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ devscripts (2.17.3) UNRELEASED; urgency=medium
(Closes: #857537)
+ Determine the names of related files from the file listings in
.changes/.buildinfo. (Closes: #857536)
+ + In remote mode, ensure files are copied locally before trying to use
+ them. Regression introduced in 2.17.2. (Closes: #857716)
-- 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 7d5b2f4..3f84b63 100755
--- a/scripts/debsign.sh
+++ b/scripts/debsign.sh
@@ -506,10 +506,8 @@ guess_signas() {
maybesign_dsc() {
local signas="$1"
local remotehost="$2"
- local remotedsc="$3"
- local dsc="$4"
+ local dsc="$3"
- ensure_local_copy "$remotehost" "$remotedsc" "$dsc" dsc
if check_already_signed "$dsc" dsc; then
echo "Leaving current signature unchanged." >&2
return
@@ -519,7 +517,7 @@ maybesign_dsc() {
if [ -n "$remotehost" ]
then
- withecho scp "$dsc" "$remotehost:$remotedsc"
+ withecho scp "$dsc" "$remotehost:$remotedir"
PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
fi
}
@@ -527,19 +525,16 @@ maybesign_dsc() {
maybesign_buildinfo() {
local signas="$1"
local remotehost="$2"
- local remotebuildinfo="$3"
- local buildinfo="$4"
- local remotedsc="$5"
- local dsc="$6"
+ local buildinfo="$3"
+ local dsc="$4"
- ensure_local_copy "$remotehost" "$remotebuildinfo" "$buildinfo" buildinfo
if check_already_signed "$buildinfo" "buildinfo"; then
echo "Leaving current signature unchanged." >&2
return
fi
- if grep -q `basename "$dsc"` "$buildinfo"; then
- maybesign_dsc "$signas" "$remotehost" "$remotedsc" "$dsc"
+ if [ -n "$dsc" ]; then
+ maybesign_dsc "$signas" "$remotehost" "$dsc"
withtempfile buildinfo "$buildinfo" fixup_buildinfo "$dsc"
fi
@@ -547,7 +542,7 @@ maybesign_buildinfo() {
if [ -n "$remotehost" ]
then
- withecho scp "$buildinfo" "$remotehost:$remotebuildinfo"
+ withecho scp "$buildinfo" "$remotehost:$remotedir"
PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
fi
}
@@ -555,29 +550,23 @@ maybesign_buildinfo() {
maybesign_changes() {
local signas="$1"
local remotehost="$2"
- local remotechanges="$3"
- local changes="$4"
- local remotebuildinfo="$5"
- local buildinfo="$6"
- local remotedsc="$7"
- local dsc="$8"
-
- ensure_local_copy "$remotehost" "$remotechanges" "$changes" changes
+ local changes="$3"
+ local buildinfo="$4"
+ local dsc="$5"
+
if check_already_signed "$changes" "changes"; then
echo "Leaving current signature unchanged." >&2
return
fi
- hasdsc="$(to_bool grep -q `basename "$dsc"` "$changes")"
- hasbuildinfo="$(to_bool grep -q `basename "$buildinfo"` "$changes")"
+ hasdsc="$(to_bool [ -n "$dsc" ])"
+ hasbuildinfo="$(to_bool [ -n "$buildinfo" ])"
if $hasbuildinfo; then
# assume that this will also sign the same dsc if it's available
- maybesign_buildinfo "$signas" "$remotehost" \
- "$remotebuildinfo" "$buildinfo" \
- "$remotedsc" "$dsc"
+ maybesign_buildinfo "$signas" "$remotehost" "$buildinfo" "$dsc"
elif $hasdsc; then
- maybesign_dsc "$signas" "$remotehost" "$remotedsc" "$dsc"
+ maybesign_dsc "$signas" "$remotehost" "$dsc"
fi
if $hasdsc; then
@@ -590,7 +579,7 @@ maybesign_changes() {
if [ -n "$remotehost" ]
then
- withecho scp "$changes" "$remotehost:$remotechanges"
+ withecho scp "$changes" "$remotehost:$remotedir"
PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
fi
}
@@ -614,20 +603,26 @@ dosigning() {
remotebuildinfo=$buildinfo
remotedsc=$dsc
remotecommands=$commands
- remotedir="`perl -e 'chomp($_="'"$dsc"'"); m%/% && s%/[^/]*$%% && print'`"
changes=`basename "$changes"`
buildinfo=`basename "$buildinfo"`
dsc=`basename "$dsc"`
commands=`basename "$commands"`
+ if [ -n "$changes" ]; then
+ if [ ! -f "$changes" ]; then
+ # Special handling for changes to support supplying a glob
+ # and downloading all matching changes files (c.f., #491627)
+ withecho scp "$remotehost:$remotechanges" .
+ fi
+ fi
+
if [ -n "$changes" ] && echo "$changes" | egrep -q '[][*?]'
then
- withecho scp "$remotehost:$remotechanges" .
for changes in $changes
do
+ dsc=
+ buildinfo=
printf "\n"
- derive_childfile "$changes" buildinfo
- derive_childfile "$changes" dsc
dosigning;
done
exit 0;
@@ -636,12 +631,6 @@ dosigning() {
if [ -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
-
ensure_local_copy "$remotehost" "$remotecommands" "$commands" commands
check_already_signed "$commands" commands && {
echo "Leaving current signature unchanged." >&2
@@ -698,7 +687,7 @@ for valid format" >&2;
if [ -n "$remotehost" ]
then
- withecho scp "$commands" "$remotehost:$remotecommands"
+ withecho scp "$commands" "$remotehost:$remotedir"
PRECIOUS_FILES=$(($PRECIOUS_FILES - 1))
fi
@@ -706,25 +695,39 @@ for valid format" >&2;
elif [ -n "$changes" ]
then
+ ensure_local_copy "$remotehost" "$remotechanges" "$changes" changes
+ derive_childfile "$changes" dsc
+ if [ -n "$dsc" ]
+ then
+ ensure_local_copy "$remotehost" "${remotedir}$dsc" "$dsc" dsc
+ fi
+ derive_childfile "$changes" buildinfo
+ if [ -n "$buildinfo" ]
+ then
+ ensure_local_copy "$remotehost" "${remotedir}$buildinfo" "$buildinfo" buildinfo
+ fi
signas="$(guess_signas "$changes")"
maybesign_changes "$signas" "$remotehost" \
- "$remotechanges" "$changes" \
- "$remotebuildinfo" "$buildinfo" \
- "$remotedsc" "$dsc"
+ "$changes" "$buildinfo" "$dsc"
report_signed
elif [ -n "$buildinfo" ]
then
+ ensure_local_copy "$remotehost" "$remotebuildinfo" "$buildinfo" buildinfo
+ derive_childfile "$buildinfo" dsc
+ if [ -n "$dsc" ]
+ then
+ ensure_local_copy "$remotehost" "${remotedir}$dsc" "$dsc" dsc
+ fi
signas="$(guess_signas "$buildinfo")"
maybesign_buildinfo "$signas" "$remotehost" \
- "$remotebuildinfo" "$buildinfo" \
- "$remotedsc" "$dsc"
+ "$buildinfo" "$dsc"
report_signed
else
+ ensure_local_copy "$remotehost" "$remotehost" "$remotedsc" dsc
signas="$(guess_signas "$dsc")"
- maybesign_dsc "$signas" "$remotehost" \
- "$remotedsc" "$dsc"
+ maybesign_dsc "$signas" "$remotehost" "$dsc"
report_signed
fi
@@ -734,9 +737,27 @@ 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"
+ local fname dir
+ fname="$(sed -n '/^\(Checksum\|Files\)/,/^\(Checksum\|Files\)/s/.*[ ]\([^ ]*\.'"$ext"'\)$/\1/p' "$base" | head -n1)"
+ get_dirname "$base" dir
+ eval "$ext=\"${dir}$fname\""
+}
+
+get_dirname() {
+ local path="$1"
+ local varname="$2"
+
+ local d
+ d="$(dirname "$path")"
+
+ if [ "$d" = "." ]
+ then
+ d=""
+ else
+ d="$d/"
+ fi
+
+ eval "$varname=\"$d\""
}
# If there is a command-line parameter, it is the name of a .changes file
@@ -803,35 +824,28 @@ case $# in
;;
*) while [ $# -gt 0 ]; do
+ changes=
+ buildinfo=
+ dsc=
+ commands=
case "$1" in
*.dsc)
- changes=
- buildinfo=
dsc=$1
- commands=
;;
*.buildinfo)
- changes=
buildinfo=$1
- derive_childfile "$buildinfo" dsc
- commands=
;;
*.changes)
changes=$1
- derive_childfile "$changes" buildinfo
- derive_childfile "$changes" dsc
- commands=
;;
*.commands)
- changes=
- buildinfo=
- dsc=
commands=$1
;;
*)
echo "$PROGNAME: Only a .changes, .buildinfo, .dsc or .commands file is allowed as argument!" >&2
exit 1 ;;
esac
+ get_dirname "$1" remotedir
dosigning
shift
done
--
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