otasigcheck: Use an explicit exit code for failures
Change-Id: I2b5860ea427a4db7e29b55cc632b92c6e2910494
diff --git a/prebuilt/common/bin/otasigcheck.sh b/prebuilt/common/bin/otasigcheck.sh
index 5131be3..7bf1228 100644
--- a/prebuilt/common/bin/otasigcheck.sh
+++ b/prebuilt/common/bin/otasigcheck.sh
@@ -12,12 +12,13 @@
if [ -f /data/system/packages.xml -a -f /tmp/releasekey ]; then
relCert=$(grep -A3 'package name="com.android.htmlviewer"' /data/system/packages.xml | grep "cert index" | head -n 1 | sed -e 's|.*"\([[:digit:]][[:digit:]]*\)".*|\1|g')
+ # Tools missing? Err on the side of caution and exit cleanly
+ if [ "z$relCert" == "z" ]; then exit 0; fi
+
grep "cert index=\"$relCert\"" /data/system/packages.xml | grep -q `cat /tmp/releasekey`
if [ $? -ne 0 ]; then
echo "You have an installed system that isn't signed with this build's key, aborting..."
- # Edify doesn't abort on non-zero executions, so let's trash the key and use sha1sum instead
- echo "INVALID" > /tmp/releasekey
- exit 1
+ exit 124
fi
fi