mkarchiso: add xorrisofs options from boot mode specific functions instead of hardcoding them in _build_iso
This commit is contained in:
parent
4dfb473748
commit
96ac5e2454
@ -36,15 +36,18 @@ The image file is constructed from some of the variables in **profiledef.sh**: `
|
||||
directory on the resulting image into which all files will be installed (defaults to `mkarchiso`)
|
||||
* `bootmodes`: A list of strings, that state the supported boot modes of the resulting image. Only the following are
|
||||
understood:
|
||||
|
||||
- `bios.syslinux.mbr`: Syslinux for x86 BIOS booting from a disk
|
||||
- `bios.syslinux.eltorito`: Syslinux for x86 BIOS booting from an optical disc
|
||||
- `uefi-x64.systemd-boot.esp`: Systemd-boot for x86_64 UEFI booting from a disk
|
||||
- `uefi-x64.systemd-boot.eltorito`: Systemd-boot for x86_64 UEFI booting from an optical disc
|
||||
Note that BIOS El Torito boot mode must always be listed before UEFI El Torito boot mode.
|
||||
* `arch`: The architecture (e.g. `x86_64`) to build the image for. This is also used to resolve the name of the packages
|
||||
file (e.g. `packages.x86_64`)
|
||||
* `pacman_conf`: The `pacman.conf` to use to install packages to the work directory when creating the image (defaults to
|
||||
the host's `/etc/pacman.conf`)
|
||||
* `airootfs_image_type`: The image type to create. The following options are understood (defaults to `squashfs`):
|
||||
|
||||
- `squashfs`: Create a squashfs image directly from the airootfs work directory
|
||||
- `ext4+squashfs`: Create an ext4 partition, copy the airootfs work directory to it and create a squashfs image from it
|
||||
* `airootfs_image_tool_options`: An array of options to pass to the tool to create the airootfs image. Currently only
|
||||
|
@ -661,30 +661,20 @@ _validate_requirements_airootfs_image_type_ext4+squashfs() {
|
||||
_validate_requirements_airootfs_image_type_squashfs
|
||||
}
|
||||
|
||||
# Build ISO
|
||||
_build_iso() {
|
||||
local xorrisofs_options=()
|
||||
|
||||
[[ -d "${out_dir}" ]] || install -d -- "${out_dir}"
|
||||
|
||||
[[ "${quiet}" == "y" ]] && xorrisofs_options+=('-quiet')
|
||||
|
||||
# xorrisofs options for x86 BIOS booting using SYSLINUX
|
||||
# shellcheck disable=SC2076
|
||||
if [[ " ${bootmodes[*]} " =~ ' bios.syslinux.' ]]; then
|
||||
|
||||
# SYSLINUX El Torito
|
||||
if [[ " ${bootmodes[*]} " =~ ' bios.syslinux.eltorito ' ]]; then
|
||||
if [[ ! -f "${isofs_dir}/isolinux/isolinux.bin" ]]; then
|
||||
_msg_error "The file '${isofs_dir}/isolinux/isolinux.bin' does not exist." 1
|
||||
fi
|
||||
_add_xorrisofs_options_bios.syslinux.eltorito() {
|
||||
xorrisofs_options+=(
|
||||
# El Torito boot image for x86 BIOS
|
||||
'-eltorito-boot' 'isolinux/isolinux.bin'
|
||||
# El Torito boot catalog file
|
||||
'-eltorito-catalog' 'isolinux/boot.cat'
|
||||
# Required options to boot with ISOLINUX
|
||||
'-no-emul-boot' '-boot-load-size' '4' '-boot-info-table'
|
||||
)
|
||||
}
|
||||
|
||||
# SYSLINUX MBR
|
||||
if [[ " ${bootmodes[*]} " =~ ' bios.syslinux.mbr ' ]]; then
|
||||
if [[ ! -f "${isofs_dir}/isolinux/isohdpfx.bin" ]]; then
|
||||
_msg_error "The file '${isofs_dir}/isolinux/isohdpfx.bin' does not exist." 1
|
||||
fi
|
||||
|
||||
_add_xorrisofs_options_bios.syslinux.mbr() {
|
||||
xorrisofs_options+=(
|
||||
# SYSLINUX MBR bootstrap code; does not work without "-eltorito-boot isolinux/isolinux.bin"
|
||||
'-isohybrid-mbr' "${isofs_dir}/isolinux/isohdpfx.bin"
|
||||
@ -703,29 +693,13 @@ _build_iso() {
|
||||
# https://dev.lovelyhq.com/libburnia/libisoburn/src/branch/master/doc/partition_offset.wiki
|
||||
'-partition_offset' '16'
|
||||
)
|
||||
fi
|
||||
|
||||
xorrisofs_options+=(
|
||||
# El Torito boot image for x86 BIOS
|
||||
'-eltorito-boot' 'isolinux/isolinux.bin'
|
||||
# El Torito boot catalog file
|
||||
'-eltorito-catalog' 'isolinux/boot.cat'
|
||||
# Required options to boot with ISOLINUX
|
||||
'-no-emul-boot' '-boot-load-size' '4' '-boot-info-table'
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
# xorrisofs options for X64 UEFI booting using systemd-boot
|
||||
# shellcheck disable=SC2076
|
||||
if [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.' ]]; then
|
||||
[[ -f "${work_dir}/efiboot.img" ]] || _msg_error "The file '${work_dir}/efiboot.img' does not exist." 1
|
||||
[[ -e "${isofs_dir}/EFI/archiso" ]] && rm -rf -- "${isofs_dir}/EFI/archiso"
|
||||
}
|
||||
|
||||
# systemd-boot in an attached EFI system partition
|
||||
if [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.esp ' ]]; then
|
||||
_add_xorrisofs_options_uefi-x64.systemd-boot.esp() {
|
||||
# Move the first partition away from the start of the ISO, otherwise the GPT will not be valid and ISO 9660
|
||||
# partition will not be mountable
|
||||
# shellcheck disable=SC2076
|
||||
[[ " ${xorrisofs_options[*]} " =~ ' -partition_offset ' ]] || xorrisofs_options+=('-partition_offset' '16')
|
||||
xorrisofs_options+=(
|
||||
# Attach efiboot.img as a second partition and set its partition type to "EFI system partition"
|
||||
@ -733,9 +707,13 @@ _build_iso() {
|
||||
# Ensure GPT is used as some systems do not support UEFI booting without it
|
||||
'-appended_part_as_gpt'
|
||||
)
|
||||
}
|
||||
|
||||
# systemd-boot via El Torito
|
||||
_add_xorrisofs_options_uefi-x64.systemd-boot.eltorito() {
|
||||
# shellcheck disable=SC2076
|
||||
if [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.esp ' ]]; then
|
||||
# systemd-boot in an attached EFI system partition via El Torito
|
||||
if [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.eltorito ' ]]; then
|
||||
xorrisofs_options+=(
|
||||
# Start a new El Torito boot entry for UEFI
|
||||
'-eltorito-alt-boot'
|
||||
@ -744,14 +722,12 @@ _build_iso() {
|
||||
# Boot image is not emulating floppy or hard disk; required for all known boot loaders
|
||||
'-no-emul-boot'
|
||||
)
|
||||
fi
|
||||
# systemd-boot in an embedded efiboot.img via El Torito
|
||||
elif [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.eltorito ' ]]; then
|
||||
else
|
||||
# The ISO will not contain a GPT partition table, so to be able to reference efiboot.img, place it as a
|
||||
# file inside the ISO 9660 file system
|
||||
install -d -m 0755 -- "${isofs_dir}/EFI/archiso"
|
||||
cp -a -- "${work_dir}/efiboot.img" "${isofs_dir}/EFI/archiso/efiboot.img"
|
||||
|
||||
# systemd-boot in an embedded efiboot.img via El Torito
|
||||
xorrisofs_options+=(
|
||||
# Start a new El Torito boot entry for UEFI
|
||||
'-eltorito-alt-boot'
|
||||
@ -761,10 +737,24 @@ _build_iso() {
|
||||
'-no-emul-boot'
|
||||
)
|
||||
fi
|
||||
|
||||
# Specify where to save the El Torito boot catalog file in case it is not already set by bios.syslinux.eltorito
|
||||
# shellcheck disable=SC2076
|
||||
[[ " ${bootmodes[*]} " =~ ' bios.' ]] || xorrisofs_options+=('-eltorito-catalog' 'EFI/boot.cat')
|
||||
fi
|
||||
}
|
||||
|
||||
# Build ISO
|
||||
_build_iso() {
|
||||
local xorrisofs_options=()
|
||||
local bootmode
|
||||
|
||||
[[ -d "${out_dir}" ]] || install -d -- "${out_dir}"
|
||||
|
||||
[[ "${quiet}" == "y" ]] && xorrisofs_options+=('-quiet')
|
||||
|
||||
# Add required xorrisofs options for each boot mode
|
||||
for bootmode in "${bootmodes[@]}"; do
|
||||
typeset -f "_add_xorrisofs_options_${bootmode}" &> /dev/null && "_add_xorrisofs_options_${bootmode}"
|
||||
done
|
||||
|
||||
_msg_info "Creating ISO image..."
|
||||
xorriso -as mkisofs \
|
||||
|
Loading…
Reference in New Issue
Block a user