Pass profile directory as parameter to mkarchiso
**archiso/mkarchiso**: Change all override option parameters (i.e. `-A`, `-C`, `-D`, `-L`, `-P` and `-g`) to not directly override the global variable they are tied to, but instead using an `override_` prefixed variable. Add `_set_overrides()` to use `override_` prefixed variables (if set) to override those without a prefix. Remove `-B` (a profile directory) from the list of parameters. The profile directory is now provided as separate non-option parameter. Add a call to `_read_profile()`, `_set_overrides()` and `command_build_profile()` to the fallthrough option of the switch-case checking `command_name` - a non-option parameter to mkarchiso. This effectively provides the possibility to set the profile directory using a non-option parameter, while still maintaining compatibility to legacy named arguments used in the configs' `build.sh` scripts. Extend the warning in regards to legacy `build.sh` based commands to mkarchiso by providing an EOL with archiso v49. Change the help output to reflect the changes and further elaborate on the legacy commands used by `build.sh` scripts. Change help output to be ordered alphabetically. Add help output for `-r` and `-g` options. Call `_set_overrides()` for legacy commands that accept one or more of the overriden options (i.e. `command_init`, `command_install`, `command_prepare` and `command_iso`). Various style fixes. **configs/{baseline,releng}/build.sh**: Change call to mkarchiso to use the profile's directory as a named argument instead of an option-argument. **README.rst**: Fix documentation on how to call mkarchiso with a profile directory. Fix wording and ordering of option arguments for run_archiso documentation. Fixes #52
This commit is contained in:
parent
e2c5b4527f
commit
d90184a7f0
10
README.rst
10
README.rst
@ -49,7 +49,7 @@ be lost on update).
|
||||
|
||||
The examples below will assume an unmodified profile in a system location (unless noted otherwise).
|
||||
|
||||
It is advised to check the help information of the **mkarchiso**:
|
||||
It is advised to consult the help output of **mkarchiso**:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
@ -60,7 +60,7 @@ Create images with packaged archiso
|
||||
|
||||
.. code:: bash
|
||||
|
||||
mkarchiso -B path/to/profile -w path/to/work_dir -o path/to/out_dir build_profile
|
||||
mkarchiso -w path/to/work_dir -o path/to/out_dir path/to/profile
|
||||
|
||||
Create images with local clone
|
||||
------------------------------
|
||||
@ -69,13 +69,13 @@ Clone this repository and run:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
./archiso/mkarchiso -B path/to/profile -w path/to/work_dir -o path/to/out_dir build_profile
|
||||
./archiso/mkarchiso -w path/to/work_dir -o path/to/out_dir path/to/profile
|
||||
|
||||
Testing
|
||||
=======
|
||||
|
||||
The convenience script **run_archiso** is provided to boot into the medium using qemu.
|
||||
It is advised to read its help information:
|
||||
It is advised to consult its help output:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
@ -91,7 +91,7 @@ Run the following to boot the iso using UEFI:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
run_archiso -i path/to/an/arch.iso -u
|
||||
run_archiso -u -i path/to/an/arch.iso
|
||||
|
||||
The script can of course also be executed from this repository:
|
||||
|
||||
|
@ -20,17 +20,22 @@ img_name="${app_name}.iso"
|
||||
sfs_mode="sfs"
|
||||
sfs_comp="xz"
|
||||
gpg_key=""
|
||||
override_gpg_key=""
|
||||
|
||||
# profile defaults
|
||||
profile=""
|
||||
iso_name="${app_name}"
|
||||
iso_label="${app_name^^}"
|
||||
override_iso_label=""
|
||||
iso_publisher="${app_name}"
|
||||
override_iso_publisher=""
|
||||
iso_application="${app_name} iso"
|
||||
override_iso_application=""
|
||||
iso_version=""
|
||||
install_dir="${app_name}"
|
||||
arch="$(uname -m)"
|
||||
pacman_conf="/etc/pacman.conf"
|
||||
override_pacman_conf=""
|
||||
bootmodes=()
|
||||
|
||||
|
||||
@ -105,36 +110,52 @@ _umount_efibootimg() {
|
||||
# $1: exit status number.
|
||||
_usage() {
|
||||
IFS='' read -r -d '' usagetext <<ENDUSAGETEXT || true
|
||||
usage ${app_name} [options] command <command options>
|
||||
general options:
|
||||
-B <profile_dir> Directory of the archiso profile to build
|
||||
-p PACKAGE(S) Package(s) to install, can be used multiple times
|
||||
-C <file> pacman configuration file.
|
||||
Default: '${pacman_conf}'
|
||||
-L <label> Set the ISO volume label
|
||||
Default: '${iso_label}'
|
||||
-P <publisher> Set a ISO publisher
|
||||
Default: '${iso_publisher}'
|
||||
-A <application> Set an application name for the ISO
|
||||
Default: '${iso_application}'
|
||||
-D <install_dir> Set an install_dir. All files will by located here.
|
||||
Default: '${install_dir}'
|
||||
NOTE: Max 8 characters, use only [a-z0-9]
|
||||
-w <work_dir> Set the working directory
|
||||
Default: '${work_dir}'
|
||||
-o <out_dir> Set the output directory
|
||||
Default: '${out_dir}'
|
||||
-s <sfs_mode> Set SquashFS image mode (img or sfs)
|
||||
img: prepare airootfs.sfs for dm-snapshot usage
|
||||
sfs: prepare airootfs.sfs for overlayfs usage
|
||||
Default: '${sfs_mode}'
|
||||
-c <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)
|
||||
Default: '${sfs_comp}'
|
||||
-v Enable verbose output
|
||||
-h This message
|
||||
commands:
|
||||
build_profile
|
||||
build an iso image from a profile
|
||||
usage ${app_name} [options] <profile_dir or legacy_command>
|
||||
options:
|
||||
-A <application> Set an application name for the ISO
|
||||
Default: '${iso_application}'
|
||||
-C <file> pacman configuration file.
|
||||
Default: '${pacman_conf}'
|
||||
-D <install_dir> Set an install_dir. All files will by located here.
|
||||
Default: '${install_dir}'
|
||||
NOTE: Max 8 characters, use only [a-z0-9]
|
||||
-L <label> Set the ISO volume label
|
||||
Default: '${iso_label}'
|
||||
-P <publisher> Set the ISO publisher
|
||||
Default: '${iso_publisher}'
|
||||
-c <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)
|
||||
Default: '${sfs_comp}'
|
||||
-g <gpg_key> Set the GPG key to be used for signing the sqashfs image
|
||||
-h This message
|
||||
-o <out_dir> Set the output directory
|
||||
Default: '${out_dir}'
|
||||
-p PACKAGE(S) Package(s) to install, can be used multiple times
|
||||
-r <run_cmd> Set a command to be run in chroot (only relevant for for command_run)
|
||||
NOTE: Deprecated, will be removed with archiso v49
|
||||
-s <sfs_mode> Set SquashFS image mode (img or sfs)
|
||||
img: prepare airootfs.sfs for dm-snapshot usage
|
||||
sfs: prepare airootfs.sfs for overlayfs usage
|
||||
Default: '${sfs_mode}'
|
||||
-v Enable verbose output
|
||||
-w <work_dir> Set the working directory
|
||||
Default: '${work_dir}'
|
||||
|
||||
profile_dir: Directory of the archiso profile to build
|
||||
|
||||
legacy_command: Legacy build.sh command
|
||||
NOTE: Deprecated, will be removed with archiso v49
|
||||
command_init
|
||||
initialize a chroot for building
|
||||
command_install
|
||||
install packages to the chroot
|
||||
command_run
|
||||
run a command in the chroot
|
||||
command_prepare
|
||||
cleanup and prepare the airootfs
|
||||
command_pkglist
|
||||
create a list of packages installed on the medium
|
||||
command_iso
|
||||
create the ISO
|
||||
ENDUSAGETEXT
|
||||
printf '%s' "${usagetext}"
|
||||
exit "${1}"
|
||||
@ -652,6 +673,29 @@ _read_profile() {
|
||||
fi
|
||||
}
|
||||
|
||||
# set overrides from mkarchiso option parameters, if present
|
||||
_set_overrides() {
|
||||
if [[ -n "$override_iso_label" ]]; then
|
||||
iso_label="$override_iso_label"
|
||||
fi
|
||||
if [[ -n "$override_iso_publisher" ]]; then
|
||||
iso_publisher="$override_iso_publisher"
|
||||
fi
|
||||
if [[ -n "$override_iso_application" ]]; then
|
||||
iso_application="$override_iso_application"
|
||||
fi
|
||||
if [[ -n "$override_install_dir" ]]; then
|
||||
install_dir="$override_install_dir"
|
||||
fi
|
||||
if [[ -n "$override_pacman_conf" ]]; then
|
||||
pacman_conf="$override_pacman_conf"
|
||||
fi
|
||||
if [[ -n "$override_gpg_key" ]]; then
|
||||
gpg_key="$override_gpg_key"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_export_gpg_publickey() {
|
||||
if [[ -n "${gpg_key}" ]]; then
|
||||
gpg --batch --output "${work_dir}/pubkey.gpg" --export "${gpg_key}"
|
||||
@ -743,27 +787,23 @@ command_build_profile() {
|
||||
_run_once _make_iso
|
||||
}
|
||||
|
||||
while getopts 'B:p:r:C:L:P:A:D:w:o:s:c:g:vh:?' arg; do
|
||||
while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh?' arg; do
|
||||
case "${arg}" in
|
||||
B)
|
||||
profile="$(realpath -- "${OPTARG}")"
|
||||
_read_profile
|
||||
;;
|
||||
p)
|
||||
read -r -a opt_pkg_list <<< "${OPTARG}"
|
||||
pkg_list+=("${opt_pkg_list[@]}")
|
||||
;;
|
||||
r) run_cmd="${OPTARG}" ;;
|
||||
C) pacman_conf="$(realpath -- "${OPTARG}")" ;;
|
||||
L) iso_label="${OPTARG}" ;;
|
||||
P) iso_publisher="${OPTARG}" ;;
|
||||
A) iso_application="${OPTARG}" ;;
|
||||
D) install_dir="${OPTARG}" ;;
|
||||
C) override_pacman_conf="$(realpath -- "${OPTARG}")" ;;
|
||||
L) override_iso_label="${OPTARG}" ;;
|
||||
P) override_iso_publisher="${OPTARG}" ;;
|
||||
A) override_iso_application="${OPTARG}" ;;
|
||||
D) override_install_dir="${OPTARG}" ;;
|
||||
w) work_dir="$(realpath -- "${OPTARG}")" ;;
|
||||
o) out_dir="$(realpath -- "${OPTARG}")" ;;
|
||||
s) sfs_mode="${OPTARG}" ;;
|
||||
c) sfs_comp="${OPTARG}" ;;
|
||||
g) gpg_key="${OPTARG}" ;;
|
||||
g) override_gpg_key="${OPTARG}" ;;
|
||||
v) quiet="n" ;;
|
||||
h|?) _usage 0 ;;
|
||||
*)
|
||||
@ -791,40 +831,46 @@ isofs_dir="${work_dir}/iso"
|
||||
|
||||
case "${command_name}" in
|
||||
init)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
_set_overrides
|
||||
command_init
|
||||
;;
|
||||
install)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
_set_overrides
|
||||
command_install
|
||||
;;
|
||||
run)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
command_run
|
||||
;;
|
||||
prepare)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
_set_overrides
|
||||
command_prepare
|
||||
;;
|
||||
pkglist)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
command_pkglist
|
||||
;;
|
||||
iso)
|
||||
_msg_warning "The '${command_name}' command is deprecated!"
|
||||
_msg_warning "The '${command_name}' command is deprecated! It will be removed with archiso v49."
|
||||
if (( $# < 2 )); then
|
||||
_msg_error "No image specified" 0
|
||||
_usage 1
|
||||
fi
|
||||
img_name="${2}"
|
||||
_set_overrides
|
||||
command_iso
|
||||
;;
|
||||
build_profile)
|
||||
command_build_profile
|
||||
;;
|
||||
*)
|
||||
_msg_error "Invalid command name '${command_name}'" 0
|
||||
_usage 1
|
||||
# NOTE: we call read_profile here, assuming that the first non-option parameter is a profile directory
|
||||
# This way we can retain backwards compatibility with legacy build.sh scripts until we deprecate the old way of
|
||||
# calling mkarchiso with named parameters in v49
|
||||
profile="$(realpath -- "${command_name}")"
|
||||
_read_profile
|
||||
_set_overrides
|
||||
command_build_profile
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
printf '\n[%s] WARNING: %s\n\n' "mkarchiso" "build.sh scripts are deprecated! Please use mkarchiso directly." >&2
|
||||
_buildsh_path="$(realpath -- "$0")"
|
||||
exec mkarchiso "$@" -B "${_buildsh_path%/*}" build_profile
|
||||
exec mkarchiso "$@" "${_buildsh_path%/*}"
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
printf '\n[%s] WARNING: %s\n\n' "mkarchiso" "build.sh scripts are deprecated! Please use mkarchiso directly." >&2
|
||||
_buildsh_path="$(realpath -- "$0")"
|
||||
exec mkarchiso "$@" -B "${_buildsh_path%/*}" build_profile
|
||||
exec mkarchiso "$@" "${_buildsh_path%/*}"
|
||||
|
Loading…
Reference in New Issue
Block a user