[dpkg] 79/200: dpkg-maintscript-helper: Handle empty versions as they are optional arguments

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:20 UTC 2017


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

infinity0 pushed a commit to branch master
in repository dpkg.

commit 0b8cb1a8ed053e2e6a28c2100397002222dd7eaf
Author: Guillem Jover <guillem at debian.org>
Date:   Sun Dec 18 12:23:04 2016 +0100

    dpkg-maintscript-helper: Handle empty versions as they are optional arguments
    
    Regression introduced in commit b51bc4ff0cd540b82e131470053eeed1c3d2f026.
    
    Closes: #848422
---
 debian/changelog                   |  2 ++
 scripts/dpkg-maintscript-helper.sh | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 136365c..f623e13 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 dpkg (1.18.17) UNRELEASED; urgency=medium
 
   [ Guillem Jover ]
+  * Handle empty versions on validation in dpkg-maintscript-helper as they
+    are optional. Regression introduced in dpkg 1.18.16. Closes: #848422
   * Documentation:
     - Clarify that dpkg-buildpackage does not run «dpkg-source --before-build»
       when using the -T option. Closes: #649531
diff --git a/scripts/dpkg-maintscript-helper.sh b/scripts/dpkg-maintscript-helper.sh
index dd65a43..81d32e0 100755
--- a/scripts/dpkg-maintscript-helper.sh
+++ b/scripts/dpkg-maintscript-helper.sh
@@ -48,8 +48,7 @@ rm_conffile() {
 		error "environment variable DPKG_MAINTSCRIPT_NAME is required"
 	[ "${CONFFILE}" != "${CONFFILE#/}" ] || \
 		error "conffile '$CONFFILE' is not an absolute path"
-	VERSIONCHECK=$(dpkg --validate-version -- "$LASTVERSION" 2>&1) || \
-		error "$VERSIONCHECK"
+	validate_optional_version "$LASTVERSION"
 
 	debug "Executing $0 rm_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"
@@ -161,8 +160,7 @@ mv_conffile() {
 		error "old-conffile '$OLDCONFFILE' is not an absolute path"
 	[ "${NEWCONFFILE}" != "${NEWCONFFILE#/}" ] || \
 		error "new-conffile '$NEWCONFFILE' is not an absolute path"
-	VERSIONCHECK=$(dpkg --validate-version -- "$LASTVERSION" 2>&1) || \
-		error "$VERSIONCHECK"
+	validate_optional_version "$LASTVERSION"
 
 	debug "Executing $0 mv_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"
@@ -493,6 +491,18 @@ abort_dir_to_symlink()
 }
 
 # Common functions
+validate_optional_version() {
+	local VERSION="$1"
+
+	if [ -z "$VERSION" ]; then
+		return
+	fi
+
+	if ! VERSIONCHECK=$(dpkg --validate-version -- "$VERSION" 2>&1); then
+		error "$VERSIONCHECK"
+	fi
+}
+
 ensure_package_owns_file() {
 	local PACKAGE="$1"
 	local FILE="$2"

-- 
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