Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

Commit 46087cb

Browse files
committed
introducing APPCACHESPLUS config variable
- allowing for additional read-only caches - useful for pre-installed stuff from different vendors and for common Android packages - helps to keep "generic" stuff separate and easier to maintain
1 parent 222183a commit 46087cb

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

adebar-cli

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PARTBACKUPDIR="images"
1515
DOCDIR="docs"
1616
CONFDIR="conf"
1717
CACHEDIR=""
18+
APPCACHESPLUS=""
1819
TRANSFER_DIR=""
1920

2021
# -------------------=[ device specifics ]=--

doc/config.sample

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ DOCDIR="docs"
1919
CONFDIR="conf"
2020
# where Adebar stores information between runs, e.g. app names
2121
CACHEDIR=""
22+
# additional cache dirs for Bloatware and other pre-installed stuff (space separated list
23+
# of directories relative to $CACHEDIR/appnames/ – directory names may NOT contain spaces
24+
# APPCACHESPLUS="sysApps/Android sysApps/Google sysApps"
25+
APPCACHESPLUS=""
2226
# base dir for transfers (install, push files, etc.
2327
TRANSFER_DIR=""
2428

lib/packagedata.lib

+33-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@
1212
# $1: package name
1313
# $2: path to apk file (for aapt)
1414
# $3: whether to retrieve the app name if not found in cache
15+
# $4: optional path to append to cache base dir. If set, only scan this (no AAPT, no update)
1516
#
1617
getAppname() {
18+
# Special cache dir?
19+
[[ -n "${CACHEDIR}" ]] && {
20+
if [[ -n "$4" && -d "${CACHEDIR}/appnames/${4}" ]]; then
21+
local CACHEDIR="${CACHEDIR}/appnames/${4}"
22+
local SCANONLY=1
23+
elif [[ -n "$4" ]]; then # specified sub-cache doesn't exist
24+
echo "$1"
25+
return
26+
else
27+
local SCANONLY=0
28+
local CACHEDIR="${CACHEDIR}/appnames"
29+
fi
30+
}
1731
# Check cache first (fastest if we have it)
18-
if [[ -n "${CACHEDIR}" && -f "${CACHEDIR}/appnames/$1" ]]; then
19-
local name="$(cat "${CACHEDIR}/appnames/$1")"
32+
if [[ -n "${CACHEDIR}" && -f "${CACHEDIR}/$1" ]]; then
33+
local name="$(cat "${CACHEDIR}/$1")"
2034
name="${name%"${name##*[![:space:]]}"}" # remove trailing spaces
2135
name="${name#"${name%%[![:space:]]*}"}" # remove leading spaces
2236
if [[ -n "${name}" ]]; then
@@ -25,12 +39,18 @@ getAppname() {
2539
fi
2640
fi
2741

42+
# ScanOnly mode (special cache dir found)?
43+
if [[ $SCANONLY -ne 0 ]]; then
44+
echo "$1"
45+
return
46+
fi
47+
2848
# still here, so not found in cache. Try AAPT (if we have it)
2949
if [[ $HAVE_AAPT -eq 1 ]]; then
3050
local str="$(adb ${ADBOPTS} shell "aapt d badging $2 2>/dev/null | grep 'application: label' | sed -n \"s/.*label\='\([^']*\)'.*/\1/p\"")" # label='Some App'"
3151
str=${str//[$'\t\r\n']} # stupid ^M
3252
if [[ -n "${str}" ]]; then
33-
[[ -n "${CACHEDIR}" && -e "${CACHEDIR}/appnames" && ! -f "${CACHEDIR}/appnames/$1" ]] && echo -n $str > "${CACHEDIR}/appnames/$1"
53+
[[ -n "${CACHEDIR}" && -e "${CACHEDIR}" && ! -f "${CACHEDIR}/$1" ]] && echo -n $str > "${CACHEDIR}/$1"
3454
echo "${str}"
3555
return
3656
fi
@@ -40,7 +60,7 @@ getAppname() {
4060
if [[ ${3} -gt 0 && -n "${APPNAME_CMD}" ]]; then
4161
name="$(${APPNAME_CMD} $1)"
4262
if [[ "${name}" != "$1" ]]; then
43-
echo "${name}" > "${CACHEDIR}/appnames/$1"
63+
echo "${name}" > "${CACHEDIR}/$1"
4464
fi
4565
echo "${name}"
4666
return
@@ -400,7 +420,15 @@ function _makeAppDoc() {
400420
local CUR_INSTALLER
401421
local APPNAME
402422
for app in ${applist[@]}; do
403-
APPNAME=$(getAppname "${app}" "${PK_CODEPATH[$app]}" $_retrieveAppNames)
423+
if [[ "$1" = "system" && -n "${APPCACHESPLUS}" ]]; then
424+
for appcache in ${APPCACHESPLUS}; do
425+
APPNAME=$(getAppname "${app}" "${PK_CODEPATH[$app]}" $_retrieveAppNames "${appcache}")
426+
[[ "${APPNAME}" != "${app}" ]] && break;
427+
done
428+
[[ "${APPNAME}" = "${app}" ]] && APPNAME=$(getAppname "${app}" "${PK_CODEPATH[$app]}" $_retrieveAppNames)
429+
else
430+
APPNAME=$(getAppname "${app}" "${PK_CODEPATH[$app]}" $_retrieveAppNames)
431+
fi
404432
if [[ -z "${PK_INSTALLER[$app]}" ]]; then # no installer
405433
if [[ "${APPNAME}" = "${app}" ]]; then
406434
tmpstring="+ $app\n"

0 commit comments

Comments
 (0)