Skip to content

Commit d60d25c

Browse files
committed
Sync with microG unofficial installer
1 parent be083f0 commit d60d25c

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

zip-content/addon.d/00-1-google-sync.sh

100644100755
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,72 @@
33
# SPDX-FileCopyrightText: none
44
# SPDX-License-Identifier: CC0-1.0
55

6+
VANITY_NAME='Google sync add-on'
7+
8+
_fix_tmpdir()
9+
{
10+
# In some cases ${TMPDIR} is not set and it cause errors with HereDocs
11+
if test -z "${TMPDIR-}" || test ! -w "${TMPDIR:?}"; then
12+
if test -w '/tmp'; then TMPDIR='/tmp'; elif test -w '/data/local/tmp'; then TMPDIR='/data/local/tmp'; elif test -w '/postinstall/tmp'; then TMPDIR='/postinstall/tmp'; fi
13+
fi
14+
}
15+
616
_init_debug_log()
717
{
18+
test -z "${DEBUG_LOG-}" || return
19+
_fix_tmpdir
820
DEBUG_LOG=0
921
DEBUG_LOG_FILE=''
1022

1123
if command 1> /dev/null -v 'getprop' && test "$(getprop 'zip.common.DEBUG_LOG' '0' || :)" = 1; then
12-
if test -d "${TMPDIR:-/tmp}" && DEBUG_LOG_FILE="${TMPDIR:-/tmp}/debug-a5k.log"; then :; else test -d '/postinstall/tmp' && DEBUG_LOG_FILE='/postinstall/tmp/debug-a5k.log'; fi
13-
if test -n "${DEBUG_LOG_FILE?}" && touch "${DEBUG_LOG_FILE:?}"; then DEBUG_LOG=1; fi
24+
if test -n "${TMPDIR-}" && test -w "${TMPDIR:?}" && DEBUG_LOG_FILE="${TMPDIR:?}/debug-a5k.log" && touch "${DEBUG_LOG_FILE:?}"; then
25+
echo 1>&2 "Writing log: ${DEBUG_LOG_FILE?}"
26+
DEBUG_LOG=1
27+
fi
1428
fi
1529
}
1630

1731
_display_msg()
1832
{
33+
_init_debug_log
1934
echo "${1?}"
2035
test "${DEBUG_LOG:?}" = 0 || echo "${1?}" 1>> "${DEBUG_LOG_FILE:?}"
2136
}
2237

2338
# NOTE: The following file come from => https://github.com/LineageOS/android_vendor_lineage/blob/HEAD/prebuilt/common/bin/backuptool.functions
2439
# shellcheck source=/dev/null
2540
command . /tmp/backuptool.functions || {
26-
_init_debug_log
2741
_display_msg 1>&2 'ERROR: Failed to source backuptool.functions'
2842
# shellcheck disable=SC2317
2943
return 9 || exit 9
3044
}
3145

3246
list_files()
3347
{
34-
cat << 'EOF'
48+
{
49+
cat << 'EOF'
3550
%PLACEHOLDER-1%
3651
EOF
52+
} || {
53+
_display_msg 1>&2 'ERROR: HereDoc failed'
54+
return 1
55+
}
3756
}
3857

3958
case "${1-}" in
4059
backup)
41-
_init_debug_log
42-
_display_msg 'Backup of Google sync add-on in progress...'
60+
_display_msg "${VANITY_NAME?} - stage: ${1?}..."
4361
list_files | while IFS='|' read -r FILE _; do
44-
if test -z "${FILE?}"; then continue; fi
62+
test -n "${FILE?}" || continue
4563
_display_msg " ${S:?}/${FILE:?}"
4664
backup_file "${S:?}/${FILE:?}"
4765
done
4866
_display_msg 'Done.'
4967
;;
5068
restore)
51-
_init_debug_log
52-
_display_msg 'Restore of Google sync add-on in progress...'
69+
_display_msg "${VANITY_NAME?} - stage: ${1?}..."
5370
list_files | while IFS='|' read -r FILE REPLACEMENT; do
54-
if test -z "${FILE?}"; then continue; fi
71+
test -n "${FILE?}" || continue
5572
R=''
5673
test -n "${REPLACEMENT?}" && R="${S:?}/${REPLACEMENT:?}"
5774
test -f "${C:?}/${S:?}/${FILE:?}" && restore_file "${S:?}/${FILE:?}" "${R?}"
@@ -71,7 +88,6 @@ case "${1-}" in
7188
# Stub
7289
;;
7390
*)
74-
_init_debug_log
7591
_display_msg 1>&2 "WARNING: addon.d unknown phase => ${1-}"
7692
;;
7793
esac

0 commit comments

Comments
 (0)