@@ -92,16 +92,29 @@ run_bootstrap_second_stage() {
92
92
93
93
local return_value
94
94
95
- if ! ln -s " termux-bootstrap-second-stage.sh" \
96
- " @TERMUX_BOOTSTRAPS__BOOTSTRAP_CONFIG_DIR@/termux-bootstrap-second-stage.sh.lock" 2> /dev/null; then
97
- log " The termux bootstrap second stage has already been run before and cannot be run again."
98
- log " If you still want to force run it again (not recommended), \
95
+ local output
96
+
97
+ output=" $( ln -s " termux-bootstrap-second-stage.sh" \
98
+ " @TERMUX_BOOTSTRAPS__BOOTSTRAP_CONFIG_DIR@/termux-bootstrap-second-stage.sh.lock" 2>&1 ) "
99
+ return_value=$?
100
+ if [ $return_value -ne 0 ]; then
101
+ if [ $return_value -eq 1 ] && [[ " $output " == * " File exists" * ]]; then
102
+ log " The termux bootstrap second stage has already been run before and cannot be run again."
103
+ log " If you still want to force run it again (not recommended), \
99
104
like in case of previous failure and it must be re-run again for testing, \
100
105
then delete the '@TERMUX_BOOTSTRAPS__BOOTSTRAP_CONFIG_DIR@/termux-bootstrap-second-stage.sh.lock' \
101
106
file manually and run 'termux-bootstrap-second-stage.sh' again."
102
- return 0
107
+ return 0
108
+ else
109
+ log_error " $output "
110
+ log_error " Failed to create lock file for termux bootstrap second stage at \
111
+ '@TERMUX_BOOTSTRAPS__BOOTSTRAP_CONFIG_DIR@/termux-bootstrap-second-stage.sh.lock'"
112
+ warn_if_process_killed " $return_value " " ln"
113
+ return $return_value
114
+ fi
103
115
fi
104
116
117
+
105
118
log " Running termux bootstrap second stage"
106
119
run_bootstrap_second_stage_inner
107
120
return_value=$?
@@ -112,6 +125,7 @@ file manually and run 'termux-bootstrap-second-stage.sh' again."
112
125
113
126
log " The termux bootstrap second stage completed successfully"
114
127
128
+
115
129
return 0
116
130
117
131
}
@@ -360,6 +374,30 @@ run_package_postinst_maintainer_scripts() {
360
374
361
375
}
362
376
377
+
378
+
379
+
380
+
381
+ warn_if_process_killed () {
382
+
383
+ local return_value=" ${1:- } "
384
+ local command=" ${2:- } "
385
+
386
+ if [[ " $return_value " == " 137" ]]; then
387
+ log_error " The '$command ' command was apparently killed with SIGKILL (signal 9). \
388
+ This may have been due to the security policies of the Android OS installed on your device.
389
+ Check https://github.com/termux/termux-app/issues/4219 for more info."
390
+ return 0
391
+ fi
392
+
393
+ return 1
394
+
395
+ }
396
+
397
+
398
+
399
+
400
+
363
401
# If running in bash, run script logic, otherwise exit with usage error
364
402
if [ -n " ${BASH_VERSION:- } " ]; then
365
403
# If script is sourced, return with error, otherwise call main function
0 commit comments