[Reproducible-commits] [dpkg] 66/105: dpkg-maintscript-helper: Decouple local declaration from command assignment

Niko Tyni ntyni at moszumanska.debian.org
Mon May 2 13:49:54 UTC 2016


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

ntyni pushed a commit to branch ntyni/reproducible_builds
in repository dpkg.

commit fbdbddc0a8454bbee8d0958086b5be3dd774843d
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Apr 1 21:17:22 2016 +0200

    dpkg-maintscript-helper: Decouple local declaration from command assignment
    
    The assignment within an export/local/declare builtin masks the command
    return value, which means that if we are running with «set -e» the
    shell will not notice an error from the command.
    
    Warned-by: shellcheck
---
 debian/changelog                   |  3 +++
 scripts/dpkg-maintscript-helper.sh | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a54288c..2c3ffd2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -57,6 +57,9 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     dpkg-maintscript-helper, instead of using a variable pathname as a regex
     with grep, which is susceptible to metacharacters acting as part of the
     regex. Proposed by Carsten Hey <carsten at debian.org>.
+  * Decouple local keyword declaration from command assignment in
+    dpkg-maintscript-helper, which masks the command return value when
+    using «set -e».
   * Portability:
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
       code, to make life easier for non-dpkg-based systems.
diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh
index 29fd857..01ea51f 100755
--- a/scripts/dpkg-maintscript-helper.sh
+++ b/scripts/dpkg-maintscript-helper.sh
@@ -88,8 +88,9 @@ prepare_rm_conffile() {
 	[ -e "$CONFFILE" ] || return 0
 	ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0
 
-	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
-	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
+	local md5sum old_md5sum
+	md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
+	old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
 		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" != "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-backup"
@@ -191,8 +192,9 @@ prepare_mv_conffile() {
 
 	ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0
 
-	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
-	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
+	local md5sum old_md5sum
+	md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
+	old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
 		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" = "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-remove"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list