Hi!

On Mon, 2016-11-21 at 01:47:45 +0530, shirish शिरीष wrote:
> The patch didn't work :(

Well that it didn't work was actually also very useful! Because in
your case it should not have worked due to having debug output
enabled. If you retry it again w/o debugging enabled it should work,
and the attached patch should make it impervious to debug settings.

> So it seems some issue is still there. I'll reboot and see if the
> issue still persists.

Yes and no. The original problem should be gone (the problem with the
exit code, the new problem with the non-empty output string due to the
debug output is new, but very welcome as it should make the code more
robust. Thanks for that. Attached new patch.

(BTW reboot should not in general fix this kind of issues. :)

Thanks,
Guillem
diff --git i/scripts/dpkg-maintscript-helper.sh w/scripts/dpkg-maintscript-helper.sh
index f20d82647..54d42d9b5 100755
--- i/scripts/dpkg-maintscript-helper.sh
+++ w/scripts/dpkg-maintscript-helper.sh
@@ -49,8 +49,9 @@ rm_conffile() {
 	[ "${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 -D0 --compare-versions -- "$LASTVERSION" eq '0' 2>&1 || true)"
+	[ -z "$VERSIONCHECK" ] || \
+		error "version '$LASTVERSION' is not valid: $VERSIONCHECK"
 
 	debug "Executing $0 rm_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"
@@ -163,8 +164,9 @@ mv_conffile() {
 	[ "${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 -D0 --compare-versions -- "$LASTVERSION" eq '0' 2>&1 || true)"
+	[ -z "$VERSIONCHECK" ] || \
+		error "version '$LASTVERSION' is not valid: $VERSIONCHECK"
 
 	debug "Executing $0 mv_conffile in $DPKG_MAINTSCRIPT_NAME" \
 	      "of $DPKG_MAINTSCRIPT_PACKAGE"

Reply via email to