blob: 8b18f9b1920e5c6836d9c783051048114025ebfa [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 Duffin00537c12018-11-28 12:22:14 +000013 com.android.okhttp \
14 com.sun \
15 dalvik \
16 java \
17 javax \
Paul Duffin997fa462019-02-15 12:58:26 +000018 junit \
Paul Duffin00537c12018-11-28 12:22:14 +000019 libcore \
20 org.apache.harmony \
21 org.json \
22 org.w3c.dom \
23 org.xml.sax \
Paul Duffinad7bf812021-04-01 11:47:54 +010024 org.xmlpull.v1 \
Paul Duffin00537c12018-11-28 12:22:14 +000025 sun \
26 "
27LIBCORE_EMAIL=libcore-team@android.com
28
Paul Duffinad7bf812021-04-01 11:47:54 +010029I18N_PACKAGES="\
30 android.icu \
31 "
32
33I18N_EMAIL=$LIBCORE_EMAIL
34
35CONSCRYPT_PACKAGES="\
36 com.android.org.conscrypt \
37 "
38
39CONSCRYPT_EMAIL=$LIBCORE_EMAIL
40
Paul Duffin00537c12018-11-28 12:22:14 +000041# List of teams.
Paul Duffinad7bf812021-04-01 11:47:54 +010042TEAMS="LIBCORE I18N CONSCRYPT"
43
44SHA=$1
Paul Duffin00537c12018-11-28 12:22:14 +000045
46# Generate the list of packages and convert to a regular expression.
47PACKAGES=$(for t in $TEAMS; do echo $(eval echo \${${t}_PACKAGES}); done)
48RE=$(echo ${PACKAGES} | sed "s/ /|/g")
Paul Duffinad7bf812021-04-01 11:47:54 +010049EXIT_CODE=0
Paul Duffinf998f8b2021-04-07 10:41:24 +010050for file in $(git show --name-only --pretty=format: $SHA | grep "boot/hiddenapi/hiddenapi-.*txt"); do
Paul Duffinad7bf812021-04-01 11:47:54 +010051 ENTRIES=$(grep -E "^\+L(${RE})/" <(git diff ${SHA}~1 ${SHA} $file) | sed "s|^\+||" || echo)
Paul Duffin00537c12018-11-28 12:22:14 +000052 if [[ -n "${ENTRIES}" ]]; then
Paul Duffinad7bf812021-04-01 11:47:54 +010053 echo -e "\e[1m\e[31m$file $SHA contains the following entries\e[0m"
Paul Duffin00537c12018-11-28 12:22:14 +000054 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 Duffinad7bf812021-04-01 11:47:54 +010060 TEAM_RE=$(echo ${PACKAGES} | sed "s/ /|/g")
61 TEAM_ENTRIES=$(grep -E "^L(${TEAM_RE})/" <(echo "${ENTRIES}") || echo)
Paul Duffin00537c12018-11-28 12:22:14 +000062 if [[ -n "${TEAM_ENTRIES}" ]]; then
63 EMAIL=$(eval echo \${${t}_EMAIL})
Paul Duffinad7bf812021-04-01 11:47:54 +010064 echo -e "\e[33mContact ${EMAIL} for help with the following:\e[0m"
65 for i in ${TEAM_ENTRIES}
Paul Duffin00537c12018-11-28 12:22:14 +000066 do
67 echo -e "\e[33m ${i}\e[0m"
68 done
69 fi
70 done
Paul Duffinad7bf812021-04-01 11:47:54 +010071 EXIT_CODE=1
Paul Duffin00537c12018-11-28 12:22:14 +000072 fi
73done
Paul Duffinad7bf812021-04-01 11:47:54 +010074exit $EXIT_CODE