Skip to content

Commit 25335b6

Browse files
committed
[update] : Simple umount_work
1 parent 106ad62 commit 25335b6

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

build.sh

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ customized_password=false
2424
customized_kernel=false
2525
customized_logpath=false
2626
pkglist_args=()
27+
modules=()
2728
DEFAULT_ARGUMENT=""
2829
alteriso_version="3.1"
2930

@@ -178,17 +179,15 @@ _umount() { if mountpoint -q "${1}"; then umount -lf "${1}"; fi; }
178179
# Mount helper Usage: _mount <source> <target>
179180
_mount() { if ! mountpoint -q "${2}" && [[ -f "${1}" ]] && [[ -d "${2}" ]]; then mount "${1}" "${2}"; fi; }
180181

181-
# Unmount chroot dir
182-
umount_chroot () {
182+
# Unmount work dir
183+
umount_work () {
183184
local _mount
184185
if [[ ! -v "build_dir" ]] || [[ "${build_dir}" = "" ]]; then
185186
msg_error "Exception error about working directory" 1
186187
fi
187-
if [[ ! -d "${build_dir}" ]]; then
188-
return 0
189-
fi
188+
[[ ! -d "${build_dir}" ]] && return 0
190189
#for _mount in $(cat "/proc/mounts" | getclm 2 | grep "$(realpath -s ${build_dir})" | tac | grep -xv "$(realpath -s ${airootfs_dir})"); do
191-
for _mount in $(find "${build_dir}" -mindepth 1 -type d -printf "%p\0" | xargs -0 -I{} bash -c "mountpoint -q {} && echo {}" | tac | grep -xv "$(realpath -s ${airootfs_dir})"); do
190+
for _mount in $(find "${build_dir}" -mindepth 1 -type d -printf "%p\0" | xargs -0 -I{} bash -c "mountpoint -q {} && echo {}" | tac); do
192191
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
193192
msg_info "Unmounting ${_mount}"
194193
_umount "${_mount}" 2> /dev/null
@@ -204,14 +203,6 @@ mount_airootfs () {
204203
_mount "${airootfs_dir}.img" "${airootfs_dir}"
205204
}
206205

207-
umount_airootfs() {
208-
if [[ -v airootfs_dir ]]; then _umount "${airootfs_dir}"; fi
209-
}
210-
211-
umount_chroot_advance() {
212-
umount_chroot
213-
umount_airootfs
214-
}
215206

216207
# Helper function to run make_*() only one time.
217208
run_once() {
@@ -221,7 +212,7 @@ run_once() {
221212
mount_airootfs
222213
eval "${@}"
223214
mkdir -p "${lockfile_dir}"; touch "${lockfile_dir}/build.${1}"
224-
umount_chroot_advance
215+
umount_work
225216
else
226217
msg_debug "Skipped because ${1} has already been executed."
227218
fi
@@ -237,7 +228,7 @@ remove() {
237228
# 強制終了時にアンマウント
238229
umount_trap() {
239230
local _status="${?}"
240-
umount_chroot_advance
231+
umount_work
241232
msg_error "It was killed by the user.\nThe process may not have completed successfully."
242233
exit "${_status}"
243234
}
@@ -533,9 +524,6 @@ prepare_build() {
533524
if [[ "${memtest86}" = true ]]; then pkglist_args+=("-m"); fi
534525
if (( "${#additional_exclude_pkg[@]}" >= 1 )); then pkglist_args+=("-e" "${additional_exclude_pkg[*]}"); fi
535526
pkglist_args+=("${modules[@]}")
536-
537-
# Unmount
538-
umount_chroot
539527
}
540528

541529

@@ -1019,7 +1007,7 @@ make_prepare() {
10191007
msg_info "Done!"
10201008
fi
10211009

1022-
umount_chroot_advance
1010+
umount_work
10231011

10241012
if [[ "${cleaning}" = true ]]; then
10251013
remove "${airootfs_dir}" "${airootfs_dir}.img"

0 commit comments

Comments
 (0)