@@ -80,8 +80,7 @@ _mount_helper()
8080 {
8181 test -n " ${DEVICE_MOUNT-} " && PATH=" ${PREVIOUS_PATH:? } " " ${DEVICE_MOUNT:? } " 2> /dev/null " ${@ } "
8282 } ||
83- mount " ${@ } " ||
84- return " ${?} "
83+ mount " ${@ } " || return " ${?} "
8584
8685 return 0
8786}
@@ -217,13 +216,15 @@ is_mounted_read_only()
217216 return 1
218217}
219218
220- remount_read_write ()
219+ _remount_read_write_helper ()
221220{
222- if test -n " ${DEVICE_MOUNT:- } " ; then
223- " ${DEVICE_MOUNT:? } " -o ' remount,rw' " ${1:? } " || " ${DEVICE_MOUNT:? } " 2> /dev/null -o ' remount,rw' " ${1:? } " " ${1:? } " || return 1
224- else
225- mount -o ' remount,rw' " ${1:? } " || return 1
226- fi
221+ {
222+ test -n " ${DEVICE_MOUNT-} " && PATH=" ${PREVIOUS_PATH:? } " " ${DEVICE_MOUNT:? } " 2> /dev/null -o ' remount,rw' " ${1:? } "
223+ } ||
224+ {
225+ test -n " ${DEVICE_MOUNT-} " && PATH=" ${PREVIOUS_PATH:? } " " ${DEVICE_MOUNT:? } " 2> /dev/null -o ' remount,rw' " ${1:? } " " ${1:? } "
226+ } ||
227+ mount -o ' remount,rw' " ${1:? } " || return " ${?} "
227228
228229 if is_mounted_read_only " ${1:? } " ; then return 1; fi
229230
@@ -377,8 +378,6 @@ _find_and_mount_system()
377378 ui_msg " Current slot: ${SLOT:- no slot} "
378379 ui_msg " Recov. fake system: ${RECOVERY_FAKE_SYSTEM:? } "
379380 ui_msg_empty_line
380- ui_msg " Android root ENV: ${ANDROID_ROOT:- } "
381- ui_msg_empty_line
382381
383382 ui_error " The ROM cannot be found!"
384383 fi
@@ -501,22 +500,22 @@ parse_setting()
501500
502501remount_read_write_if_needed ()
503502{
504- local _mountpoint _required
505- _mountpoint=" ${1:? } "
503+ local _required
506504 _required=" ${2:- true} "
507505
508- if is_mounted " ${_mountpoint :? } " && is_mounted_read_only " ${_mountpoint :? } " ; then
509- ui_msg " INFO: The '${_mountpoint :- } ' mount point is read-only, it will be remounted"
510- remount_read_write " ${_mountpoint :? } " || {
506+ if is_mounted_read_only " ${1 :? } " ; then
507+ ui_msg " INFO: The '${1? } ' mountpoint is read-only, it will be remounted"
508+ _remount_read_write_helper " ${1 :? } " || {
511509 if test " ${_required:? } " = ' true' ; then
512- ui_error " Remounting of '${_mountpoint :- } ' failed"
510+ ui_error " Remounting of '${1? } ' failed"
513511 else
514- ui_warning " Remounting of '${_mountpoint :- } ' failed"
512+ ui_warning " Remounting of '${1? } ' failed"
515513 ui_msg_empty_line
516514 return 1
517515 fi
518516 }
519517 fi
518+
520519 return 0
521520}
522521
@@ -840,9 +839,9 @@ initialize()
840839 export IS_INSTALLATION
841840
842841 if is_mounted_read_only " ${SYS_MOUNTPOINT:? } " ; then
843- ui_msg " INFO: The '${SYS_MOUNTPOINT:- } ' mount point is read-only, it will be remounted"
842+ ui_msg " INFO: The '${SYS_MOUNTPOINT? } ' mountpoint is read-only, it will be remounted"
844843 ui_msg_empty_line
845- remount_read_write " ${SYS_MOUNTPOINT:? } " || {
844+ _remount_read_write_helper " ${SYS_MOUNTPOINT:? } " || {
846845 deinitialize
847846
848847 ui_msg_empty_line
@@ -853,13 +852,11 @@ initialize()
853852 ui_msg " Current slot: ${SLOT:- no slot} "
854853 ui_msg " Recov. fake system: ${RECOVERY_FAKE_SYSTEM:? } "
855854 ui_msg_empty_line
856- ui_msg " Android root ENV: ${ANDROID_ROOT:- } "
857- ui_msg_empty_line
858855
859856 if test " ${VERITY_MODE?} " = ' enforcing' ; then
860- ui_error " Remounting of '${SYS_MOUNTPOINT:- } ' failed, you should DISABLE dm-verity!!!"
857+ ui_error " Remounting of '${SYS_MOUNTPOINT? } ' failed, you should DISABLE dm-verity!!!"
861858 else
862- ui_error " Remounting of '${SYS_MOUNTPOINT:- } ' failed!!!"
859+ ui_error " Remounting of '${SYS_MOUNTPOINT? } ' failed!!!"
863860 fi
864861 }
865862 fi
@@ -889,7 +886,7 @@ initialize()
889886 if mount_partition_if_exist " userdata${NL:? } DATAFS${NL:? } " ' data' " ${ANDROID_DATA-} " ; then
890887 DATA_PATH=" ${LAST_MOUNTPOINT:? } "
891888 UNMOUNT_DATA=" ${LAST_PARTITION_MUST_BE_UNMOUNTED:? } "
892- remount_read_write_if_needed " ${LAST_MOUNTPOINT:? } " true
889+ remount_read_write_if_needed " ${LAST_MOUNTPOINT:? } "
893890 else
894891 ui_warning " The data partition cannot be mounted, so updates of installed / removed apps cannot be automatically deleted and their Dalvik cache cannot be automatically cleaned. I suggest to manually do a factory reset after flashing this ZIP."
895892 fi
@@ -962,12 +959,18 @@ initialize()
962959
963960deinitialize ()
964961{
965- if test " ${UNMOUNT_SYSTEM:? } " -eq 1 && test -n " ${SYS_MOUNTPOINT-} " ; then unmount " ${SYS_MOUNTPOINT:? } " ; fi
962+ if test " ${UNMOUNT_DATA:? } " = ' 1' && test -n " ${DATA_PATH-} " ; then _unmount_helper " ${DATA_PATH:? } " ; fi
963+
964+ if test " ${UNMOUNT_PRODUCT:? } " = ' 1' && test -n " ${PRODUCT_PATH-} " ; then _unmount_helper " ${PRODUCT_PATH:? } " ; fi
965+ if test " ${UNMOUNT_VENDOR:? } " = ' 1' && test -n " ${VENDOR_PATH-} " ; then _unmount_helper " ${VENDOR_PATH:? } " ; fi
966+ if test " ${UNMOUNT_SYS_EXT:? } " = ' 1' && test -n " ${SYS_EXT_PATH-} " ; then _unmount_helper " ${SYS_EXT_PATH:? } " ; fi
967+ if test " ${UNMOUNT_ODM:? } " = ' 1' && test -n " ${ODM_PATH-} " ; then _unmount_helper " ${ODM_PATH:? } " ; fi
968+
969+ if test " ${UNMOUNT_SYSTEM:? } " = ' 1' && test -n " ${SYS_MOUNTPOINT-} " ; then _unmount_helper " ${SYS_MOUNTPOINT:? } " ; fi
970+
966971 if test -e " ${TMP_PATH:? } /system_mountpoint" ; then
967- rmdir -- " ${TMP_PATH:? } /system_mountpoint" || ui_error ' Failed to delete the temp mountpoint'
972+ rmdir -- " ${TMP_PATH:? } /system_mountpoint" || ui_error ' Failed to delete the temp system mountpoint'
968973 fi
969-
970- if test " ${UNMOUNT_DATA:? } " -eq 1 && test -n " ${DATA_PATH-} " ; then unmount " ${DATA_PATH:? } " ; fi
971974}
972975
973976clean_previous_installations ()
@@ -1272,11 +1275,11 @@ get_free_disk_space_of_partition()
12721275display_free_space ()
12731276{
12741277 if test -n " ${2?} " && test " ${2:? } " -ge 0; then
1275- ui_msg " Free space on ${1?} : $( convert_bytes_to_mb " ${2:? } " || :) MB ($( convert_bytes_to_human_readable_format 2> /dev/null " ${2:? } " || :) )"
1278+ ui_msg " Free space on ${1?} : $( convert_bytes_to_mb " ${2:? } " || :) MB ($( convert_bytes_to_human_readable_format " ${2:? } " || :) )"
12761279 return 0
12771280 fi
12781281
1279- ui_warning " Unable to get free disk space, output for '${1?} ' => $( stat -f -c ' %a * %S' -- " ${1:? } " || :) "
1282+ ui_warning " Unable to get free disk space, output for '${1?} ' => $( stat 2>&1 -f -c ' %a * %S' -- " ${1:? } " || :) "
12801283 return 1
12811284}
12821285
@@ -1469,8 +1472,6 @@ perform_installation()
14691472 ui_msg ' Installing utilities...'
14701473 perform_secure_copy_to_device ' bin'
14711474 fi
1472-
1473- delete " ${TMP_PATH:? } /origin"
14741475}
14751476
14761477finalize_and_report_success ()
@@ -1596,31 +1597,14 @@ validate_return_code_warning()
15961597}
15971598
15981599# Mounting related functions
1599- unmount ()
1600+ _unmount_helper ()
16001601{
1601- local partition
1602- partition=" $( _canonicalize " ${1:? } " ) "
1603-
1604- umount " ${partition:? } " || ui_warning " Failed to unmount '${partition} '"
1605- return 0 # Never fail
1606- }
1607-
1608- unmount_extra_partitions ()
1609- {
1610- if test " ${UNMOUNT_PRODUCT:? } " = ' 1' && test -n " ${PRODUCT_PATH-} " ; then
1611- unmount " ${PRODUCT_PATH:? } "
1612- fi
1613- if test " ${UNMOUNT_VENDOR:? } " = ' 1' && test -n " ${VENDOR_PATH-} " ; then
1614- unmount " ${VENDOR_PATH:? } "
1615- fi
1616- if test " ${UNMOUNT_SYS_EXT:? } " = ' 1' && test -n " ${SYS_EXT_PATH-} " ; then
1617- unmount " ${SYS_EXT_PATH:? } "
1618- fi
1619- if test " ${UNMOUNT_ODM:? } " = ' 1' && test -n " ${ODM_PATH-} " ; then
1620- unmount " ${ODM_PATH:? } "
1621- fi
1602+ umount " ${1:? } " || {
1603+ ui_warning " Failed to unmount '${1:? } '"
1604+ return 1
1605+ }
16221606
1623- return 0 # Never fail
1607+ return 0
16241608}
16251609
16261610# Getprop related functions
0 commit comments