From b040ef1774ed3f3755128b18fdd5ba4eb2598794 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Tue, 3 Aug 2021 12:04:11 +0300 Subject: mkarchiso: ensure there are no existing image files before trying to create them This could prevent a few issues when creating an image file when re-running mkarchiso after a failure. Remove useless test before running rm -f. The command will always succeed. --- archiso/mkarchiso | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'archiso/mkarchiso') diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 8b43f75..e726e0e 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -160,6 +160,7 @@ _cleanup_pacstrap_dir() { # $@: options to pass to mksquashfs _run_mksquashfs() { local image_path="${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" + rm -f -- "${image_path}" if [[ "${quiet}" == "y" ]]; then mksquashfs "$@" "${image_path}" -noappend "${airootfs_image_tool_options[@]}" -no-progress > /dev/null else @@ -186,6 +187,7 @@ _mkairootfs_ext4+squashfs() { '-U' 'clear' ) [[ ! "${quiet}" == "y" ]] || mkfs_ext4_options+=('-q') + rm -f -- "${pacstrap_dir}.img" E2FSPROGS_FAKE_TIME="${SOURCE_DATE_EPOCH}" mkfs.ext4 "${mkfs_ext4_options[@]}" -- "${pacstrap_dir}.img" 32G tune2fs -c 0 -i 0 -- "${pacstrap_dir}.img" > /dev/null _msg_info "Done!" @@ -213,6 +215,7 @@ _mkairootfs_erofs() { install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" local image_path="${isofs_dir}/${install_dir}/${arch}/airootfs.erofs" + rm -f -- "${image_path}" # Generate reproducible file system UUID from SOURCE_DATE_EPOCH fsuuid="$(uuidgen --sha1 --namespace 93a870ff-8565-4cf3-a67b-f47299271a96 --name "${SOURCE_DATE_EPOCH}")" _msg_info "Creating EROFS image, this may take some time..." @@ -490,7 +493,7 @@ _make_efibootimg() { )" # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html - [[ -e "${work_dir}/efiboot.img" ]] && rm -f -- "${work_dir}/efiboot.img" + rm -f -- "${work_dir}/efiboot.img" _msg_info "Creating FAT image of size: ${imgsize} KiB..." mkfs.fat -C -n ARCHISO_EFI "${work_dir}/efiboot.img" "${imgsize}" @@ -903,6 +906,7 @@ _build_iso_image() { typeset -f "_add_xorrisofs_options_${bootmode}" &> /dev/null && "_add_xorrisofs_options_${bootmode}" done + rm -f -- "${out_dir}/${image_name}" _msg_info "Creating ISO image..." xorriso -as mkisofs \ -iso-level 3 \ -- cgit v1.2.3-54-g00ecf