Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archiso/mkarchiso
diff options
context:
space:
mode:
Diffstat (limited to 'archiso/mkarchiso')
-rwxr-xr-xarchiso/mkarchiso25
1 files changed, 23 insertions, 2 deletions
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