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).
|
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
|
.. code:: bash
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ Create images with packaged archiso
|
|||||||
|
|
||||||
.. code:: bash
|
.. 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
|
Create images with local clone
|
||||||
------------------------------
|
------------------------------
|
||||||
@ -69,13 +69,13 @@ Clone this repository and run:
|
|||||||
|
|
||||||
.. code:: bash
|
.. 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
|
Testing
|
||||||
=======
|
=======
|
||||||
|
|
||||||
The convenience script **run_archiso** is provided to boot into the medium using qemu.
|
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
|
.. code:: bash
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ Run the following to boot the iso using UEFI:
|
|||||||
|
|
||||||
.. code:: bash
|
.. 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:
|
The script can of course also be executed from this repository:
|
||||||
|
|
||||||
|
@ -20,17 +20,22 @@ img_name="${app_name}.iso"
|
|||||||
sfs_mode="sfs"
|
sfs_mode="sfs"
|
||||||
sfs_comp="xz"
|
sfs_comp="xz"
|
||||||
gpg_key=""
|
gpg_key=""
|
||||||
|
override_gpg_key=""
|
||||||
|
|
||||||
# profile defaults
|
# profile defaults
|
||||||
profile=""
|
profile=""
|
||||||
iso_name="${app_name}"
|
iso_name="${app_name}"
|
||||||
iso_label="${app_name^^}"
|
iso_label="${app_name^^}"
|
||||||
|
override_iso_label=""
|
||||||
iso_publisher="${app_name}"
|
iso_publisher="${app_name}"
|
||||||
|
override_iso_publisher=""
|
||||||
iso_application="${app_name} iso"
|
iso_application="${app_name} iso"
|
||||||
|
override_iso_application=""
|
||||||
iso_version=""
|
iso_version=""
|
||||||
install_dir="${app_name}"
|
install_dir="${app_name}"
|
||||||
arch="$(uname -m)"
|
arch="$(uname -m)"
|
||||||
pacman_conf="/etc/pacman.conf"
|
pacman_conf="/etc/pacman.conf"
|
||||||
|
override_pacman_conf=""
|
||||||
bootmodes=()
|
bootmodes=()
|
||||||
|
|
||||||
|
|
||||||
@ -105,36 +110,52 @@ _umount_efibootimg() {
|
|||||||
# $1: exit status number.
|
# $1: exit status number.
|
||||||
_usage() {
|
_usage() {
|
||||||
IFS='' read -r -d '' usagetext <<ENDUSAGETEXT || true
|
IFS='' read -r -d '' usagetext <<ENDUSAGETEXT || true
|
||||||
usage ${app_name} [options] command <command options>
|
usage ${app_name} [options] <profile_dir or legacy_command>
|
||||||
general options:
|
options:
|
||||||
-B <profile_dir> Directory of the archiso profile to build
|
-A <application> Set an application name for the ISO
|
||||||
-p PACKAGE(S) Package(s) to install, can be used multiple times
|
Default: '${iso_application}'
|
||||||
-C <file> pacman configuration file.
|
-C <file> pacman configuration file.
|
||||||
Default: '${pacman_conf}'
|
Default: '${pacman_conf}'
|
||||||
-L <label> Set the ISO volume label
|
-D <install_dir> Set an install_dir. All files will by located here.
|
||||||
Default: '${iso_label}'
|
Default: '${install_dir}'
|
||||||
-P <publisher> Set a ISO publisher
|
NOTE: Max 8 characters, use only [a-z0-9]
|
||||||
Default: '${iso_publisher}'
|
-L <label> Set the ISO volume label
|
||||||
-A <application> Set an application name for the ISO
|
Default: '${iso_label}'
|
||||||
Default: '${iso_application}'
|
-P <publisher> Set the ISO publisher
|
||||||
-D <install_dir> Set an install_dir. All files will by located here.
|
Default: '${iso_publisher}'
|
||||||
Default: '${install_dir}'
|
-c <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)
|
||||||
NOTE: Max 8 characters, use only [a-z0-9]
|
Default: '${sfs_comp}'
|
||||||
-w <work_dir> Set the working directory
|
-g <gpg_key> Set the GPG key to be used for signing the sqashfs image
|
||||||
Default: '${work_dir}'
|
-h This message
|
||||||
-o <out_dir> Set the output directory
|
-o <out_dir> Set the output directory
|
||||||
Default: '${out_dir}'
|
Default: '${out_dir}'
|
||||||
-s <sfs_mode> Set SquashFS image mode (img or sfs)
|
-p PACKAGE(S) Package(s) to install, can be used multiple times
|
||||||
img: prepare airootfs.sfs for dm-snapshot usage
|
-r <run_cmd> Set a command to be run in chroot (only relevant for for command_run)
|
||||||
sfs: prepare airootfs.sfs for overlayfs usage
|
NOTE: Deprecated, will be removed with archiso v49
|
||||||
Default: '${sfs_mode}'
|
-s <sfs_mode> Set SquashFS image mode (img or sfs)
|
||||||
-c <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)
|
img: prepare airootfs.sfs for dm-snapshot usage
|
||||||
Default: '${sfs_comp}'
|
sfs: prepare airootfs.sfs for overlayfs usage
|
||||||
-v Enable verbose output
|
Default: '${sfs_mode}'
|
||||||
-h This message
|
-v Enable verbose output
|
||||||
commands:
|
-w <work_dir> Set the working directory
|
||||||
build_profile
|
Default: '${work_dir}'
|
||||||
build an iso image from a profile
|
|
||||||
|
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
|
ENDUSAGETEXT
|
||||||
printf '%s' "${usagetext}"
|
printf '%s' "${usagetext}"
|
||||||
exit "${1}"
|
exit "${1}"
|
||||||
@ -652,6 +673,29 @@ _read_profile() {
|
|||||||
fi
|
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() {
|
_export_gpg_publickey() {
|
||||||
if [[ -n "${gpg_key}" ]]; then
|
if [[ -n "${gpg_key}" ]]; then
|
||||||
gpg --batch --output "${work_dir}/pubkey.gpg" --export "${gpg_key}"
|
gpg --batch --output "${work_dir}/pubkey.gpg" --export "${gpg_key}"
|
||||||
@ -743,27 +787,23 @@ command_build_profile() {
|
|||||||
_run_once _make_iso
|
_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
|
case "${arg}" in
|
||||||
B)
|
|
||||||
profile="$(realpath -- "${OPTARG}")"
|
|
||||||
_read_profile
|
|
||||||
;;
|
|
||||||
p)
|
p)
|
||||||
read -r -a opt_pkg_list <<< "${OPTARG}"
|
read -r -a opt_pkg_list <<< "${OPTARG}"
|
||||||
pkg_list+=("${opt_pkg_list[@]}")
|
pkg_list+=("${opt_pkg_list[@]}")
|
||||||
;;
|
;;
|
||||||
r) run_cmd="${OPTARG}" ;;
|
r) run_cmd="${OPTARG}" ;;
|
||||||
C) pacman_conf="$(realpath -- "${OPTARG}")" ;;
|
C) override_pacman_conf="$(realpath -- "${OPTARG}")" ;;
|
||||||
L) iso_label="${OPTARG}" ;;
|
L) override_iso_label="${OPTARG}" ;;
|
||||||
P) iso_publisher="${OPTARG}" ;;
|
P) override_iso_publisher="${OPTARG}" ;;
|
||||||
A) iso_application="${OPTARG}" ;;
|
A) override_iso_application="${OPTARG}" ;;
|
||||||
D) install_dir="${OPTARG}" ;;
|
D) override_install_dir="${OPTARG}" ;;
|
||||||
w) work_dir="$(realpath -- "${OPTARG}")" ;;
|
w) work_dir="$(realpath -- "${OPTARG}")" ;;
|
||||||
o) out_dir="$(realpath -- "${OPTARG}")" ;;
|
o) out_dir="$(realpath -- "${OPTARG}")" ;;
|
||||||
s) sfs_mode="${OPTARG}" ;;
|
s) sfs_mode="${OPTARG}" ;;
|
||||||
c) sfs_comp="${OPTARG}" ;;
|
c) sfs_comp="${OPTARG}" ;;
|
||||||
g) gpg_key="${OPTARG}" ;;
|
g) override_gpg_key="${OPTARG}" ;;
|
||||||
v) quiet="n" ;;
|
v) quiet="n" ;;
|
||||||
h|?) _usage 0 ;;
|
h|?) _usage 0 ;;
|
||||||
*)
|
*)
|
||||||
@ -791,40 +831,46 @@ isofs_dir="${work_dir}/iso"
|
|||||||
|
|
||||||
case "${command_name}" in
|
case "${command_name}" in
|
||||||
init)
|
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
|
command_init
|
||||||
;;
|
;;
|
||||||
install)
|
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
|
command_install
|
||||||
;;
|
;;
|
||||||
run)
|
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
|
command_run
|
||||||
;;
|
;;
|
||||||
prepare)
|
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
|
command_prepare
|
||||||
;;
|
;;
|
||||||
pkglist)
|
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
|
command_pkglist
|
||||||
;;
|
;;
|
||||||
iso)
|
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
|
if (( $# < 2 )); then
|
||||||
_msg_error "No image specified" 0
|
_msg_error "No image specified" 0
|
||||||
_usage 1
|
_usage 1
|
||||||
fi
|
fi
|
||||||
img_name="${2}"
|
img_name="${2}"
|
||||||
|
_set_overrides
|
||||||
command_iso
|
command_iso
|
||||||
;;
|
;;
|
||||||
build_profile)
|
|
||||||
command_build_profile
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
_msg_error "Invalid command name '${command_name}'" 0
|
# NOTE: we call read_profile here, assuming that the first non-option parameter is a profile directory
|
||||||
_usage 1
|
# 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
|
esac
|
||||||
|
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
printf '\n[%s] WARNING: %s\n\n' "mkarchiso" "build.sh scripts are deprecated! Please use mkarchiso directly." >&2
|
printf '\n[%s] WARNING: %s\n\n' "mkarchiso" "build.sh scripts are deprecated! Please use mkarchiso directly." >&2
|
||||||
_buildsh_path="$(realpath -- "$0")"
|
_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
|
printf '\n[%s] WARNING: %s\n\n' "mkarchiso" "build.sh scripts are deprecated! Please use mkarchiso directly." >&2
|
||||||
_buildsh_path="$(realpath -- "$0")"
|
_buildsh_path="$(realpath -- "$0")"
|
||||||
exec mkarchiso "$@" -B "${_buildsh_path%/*}" build_profile
|
exec mkarchiso "$@" "${_buildsh_path%/*}"
|
||||||
|
Loading…
Reference in New Issue
Block a user