summaryrefslogtreecommitdiff
path: root/parabolaiso/mkparabolaiso
diff options
context:
space:
mode:
Diffstat (limited to 'parabolaiso/mkparabolaiso')
-rwxr-xr-xparabolaiso/mkparabolaiso248
1 files changed, 52 insertions, 196 deletions
diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso
index 11a9a91..df8f184 100755
--- a/parabolaiso/mkparabolaiso
+++ b/parabolaiso/mkparabolaiso
@@ -17,8 +17,6 @@ quiet="y"
work_dir="work"
out_dir="out"
img_name="${app_name}.iso"
-sfs_mode="sfs"
-sfs_comp="xz"
gpg_key=""
override_gpg_key=""
@@ -34,10 +32,12 @@ override_iso_application=""
iso_version=""
install_dir="${app_name}"
override_install_dir=""
-arch="${arch:-$(uname -m)}" # leave $(uname -m) only in parabolaiso v49+
+arch="$(uname -m)"
pacman_conf="/etc/pacman.conf"
override_pacman_conf=""
bootmodes=()
+airootfs_image_type="squashfs"
+airootfs_image_tool_options=('-comp' 'xz')
# Show an INFO message
@@ -95,7 +95,7 @@ _umount_airootfs() {
# $1: exit status number.
_usage() {
IFS='' read -r -d '' usagetext <<ENDUSAGETEXT || true
-usage ${app_name} [options] <profile_dir or legacy_command>
+usage: ${app_name} [options] <profile_dir>
options:
-A <application> Set an application name for the ISO
Default: '${iso_application}'
@@ -108,39 +108,16 @@ usage ${app_name} [options] <profile_dir or legacy_command>
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 squashfs 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 legacy 'run' command)
- NOTE: Deprecated, will be removed with parabolaiso 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 parabolaiso profile to build
-
- legacy_command: Legacy build.sh command
- NOTE: Deprecated, will be removed with parabolaiso v49
- init
- initialize a chroot for building
- install
- install packages to the chroot
- run
- run a command in the chroot
- prepare
- cleanup and prepare the airootfs
- pkglist
- create a list of packages installed on the medium
- iso
- create the ISO
ENDUSAGETEXT
printf '%s' "${usagetext}"
exit "${1}"
@@ -149,55 +126,27 @@ ENDUSAGETEXT
# Shows configuration according to command mode.
# $1: build_profile | init | install | run | prepare | iso
_show_config() {
- local _mode="$1" build_date
+ local build_date
build_date="$(date --utc --iso-8601=seconds -d "@${SOURCE_DATE_EPOCH}")"
_msg_info "${app_name} configuration settings"
- [[ ! -d "${command_name}" ]] && _msg_info " Legacy Command: ${command_name}"
_msg_info " Architecture: ${arch}"
_msg_info " Working directory: ${work_dir}"
_msg_info " Installation directory: ${install_dir}"
- case "${_mode}" in
- build_profile)
- _msg_info " Build date: ${build_date}"
- _msg_info " Output directory: ${out_dir}"
- _msg_info " GPG key: ${gpg_key:-None}"
- _msg_info " Profile: ${profile}"
- _msg_info "Pacman configuration file: ${pacman_conf}"
- _msg_info " Image file name: ${img_name}"
- _msg_info " ISO volume label: ${iso_label}"
- _msg_info " ISO publisher: ${iso_publisher}"
- _msg_info " ISO application: ${iso_application}"
- _msg_info " Boot modes: ${bootmodes[*]}"
- _msg_info " Packages: ${pkg_list[*]}"
- if [[ "${arch}" == "dual" ]]; then
- _msg_info " Packages (x86_64): ${pkg_list_x86_64[*]:-None}"
- _msg_info " Packages (i686): ${pkg_list_i686[*]:-None}"
- fi
- ;;
- init)
- _msg_info "Pacman configuration file: ${pacman_conf}"
- ;;
- install)
- _msg_info " GPG key: ${gpg_key:-None}"
- _msg_info "Pacman configuration file: ${pacman_conf}"
- _msg_info " Packages: ${pkg_list[*]}"
- ;;
- run)
- _msg_info " Run command: ${run_cmd}"
- ;;
- prepare)
- _msg_info " GPG key: ${gpg_key:-None}"
- ;;
- pkglist)
- ;;
- iso)
- _msg_info " Output directory: ${out_dir}"
- _msg_info " Image file name: ${img_name}"
- _msg_info " ISO volume label: ${iso_label}"
- _msg_info " ISO publisher: ${iso_publisher}"
- _msg_info " ISO application: ${iso_application}"
- ;;
- esac
+ _msg_info " Build date: ${build_date}"
+ _msg_info " Output directory: ${out_dir}"
+ _msg_info " GPG key: ${gpg_key:-None}"
+ _msg_info " Profile: ${profile}"
+ _msg_info "Pacman configuration file: ${pacman_conf}"
+ _msg_info " Image file name: ${img_name}"
+ _msg_info " ISO volume label: ${iso_label}"
+ _msg_info " ISO publisher: ${iso_publisher}"
+ _msg_info " ISO application: ${iso_application}"
+ _msg_info " Boot modes: ${bootmodes[*]}"
+ _msg_info " Packages: ${pkg_list[*]}"
+ if [[ "${arch}" == "dual" ]]; then
+ _msg_info " Packages (x86_64): ${pkg_list_x86_64[*]:-None}"
+ _msg_info " Packages (i686): ${pkg_list_i686[*]:-None}"
+ fi
[[ "${quiet}" == "y" ]] || printf '\n'
}
@@ -250,6 +199,23 @@ _cleanup() {
_msg_info "Done!"
}
+_mkairootfs_create_image() {
+ if (( $# < 1 )); then
+ _msg_error "Function '${FUNCNAME[0]}' requires at least one argument" 1
+ fi
+
+ image_path="${isofs_dir}/${install_dir}/${arch}/airootfs.sfs"
+ if [[ "${airootfs_image_type}" =~ .*squashfs ]] ; then
+ if [[ "${quiet}" == "y" ]]; then
+ mksquashfs "$@" "${image_path}" -noappend "${airootfs_image_tool_options[@]}" -no-progress > /dev/null
+ else
+ mksquashfs "$@" "${image_path}" -noappend "${airootfs_image_tool_options[@]}"
+ fi
+ else
+ _msg_error "Unsupported image type: '${airootfs_image_type}'" 1
+ fi
+}
+
# Makes a ext4 filesystem inside a SquashFS from a source directory.
_mkairootfs_img() {
if [[ ! -e "${airootfs_dir}" ]]; then
@@ -272,13 +238,7 @@ _mkairootfs_img() {
_umount_airootfs
install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}"
_msg_info "Creating SquashFS image, this may take some time..."
- if [[ "${quiet}" = "y" ]]; then
- mksquashfs "${airootfs_dir}.img" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \
- -comp "${sfs_comp}" -no-progress > /dev/null
- else
- mksquashfs "${airootfs_dir}.img" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \
- -comp "${sfs_comp}"
- fi
+ _mkairootfs_create_image "${airootfs_dir}.img"
_msg_info "Done!"
rm -- "${airootfs_dir}.img"
}
@@ -291,13 +251,7 @@ _mkairootfs_sfs() {
install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}"
_msg_info "Creating ${arch} SquashFS image, this may take some time..."
- if [[ "${quiet}" = "y" ]]; then
- mksquashfs "${airootfs_dir}" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \
- -comp "${sfs_comp}" -no-progress > /dev/null
- else
- mksquashfs "${airootfs_dir}" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \
- -comp "${sfs_comp}"
- fi
+ _mkairootfs_create_image "${airootfs_dir}"
_msg_info "Done!"
}
@@ -692,10 +646,12 @@ _make_boot_uefi-x64.refind.eltorito() {
# Build airootfs filesystem image
_make_prepare() {
- if [[ "${sfs_mode}" == "sfs" ]]; then
+ if [[ "${airootfs_image_type}" == "squashfs" ]]; then # prepare airootfs.sfs for overlayfs usage (default)
_run_once _mkairootfs_sfs
- else
+ elif [[ "${airootfs_image_type}" == "ext4+squashfs" ]]; then # prepare airootfs.sfs for dm-snapshot usage
_run_once _mkairootfs_img
+ else
+ _msg_error "Unsupported image type: '${airootfs_image_type}'" 1
fi
_mkchecksum
if [[ "${gpg_key}" ]]; then
@@ -913,64 +869,7 @@ _make_pkglist() {
_msg_info "Done!"
}
-command_pkglist() {
- _show_config "${FUNCNAME[0]#command_}"
- _make_pkglist
-}
-
-# Create an ISO9660 filesystem from "iso" directory.
-command_iso() {
- bootmodes=('bios.syslinux.mbr' 'bios.syslinux.eltorito')
-
- # If exists, add an EFI "El Torito" boot image (FAT filesystem) to ISO-9660 image.
- if [[ -f "${work_dir}/efiboot.img" ]]; then
- if [[ -e "${airootfs_dir}/usr/share/refind/refind_x64.efi" ]]; then
- bootmodes+=('uefi-x64.refind.esp' 'uefi-x64.refind.eltorito')
- else
- bootmodes+=('uefi-x64.systemd-boot.esp' 'uefi-x64.systemd-boot.eltorito')
- fi
- fi
-
- _show_config "${FUNCNAME[0]#command_}"
- _make_iso
-}
-
-# create airootfs.sfs filesystem, and push it in "iso" directory.
-command_prepare() {
- _show_config "${FUNCNAME[0]#command_}"
-
- _cleanup
- _make_prepare
-}
-
-# Install packages on airootfs.
-# A basic check to avoid double execution/reinstallation is done via hashing package names.
-command_install() {
- if [[ ! -f "${pacman_conf}" ]]; then
- _msg_error "Pacman config file '${pacman_conf}' does not exist" 1
- fi
-
- if (( ${#pkg_list[@]} == 0 )); then
- _msg_error "Packages must be specified" 0
- _usage 1
- fi
-
- _show_config "${FUNCNAME[0]#command_}"
-
- _make_packages
-}
-
-command_init() {
- _show_config "${FUNCNAME[0]#command_}"
- _chroot_init
-}
-
-command_run() {
- _show_config "${FUNCNAME[0]#command_}"
- _chroot_run
-}
-
-command_build_profile() {
+_build_profile() {
# Set up essential directory paths
airootfs_dir="${work_dir}/${arch}/airootfs"
isofs_dir="${work_dir}/iso"
@@ -986,7 +885,7 @@ command_build_profile() {
printf '%s\n' "$SOURCE_DATE_EPOCH" > "${work_dir}/build_date"
fi
- _show_config "${FUNCNAME[0]#command_}"
+ _show_config
_run_dual '_run_once _make_pacman_conf'
_run_once _export_gpg_publickey
@@ -1000,7 +899,7 @@ command_build_profile() {
_run_once _make_iso
}
-while getopts '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:g:vh?' arg; do
case "${arg}" in
p)
read -r -a opt_pkg_list <<< "${OPTARG}"
@@ -1014,8 +913,6 @@ while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh?' arg; do
D) override_install_dir="${OPTARG}" ;;
w) work_dir="$(realpath -- "${OPTARG}")" ;;
o) out_dir="$(realpath -- "${OPTARG}")" ;;
- s) sfs_mode="${OPTARG}" ;;
- c) sfs_comp="${OPTARG}" ;;
g) override_gpg_key="${OPTARG}" ;;
v) quiet="n" ;;
h|?) _usage 0 ;;
@@ -1029,7 +926,7 @@ done
shift $((OPTIND - 1))
if (( $# < 1 )); then
- _msg_error "No command specified" 0
+ _msg_error "No profile specified" 0
_usage 1
fi
@@ -1037,55 +934,14 @@ if (( EUID != 0 )); then
_msg_error "${app_name} must be run as root." 1
fi
-command_name="${1}"
+# get the absolute path representation of the first non-option argument
+profile="$(realpath -- "${1}")"
# Set directory path defaults for legacy commands
airootfs_dir="${work_dir}/airootfs"
isofs_dir="${work_dir}/iso"
-
-case "${command_name}" in
- init)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- _set_overrides
- command_init
- ;;
- install)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- _set_overrides
- command_install
- ;;
- run)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- command_run
- ;;
- prepare)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- _set_overrides
- command_prepare
- ;;
- pkglist)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- command_pkglist
- ;;
- iso)
- _msg_warning "The '${command_name}' command is deprecated! It will be removed with parabolaiso v49."
- if (( $# < 2 )); then
- _msg_error "No image specified" 0
- _usage 1
- fi
- img_name="${2}"
- _set_overrides
- command_iso
- ;;
- *)
- # 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 mkparabolaiso with named parameters in v49
- profile="$(realpath -- "${command_name}")"
- _read_profile
- _set_overrides
- command_build_profile
- ;;
-esac
+_read_profile
+_set_overrides
+_build_profile
# vim:ts=4:sw=4:et: