@@ -21,6 +21,42 @@ link_folder()
21
21
ln -sf " ${2} " " ${1} " || mkdir -p " ${1} " || fail_with_msg " Failed to link dir '${1} '"
22
22
}
23
23
24
+ ui_print ()
25
+ {
26
+ echo " ui_print ${1} "
27
+ }
28
+
29
+ recovery_flash_start ()
30
+ {
31
+ ui_print " I:Set page: 'install'"
32
+ ui_print " I:Set page: 'flash_confirm'"
33
+ ui_print " I:Set page: 'flash_zip'"
34
+ ui_print " I:operation_start: 'Flashing'"
35
+ ui_print " Installing zip file '${1} '"
36
+ # ui_print "Checking for MD5 file..."
37
+ # ui_print "MD5 matched for '${1}'."
38
+ ui_print " I:Update binary zip"
39
+ }
40
+
41
+ recovery_flash_end ()
42
+ {
43
+ if test " ${1} " -eq 0; then
44
+ ui_print " I:Updater process ended with RC=0"
45
+ else
46
+ ui_print " Updater process ended with ERROR: ${1} "
47
+ ui_print " Error installing zip file '${2} '"
48
+ fi
49
+ ui_print " Updating partition details..."
50
+ ui_print " ...done"
51
+ ui_print " I:Set page: 'flash_done'"
52
+ if test " ${1} " -eq 0; then
53
+ ui_print " I:operation_end - status=0"
54
+ else
55
+ ui_print " I:operation_end - status=1"
56
+ fi
57
+ ui_print ' '
58
+ }
59
+
24
60
if test -z " ${1} " ; then fail_with_msg ' You must pass the filename of the flashable ZIP as parameter' ; fi
25
61
26
62
# Reset environment
@@ -102,14 +138,15 @@ chmod +x "${TMPDIR}/updater" || fail_with_msg "chmod failed on '${TMPDIR}/update
102
138
103
139
# Setup recovery output
104
140
recovery_fd=99
141
+ recovery_logs_dir=" ${THIS_SCRIPT_DIR} /output"
105
142
if test -e " /proc/self/fd/${recovery_fd} " ; then fail_with_msg ' Recovery FD already exist' ; fi
106
- mkdir -p " ${THIS_SCRIPT_DIR} /output "
107
- touch " ${THIS_SCRIPT_DIR} /output/ recovery-output.log"
143
+ mkdir -p " ${recovery_logs_dir} "
144
+ touch " ${recovery_logs_dir} / recovery-output-raw .log"
108
145
if test " ${uname_o_saved} " ! = ' MS/Windows' ; then
109
- sudo chattr +aAd " ${THIS_SCRIPT_DIR} /output/ recovery-output.log" || fail_with_msg " chattr failed on 'recovery-output.log'"
146
+ sudo chattr +aAd " ${recovery_logs_dir} / recovery-output-raw .log" || fail_with_msg " chattr failed on 'recovery-output-raw .log'"
110
147
fi
111
148
# shellcheck disable=SC3023
112
- exec 99>> " ${THIS_SCRIPT_DIR} /output/ recovery-output.log"
149
+ exec 99>> " ${recovery_logs_dir} / recovery-output-raw .log"
113
150
114
151
# Simulate the environment variables (part 2)
115
152
PATH=" ${OVERRIDE_DIR} :${BASE_SIMULATION_PATH} /sbin:${ANDROID_ROOT} /bin:${PATH} " # We have to keep the original folders inside PATH otherwise everything stop working
@@ -131,15 +168,17 @@ FLASHABLE_ZIP_NAME="$("${CUSTOM_BUSYBOX}" basename "${FLASHABLE_ZIP_PATH}")" ||
131
168
chmod +x " ${TMPDIR} /update-binary" || fail_with_msg " chmod failed on '${TMPDIR} /update-binary'"
132
169
133
170
# Execute the script that will run the flashable zip
171
+ recovery_flash_start " ${SECONDARY_STORAGE} /${FLASHABLE_ZIP_NAME} " 1>& " ${recovery_fd} "
134
172
set +e
135
- " ${CUSTOM_BUSYBOX} " ash " ${TMPDIR} /updater" 3 " ${recovery_fd} " " ${SECONDARY_STORAGE} /${FLASHABLE_ZIP_NAME} " | TZ=UTC ts ' [%H:%M:%S] ' ; STATUS=" $? "
173
+ " ${CUSTOM_BUSYBOX} " ash " ${TMPDIR} /updater" 3 " ${recovery_fd} " " ${SECONDARY_STORAGE} /${FLASHABLE_ZIP_NAME} " 1>> " ${recovery_logs_dir} /recovery-stdout-stderr.log " 2>&1 ; STATUS=" ${?} "
136
174
set -e
175
+ recovery_flash_end " ${STATUS} " " ${SECONDARY_STORAGE} /${FLASHABLE_ZIP_NAME} " 1>& " ${recovery_fd} "
137
176
138
177
# Close recovery output
139
178
# shellcheck disable=SC3023
140
179
exec 99>& -
141
180
if test " ${uname_o_saved} " ! = ' MS/Windows' ; then
142
- sudo chattr -a " ${THIS_SCRIPT_DIR} /output/ recovery-output.log" || fail_with_msg " chattr failed on 'recovery-output.log'"
181
+ sudo chattr -a " ${recovery_logs_dir} / recovery-output-raw .log" || fail_with_msg " chattr failed on 'recovery-output-raw .log'"
143
182
fi
144
183
145
184
# Parse recovery output
@@ -152,15 +191,17 @@ while IFS=' ' read -r ui_command text; do
152
191
echo " ${text} "
153
192
last_msg_printed=true
154
193
fi
194
+ elif test " ${ui_command} " = ' custom_std' ; then
195
+ echo " ${text} "
155
196
else
156
- echo " > COMMAND: ${ui_command} ${text} "
197
+ echo " > ${ui_command} ${text} "
157
198
last_msg_printed=false
158
199
fi
159
- done < " ${THIS_SCRIPT_DIR} /output/ recovery-output.log" > " ${THIS_SCRIPT_DIR} /output/ recovery-output-parsed .log"
200
+ done < " ${recovery_logs_dir} / recovery-output-raw .log" > " ${recovery_logs_dir} / recovery-output.log"
160
201
161
202
# Final cleanup
162
203
cd " ${INIT_DIR} " || fail_with_msg ' Failed to change back the folder'
163
204
unset TMPDIR
164
205
rm -rf -- " ${OUR_TEMP_DIR:? } " &
165
206
set +e
166
- if test " ${STATUS} " -ne 0; then fail_with_msg " Installation failed with error ${STATUS} " ; fi
207
+ if test " ${STATUS} " -ne 0; then exit " ${STATUS} " ; fi
0 commit comments