Ricardo Cerqueira | aff5e54 | 2014-05-09 22:24:12 +0100 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | |
| 3 | # Validate that the incoming OTA is compatible with an already-installed |
| 4 | # system |
| 5 | |
Brint E. Kriebel | 84ec9f5 | 2014-09-24 12:46:09 -0700 | [diff] [blame] | 6 | grep -q "Command:.*\"--wipe\_data\"" /tmp/recovery.log |
| 7 | if [ $? -eq 0 ]; then |
| 8 | echo "Data will be wiped after install; skipping signature check..." |
| 9 | exit 0 |
| 10 | fi |
| 11 | |
Ricardo Cerqueira | aff5e54 | 2014-05-09 22:24:12 +0100 | [diff] [blame] | 12 | if [ -f /data/system/packages.xml -a -f /tmp/releasekey ]; then |
Brint E. Kriebel | 8cc3992 | 2014-07-11 18:44:15 -0700 | [diff] [blame] | 13 | 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 Cerqueira | aff5e54 | 2014-05-09 22:24:12 +0100 | [diff] [blame] | 14 | |
Ricardo Cerqueira | d2248b2 | 2014-12-01 15:15:15 +0000 | [diff] [blame^] | 15 | # Tools missing? Err on the side of caution and exit cleanly |
| 16 | if [ "z$relCert" == "z" ]; then exit 0; fi |
| 17 | |
Ricardo Cerqueira | aff5e54 | 2014-05-09 22:24:12 +0100 | [diff] [blame] | 18 | grep "cert index=\"$relCert\"" /data/system/packages.xml | grep -q `cat /tmp/releasekey` |
| 19 | if [ $? -ne 0 ]; then |
| 20 | echo "You have an installed system that isn't signed with this build's key, aborting..." |
Ricardo Cerqueira | d2248b2 | 2014-12-01 15:15:15 +0000 | [diff] [blame^] | 21 | exit 124 |
Ricardo Cerqueira | aff5e54 | 2014-05-09 22:24:12 +0100 | [diff] [blame] | 22 | fi |
| 23 | fi |
| 24 | |
| 25 | exit 0 |