Skip to content

Commit 505735d

Browse files
committed
Sync with microG unofficial installer
1 parent 83517ce commit 505735d

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

includes/common.sh

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ _get_byte_length()
381381
_dl_validate_exit_code()
382382
{
383383
test "${DL_DEBUG:?}" = 'false' || ui_debug "${1?} exit code: ${2?}"
384+
test "${2:?}" -lt 10 || return 10
384385
return "${2:?}"
385386
}
386387

@@ -392,23 +393,23 @@ _dl_validate_status_code_from_header_file()
392393
test "${DL_DEBUG:?}" != 'true' || ui_debug "Status code: ${_status_code?}"
393394

394395
case "${_status_code?}" in
395-
2*) return 0 ;; # Successful responses like "200 OK" => OK
396-
3*) return 30 ;; # Various types of redirects => follow them
397-
403) return 43 ;; # 403 Forbidden (the server is refusing us) => do NOT re-try to use the same server
398-
404) return 44 ;; # 404 Not Found (the file was deleted) => skip it
399-
5*) return 50 ;; # Various types of server errors => do NOT re-try to use the same server
396+
2*) return 0 ;; # Successful responses like "200 OK" => good
397+
3*) return 30 ;; # Various types of redirects => follow them
398+
404) return 144 ;; # 404 Not Found (the file was deleted) => skip only current file
399+
403) return 43 ;; # 403 Forbidden (the server is refusing us) => do NOT try to use the same server again
400+
5*) return 50 ;; # Various types of server errors => do NOT try to use the same server again
400401
*) ;;
401402
esac
402403

403-
return 99 # Unknown error
404+
return 99 # Unknown errors => do NOT try to use the same server again
404405
}
405406

406407
_parse_webpage_and_get_url()
407408
{
408409
local _desc _url _referrer _search_pattern
409410
local _domain _cookies _parsed_code _parsed_url _status
410411
local _headers_file
411-
local _status_code
412+
local _server_status_code
412413

413414
_desc="${1?}"
414415
_url="${2:?}"
@@ -437,9 +438,9 @@ _parse_webpage_and_get_url()
437438
_parsed_code="$("${WGET_CMD:?}" -q -O '-' "${@}" -- "${_url:?}" 2> "${_headers_file:?}")" || _status="${?}"
438439
test "${DL_DEBUG:?}" != 'true' || cat 1>&2 "${_headers_file:?}"
439440
_dl_validate_status_code_from_header_file "${_headers_file:?}" || {
440-
_status="${?}"
441+
_server_status_code="${?}"
441442
ui_debug "Failed at ${_desc?}"
442-
return "${_status:?}"
443+
return "${_server_status_code:?}"
443444
}
444445
_dl_validate_exit_code 'wget' "${_status:?}" || return 16
445446
test -n "${_parsed_code?}" || return 17
@@ -465,7 +466,7 @@ _parse_webpage_and_get_url()
465466
}
466467
rm -f "${_headers_file:?}" || return 23
467468

468-
printf '%s\n' "${_parsed_url:?}"
469+
printf '%s\n' "${_parsed_url:?}" || return 24
469470
}
470471

471472
dl_debug()
@@ -680,7 +681,10 @@ _direct_download()
680681
local _url _method _referrer _origin _authorization _accept
681682
local _is_ajax='false'
682683
local _cookies=''
684+
local _status _domain _headers_file
685+
local _server_status_code
683686

687+
_status=0
684688
_url="${1:?}"
685689
_output="${2:?}"
686690
_method="${3:-GET}" # Optional (only GET and POST are supported, GET is default)
@@ -691,23 +695,42 @@ _direct_download()
691695
if test -n "${_origin?}"; then _is_ajax='true'; fi
692696

693697
if test "${_is_ajax:?}" = 'true' || test "${_accept?}" = 'all'; then
694-
set -- -U "${DL_UA:?}" --header "${DL_ACCEPT_ALL_HEADER:?}" --header "${DL_ACCEPT_LANG_HEADER:?}" || return "${?}"
698+
set -- -U "${DL_UA:?}" --header "${DL_ACCEPT_ALL_HEADER:?}" --header "${DL_ACCEPT_LANG_HEADER:?}" || return 11
695699
else
696-
set -- -U "${DL_UA:?}" --header "${DL_ACCEPT_HEADER:?}" --header "${DL_ACCEPT_LANG_HEADER:?}" || return "${?}"
700+
set -- -U "${DL_UA:?}" --header "${DL_ACCEPT_HEADER:?}" --header "${DL_ACCEPT_LANG_HEADER:?}" || return 12
697701
fi
698702

699703
if test "${_is_ajax:?}" != 'true'; then
700-
if _cookies="$(_load_cookies "${_url:?}")"; then _cookies="${_cookies%; }"; else return "${?}"; fi
704+
if _cookies="$(_load_cookies "${_url:?}")"; then _cookies="${_cookies%; }"; else return 13; fi
701705
fi
702706

703-
if test -n "${_referrer?}"; then set -- "${@}" --header "Referer: ${_referrer:?}" || return "${?}"; fi
704-
if test -n "${_authorization?}"; then set -- "${@}" --header "Authorization: ${_authorization:?}" || return "${?}"; fi
705-
if test -n "${_origin?}"; then set -- "${@}" --header "Origin: ${_origin:?}" || return "${?}"; fi
706-
if test -n "${_cookies?}"; then set -- "${@}" --header "Cookie: ${_cookies:?}" || return "${?}"; fi
707-
if test "${_method:?}" = 'POST'; then set -- "${@}" --post-data '' || return "${?}"; fi
707+
if test -n "${_referrer?}"; then set -- "${@}" --header "Referer: ${_referrer:?}" || return 14; fi
708+
if test -n "${_authorization?}"; then set -- "${@}" --header "Authorization: ${_authorization:?}" || return 15; fi
709+
if test -n "${_origin?}"; then set -- "${@}" --header "Origin: ${_origin:?}" || return 16; fi
710+
if test -n "${_cookies?}"; then set -- "${@}" --header "Cookie: ${_cookies:?}" || return 17; fi
711+
if test "${_method:?}" = 'POST'; then set -- "${@}" --post-data '' || return 18; fi
708712

709-
if test "${DL_DEBUG:?}" = 'true'; then dl_debug "${_url:?}" "${_method:?}" "${@}"; fi
710-
"${WGET_CMD:?}" -q -O "${_output:?}" "${@}" -- "${_url:?}"
713+
_domain="$(get_domain_from_url "${_url:?}")" || return 19
714+
_headers_file="${MAIN_DIR:?}/cache/temp/headers/${_domain:?}.dat"
715+
test -d "${MAIN_DIR:?}/cache/temp/headers" || mkdir -p "${MAIN_DIR:?}/cache/temp/headers" || return 20
716+
717+
if test "${DL_DEBUG:?}" = 'true'; then
718+
dl_debug "${_url:?}" "${_method:?}" "${@}"
719+
fi
720+
721+
"${WGET_CMD:?}" -q -S -O "${_output:?}" "${@}" -- "${_url:?}" 2> "${_headers_file:?}" || _status="${?}"
722+
test "${DL_DEBUG:?}" != 'true' || cat 1>&2 "${_headers_file:?}"
723+
_dl_validate_status_code_from_header_file "${_headers_file:?}" || {
724+
_server_status_code="${?}"
725+
if test "${_server_status_code:?}" -ne 30; then
726+
#ui_debug "Failed at ${_desc?}"
727+
return "${_server_status_code:?}"
728+
fi
729+
}
730+
_dl_validate_exit_code 'wget' "${_status:?}" || return "${?}"
731+
732+
rm -f "${_headers_file:?}" || return 21
733+
return 0
711734
}
712735

713736
report_failure()
@@ -720,7 +743,7 @@ report_failure()
720743

721744
report_failure_one()
722745
{
723-
readonly DL_TYPE_1_FAILED='true'
746+
test "${1:?}" -ge 100 || readonly DL_TYPE_1_FAILED='true'
724747

725748
#printf '%s - ' "Failed at '${2}' with ret. code ${1:?}"
726749
test -z "${3-}" || ui_debug "${3:?}"
@@ -770,7 +793,7 @@ dl_type_one()
770793
local _base_url _result
771794

772795
_init_dl
773-
_base_url="$(get_base_url "${1:?}")" || report_failure_one "${?}" || return "${?}"
796+
_base_url="$(get_base_url "${1:?}")" || return 2
774797

775798
_set_url "${1:?}"
776799
_set_referrer "${_base_url:?}/"

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-5618-g3ddcebe75 (2025-07-30)** => win/busybox.exe
12+
- `BusyBox for Windows`_ **1.38.0-PRE-5755-g5e60bd4a7 (2025-08-18)** => 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/win/busybox.exe

512 Bytes
Binary file not shown.

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.2.21-alpha
8+
version=v1.3.2.22-alpha
99
versionCode=6
1010
author=ale5000
1111
description=It installs Google sync adapters on Android.

0 commit comments

Comments
 (0)