From e09959ed0aba19e6b7f6789c1c57632414c5ec4b Mon Sep 17 00:00:00 2001 From: David P Date: Mon, 2 Aug 2021 17:59:43 -0400 Subject: sync with archiso v57 archiso: a4691b8 (tag: v57) Merge branch 'changelog/57' 12c21b1 (origin/changelog/57) Add changelog for 57 0ccb4f8 Merge branch 'issues/143' 0fa1c0e (origin/issues/143) mkarchiso: Do not run _build_iso_base once 9462e4c Merge branch 'issues/117' f4324e2 (origin/issues/117) Remove SPDX license identifier from releng configs 00a1e8e Remove SPDX license identifier from releng configs a07ff5c Merge remote-tracking branch 'nl6720/bootmodes-2' 610ff2a mkarchiso: improve functions and comments 1cec901 Merge remote-tracking branch 'nl6720/RouteMetric' 8fa110e configs/*/airootfs/etc/systemd/system/systemd-networkd-wait-online.service.d/wait-for-only-one-interface.conf: document why the drop-in file exists c6a1ccc configs/releng/airootfs/etc/systemd/network/: move RouteMetric= from [DHCPv6] to [IPv6AcceptRA] Signed-off-by: David P --- parabolaiso/mkparabolaiso | 250 ++++++++++++++++++++++++++-------------------- 1 file changed, 141 insertions(+), 109 deletions(-) (limited to 'parabolaiso/mkparabolaiso') diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso index 22b0167..aaef80d 100755 --- a/parabolaiso/mkparabolaiso +++ b/parabolaiso/mkparabolaiso @@ -176,6 +176,8 @@ _cleanup_pacstrap_dir() { _msg_info "Done!" } +# Create a squashfs image and place it in the ISO 9660 file system. +# $@: options to pass to mksquashfs _run_mksquashfs() { local image_path="${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" if [[ "${quiet}" == "y" ]]; then @@ -185,7 +187,8 @@ _run_mksquashfs() { fi } -# Makes a ext4 filesystem inside a SquashFS from a source directory. +# Create an ext4 image containing the root file system and pack it inside a squashfs image. +# Save the squashfs image on the ISO 9660 file system. _mkairootfs_ext4+squashfs() { [[ -e "${pacstrap_dir}" ]] || _msg_error "The path '${pacstrap_dir}' does not exist" 1 @@ -210,29 +213,16 @@ _mkairootfs_ext4+squashfs() { rm -- "${pacstrap_dir}.img" } -# Makes a SquashFS filesystem from a source directory. +# Create a squashfs image containing the root file system and saves it on the ISO 9660 file system. _mkairootfs_squashfs() { [[ -e "${pacstrap_dir}" ]] || _msg_error "The path '${pacstrap_dir}' does not exist" 1 install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" _msg_info "Creating ${arch} SquashFS image, this may take some time..." _run_mksquashfs "${pacstrap_dir}" - _msg_info "Done!" } -_mkchecksum() { - _msg_info "Creating checksum file for self-test..." - cd -- "${isofs_dir}/${install_dir}/${arch}" - if [[ -e "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" ]]; then - sha512sum airootfs.sfs > airootfs.sha512 - elif [[ -e "${isofs_dir}/${install_dir}/${arch}/airootfs.erofs" ]]; then - sha512sum airootfs.erofs > airootfs.sha512 - fi - cd -- "${OLDPWD}" - _msg_info "Done!" -} - -# Makes an EROFS file system from a source directory. +# Create an EROFS image containing the root file system and saves it on the ISO 9660 file system. _mkairootfs_erofs() { local fsuuid [[ -e "${pacstrap_dir}" ]] || _msg_error "The path '${pacstrap_dir}' does not exist" 1 @@ -246,6 +236,20 @@ _mkairootfs_erofs() { _msg_info "Done!" } +# Create checksum file for the rootfs image. +_mkchecksum() { + _msg_info "Creating checksum file for self-test..." + cd -- "${isofs_dir}/${install_dir}/${arch}" + if [[ -e "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" ]]; then + sha512sum airootfs.sfs > airootfs.sha512 + elif [[ -e "${isofs_dir}/${install_dir}/${arch}/airootfs.erofs" ]]; then + sha512sum airootfs.erofs > airootfs.sha512 + fi + cd -- "${OLDPWD}" + _msg_info "Done!" +} + +# GPG sign the root file system image. _mksignature() { _msg_info "Signing ${arch} rootfs image..." cd -- "${isofs_dir}/${install_dir}/${arch}" @@ -260,6 +264,7 @@ _mksignature() { } # Helper function to run functions only one time. +# $1: function name _run_once() { if [[ ! -e "${work_dir}/${run_once_mode}.${1}.${arch}" ]]; then "$1" @@ -267,7 +272,8 @@ _run_once() { fi } -# Helper function to run functions for both architectures +# Helper function to run commands for the i686 and x86_64 architectures. +# $@: commands to run in both architectures _run_dual() { local cmd if [[ "${arch}" == "dual" ]]; then @@ -289,13 +295,13 @@ _run_dual() { fi } -# Set up custom pacman.conf with custom cache and pacman hook directories +# Set up custom pacman.conf with custom cache and pacman hook directories. _make_pacman_conf() { local _cache_dirs _system_cache_dirs _profile_cache_dirs _system_cache_dirs="$(pacman-conf CacheDir| tr '\n' ' ')" _profile_cache_dirs="$(pacman-conf --config "${pacman_conf}" CacheDir| tr '\n' ' ')" - # only use the profile's CacheDir, if it is not the default and not the same as the system cache dir + # Only use the profile's CacheDir, if it is not the default and not the same as the system cache dir. if [[ "${_profile_cache_dirs}" != "/var/cache/pacman/pkg" ]] && \ [[ "${_system_cache_dirs}" != "${_profile_cache_dirs}" ]]; then _cache_dirs="${_profile_cache_dirs}" @@ -314,7 +320,7 @@ _make_pacman_conf() { /\[options\]/a HookDir = ${pacstrap_dir}/etc/pacman.d/hooks/" > "${work_dir}/${buildmode}.pacman.conf.${arch}" } -# Prepare working directory and copy custom airootfs files (airootfs) +# Prepare working directory and copy custom root file system files. _make_custom_airootfs() { local passwd=() local filename permissions @@ -347,7 +353,7 @@ _make_custom_airootfs() { fi } -# Install desired packages to airootfs +# Install desired packages to the root file system _make_packages() { _msg_info "Installing packages to '${pacstrap_dir}/'..." @@ -374,7 +380,7 @@ _make_packages() { _msg_info "Done! Packages installed successfully." } -# Customize installation (airootfs) +# Customize installation. _make_customize_airootfs() { local passwd=() @@ -419,7 +425,7 @@ _make_bootmodes() { done } -# Prepare kernel/initramfs ${install_dir}/boot/ +# Copy kernel and initramfs to ISO 9660 _make_boot_on_iso9660() { _msg_info "Preparing ${arch} kernel and initramfs for the ISO 9660 file system..." install -d -m 0755 -- "${isofs_dir}/${install_dir}/boot/${arch}" @@ -428,7 +434,7 @@ _make_boot_on_iso9660() { _msg_info "Done!" } -# Prepare /syslinux +# Prepare syslinux for booting from MBR (isohybrid) _make_bootmode_bios.syslinux.mbr() { _msg_info "Setting up SYSLINUX for BIOS booting from a disk..." install -d -m 0755 -- "${isofs_dir}/syslinux" @@ -468,7 +474,7 @@ _make_bootmode_bios.syslinux.mbr() { _msg_info "Done! SYSLINUX set up for BIOS booting from a disk successfully." } -# Prepare /syslinux for El-Torito booting +# Prepare syslinux for El-Torito booting _make_bootmode_bios.syslinux.eltorito() { _msg_info "Setting up SYSLINUX for BIOS booting from an optical disc..." install -d -m 0755 -- "${isofs_dir}/syslinux" @@ -481,53 +487,7 @@ _make_bootmode_bios.syslinux.eltorito() { _msg_info "Done! SYSLINUX set up for BIOS booting from an optical disc successfully." } -# Prepare /EFI on ISO-9660 -_make_efi_dir_on_iso9660() { - _msg_info "Preparing an /EFI directory for the ISO 9660 file system..." - install -d -m 0755 -- "${isofs_dir}/EFI/BOOT" - install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \ - "${isofs_dir}/EFI/BOOT/BOOTx64.EFI" - - install -d -m 0755 -- "${isofs_dir}/loader/entries" - install -m 0644 -- "${profile}/efiboot/loader/loader.conf" "${isofs_dir}/loader/" - - for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do - sed "s|%PARABOLAISO_LABEL%|${iso_label}|g; - s|%INSTALL_DIR%|${install_dir}|g; - s|%ARCH%|${arch}|g" \ - "${_conf}" > "${isofs_dir}/loader/entries/${_conf##*/}" - done - - # edk2-shell based UEFI shell - # shellx64.efi is picked up automatically when on / - if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then - install -m 0644 -- "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" "${isofs_dir}/shellx64.efi" - fi -} - -_make_refind_efi_dir_on_iso9660() { - _msg_info "Preparing an /EFI directory for the ISO 9660 file system..." - install -d -m 0755 -- "${isofs_dir}/EFI/BOOT/entries" - install -m 0644 -- "${pacstrap_dir}/usr/share/refind/refind_x64.efi" \ - "${isofs_dir}/EFI/BOOT/BOOTx64.EFI" - - install -m 0644 -- "${profile}/efiboot/EFI/BOOT/refind.conf" "${isofs_dir}/EFI/BOOT/" - - for _conf in "${profile}/efiboot/EFI/BOOT/entries/"*".conf"; do - sed "s|%PARABOLAISO_LABEL%|${iso_label}|g; - s|%INSTALL_DIR%|${install_dir}|g; - s|%ARCH%|${arch}|g" \ - "${_conf}" > "${isofs_dir}/EFI/BOOT/entries/${_conf##*/}" - done - - # edk2-shell based UEFI shell - # shellx64.efi is picked up automatically when on / - if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then - install -m 0644 -- "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" "${isofs_dir}/shellx64.efi" - fi -} - -# Prepare kernel/initramfs on efiboot.img +# Copy kernel and initramfs to FAT image _make_boot_on_fat() { _msg_info "Preparing kernel and initramfs for the FAT file system..." mmd -i "${work_dir}/efiboot.img" \ @@ -537,33 +497,49 @@ _make_boot_on_fat() { _msg_info "Done!" } -# Prepare efiboot.img::/EFI for EFI boot mode +# Create a FAT image (efiboot.img) which will serve as the EFI system partition +# $1: image size in bytes +_make_efibootimg() { + local imgsize="0" + + # Convert from bytes to KiB and round up to the next full MiB with an additional MiB for reserved sectors. + imgsize="$(awk 'function ceil(x){return int(x)+(x>int(x))} + function byte_to_kib(x){return x/1024} + function mib_to_kib(x){return x*1024} + END {print mib_to_kib(ceil((byte_to_kib($1)+1024)/1024))}' <<< "${1}" + )" + # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: + # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html + [[ -e "${work_dir}/efiboot.img" ]] && rm -f -- "${work_dir}/efiboot.img" + _msg_info "Creating FAT image of size: ${imgsize} KiB..." + mkfs.fat -C -n PARAISO_EFI "${work_dir}/efiboot.img" "${imgsize}" + + # Create the default/fallback boot path in which a boot loaders will be placed later. + mmd -i "${work_dir}/efiboot.img" ::/EFI ::/EFI/BOOT +} + +# Prepare efiboot.img::/EFI for EFI boot mode (systemd) _make_bootmode_uefi-x64.systemd-boot.esp() { - local efiboot_imgsize="0" + local efiboot_imgsize _msg_info "Setting up systemd-boot for UEFI booting..." - # the required image size in KiB (rounded up to the next full MiB with an additional MiB for reserved sectors) + # Calculate the required FAT image size in bytes efiboot_imgsize="$(du -bc \ "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \ "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" \ "${profile}/efiboot/" \ "${pacstrap_dir}/boot/vmlinuz-"* \ "${pacstrap_dir}/boot/initramfs-"*".img" \ - 2>/dev/null | awk 'function ceil(x){return int(x)+(x>int(x))} - function byte_to_kib(x){return x/1024} - function mib_to_kib(x){return x*1024} - END {print mib_to_kib(ceil((byte_to_kib($1)+1024)/1024))}' - )" - # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: - # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html - [[ -e "${work_dir}/efiboot.img" ]] && rm -f -- "${work_dir}/efiboot.img" - _msg_info "Creating FAT image of size: ${efiboot_imgsize} KiB..." - mkfs.fat -C -n PARAISO_EFI "${work_dir}/efiboot.img" "$efiboot_imgsize" + "${_available_ucodes[@]}" \ + 2>/dev/null | awk 'END { print $1 }')" + # Create a FAT image for the EFI system partition + _make_efibootimg "$efiboot_imgsize" - mmd -i "${work_dir}/efiboot.img" ::/EFI ::/EFI/BOOT + # Copy systemd-boot EFI binary to the default/fallback boot path mcopy -i "${work_dir}/efiboot.img" \ "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/BOOTx64.EFI + # Copy systemd-boot configuration files mmd -i "${work_dir}/efiboot.img" ::/loader ::/loader/entries mcopy -i "${work_dir}/efiboot.img" "${profile}/efiboot/loader/loader.conf" ::/loader/ for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do @@ -579,38 +555,35 @@ _make_bootmode_uefi-x64.systemd-boot.esp() { "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ::/shellx64.efi fi - # Copy kernel and initramfs + # Copy kernel and initramfs to FAT image. + # systemd-boot can only access files from the EFI system partition it was launched from. _make_boot_on_fat _msg_info "Done! systemd-boot set up for UEFI booting successfully." } +# Prepare efiboot.img::/EFI for EFI boot mode (rEFInd) _make_bootmode_uefi-x64.refind.esp() { - local efiboot_imgsize="0" + local efiboot_imgsize _msg_info "Setting up rEFInd for UEFI booting..." - # the required image size in KiB (rounded up to the next full MiB with an additional MiB for reserved sectors) + # Calculate the required FAT image size in bytes efiboot_imgsize="$(du -bc \ "${pacstrap_dir}/usr/share/refind/refind_x64.efi" \ "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" \ "${profile}/efiboot/" \ "${pacstrap_dir}/boot/vmlinuz-"* \ "${pacstrap_dir}/boot/initramfs-"*".img" \ - 2>/dev/null | awk 'function ceil(x){return int(x)+(x>int(x))} - function byte_to_kib(x){return x/1024} - function mib_to_kib(x){return x*1024} - END {print mib_to_kib(ceil((byte_to_kib($1)+1024)/1024))}' - )" - # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: - # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html - [[ -e "${work_dir}/efiboot.img" ]] && rm -f -- "${work_dir}/efiboot.img" - _msg_info "Creating FAT image of size: ${efiboot_imgsize} KiB..." - mkfs.fat -C -n PARAISO_EFI "${work_dir}/efiboot.img" "$efiboot_imgsize" + "${_available_ucodes[@]}" \ + 2>/dev/null | awk 'END { print $1 }')" + # Create a FAT image for the EFI system partition + _make_efibootimg "$efiboot_imgsize" - mmd -i "${work_dir}/efiboot.img" ::/EFI ::/EFI/BOOT + # Copy rEFInd EFI binary to the default/fallback boot path mcopy -i "${work_dir}/efiboot.img" \ "${pacstrap_dir}/usr/share/refind/refind_x64.efi" ::/EFI/BOOT/BOOTx64.EFI + # Copy rEFInd configuration files mmd -i "${work_dir}/efiboot.img" ::/EFI/BOOT/entries mcopy -i "${work_dir}/efiboot.img" "${profile}/efiboot/EFI/BOOT/refind.conf" ::/EFI/BOOT/ for _conf in "${profile}/efiboot/EFI/BOOT/entries/"*".conf"; do @@ -626,23 +599,81 @@ _make_bootmode_uefi-x64.refind.esp() { "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ::/shellx64.efi fi - # Copy kernel and initramfs + # Copy kernel and initramfs to FAT image. + # systemd-boot can only access files from the EFI system partition it was launched from. _make_boot_on_fat _msg_info "Done! rEFInd set up for UEFI booting successfully." } -# Prepare efiboot.img::/EFI for "El Torito" EFI boot mode +# Prepare system-boot for El Torito booting _make_bootmode_uefi-x64.systemd-boot.eltorito() { + # El Torito UEFI boot requires an image containing the EFI system partition. + # uefi-x64.systemd-boot.eltorito has the same requirements as uefi-x64.systemd-boot.esp _run_once _make_bootmode_uefi-x64.systemd-boot.esp - # Set up /EFI on ISO-9660 to allow preparing an installation medium by manually copying files - _run_once _make_efi_dir_on_iso9660 + + # Additionally set up system-boot in ISO 9660. This allows creating a medium for the live environment by using + # manual partitioning and simply copying the ISO 9660 file system contents. + # This is not related to El Torito booting and no firmware uses these files. + _msg_info "Preparing an /EFI directory for the ISO 9660 file system..." + install -d -m 0755 -- "${isofs_dir}/EFI/BOOT" + + # Copy systemd-boot EFI binary to the default/fallback boot path + install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \ + "${isofs_dir}/EFI/BOOT/BOOTx64.EFI" + + # Copy systemd-boot configuration files + install -d -m 0755 -- "${isofs_dir}/loader/entries" + install -m 0644 -- "${profile}/efiboot/loader/loader.conf" "${isofs_dir}/loader/" + for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do + sed "s|%PARABOLAISO_LABEL%|${iso_label}|g; + s|%INSTALL_DIR%|${install_dir}|g; + s|%ARCH%|${arch}|g" \ + "${_conf}" > "${isofs_dir}/loader/entries/${_conf##*/}" + done + + # edk2-shell based UEFI shell + # shellx64.efi is picked up automatically when on / + if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then + install -m 0644 -- "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" "${isofs_dir}/shellx64.efi" + fi + + _msg_info "Done!" } +# Prepare rEFInd for El Torito booting _make_bootmode_uefi-x64.refind.eltorito() { + # El Torito UEFI boot requires an image containing the EFI system partition. + # uefi-x64.refind.eltorito has the same requirements as uefi-x64.refind.esp _run_once _make_bootmode_uefi-x64.refind.esp - # Set up /EFI on ISO-9660 to allow preparing an installation medium by manually copying files - _run_once _make_refind_efi_dir_on_iso9660 + + # Additionally set up rEFInd in ISO 9660. This allows creating a medium for the live environment by using + # manual partitioning and simply copying the ISO 9660 file system contents. + # This is not related to El Torito booting and no firmware uses these files. + _msg_info "Preparing an /EFI directory for the ISO 9660 file system..." + install -d -m 0755 -- "${isofs_dir}/EFI/BOOT" + + # Copy rEFInd EFI binary to the default/fallback boot path + install -m 0644 -- "${pacstrap_dir}/usr/share/refind/refind_x64.efi" \ + "${isofs_dir}/EFI/BOOT/BOOTx64.EFI" + + # Copy rEFInd configuration files + install -d -m 0755 -- "${isofs_dir}/EFI/BOOT/entries" + install -m 0644 -- "${profile}/efiboot/EFI/BOOT/refind.conf" "${isofs_dir}/EFI/BOOT/" + for _conf in "${profile}/efiboot/EFI/BOOT/entries/"*".conf"; do + sed "s|%PARABOLAISO_LABEL%|${iso_label}|g; + s|%INSTALL_DIR%|${install_dir}|g; + s|%ARCH%|${arch}|g" \ + "${_conf}" > "${isofs_dir}/EFI/BOOT/entries/${_conf##*/}" + done + + # edk2-shell based UEFI shell + # shellx64.efi is picked up automatically when on / + if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then + install -m 0644 -- "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" "${isofs_dir}/shellx64.efi" + fi + + _msg_info "Done!" } _validate_requirements_bootmode_bios.syslinux.mbr() { @@ -684,6 +715,7 @@ _validate_requirements_bootmode_bios.syslinux.mbr() { } _validate_requirements_bootmode_bios.syslinux.eltorito() { + # bios.syslinux.eltorito has the exact same requirements as bios.syslinux.mbr _validate_requirements_bootmode_bios.syslinux.mbr } @@ -896,7 +928,7 @@ _add_xorrisofs_options_bios.syslinux.eltorito() { ) } -# SYSLINUX MBR +# SYSLINUX MBR (isohybrid) _add_xorrisofs_options_bios.syslinux.mbr() { xorrisofs_options+=( # SYSLINUX MBR bootstrap code; does not work without "-eltorito-boot syslinux/isolinux.bin" @@ -1483,7 +1515,7 @@ _build_buildmode_bootstrap() { _build_buildmode_netboot() { local run_once_mode="${buildmode}" - _run_once _build_iso_base + _build_iso_base if [[ -v cert_list ]]; then _run_once _sign_netboot_artifacts fi @@ -1494,7 +1526,7 @@ _build_buildmode_netboot() { _build_buildmode_iso() { local image_name="${iso_name}-${iso_version}-${arch}.iso" local run_once_mode="${buildmode}" - _run_once _build_iso_base + _build_iso_base _run_once _build_iso_image } -- cgit v1.2.2