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