Skip to content

Commit cbbf308

Browse files
committed
Sync with microG unofficial installer
1 parent 9d30d59 commit cbbf308

File tree

4 files changed

+144
-91
lines changed

4 files changed

+144
-91
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,11 @@ if test "${_ub_we_mounted_tmp:?}" = true; then
251251
umount '/tmp' || ui_error 'Failed to unmount the temp folder'
252252
fi
253253

254-
if test "${STATUS:?}" -ne 0; then ui_error "Installation script failed" "${STATUS}"; fi
255-
if test "${UNKNOWN_ERROR:?}" -ne 0; then ui_error 'Installation failed with an unknown error'; fi
254+
case "${STATUS?}" in
255+
'0') # Success
256+
test "${UNKNOWN_ERROR:?}" -eq 0 || ui_error 'Installation failed with an unknown error' ;;
257+
'250') # TEST mode
258+
ui_msg 'TEST mode completed!' ;;
259+
*) # Failure
260+
ui_error "Installation script failed" "${STATUS:?}" ;;
261+
esac

zip-content/customize.sh

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ _send_text_to_recovery()
136136
if test "${RECOVERY_OUTPUT:?}" != 'true'; then return; fi # Nothing to do here
137137

138138
if test -n "${RECOVERY_PIPE?}"; then
139-
printf 'ui_print %s\nui_print\n' "${1?}" >> "${RECOVERY_PIPE:?}"
139+
printf 'ui_print %s\nui_print\n' "${1?}" 1>> "${RECOVERY_PIPE:?}"
140140
else
141141
printf 'ui_print %s\nui_print\n' "${1?}" 1>&"${OUTFD:?}"
142142
fi
@@ -152,6 +152,8 @@ _print_text()
152152
# shellcheck disable=SC2059
153153
printf "${1:?}\n" "${2?}"
154154
fi
155+
156+
if test "${DEBUG_LOG_ENABLED:?}" = '1' && test -n "${ORIGINAL_STDERR_FD_PATH?}"; then printf '%s\n' "${2?}" 1>> "${ORIGINAL_STDERR_FD_PATH:?}"; fi
155157
}
156158

157159
ui_error()
@@ -183,18 +185,19 @@ ui_msg()
183185
if test "${RECOVERY_OUTPUT:?}" = 'true'; then
184186
_send_text_to_recovery "${1:?}"
185187
else
186-
printf '%s\n' "${1:?}"
188+
_print_text '%s' "${1:?}"
187189
fi
188190
}
189191

190192
ui_debug()
191193
{
192-
printf 1>&2 '%s\n' "${1?}"
194+
_print_text 1>&2 '%s' "${1?}"
193195
}
194196

195197
enable_debug_log()
196198
{
197199
if test "${DEBUG_LOG_ENABLED}" -eq 1; then return; fi
200+
local _backup_stderr
198201

199202
ui_debug "Creating log: ${LOG_PATH:?}"
200203
_send_text_to_recovery "Creating log: ${LOG_PATH:?}"
@@ -205,27 +208,39 @@ enable_debug_log()
205208
return
206209
}
207210

208-
export NO_COLOR=1
209-
export DEBUG_LOG_ENABLED=1
210-
211211
# If they are already in use, then use alternatives
212212
if {
213213
command 1>&6 || command 1>&7
214214
} 2> /dev/null; then
215215
export ALTERNATIVE_FDS=1
216216
# shellcheck disable=SC3023
217217
exec 88>&1 89>&2 # Backup stdout and stderr
218+
_backup_stderr=89
218219
else
219220
export ALTERNATIVE_FDS=0
220221
exec 6>&1 7>&2 # Backup stdout and stderr
222+
_backup_stderr=7
221223
fi
224+
222225
exec 1>> "${LOG_PATH:?}" 2>&1
226+
227+
export NO_COLOR=1
228+
if test -e "/proc/$$/fd/${_backup_stderr:?}"; then
229+
export ORIGINAL_STDERR_FD_PATH="/proc/$$/fd/${_backup_stderr:?}"
230+
else
231+
export ORIGINAL_STDERR_FD_PATH=''
232+
fi
233+
export DEBUG_LOG_ENABLED=1
223234
}
224235

225236
disable_debug_log()
226237
{
227238
if test "${DEBUG_LOG_ENABLED}" -ne 1; then return; fi
228239

240+
export DEBUG_LOG_ENABLED=0
241+
unset ORIGINAL_STDERR_FD_PATH
242+
unset NO_COLOR
243+
229244
if test "${ALTERNATIVE_FDS:?}" -eq 0; then
230245
exec 1>&6 2>&7 # Restore stdout and stderr
231246
exec 6>&- 7>&-
@@ -234,9 +249,6 @@ disable_debug_log()
234249
# shellcheck disable=SC3023
235250
exec 88>&- 89>&-
236251
fi
237-
238-
export DEBUG_LOG_ENABLED=0
239-
unset NO_COLOR
240252
}
241253

242254
set_perm()
@@ -384,33 +396,30 @@ fi
384396

385397
ui_debug 'Parsing common settings...'
386398

387-
_simple_getprop()
399+
simple_getprop()
388400
{
389-
if test -n "${DEVICE_GETPROP?}"; then
390-
"${DEVICE_GETPROP:?}" "${1:?}" || return "${?}"
391-
elif command -v getprop 1> /dev/null; then
392-
getprop "${1:?}" || return "${?}"
401+
local _val
402+
403+
if test -n "${DEVICE_GETPROP?}" && _val="$(PATH="${PREVIOUS_PATH:?}" "${DEVICE_GETPROP:?}" "${@}")"; then
404+
:
405+
elif command 1> /dev/null -v 'getprop' && _val="$(getprop "${@}")"; then
406+
:
393407
else
394-
return 1
408+
return 2
395409
fi
410+
411+
test -n "${_val?}" || return 1
412+
printf '%s\n' "${_val:?}"
396413
}
414+
397415
_get_common_setting()
398416
{
399-
local _val
400-
if _val="$(_simple_getprop "zip.common.${1:?}")" && test -n "${_val?}"; then
401-
printf '%s\n' "${_val:?}"
402-
return
403-
fi
404-
405-
# Fallback to the default value
406-
printf '%s\n' "${2?}"
417+
simple_getprop "zip.common.${1:?}" ||
418+
printf '%s\n' "${2?}" # Fallback to the default value
407419
}
408420

409421
DEBUG_LOG="$(_get_common_setting 'DEBUG_LOG' "${DEBUG_LOG:-0}")"
410422

411-
unset -f _simple_getprop
412-
unset -f _get_common_setting
413-
414423
test "${DEBUG_LOG:?}" -ne 0 && enable_debug_log # Enable file logging if needed
415424

416425
LIVE_SETUP_ALLOWED="${LIVE_SETUP_ALLOWED:-true}"

0 commit comments

Comments
 (0)