Skip to content

Commit

Permalink
Improved compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git committed Sep 4, 2023
1 parent 1294648 commit 2a41c75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions zip-content/META-INF/com/google/android/update-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export ZIPFILE="${3:?}"

echo 'PRELOADER 1'

command 1> /dev/null -v printf ||
{
printf()
{
echo "${2?}"
}
}

# Detect whether we are in boot mode
_ub_detect_bootmode()
{
Expand Down
9 changes: 7 additions & 2 deletions zip-content/zip-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileType: SOURCE

readonly ZIPINSTALL_VERSION='0.7'
readonly ZIPINSTALL_VERSION='0.8'

umask 022 || exit 6

Expand Down Expand Up @@ -131,6 +131,8 @@ if test -z "${TMPDIR:-}" || test ! -w "${TMPDIR:?}"; then
fi
export TMPDIR

PATH="${PATH:-}:."

SCRIPT_NAME="${TMPDIR:?}/update-binary" || exit 12
UPD_SCRIPT_NAME="${TMPDIR:?}/updater-script" || exit 12
ZIPFILE="${1:?}"
Expand All @@ -147,11 +149,14 @@ test -s "${SCRIPT_NAME:?}" || {
unzip -p -qq "${ZIPFILE:?}" 'META-INF/com/google/android/updater-script' 1> "${UPD_SCRIPT_NAME:?}" || true # Not strictly needed

STATUS=0
if test '#!' = "$(head -q -c 2 -- "${SCRIPT_NAME:?}" || true)"; then
if ! command 1> /dev/null -v head || test '#!' = "$(head -q -c 2 -- "${SCRIPT_NAME:?}" || true)"; then
printf '%s\n' 'Executing script...'

# Use STDERR (2) for recovery messages to avoid possible problems with subshells intercepting output
sh -- "${SCRIPT_NAME:?}" 3 2 "${ZIPFILE:?}" 'zip-install' "${ZIPINSTALL_VERSION:?}" || STATUS="${?}"
else
printf '%s\n' 'Executing binary...'

# Legacy versions of chmod don't support +x and --
chmod 0755 "${SCRIPT_NAME:?}" || {
ui_show_error "chmod failed on '${SCRIPT_NAME:?}'"
Expand Down

0 comments on commit 2a41c75

Please sign in to comment.