Просмотр исходного кода

dpkg-maintscript-helper: Use the new --validate-version command

Do not abuse the --compare-versions command to perform version
validation, use the new --validate-version command expressly added
now to perform such task. Because the latter returns appropriate exit
codes, does not print messages in debug mode and is the correct
interface to use.

Closes: #844701
Guillem Jover лет назад: 9
Родитель
Сommit
b51bc4ff0c
2 измененных файлов с 7 добавлено и 6 удалено
  1. 3 0
      debian/changelog
  2. 4 6
      scripts/dpkg-maintscript-helper.sh

+ 3 - 0
debian/changelog

@@ -15,6 +15,9 @@ dpkg (1.18.16) UNRELEASED; urgency=medium
   * Add new dpkg --validate-<thing> commands to validate the syntax of
     various <thing>s, where the current list is «pkgname», «trigname»,
     «archname» and «version».
+  * Use the new dpkg --validate-version command in dpkg-maintscript-helper,
+    instead of abusing the --compare-versions command to perform version
+    validation. Closes: #844701
   * Perl modules:
     - Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
       DPKG_DATADIR environment variables in Dpkg::Build::Info.

+ 4 - 6
scripts/dpkg-maintscript-helper.sh

@@ -48,9 +48,8 @@ rm_conffile() {
 		error "environment variable DPKG_MAINTSCRIPT_NAME is required"
 	[ "${CONFFILE}" != "${CONFFILE#/}" ] || \
 		error "conffile '$CONFFILE' is not an absolute path"
-	# Use --compare-versions to validate the version number.
-	[ -z "$(dpkg --compare-versions -- "$LASTVERSION" eq '0' 2>&1)" ] || \
-		error "version '$LASTVERSION' is not valid"
+	VERSIONCHECK=$(dpkg --validate-version -- "$LASTVERSION" 2>&1) || \
+		error "$VERSIONCHECK"
 
 	debug "Executing $0 rm_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"
@@ -162,9 +161,8 @@ mv_conffile() {
 		error "old-conffile '$OLDCONFFILE' is not an absolute path"
 	[ "${NEWCONFFILE}" != "${NEWCONFFILE#/}" ] || \
 		error "new-conffile '$NEWCONFFILE' is not an absolute path"
-	# Use --compare-versions to validate the version number.
-	[ -z "$(dpkg --compare-versions -- "$LASTVERSION" eq '0' 2>&1)" ] || \
-		error "version '$LASTVERSION' is not valid"
+	VERSIONCHECK=$(dpkg --validate-version -- "$LASTVERSION" 2>&1) || \
+		error "$VERSIONCHECK"
 
 	debug "Executing $0 mv_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"