index : archiso32 | |
Archlinux32 iso tools | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | CHANGELOG.rst | 1 | ||||
-rwxr-xr-x | archiso/mkarchiso | 25 |
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 53b8c47..6906305 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,7 @@ Added - Added classes for Memtest86+ and UEFI Shell menuentries. - Add foot-terminfo and wezterm-terminfo packages to releng to support terminal emulators using them. E.g. when installing via SSH. +- Add a new ``-r`` option to ``mkarchiso`` that deletes the working directly after the build. Changed ------- diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 18b6ed7..66a8f45 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -39,6 +39,7 @@ pacman_conf="" packages="" bootstrap_packages="" pacstrap_dir="" +declare -i rm_work_dir=0 buildmodes=() bootmodes=() airootfs_image_type="" @@ -110,6 +111,7 @@ usage: ${app_name} [options] <profile_dir> Default: '${out_dir}' -p [package ..] Package(s) to install. Multiple packages are provided as quoted, space delimited list. + -r Delete the working directory at the end. -v Enable verbose output -w <work_dir> Set the working directory Default: '${work_dir}' @@ -1658,6 +1660,9 @@ _set_overrides() { elif [[ -z "$quiet" ]]; then quiet="y" fi + if [[ -v override_rm_work_dir ]]; then + rm_work_dir="$override_rm_work_dir" + fi # Set variables that do not have overrides [[ -n "$airootfs_image_type" ]] || airootfs_image_type="squashfs" @@ -1730,6 +1735,16 @@ _make_pkglist() { _msg_info "Done!" } +# Create working directory +_make_work_dir() { + if [[ ! -d "${work_dir}" ]]; then + install -d -- "${work_dir}" + elif (( rm_work_dir )); then + rm_work_dir=0 + _msg_warning "Working directory removal requested, but '${work_dir}' already exists. It will not be removed!" 0 + fi +} + # build the base for an ISO and/or a netboot target _build_iso_base() { local run_once_mode="base" @@ -1741,7 +1756,7 @@ _build_iso_base() { isofs_dir="${work_dir}/iso" # Create working directory - [[ -d "${work_dir}" ]] || install -d -- "${work_dir}" + _run_once _make_work_dir # Write build date to file if it does not exist already [[ -e "${work_dir}/build_date" ]] || printf '%s\n' "$SOURCE_DATE_EPOCH" > "${work_dir}/build_date" @@ -1820,9 +1835,14 @@ _build() { for buildmode in "${buildmodes[@]}"; do _run_once "_build_buildmode_${buildmode}" done + if (( rm_work_dir )); then + _msg_info 'Removing the working directory...' + rm -rf -- "${work_dir:?}/" + _msg_info 'Done!' + fi } -while getopts 'c:p:C:L:P:A:D:w:m:o:g:G:vh?' arg; do +while getopts 'c:p:C:L:P:A:D:w:m:o:g:G:vrh?' arg; do case "${arg}" in p) read -r -a override_pkg_list <<< "${OPTARG}" ;; C) override_pacman_conf="${OPTARG}" ;; @@ -1837,6 +1857,7 @@ while getopts 'c:p:C:L:P:A:D:w:m:o:g:G:vh?' arg; do g) override_gpg_key="${OPTARG}" ;; G) override_gpg_sender="${OPTARG}" ;; v) override_quiet="n" ;; + r) declare -i override_rm_work_dir=1 ;; h|?) _usage 0 ;; *) _msg_error "Invalid argument '${arg}'" 0 |