blob: 938607e7b7943af2d7dc55dcbf9688e8253d5634 [file] [log] [blame]
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +01001#!/bin/bash
2
3base="$(dirname "$(readlink -f -- $0)")/.."
4cd $base
5
6#Keep knownKeys
Pierre-Hugues Husson72801462018-11-03 20:55:21 +01007rm -f tests/priorities fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +01008touch tests/priorities tests/knownKeys
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +01009find -name AndroidManifest.xml |while read manifest;do
10 folder="$(dirname "$manifest")"
11 #Ensure this overlay doesn't override blacklist-ed properties
12 for b in $(cat tests/blacklist);do
13 if grep -qRF "$b" $folder;then
14 echo "Overlay $folder is defining $b which is forbidden"
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010015 touch fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010016 fi
17 done
18
19 #Everything after that is specifically for static overlays, targetting framework-res
20 isStatic="$(xmlstarlet sel -t -m '//overlay' -v @android:isStatic -n $manifest)"
21 [ "$isStatic" != "true" ] && continue
22
23 #Ensure priorities unique-ness
24 priority="$(xmlstarlet sel -t -m '//overlay' -v @android:priority -n $manifest)"
25 if grep -qE '^'$priority'$' tests/priorities;then
26 echo $manifest priority $priority conflicts with another manifest
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010027 touch fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010028 fi
29 echo $priority >> tests/priorities
30
31 systemPropertyName="$(xmlstarlet sel -t -m '//overlay' -v @android:requiredSystemPropertyName -n $manifest)"
32 if [ "$systemPropertyName" == "ro.vendor.product.name" ];then
33 echo "$manifest: ro.vendor.product.name is deprecated. Please use ro.vendor.build.fingerprint"
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010034 touch fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010035 fi
36
37 #Ensure the overloaded properties exist in AOSP
38 find "$folder" -name \*.xml |while read xml;do
39 keys="$(xmlstarlet sel -t -m '//resources/*' -v @name -n $xml)"
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010040 for key in $keys;do
Pierre-Hugues Husson03811922018-10-31 00:08:08 +010041 grep -qE '^'$key'$' tests/knownKeys && continue
Pierre-Hugues Husson3de1d742018-10-30 23:52:01 +010042 #Run the ag only on phh's machine. Assume that knownKeys is full enough.
43 #If it's enough, ask phh to update it
44 if [ -d /build/AOSP-9.0 ] && ag '"'$key'"' /build/AOSP-9.0/frameworks/base/core/res/res > /dev/null;then
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010045 echo $key >> tests/knownKeys
46 else
47 echo $xml defines a non-existing attribute $key
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010048 touch fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010049 fi
50 done
51 done
52done
53rm -f tests/priorities
54
Pierre-Hugues Hussonf6418262018-11-03 20:38:36 +010055if find -name \*.xml |xargs dos2unix -ic |grep -qE .;then
56 echo "The following files have dos end of lines"
57 find -name \*.xml |xargs dos2unix -ic
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010058 touch fail
Pierre-Hugues Hussonf6418262018-11-03 20:38:36 +010059fi
60
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010061if [ -f fail ];then exit 1; fi