Skip to content

Commit 922841b

Browse files
committed
Sync with microG unofficial installer
1 parent 1af8acb commit 922841b

File tree

13 files changed

+223
-99
lines changed

13 files changed

+223
-99
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fi
255255

256256
printf '%s\n' 'Setting name;Visibility;Type' 1> "${TEMP_DIR:?}/zip-content/setprop-settings-list.csv" || ui_error 'Failed to generate setprop settings list (1)'
257257
printf '%s\n' 'DRY_RUN;local;integer' 1>> "${TEMP_DIR:?}/zip-content/setprop-settings-list.csv" || ui_error 'Failed to generate setprop settings list (2)'
258-
printf '%s\n' 'KEY_TEST_ONLY;local;integer' 1>> "${TEMP_DIR:?}/zip-content/setprop-settings-list.csv" || ui_error 'Failed to generate setprop settings list (3)'
258+
printf '%s\n' 'KEY_TEST_ONLY;local;numeric-boolean' 1>> "${TEMP_DIR:?}/zip-content/setprop-settings-list.csv" || ui_error 'Failed to generate setprop settings list (3)'
259259

260260
while IFS='#=; ' read -r _ PROP_NAME PROP_VALUE PROP PROP_VISIBILITY PROP_TYPE _; do
261261
if test "${PROP?}" != 'setprop'; then continue; fi

includes/common.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export ftp_proxy="${ftp_proxy-}"
7979
{
8080
readonly WGET_CMD='wget'
8181
readonly DL_UA='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0'
82-
readonly DL_ACCEPT_HEADER='Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'
82+
readonly DL_ACCEPT_HEADER='Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
8383
readonly DL_ACCEPT_ALL_HEADER='Accept: */*'
8484
readonly DL_ACCEPT_LANG_HEADER='Accept-Language: en-US,en;q=0.5'
8585
readonly DL_DNT_HEADER='DNT: 1'
@@ -531,7 +531,9 @@ send_web_request_and_output_response()
531531
if test -n "${_authorization?}"; then set -- "${@}" --header "Authorization: ${_authorization:?}" || return "${?}"; fi
532532
if test "${_method:?}" = 'POST'; then
533533
_body_data_length="$(_get_byte_length "${_body_data?}")" || return "${?}"
534-
set -- "${@}" --header 'Content-Type: text/plain;charset=UTF-8' --header "Content-Length: ${_body_data_length:?}" || return "${?}"
534+
if test "${_body_data_length:?}" -gt 0; then
535+
set -- "${@}" --header 'Content-Type: text/plain;charset=UTF-8' --header "Content-Length: ${_body_data_length:?}" || return "${?}"
536+
fi
535537
fi
536538
if test -n "${_origin?}"; then set -- "${@}" --header "Origin: ${_origin:?}" || return "${?}"; fi
537539
if test -n "${_cookies?}"; then set -- "${@}" --header "Cookie: ${_cookies:?}" || return "${?}"; fi
@@ -766,6 +768,7 @@ dl_type_two()
766768
while true; do
767769
_http_headers="$(send_web_request_and_output_headers "${_last_location_url:?}" 'GET')"
768770
_status_code="$(parse_headers_and_get_status_code "${_http_headers?}")"
771+
if test "${DL_DEBUG:?}" = 'true'; then printf '%s\n' "Status code: ${_status_code?}"; fi
769772

770773
case "${_status_code?}" in
771774
2*) # Final location URL found (usually 200)
@@ -779,11 +782,11 @@ dl_type_two()
779782
}
780783
;;
781784
404)
782-
report_failure 2 "77" "get location url ${_count:?}" 'THE FILE HAS BEEN DELETED ON THE SERVER!!!'
785+
report_failure 2 "77" "get location url ${_count:?}" 'WARNING: THE FILE HAS BEEN DELETED ON THE SERVER!!!'
783786
return "${?}"
784787
;;
785788
*)
786-
report_failure 2 "78" "get location url ${_count:?}" "UNSUPPORTED HTTP STATUS CODE: ${_status_code?}"
789+
report_failure 2 "78" "get location url ${_count:?}" "Unsupported HTTP status code: ${_status_code?}"
787790
return "${?}"
788791
;;
789792
esac
@@ -796,10 +799,10 @@ dl_type_two()
796799

797800
_loc_code="$(printf '%s\n' "${_last_location_url:?}" | cut -d '/' -f '5-' -s)" ||
798801
report_failure 2 "${?}" 'get location code' || return "${?}"
799-
# DEBUG => echo "${_loc_code:?}"
802+
if test "${DL_DEBUG:?}" = 'true'; then printf '%s\n' "Loc code: ${_loc_code?}"; fi
800803

801804
sleep 0.2
802-
_json_response="$(send_web_request_and_output_response "${_base_api_url:?}/accounts" 'POST' "${_base_referrer:?}" "${_base_origin:?}" '' '' '{}')" ||
805+
_json_response="$(send_web_request_and_output_response "${_base_api_url:?}/accounts" 'POST' "${_base_referrer:?}" "${_base_origin:?}" '' '' '')" ||
803806
report_failure 2 "${?}" 'do AJAX post req' || return "${?}"
804807
if test "${DL_DEBUG:?}" = 'true'; then printf '%s\n' "${_json_response?}"; fi
805808

@@ -867,7 +870,7 @@ dl_file()
867870

868871
if test "${CI:-false}" = 'false'; then sleep 0.5; else sleep 3; fi
869872
case "${_domain:?}" in
870-
*\.'go''file''.io')
873+
*\.'go''file''.io' | 'go''file''.io')
871874
printf '\n %s: ' 'DL type 2'
872875
dl_type_two "${_url:?}" "${MAIN_DIR:?}/cache/${1:?}/${2:?}" || _status="${?}"
873876
;;

tools/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TOOLS
99

1010
- zipsigner_ **3.0** => zipsigner.jar
1111
- zipsigner_ **3.0** (Dalvik) => zipsigner-dvk.jar
12-
- `BusyBox for Windows`_ **1.38.0-PRE-5578-g14ccc45d5 (2025-02-03)** => win/busybox.exe
12+
- `BusyBox for Windows`_ **1.38.0-PRE-5580-g3de63bc17 (2025-03-17)** => win/busybox.exe
1313
- `BusyBox legacy for Windows`_ **1.21.0-TIG-931-g7e6a84d (2012-11-29)** => win/busybox-legacy.bin
1414
- Zip_ **3.0** => win/zip.exe
1515
- UnZip_ **6.0** => win/unzip.exe

tools/get-signature.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@
66
# shellcheck disable=SC3043 # In POSIX sh, local is undefined
77

88
export SCRIPT_NAME='Get signature'
9-
export SCRIPT_VERSION='0.0.1'
9+
export SCRIPT_VERSION='0.0.3'
1010

11-
"${APKSIGNER_PATH:-apksigner}" verify --min-sdk-version 24 --print-certs -- "${1:?}" | grep -m 1 -F -e 'certificate SHA-256 digest' | cut -d ':' -f '2-' -s | tr -d -- ' ' | tr -- '[:lower:]' '[:upper:]' | sed -e 's/../&:/g;s/:$//'
11+
get_cert_sha256()
12+
{
13+
local _cert_sha256
14+
15+
test -n "${APKSIGNER_PATH-}" || APKSIGNER_PATH="$(command -v 'apksigner')" || APKSIGNER_PATH="$(command -v 'apksigner.bat')" || :
16+
17+
if test -n "${APKSIGNER_PATH-}"; then
18+
_cert_sha256="$("${APKSIGNER_PATH:?}" verify --min-sdk-version 24 --print-certs -- "${1:?}" | grep -m 1 -F -e 'certificate SHA-256 digest:' | cut -d ':' -f '2-' -s | tr -d -- ' ' | tr -- '[:lower:]' '[:upper:]' | sed -e 's/../&:/g;s/:$//')" || _cert_sha256=''
19+
elif command 1> /dev/null -v 'keytool'; then
20+
_cert_sha256="$(keytool -printcert -jarfile "${1:?}" | grep -m 1 -F -e 'SHA256:' | cut -d ':' -f '2-' -s | tr -d -- ' ')" || _cert_sha256=''
21+
fi
22+
23+
if test -n "${_cert_sha256?}"; then
24+
printf '%s\n' "sha256-cert-digest=\"${_cert_sha256:?}\""
25+
else
26+
return 1
27+
fi
28+
}
29+
30+
get_cert_sha256 "${@}"

tools/win/busybox.exe

0 Bytes
Binary file not shown.

tools/win/man/cat1/busybox.1.gz

-190 Bytes
Binary file not shown.

zip-content/META-INF/com/google/android/update-binary.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ unset RANDOM_IS_SEEDED
2828

2929
### PREVENTIVE CHECKS ###
3030

31-
command 1> /dev/null -v printf || {
31+
_redirect_command()
32+
{
33+
eval " ${1:?}() { busybox '${1:?}' \"\${@}\"; } " || {
34+
echo 1>&2 "ERROR: Replacing ${1?} failed"
35+
exit 100
36+
}
37+
}
38+
39+
command 1> /dev/null -v 'printf' || {
3240
if command 1> /dev/null -v busybox; then
33-
alias printf='busybox printf'
41+
_redirect_command 'printf'
3442
else
3543
{
3644
printf()
@@ -48,7 +56,7 @@ command 1> /dev/null -v printf || {
4856

4957
command 1> /dev/null -v uname || {
5058
if command 1> /dev/null -v busybox; then
51-
alias uname='busybox uname'
59+
_redirect_command 'uname'
5260
elif command 1> /dev/null -v getprop; then
5361
{
5462
uname()
@@ -69,22 +77,26 @@ command 1> /dev/null -v uname || {
6977
fi
7078
}
7179

72-
command 1> /dev/null -v dirname || {
80+
command 1> /dev/null -v 'dirname' || {
7381
dirname()
7482
{
7583
printf '%s\n' "${1%/*}"
7684
}
7785
}
7886

79-
command 1> /dev/null -v unzip || {
87+
command 1> /dev/null -v 'unzip' || {
8088
if command 1> /dev/null -v busybox; then
81-
alias unzip='busybox unzip'
89+
_redirect_command 'unzip'
8290
else
8391
printf 1>&2 '\033[1;31m%s\033[0m\n' "ERROR: Missing => unzip"
8492
exit 100
8593
fi
8694
}
8795

96+
command 1> /dev/null -v 'grep' || {
97+
if command 1> /dev/null -v busybox; then _redirect_command 'grep'; fi
98+
}
99+
88100
### FUNCTIONS AND CODE ###
89101

90102
# Detect whether we are in boot mode
@@ -243,8 +255,11 @@ package_extract_file 'customize.sh' "${_ub_our_main_script:?}"
243255

244256
echo "Loading ${LAST_RANDOM:?}-customize.sh..."
245257
# shellcheck source=SCRIPTDIR/../../../../customize.sh
246-
. "${_ub_our_main_script:?}" || ui_error "Failed to source customize.sh"
247-
rm -f "${_ub_our_main_script:?}" || ui_error "Failed to delete customize.sh"
258+
command . "${_ub_our_main_script:?}" || ui_error "Failed to source '${_ub_our_main_script?}'"
259+
260+
if test -f "${_ub_our_main_script:?}"; then
261+
rm "${_ub_our_main_script:?}" || ui_error "Failed to delete '${_ub_our_main_script?}'"
262+
fi
248263
unset _ub_our_main_script
249264

250265
if test "${_ub_we_mounted_tmp:?}" = true; then

zip-content/customize.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ _log_path_setter()
108108
if test ! -e "${1:?}"; then return 1; fi
109109

110110
local _path
111-
_path="$(readlink -f "${1:?}")" || _path="$(realpath "${1:?}")" || return 1
111+
_path="$(readlink 2> /dev/null -f "${1:?}")" || _path="$(realpath "${1:?}")" || return 1
112112
if test -w "${_path:?}"; then
113113
LOG_PATH="${_path:?}/debug-a5k.log"
114114
return 0

zip-content/inc/common-functions.sh

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ mount_partition_if_possible()
708708

709709
_get_local_settings()
710710
{
711-
if test "${LOCAL_SETTINGS_READ:-false}" = 'true'; then return; fi
711+
test "${LOCAL_SETTINGS_READ:-false}" = 'false' || return
712712

713713
ui_debug 'Parsing local settings...'
714714
ui_debug ''
@@ -719,34 +719,53 @@ _get_local_settings()
719719
export LOCAL_SETTINGS LOCAL_SETTINGS_READ
720720
}
721721

722+
_parse_setting_helper()
723+
{
724+
local _val
725+
726+
# If the length is 2 it is empty: []
727+
if _val="$(printf '%s\n' "${LOCAL_SETTINGS?}" | grep -m 1 -F -e "[${1:?}]" | cut -d ':' -f '2-' -s)" && _val="${_val# }" && test "${#_val}" -gt 2; then
728+
printf '%s\n' "${_val?}" | cut -c "2-$((${#_val} - 1))"
729+
return 0
730+
fi
731+
732+
return 1
733+
}
734+
722735
parse_setting()
723736
{
724-
local _var _use_last_choice
737+
local _var _sett_type _sett_name _sett_default_val _sett_use_prev_choice
738+
739+
_sett_type="${1:-app}"
740+
_sett_name="${2:?}"
741+
_sett_default_val="${3?}"
742+
_sett_use_prev_choice="${4:-true}"
725743

726-
_use_last_choice="${3:-true}"
727744
_get_local_settings
728745

729-
_var="$(printf '%s\n' "${LOCAL_SETTINGS?}" | grep -m 1 -F -e "[zip.${MODULE_ID:?}.${1:?}]" | cut -d ':' -f '2-' -s)" || _var=''
730-
_var="${_var# }"
731-
if test "${#_var}" -gt 2; then
732-
printf '%s\n' "${_var?}" | cut -c "2-$((${#_var} - 1))"
746+
if test "${_sett_type:?}" = 'app'; then
747+
if _parse_setting_helper "zip.${MODULE_ID:?}.APP_${_sett_name:?}" || _parse_setting_helper "zip.${MODULE_ID:?}.INSTALL_${_sett_name:?}"; then
748+
return
749+
fi
750+
_sett_name="APP_${_sett_name:?}"
751+
elif _parse_setting_helper "zip.${MODULE_ID:?}.${_sett_name:?}"; then
733752
return
734753
fi
735754

736755
# Fallback to the last choice
737-
if test "${_use_last_choice:?}" = 'true' && _var="$(simple_file_getprop "${1:?}" "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop")" && test -n "${_var?}"; then
756+
if test "${_sett_use_prev_choice:?}" = 'true' && _var="$(simple_file_getprop "${_sett_name:?}" "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop")" && test -n "${_var?}"; then
738757
printf '%s\n' "${_var:?}"
739758
return
740-
elif test "${_use_last_choice:?}" = 'custom' && _var="$(simple_file_getprop "${4:?}" "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop")" && test -n "${_var?}"; then
759+
elif test "${_sett_use_prev_choice:?}" = 'custom' && _var="$(simple_file_getprop "${5:?}" "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop")" && test -n "${_var?}"; then
741760
case "${_var:?}" in
742-
"${5:?}") printf '1\n' ;;
743-
*) printf '0\n' ;;
761+
"${6:?}") printf '%s\n' '1' ;;
762+
*) printf '%s\n' '0' ;;
744763
esac
745764
return
746765
fi
747766

748767
# Fallback to the default value
749-
printf '%s\n' "${2?}"
768+
printf '%s\n' "${_sett_default_val?}"
750769
}
751770

752771
remount_read_write()
@@ -1025,7 +1044,7 @@ initialize()
10251044
# Make sure that the commands are still overridden here (most shells don't have the ability to export functions)
10261045
if test "${TEST_INSTALL:-false}" != 'false' && test -f "${RS_OVERRIDE_SCRIPT:?}"; then
10271046
# shellcheck source=SCRIPTDIR/../../recovery-simulator/inc/configure-overrides.sh
1028-
. "${RS_OVERRIDE_SCRIPT:?}" || exit "${?}"
1047+
command . "${RS_OVERRIDE_SCRIPT:?}" || ui_error "Sourcing override script failed with error: ${?}"
10291048
fi
10301049

10311050
PRODUCT_PATH=''
@@ -1056,11 +1075,11 @@ initialize()
10561075

10571076
_get_local_settings
10581077

1059-
DRY_RUN="$(parse_setting 'DRY_RUN' "${DRY_RUN:?}" 'false')"
1060-
KEY_TEST_ONLY="$(parse_setting 'KEY_TEST_ONLY' "${KEY_TEST_ONLY:?}" 'false')"
1078+
DRY_RUN="$(parse_setting 'general' 'DRY_RUN' "${DRY_RUN:?}" 'false')"
1079+
KEY_TEST_ONLY="$(parse_setting 'general' 'KEY_TEST_ONLY' "${KEY_TEST_ONLY:?}" 'false')"
10611080

1062-
LIVE_SETUP_DEFAULT="$(parse_setting 'LIVE_SETUP_DEFAULT' "${LIVE_SETUP_DEFAULT:?}" 'false')"
1063-
LIVE_SETUP_TIMEOUT="$(parse_setting 'LIVE_SETUP_TIMEOUT' "${LIVE_SETUP_TIMEOUT:?}" 'false')"
1081+
LIVE_SETUP_DEFAULT="$(parse_setting 'general' 'LIVE_SETUP_DEFAULT' "${LIVE_SETUP_DEFAULT:?}" 'false')"
1082+
LIVE_SETUP_TIMEOUT="$(parse_setting 'general' 'LIVE_SETUP_TIMEOUT' "${LIVE_SETUP_TIMEOUT:?}" 'false')"
10641083

10651084
case "${KEY_TEST_ONLY?}" in '' | *[!0-1]*) KEY_TEST_ONLY=1 ;; *) ;; esac
10661085
if test "${KEY_TEST_ONLY:?}" -eq 1; then DRY_RUN=2; fi
@@ -1173,12 +1192,17 @@ initialize()
11731192

11741193
IS_EMU='false'
11751194
case "${BUILD_DEVICE?}" in
1176-
'windows_x86_64' | 'emu64'*) IS_EMU='true' ;;
1177-
*) ;;
1195+
'windows_'* | 'emu64'*) IS_EMU='true' ;;
1196+
'generic_'*) if is_string_starting_with 'EMULATOR' "$(sys_getprop 'ro.serialno' || :)"; then IS_EMU='true'; fi ;;
1197+
*)
1198+
if
1199+
is_string_starting_with 'sdk_google_phone_' "${BUILD_PRODUCT?}" ||
1200+
is_valid_prop "$(simple_getprop 'ro.leapdroid.version' || printf '%s\n' 'unknown' || :)"
1201+
then
1202+
IS_EMU='true'
1203+
fi
1204+
;;
11781205
esac
1179-
if is_string_starting_with 'sdk_google_phone_' "${BUILD_PRODUCT?}" || is_valid_prop "$(simple_getprop 'ro.leapdroid.version' || printf '%s\n' 'unknown' || :)"; then
1180-
IS_EMU='true'
1181-
fi
11821206
readonly IS_EMU
11831207
export IS_EMU
11841208

@@ -1360,7 +1384,7 @@ clean_previous_installations()
13601384
readonly IS_INCLUDED='true'
13611385
export IS_INCLUDED
13621386
# shellcheck source=SCRIPTDIR/../scripts/uninstall.sh
1363-
. "${TMP_PATH:?}/uninstall.sh"
1387+
command . "${TMP_PATH:?}/uninstall.sh" || ui_error "Sourcing uninstall script failed with error: ${?}"
13641388

13651389
delete "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop"
13661390

@@ -1451,7 +1475,7 @@ prepare_installation()
14511475
echo '# SPDX-FileCopyrightText: none'
14521476
echo '# SPDX-License-Identifier: CC0-1.0'
14531477
echo ''
1454-
echo 'install.type=system'
1478+
echo 'install.destination=system'
14551479
echo "install.build.type=${BUILD_TYPE:?}"
14561480
echo "install.version.code=${MODULE_VERCODE:?}"
14571481
echo "install.version=${MODULE_VERSION:?}"
@@ -2121,7 +2145,7 @@ copy_file()
21212145

21222146
move_file()
21232147
{
2124-
mv -f "$1" "$2"/ || ui_error "Failed to move the file '$1' to '$2'" 100
2148+
mv -f "$1" "$2"/ || ui_error "Failed to move the file '$1' to '$2'" 101
21252149
}
21262150

21272151
move_rename_file()
@@ -2175,12 +2199,31 @@ delete_temp()
21752199
{
21762200
for filename in "${@}"; do
21772201
if test -e "${TMP_PATH:?}/${filename?}"; then
2178-
#ui_debug "Deleting '${TMP_PATH?}/${filename?}'..."
2179-
rm -rf -- "${TMP_PATH:?}/${filename:?}" || ui_error 'Failed to delete temp files/folders' 103
2202+
# ui_debug "Deleting '${TMP_PATH?}/${filename?}'..."
2203+
rm -rf -- "${TMP_PATH:?}/${filename:?}" || ui_error 'Failed to delete temp files/folders in delete_temp()' 103
21802204
fi
21812205
done
21822206
}
21832207

2208+
delete_if_sha256_match()
2209+
{
2210+
local _filename _filehash _hash
2211+
2212+
if test -f "${1:?}"; then
2213+
_filename="${1:?}"
2214+
_filehash="$(sha256sum -- "${_filename:?}" | cut -d ' ' -f '1' -s)" || ui_error 'Failed to calculate SHA256 hash' 103
2215+
shift
2216+
for _hash in "${@}"; do
2217+
if test "${_hash:?}" = "${_filehash:?}"; then
2218+
ui_debug "Deleting '${_filename:?}'..."
2219+
rm -f -- "${_filename:?}" || ui_error 'Failed to delete file in delete_if_sha256_match()' 103
2220+
return
2221+
fi
2222+
done
2223+
ui_debug "Deletion of '${_filename:?}' skipped due to hash mismatch!"
2224+
fi
2225+
}
2226+
21842227
delete_dir_if_empty()
21852228
{
21862229
if test -d "$1"; then

zip-content/module.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
numericId=928871
66
id=google-sync-addon
77
name=Google Sync add-on
8-
version=v1.3.1.85-alpha
8+
version=v1.3.1.86-alpha
99
versionCode=5
1010
author=ale5000
1111
description=It installs Google sync adapters on Android.

0 commit comments

Comments
 (0)