2 #This file is part of The Open GApps script of @mfonville.
4 # The Open GApps scripts are free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # These scripts are distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
15 command -v realpath
>/dev
/null
2>&1 ||
{ echo "realpath is required but it's not installed, aborting." >&2; exit 1; }
17 SOURCES
="$TOP/sources"
18 SCRIPTS
="$TOP/scripts"
19 CERTIFICATES
="$SCRIPTS/certificates"
20 # shellcheck source=scripts/inc.tools.sh
21 .
"$SCRIPTS/inc.tools.sh"
22 # shellcheck source=scripts/inc.compatibility.sh
23 .
"$SCRIPTS/inc.compatibility.sh"
24 # shellcheck source=scripts/inc.sourceshelper.sh
25 .
"$SCRIPTS/inc.sourceshelper.sh"
28 checktools aapt coreutils jarsigner
33 nobeta
) nobeta
="! -ipath '*.beta*'";;
34 nohelp
) nohelp
="nohelp";;
35 noleanback
) noleanback
="! -ipath '*.leanback*'";;
36 nosig
) nosig
="nosig";;
37 nostub
) nostub
="! -ipath '*.stub*'";;
38 all
) filterapparchs
="${filterapparchs} all";;
39 arm
) filterapparchs
="${filterapparchs} arm";;
40 arm64
) filterapparchs
="${filterapparchs} arm64";;
41 x86
) filterapparchs
="${filterapparchs} x86";;
42 x86_64
) filterapparchs
="${filterapparchs} x86_64";;
43 max
*mb
) filtermaxsize
="${1:3:-2}"
44 [ ! -z "${filtermaxsize##*[!0-9]*}" ] ||
{ echo "ERROR: invalid argument" && exit 1; };;
45 min
*mb
) filterminsize
="${1:3:-2}"
46 [ ! -z "${filterminsize##*[!0-9]*}" ] ||
{ echo "ERROR: invalid argument" && exit 1; };;
47 *-*) buildarch
="$(echo "$1" | cut -f 1 -d '-')"
48 maxsdk
="$(echo "$1" | cut -f 2 -d '-')"
49 [ ! -z "${maxsdk##*[!0-9]*}" ] ||
{ echo "ERROR: invalid argument" && exit 1; };;
50 *) [ ! -z "${1##*[!0-9]*}" ] && maxsdk
="$1" ||
{ echo "ERROR: invalid argument" && exit 1; };;
70 if [ -z "$hash" ] && [ -z "$nohelp" ]; then
71 echo "=== Simple How To ===:
72 * No arguments: Show all packages of all architectures and SDK-levels
74 * SDK-level as a argument: Show packages that are eligable to be picked when building for specified SDK-level
75 * all|arm|arm64|x86|x86_64: Show only packages of given architecture
76 * These arguments can be combined in any order and multiple architectures can be supplied
77 * Example command: './report_sources.sh 22 all arm arm64'
79 * (all|arm|arm64|x86|x86_64)-(SDK-level): Show packages that will be selected when building for specified architecture and SDK-level
80 * Example command: './report_sources.sh arm-22'
82 * hash: If you add hash as an extra argument, the result will not be returned as human readable, but with a unique hash for the resultset
83 * max*mb: If you specify a number for *, the result will only include APKs that are at most that size (or equal) in (rounded) MiBs
84 * min*mb: If you specify a number for *, the result will only include APKs that are at least that size (or equal) in (rounded) MiBs
85 * nobeta: If you add nobeta as an extra argument, the result will not include the apps that are marked as beta (=ending on .beta)
86 * nohelp: If you add nohelp as an extra argument, the result will not include this helptext (not necessary if hash is used)
87 * noleanback: If you add noleanback as an extra argument, the result will not include the apps that are marked as leanback (=ending on .leanback)
88 * nosig: Skips signature checking (which takes a lot of CPU power); NB: this does change the hash result!
89 * nostub: If you add nostub as an extra argument, the result will not include the apps that are marked as stub (=ending on .stub)
90 * Example command: './report_sources.sh arm-22 hash'
91 --------------------------------------------------------------------------------------------------------------------------"
95 arm64|x86
) fallbackarchs
="arm";;
96 x86_64
) fallbackarchs
="x86 arm";;
100 result
="$(printf "%61s|
%6s|
%3s|
%15s|
%35s|
%10s|
%3s|
%4s
" "Application Name
" "Arch.
" "SDK
" "DPI
" "Version Name
" "Version
" "MiB
" "Sig.
")
101 ------------------------------------------------------------------------------------------------------------------------------------------------"
102 searchstring
="find '$SOURCES/' -iname '*.apk' $nobeta $noleanback | awk -F '/' '{print \$(NF-3)}' | sort | uniq"
103 allapps
="$(eval "$searchstring")"
104 for appname
in $allapps; do
105 appnamefiles
="$(find "$SOURCES/" -iname "*.apk
" -ipath "*/$appname/*")"
106 if [ -n "$buildarch" ]; then
107 apparchs
="$buildarch $fallbackarchs all"
108 elif [ -n "$filterapparchs" ];then
109 apparchs
="$filterapparchs"
111 apparchs
="$(printf "%s
" "$appnamefiles" | awk -F '/' '{print $(NF-5)}' | sort | uniq)"
114 for arch
in $apparchs; do
115 appsdkfiles
="$(find "$SOURCES/$arch/" -iname "*.apk
" -ipath "*/$appname/*")"
116 appsdks
="$(printf "%s
" "$appsdkfiles" | awk -F '/' '{print $(NF-2)}' | sort -r -g | uniq)"
118 for sdk
in $appsdks; do
119 if [ "$sdk" -le "$maxsdk" ]; then
120 appdpifiles
="$(find "$SOURCES/$arch/" -iname "*.apk
" -ipath "*/$appname/$sdk/*")"
121 appdpis
="$(printf "%s
" "$appdpifiles" | awk -F '/' '{print $(NF-1)}' | sort | uniq)"
122 for dpi
in $appdpis; do
123 appversionfile
="$(find "$SOURCES/$arch/" -iname "*.apk
" -ipath "*/$appname/$sdk/$dpi/*" | head -n 1)"
124 apksize
="$(du --apparent-size -m "$appversionfile" | cut -f 1)"
125 if { [ -z "$filtermaxsize" ] ||
[ "$apksize" -le "$filtermaxsize" ];} && { [ -z "$filterminsize" ] ||
[ "$apksize" -ge "$filterminsize" ];} then
126 getapkproperties
"$appversionfile" #set versionname and versioncode
127 if [ -z "$nosig" ]; then
128 if verifyapk
"$appversionfile" "silent"; then
137 $(printf "%61s|
%6s|
%3s|
%15s|
%35s|
%10s|
%3s|
%4s
" "$appname" "$arch" "$sdk" "$dpi" "$versionname" "$versioncode" "$apksize" "$signed")"
140 if [ -n "$buildarch" ]; then
141 break 2 #when selecting for the build of a specified architeture and sdk, only one architecture result is enough
142 elif [ "$maxsdk" != "99" ];then
143 break #if a specific sdk level is supplied, we only show 1 relevant version
149 if [ -z "$hash" ]; then
152 printf "%s" "$result" |
md5sum | cut
-f1 -d' '