Skip to content

Commit 2c97e9b

Browse files
committed
[fix] : Fixed cleanup
1 parent 4fc0350 commit 2c97e9b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

build.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,6 @@ remove() {
247247
for _file in "${@}"; do msg_debug "Removing ${_file}"; rm -rf "${_file}"; done
248248
}
249249

250-
remove_find(){
251-
local _dir
252-
for _dir in "${@}"; do
253-
if [[ -d "${_dir}" ]]; then
254-
msg_debug "Removing ${_dir}"
255-
find "${_dir}" -mindepth 1 -delete
256-
fi
257-
done
258-
}
259-
260250
# 強制終了時にアンマウント
261251
umount_trap() {
262252
local _status="${?}"
@@ -304,7 +294,17 @@ _chroot_run() {
304294
_cleanup_common () {
305295
msg_info "Cleaning up what we can on airootfs..."
306296

307-
remove_find "${airootfs_dir}/var/lib/pacman" "${airootfs_dir}/var/lib/pacman/sync" "${airootfs_dir}/var/cache/pacman/pkg" "${airootfs_dir}/var/log" "${airootfs_dir}/var/tmp"
297+
# Delete pacman database sync cache files (*.tar.gz)
298+
[[ -d "${airootfs_dir}/var/lib/pacman" ]] && find "${airootfs_dir}/var/lib/pacman" -maxdepth 1 -type f -delete
299+
# Delete pacman database sync cache
300+
[[ -d "${airootfs_dir}/var/lib/pacman/sync" ]] && find "${airootfs_dir}/var/lib/pacman/sync" -delete
301+
# Delete pacman package cache
302+
[[ -d "${airootfs_dir}/var/cache/pacman/pkg" ]] && find "${airootfs_dir}/var/cache/pacman/pkg" -type f -delete
303+
# Delete all log files, keeps empty dirs.
304+
[[ -d "${airootfs_dir}/var/log" ]] && find "${airootfs_dir}/var/log" -type f -delete
305+
# Delete all temporary files and dirs
306+
[[ -d "${airootfs_dir}/var/tmp" ]] && find "${airootfs_dir}/var/tmp" -mindepth 1 -delete
307+
# Delete package pacman related files.
308308
find "${work_dir}" \( -name '*.pacnew' -o -name '*.pacsave' -o -name '*.pacorig' \) -delete
309309

310310
# Create an empty /etc/machine-id
@@ -315,7 +315,9 @@ _cleanup_common () {
315315

316316
_cleanup_airootfs(){
317317
_cleanup_common
318-
remove_find "${airootfs_dir}/boot"
318+
319+
# Delete all files in /boot
320+
[[ -d "${airootfs_dir}/boot" ]] && find "${airootfs_dir}/boot" -mindepth 1 -delete
319321
}
320322

321323
_mkchecksum() {

0 commit comments

Comments
 (0)