mkarchiso: add a -r option to delete the working directory
`-r` will instruct to delete the working directory at the end of a `mkarchiso` run. If the specified directory already exists, then it will not be deleted and instead produce a warning. Implements #211
This commit is contained in:
parent
b9cec1e08b
commit
b5e7f5afc5
@ -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
|
||||
-------
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user