blob: ad7f3a3e8aa6b241f8e44dfbae3a8b94e28c4002 [file] [log] [blame]
Ricardo Cerqueiraaff5e542014-05-09 22:24:12 +01001#!/sbin/sh
2
3# Validate that the incoming OTA is compatible with an already-installed
4# system
5
Brint E. Kriebel84ec9f52014-09-24 12:46:09 -07006grep -q "Command:.*\"--wipe\_data\"" /tmp/recovery.log
7if [ $? -eq 0 ]; then
8 echo "Data will be wiped after install; skipping signature check..."
9 exit 0
10fi
11
Brint E. Kriebel1d055a32014-11-28 17:39:21 -080012grep -q "Command:.*\"--headless\"" /tmp/recovery.log
13if [ $? -eq 0 ]; then
14 echo "Headless mode install; skipping signature check..."
15 exit 0
16fi
17
Ricardo Cerqueiraaff5e542014-05-09 22:24:12 +010018if [ -f /data/system/packages.xml -a -f /tmp/releasekey ]; then
Brint E. Kriebel8cc39922014-07-11 18:44:15 -070019 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')
Ricardo Cerqueiraaff5e542014-05-09 22:24:12 +010020
Ricardo Cerqueirad2248b22014-12-01 15:15:15 +000021 # Tools missing? Err on the side of caution and exit cleanly
22 if [ "z$relCert" == "z" ]; then exit 0; fi
23
Ricardo Cerqueiraaff5e542014-05-09 22:24:12 +010024 grep "cert index=\"$relCert\"" /data/system/packages.xml | grep -q `cat /tmp/releasekey`
25 if [ $? -ne 0 ]; then
26 echo "You have an installed system that isn't signed with this build's key, aborting..."
Ricardo Cerqueirad2248b22014-12-01 15:15:15 +000027 exit 124
Ricardo Cerqueiraaff5e542014-05-09 22:24:12 +010028 fi
29fi
30
31exit 0