File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -390,7 +390,6 @@ prepare_env() {
390390
391391 # Check work dir
392392 if [[ " ${normwork} " = false ]]; then
393- umount_chroot_advance
394393 msg_info " Deleting the contents of ${build_dir} ..."
395394 _run_cleansh
396395 fi
Original file line number Diff line number Diff line change @@ -86,9 +86,19 @@ remove() {
8686# Unmount chroot dir
8787umount_chroot () {
8888 local _mount
89- for _mount in $( cat /proc/mounts | getclm 2 | grep $( realpath ${work_dir} ) | tac) ; do
90- msg_info " Unmounting ${_mount} "
91- umount -lf " ${_mount} " 2> /dev/null
89+ if [[ ! -v " build_dir" ]] || [[ " ${build_dir} " = " " ]]; then
90+ msg_error " Exception error about working directory" 1
91+ fi
92+ if [[ ! -d " ${build_dir} " ]]; then
93+ return 0
94+ fi
95+ for _mount in $( cat " /proc/mounts" | getclm 2 | grep " $( realpath -s ${build_dir} ) " | tac | grep -xv " $( realpath -s ${build_dir} ) /${arch} /airootfs" ) ; do
96+ if echo " ${_mount} " | grep " ${work_dir} " > /dev/null 2>&1 || echo " ${_mount} " | grep " ${script_path} " > /dev/null 2>&1 || echo " ${_mount} " | grep " ${out_dir} " > /dev/null 2>&1 ; then
97+ msg_info " Unmounting ${_mount} "
98+ _umount " ${_mount} " 2> /dev/null
99+ else
100+ msg_error " It is dangerous to unmount a directory that is not managed by the script."
101+ fi
92102 done
93103}
94104
@@ -132,6 +142,10 @@ done
132142
133143shift $(( OPTIND - 1 ))
134144
145+ if [[ ! -v work_dir ]] && [[ " ${work_dir} " = " " ]]; then
146+ exit 1
147+ fi
148+
135149if [[ ! " ${noconfirm} " = true ]] && (( "$(find "${work_dir} " - type f 2 > / dev/ null | wc - l)" != 0 )) ; then
136150 msg_warn " Forcibly unmount all devices mounted under the following directories and delete them recursively."
137151 msg_warn " ${work_dir} "
You can’t perform that action at this time.
0 commit comments