Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | base="$(dirname "$(readlink -f -- $0)")/.." |
| 4 | cd $base |
| 5 | |
| 6 | #Keep knownKeys |
Pierre-Hugues Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 7 | rm -f tests/priorities fail |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 8 | touch tests/priorities tests/knownKeys |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 9 | find -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 Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 15 | touch fail |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 16 | 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 Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 27 | touch fail |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 28 | 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 Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 34 | touch fail |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 35 | 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 Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 40 | for key in $keys;do |
Pierre-Hugues Husson | 0381192 | 2018-10-31 00:08:08 +0100 | [diff] [blame] | 41 | grep -qE '^'$key'$' tests/knownKeys && continue |
Pierre-Hugues Husson | 3de1d74 | 2018-10-30 23:52:01 +0100 | [diff] [blame] | 42 | #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 Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 45 | echo $key >> tests/knownKeys |
| 46 | else |
| 47 | echo $xml defines a non-existing attribute $key |
Pierre-Hugues Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 48 | touch fail |
Pierre-Hugues Husson | 9212e18 | 2018-10-30 23:40:10 +0100 | [diff] [blame] | 49 | fi |
| 50 | done |
| 51 | done |
| 52 | done |
| 53 | rm -f tests/priorities |
| 54 | |
Pierre-Hugues Husson | f641826 | 2018-11-03 20:38:36 +0100 | [diff] [blame] | 55 | if 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 Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 58 | touch fail |
Pierre-Hugues Husson | f641826 | 2018-11-03 20:38:36 +0100 | [diff] [blame] | 59 | fi |
| 60 | |
Pierre-Hugues Husson | 7280146 | 2018-11-03 20:55:21 +0100 | [diff] [blame^] | 61 | if [ -f fail ];then exit 1; fi |