Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | # Make sure that entries are not added for packages that are already fully handled using |
| 4 | # annotations. |
| 5 | LOCAL_DIR="$( dirname ${BASH_SOURCE} )" |
| 6 | # Each team should add a <team>_PACKAGES and <team>_EMAIL with the list of packages and |
| 7 | # the team email to use in the event of this detecting an entry in a <team> package. Also |
| 8 | # add <team> to the TEAMS list. |
| 9 | LIBCORE_PACKAGES="\ |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 10 | android.system \ |
Paul Duffin | 997fa46 | 2019-02-15 12:58:26 +0000 | [diff] [blame] | 11 | android.test \ |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 12 | com.android.bouncycastle \ |
Paul Duffin | 352956b | 2018-12-07 11:52:19 +0000 | [diff] [blame] | 13 | com.android.i18n.phonenumbers \ |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 14 | com.android.okhttp \ |
| 15 | com.sun \ |
| 16 | dalvik \ |
| 17 | java \ |
| 18 | javax \ |
Paul Duffin | 997fa46 | 2019-02-15 12:58:26 +0000 | [diff] [blame] | 19 | junit \ |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 20 | libcore \ |
| 21 | org.apache.harmony \ |
| 22 | org.json \ |
| 23 | org.w3c.dom \ |
| 24 | org.xml.sax \ |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 25 | org.xmlpull.v1 \ |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 26 | sun \ |
| 27 | " |
| 28 | LIBCORE_EMAIL=libcore-team@android.com |
| 29 | |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 30 | I18N_PACKAGES="\ |
| 31 | android.icu \ |
| 32 | " |
| 33 | |
| 34 | I18N_EMAIL=$LIBCORE_EMAIL |
| 35 | |
| 36 | CONSCRYPT_PACKAGES="\ |
| 37 | com.android.org.conscrypt \ |
| 38 | " |
| 39 | |
| 40 | CONSCRYPT_EMAIL=$LIBCORE_EMAIL |
| 41 | |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 42 | # List of teams. |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 43 | TEAMS="LIBCORE I18N CONSCRYPT" |
| 44 | |
| 45 | SHA=$1 |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 46 | |
| 47 | # Generate the list of packages and convert to a regular expression. |
| 48 | PACKAGES=$(for t in $TEAMS; do echo $(eval echo \${${t}_PACKAGES}); done) |
| 49 | RE=$(echo ${PACKAGES} | sed "s/ /|/g") |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 50 | EXIT_CODE=0 |
| 51 | for file in $(git show --name-only --pretty=format: $SHA | grep "config/hiddenapi-.*txt"); do |
| 52 | ENTRIES=$(grep -E "^\+L(${RE})/" <(git diff ${SHA}~1 ${SHA} $file) | sed "s|^\+||" || echo) |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 53 | if [[ -n "${ENTRIES}" ]]; then |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 54 | echo -e "\e[1m\e[31m$file $SHA contains the following entries\e[0m" |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 55 | echo -e "\e[1m\e[31mfor packages that are handled using UnsupportedAppUsage. Please remove\e[0m" |
| 56 | echo -e "\e[1m\e[31mthese entries and add annotations instead.\e[0m" |
| 57 | # Partition the entries by team and provide contact details to aid in fixing the issue. |
| 58 | for t in ${TEAMS} |
| 59 | do |
| 60 | PACKAGES=$(eval echo \${${t}_PACKAGES}) |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 61 | TEAM_RE=$(echo ${PACKAGES} | sed "s/ /|/g") |
| 62 | TEAM_ENTRIES=$(grep -E "^L(${TEAM_RE})/" <(echo "${ENTRIES}") || echo) |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 63 | if [[ -n "${TEAM_ENTRIES}" ]]; then |
| 64 | EMAIL=$(eval echo \${${t}_EMAIL}) |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 65 | echo -e "\e[33mContact ${EMAIL} for help with the following:\e[0m" |
| 66 | for i in ${TEAM_ENTRIES} |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 67 | do |
| 68 | echo -e "\e[33m ${i}\e[0m" |
| 69 | done |
| 70 | fi |
| 71 | done |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 72 | EXIT_CODE=1 |
Paul Duffin | 00537c1 | 2018-11-28 12:22:14 +0000 | [diff] [blame] | 73 | fi |
| 74 | done |
Paul Duffin | ad7bf81 | 2021-04-01 11:47:54 +0100 | [diff] [blame^] | 75 | exit $EXIT_CODE |