blob: 2924e010983013b7aae4eb21695248f709397d24 [file] [log] [blame]
Paul Duffin00537c12018-11-28 12:22:14 +00001#!/bin/bash
2set -e
3# Make sure that entries are not added for packages that are already fully handled using
4# annotations.
5LOCAL_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.
9LIBCORE_PACKAGES="\
Paul Duffin00537c12018-11-28 12:22:14 +000010 android.system \
Paul Duffin997fa462019-02-15 12:58:26 +000011 android.test \
Paul Duffin00537c12018-11-28 12:22:14 +000012 com.android.bouncycastle \
Paul Duffin352956b2018-12-07 11:52:19 +000013 com.android.i18n.phonenumbers \
Paul Duffin00537c12018-11-28 12:22:14 +000014 com.android.okhttp \
15 com.sun \
16 dalvik \
17 java \
18 javax \
Paul Duffin997fa462019-02-15 12:58:26 +000019 junit \
Paul Duffin00537c12018-11-28 12:22:14 +000020 libcore \
21 org.apache.harmony \
22 org.json \
23 org.w3c.dom \
24 org.xml.sax \
Paul Duffinad7bf812021-04-01 11:47:54 +010025 org.xmlpull.v1 \
Paul Duffin00537c12018-11-28 12:22:14 +000026 sun \
27 "
28LIBCORE_EMAIL=libcore-team@android.com
29
Paul Duffinad7bf812021-04-01 11:47:54 +010030I18N_PACKAGES="\
31 android.icu \
32 "
33
34I18N_EMAIL=$LIBCORE_EMAIL
35
36CONSCRYPT_PACKAGES="\
37 com.android.org.conscrypt \
38 "
39
40CONSCRYPT_EMAIL=$LIBCORE_EMAIL
41
Paul Duffin00537c12018-11-28 12:22:14 +000042# List of teams.
Paul Duffinad7bf812021-04-01 11:47:54 +010043TEAMS="LIBCORE I18N CONSCRYPT"
44
45SHA=$1
Paul Duffin00537c12018-11-28 12:22:14 +000046
47# Generate the list of packages and convert to a regular expression.
48PACKAGES=$(for t in $TEAMS; do echo $(eval echo \${${t}_PACKAGES}); done)
49RE=$(echo ${PACKAGES} | sed "s/ /|/g")
Paul Duffinad7bf812021-04-01 11:47:54 +010050EXIT_CODE=0
51for 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 Duffin00537c12018-11-28 12:22:14 +000053 if [[ -n "${ENTRIES}" ]]; then
Paul Duffinad7bf812021-04-01 11:47:54 +010054 echo -e "\e[1m\e[31m$file $SHA contains the following entries\e[0m"
Paul Duffin00537c12018-11-28 12:22:14 +000055 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 Duffinad7bf812021-04-01 11:47:54 +010061 TEAM_RE=$(echo ${PACKAGES} | sed "s/ /|/g")
62 TEAM_ENTRIES=$(grep -E "^L(${TEAM_RE})/" <(echo "${ENTRIES}") || echo)
Paul Duffin00537c12018-11-28 12:22:14 +000063 if [[ -n "${TEAM_ENTRIES}" ]]; then
64 EMAIL=$(eval echo \${${t}_EMAIL})
Paul Duffinad7bf812021-04-01 11:47:54 +010065 echo -e "\e[33mContact ${EMAIL} for help with the following:\e[0m"
66 for i in ${TEAM_ENTRIES}
Paul Duffin00537c12018-11-28 12:22:14 +000067 do
68 echo -e "\e[33m ${i}\e[0m"
69 done
70 fi
71 done
Paul Duffinad7bf812021-04-01 11:47:54 +010072 EXIT_CODE=1
Paul Duffin00537c12018-11-28 12:22:14 +000073 fi
74done
Paul Duffinad7bf812021-04-01 11:47:54 +010075exit $EXIT_CODE