From 65c113f9a234fd37210ee1899952c2b70aa60c6d Mon Sep 17 00:00:00 2001 From: Dennis Groenen Date: Tue, 16 Oct 2012 17:05:41 +0200 Subject: [PATCH] don't warn about backup SHA1 when the providing package has changed --- debian/scripts/functions | 6 ++++++ debian/scripts/install-binary.sh | 1 + debian/scripts/uninstall-binary.sh | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/debian/scripts/functions b/debian/scripts/functions index f5446f0..6d532b6 100644 --- a/debian/scripts/functions +++ b/debian/scripts/functions @@ -52,3 +52,9 @@ CHECK_ROOT() { exit 1 fi } + +# Get the version string of the package providing /bin/busybox +GETBBVERSION() { + # XXX We assume the package "busybox" provides /bin/busybox + /usr/bin/dpkg -s busybox | awk '/^Version:/ {print $2}' +} diff --git a/debian/scripts/install-binary.sh b/debian/scripts/install-binary.sh index 55ef026..27b66c5 100755 --- a/debian/scripts/install-binary.sh +++ b/debian/scripts/install-binary.sh @@ -52,6 +52,7 @@ BACKUP() { $EXECPWR cp -a /bin/busybox $DISTBIN $EXECPWR sha1sum $DISTBIN | $EXECPWR awk '{ print $1 }' \ > $INSTALLDIR/busybox.distrib.sha1 + GETBBVERSION > $INSTALLDIR/busybox.distrib.version fi } diff --git a/debian/scripts/uninstall-binary.sh b/debian/scripts/uninstall-binary.sh index 205213a..c0c1496 100755 --- a/debian/scripts/uninstall-binary.sh +++ b/debian/scripts/uninstall-binary.sh @@ -46,7 +46,10 @@ CHECK_BACKUP() { # Secondly, check the integrity of the backup if test -e $INSTALLDIR/busybox.distrib.sha1; then if test ! "`cat $INSTALLDIR/busybox.distrib.sha1`" == "$ORIGBINARY_SHA1"; then - echo -e "Warning: the backed-up original binary has been modified since installing busybox-power (invalid SHA1 checksum). Do not continue unless you're sure $DISTBIN isn't corrupted.\n" >> /tmp/busybox-power-error + if test "`cat $INSTALLDIR/busybox.distrib.version`" == "`GETBBVERSION`"; then + # The backup has been changed whilst busybox hasn't been upgraded + echo -e "Warning: the backed-up original binary has been modified since installing busybox-power (invalid SHA1 checksum). Do not continue unless you're sure $DISTBIN isn't corrupted.\n" >> /tmp/busybox-power-error + fi fi else echo -e "Warning: couldn't load the saved SHA1 checksum of the original binary; the integrity of the backup of the original binary can not be guaranteed.\n" >> /tmp/busybox-power-error @@ -145,6 +148,7 @@ UNSYMLINK() { # Action to be performed after restoring original busybox CLEANUP() { OLDFILES="busybox-power.symlinks + busybox.distrib.version busybox.distrib.sha1" for file in $OLDFILES; do -- 1.7.9.5