Skip to content

Commit

Permalink
Inform the user if the previous installation has failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git committed Sep 2, 2023
1 parent f13863a commit e87b771
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions zip-content/inc/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,11 @@ initialize()
readonly MODULE_NAME MODULE_VERSION MODULE_VERCODE MODULE_AUTHOR
export MODULE_NAME MODULE_VERSION MODULE_VERCODE MODULE_AUTHOR

if test -e "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.failed"; then
ui_warning 'The previous installation has failed!!!'
ui_msg_empty_line
fi

# Previously installed module version code (0 if wasn't installed)
PREV_MODULE_VERCODE="$(simple_file_getprop 'install.version.code' "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.prop")" || PREV_MODULE_VERCODE=''
case "${PREV_MODULE_VERCODE:-}" in
Expand Down Expand Up @@ -774,7 +779,9 @@ _move_app_into_subfolder()
replace_permission_placeholders()
{
if test -e "${TMP_PATH:?}/files/etc/${1:?}"; then
{ grep -l -r -F -e "${2:?}" -- "${TMP_PATH:?}/files/etc/${1:?}" || true; } | while IFS='' read -r file_name; do
{
grep -l -r -F -e "${2:?}" -- "${TMP_PATH:?}/files/etc/${1:?}" || true
} | while IFS='' read -r file_name; do
ui_debug " ${file_name#"${TMP_PATH}/files/"}"
replace_line_in_file "${file_name:?}" "${2:?}" "${3:?}"
done || ui_warning "Failed to replace '${2?}' in 'files/etc/${1?}'"
Expand Down Expand Up @@ -865,7 +872,10 @@ perform_secure_copy_to_device()
create_dir "${SYS_PATH:?}/${1:?}"
cp 2> /dev/null -rpf -- "${TMP_PATH:?}/files/${1:?}"/* "${SYS_PATH:?}/${1:?}"/ ||
_error="$(cp 2>&1 -rpf -- "${TMP_PATH:?}/files/${1:?}"/* "${SYS_PATH:?}/${1:?}"/)" ||
ui_error "Failed to copy '${1?}' to the device due to => $(printf '%s\n' "${_error?}" | head -n 1 || true)"
{
touch "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.failed" || true
ui_error "Failed to copy '${1?}' to the device due to => $(printf '%s\n' "${_error?}" | head -n 1 || true)"
}
}

perform_installation()
Expand Down Expand Up @@ -896,6 +906,7 @@ perform_installation()

finalize_and_report_success()
{
rm -f -- "${SYS_PATH:?}/etc/zips/${MODULE_ID:?}.failed" || true
deinitialize
touch "${TMP_PATH:?}/installed"

Expand Down

0 comments on commit e87b771

Please sign in to comment.