blob: fa8ffcda17c44c3099220deb53811e6974f2edcc [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
Pierre-Hugues Hussonc598ee62018-11-03 20:57:44 +010044 if [ -d /build/AOSP-9.0 ] && \
45 (ag '"'$key'"' /build/AOSP-9.0/frameworks/base/core/res/res || \
46 ag '"'$key'"' /build/AOSP-8.1/frameworks/base/core/res/res)> /dev/null ;then
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010047 echo $key >> tests/knownKeys
48 else
49 echo $xml defines a non-existing attribute $key
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010050 touch fail
Pierre-Hugues Husson9212e182018-10-30 23:40:10 +010051 fi
52 done
53 done
54done
55rm -f tests/priorities
56
Pierre-Hugues Hussonf6418262018-11-03 20:38:36 +010057if find -name \*.xml |xargs dos2unix -ic |grep -qE .;then
58 echo "The following files have dos end of lines"
59 find -name \*.xml |xargs dos2unix -ic
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010060 touch fail
Pierre-Hugues Hussonf6418262018-11-03 20:38:36 +010061fi
62
Pierre-Hugues Husson72801462018-11-03 20:55:21 +010063if [ -f fail ];then exit 1; fi