From 0c6e6c6448e6a7292d8a5ba04b51820eb8a794d2 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Fri, 6 Sep 2024 20:29:40 +0200 Subject: [PATCH] code cleanup, movr common paramters to common.sh --- usr/lib/archboot/common.sh | 8 ++++++++ usr/lib/archboot/container.sh | 2 +- usr/lib/archboot/iso.sh | 10 ++-------- usr/lib/archboot/release.sh | 10 ++++------ usr/lib/archboot/run/container.sh | 2 +- usr/lib/archboot/run/iso.sh | 6 +++--- usr/lib/archboot/run/uki.sh | 4 ++-- usr/lib/archboot/uki.sh | 10 +--------- 8 files changed, 22 insertions(+), 30 deletions(-) diff --git a/usr/lib/archboot/common.sh b/usr/lib/archboot/common.sh index 7662b45b7..50f97d5a7 100644 --- a/usr/lib/archboot/common.sh +++ b/usr/lib/archboot/common.sh @@ -26,6 +26,9 @@ else _ARCHBOOT="archboot" _ARCH="x86_64" fi +_CONFIG_DIR="/etc/archboot" +_AMD_UCODE="/boot/amd-ucode.img" +_INTEL_UCODE="/boot/intel-ucode.img" _PACMAN_MIRROR="/etc/pacman.d/mirrorlist" _PACMAN_CONF="/etc/pacman.conf" _PACMAN_LIB="/var/lib/pacman" @@ -359,3 +362,8 @@ _create_cpio() { popd >"${_NO_LOG}" || return 1 echo "Build complete." } + +_reproducibility() { + # Reproducibility: set all timestamps to 0 + fd . "${1}" -u --min-depth 1 -X touch -hcd "@0" +} diff --git a/usr/lib/archboot/container.sh b/usr/lib/archboot/container.sh index af6466bb3..368fad246 100644 --- a/usr/lib/archboot/container.sh +++ b/usr/lib/archboot/container.sh @@ -232,7 +232,7 @@ _copy_archboot_defaults() { cp /etc/archboot/defaults "${1}"/etc/archboot/defaults } -_reproducibility() { +_container_reproducibility() { echo "Reproducibility changes..." #shellcheck disable=SC2016 sd '(INSTALLDATE%)\n.*' '$1\n0' "${1}""${_PACMAN_LIB}"/local/*/desc diff --git a/usr/lib/archboot/iso.sh b/usr/lib/archboot/iso.sh index e20555a6a..018c68850 100644 --- a/usr/lib/archboot/iso.sh +++ b/usr/lib/archboot/iso.sh @@ -2,7 +2,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # created by Tobias Powalowski . /etc/archboot/defaults -_CONFIG_DIR="/etc/archboot" _ISODIR="$(mktemp -d ISODIR.XXX)" _BOOTLOADER="/usr/share/archboot/bootloader" @@ -107,14 +106,14 @@ _prepare_ucode() { # only x86_64 if [[ "${_ARCH}" == "x86_64" ]]; then echo "Preparing intel-ucode..." - cp /boot/intel-ucode.img "${_ISODIR}/boot/" + cp "${_INTEL_UCODE}" "${_ISODIR}/boot/" mkdir -p "${_ISODIR}"/licenses/intel-ucode cp /usr/share/licenses/intel-ucode/LICENSE "${_ISODIR}/licenses/intel-ucode" fi # both x86_64 and aarch64 if ! [[ "${_ARCH}" == "riscv64" ]]; then echo "Preparing amd-ucode..." - cp /boot/amd-ucode.img "${_ISODIR}/boot/" + cp "${_AMD_UCODE}" "${_ISODIR}/boot/" mkdir -p "${_ISODIR}"/licenses/amd-ucode cp /usr/share/licenses/amd-ucode/LICENSE.amd-ucode "${_ISODIR}/licenses/amd-ucode" fi @@ -175,11 +174,6 @@ _prepare_background() { cp ${_GRUB_BACKGROUND} "${_ISODIR}/boot/grub/archboot-background.png" } -_reproducibility() { - # Reproducibility: set all timestamps to 0 - fd . "${_ISODIR}" -u --min-depth 1 -X touch -hcd "@0" -} - _prepare_uefi_image() { echo "Preparing UEFI image..." ## get size of boot files diff --git a/usr/lib/archboot/release.sh b/usr/lib/archboot/release.sh index 4696c1b80..6ffcd1029 100644 --- a/usr/lib/archboot/release.sh +++ b/usr/lib/archboot/release.sh @@ -2,8 +2,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # created by Tobias Powalowski . /etc/archboot/defaults -_AMD_UCODE="boot/amd-ucode.img" -_INTEL_UCODE="boot/intel-ucode.img" _INITRD="boot/initrd-${_ARCH}.img" _INITRD_LATEST="boot/initrd-latest-${_ARCH}.img" _INITRD_LOCAL="boot/initrd-local-${_ARCH}.img" @@ -102,8 +100,8 @@ _create_iso() { for i in *.iso; do if echo "${i}" | rg -v 'local' | rg -vq 'latest'; then isoinfo -R -i "${i}" -x /efi.img 2>"${_NO_LOG}" > efi.img - mcopy -m -i efi.img ::/"${_AMD_UCODE}" ./"${_AMD_UCODE}" - [[ "${_ARCH}" == "aarch64" ]] || mcopy -m -i efi.img ::/"${_INTEL_UCODE}" ./"${_INTEL_UCODE}" + mcopy -m -i efi.img ::"${_AMD_UCODE}" ."${_AMD_UCODE}" + [[ "${_ARCH}" == "aarch64" ]] || mcopy -m -i efi.img ::"${_INTEL_UCODE}" ."${_INTEL_UCODE}" mcopy -m -i efi.img ::/"${_INITRD}" ./"${_INITRD}" mcopy -m -i efi.img ::/"${_KERNEL_ARCHBOOT}" ./"${_KERNEL_ARCHBOOT}" elif echo "${i}" | rg -q 'latest'; then @@ -137,8 +135,8 @@ _create_iso() { cp "${_W_DIR}/boot/Image" "boot/Image-${_ARCH}" _KERNEL_ARCHBOOT="boot/Image-${_ARCH}" fi - [[ -n "${_INTEL_UCODE}" ]] && _INTEL_UCODE="--initrd=${_INTEL_UCODE}" - [[ -n "${_AMD_UCODE}" ]] && _AMD_UCODE="--initrd=${_AMD_UCODE}" + [[ -n "${_INTEL_UCODE}" ]] && _INTEL_UCODE="--initrd=.${_INTEL_UCODE}" + [[ -n "${_AMD_UCODE}" ]] && _AMD_UCODE="--initrd=.${_AMD_UCODE}" rm -r "${_W_DIR:?}"/boot mv boot "${_W_DIR}" for initrd in ${_INITRD} ${_INITRD_LATEST} ${_INITRD_LOCAL}; do diff --git a/usr/lib/archboot/run/container.sh b/usr/lib/archboot/run/container.sh index 13f84baaa..63d16fe38 100755 --- a/usr/lib/archboot/run/container.sh +++ b/usr/lib/archboot/run/container.sh @@ -53,7 +53,7 @@ else fi fi _change_pacman_conf "${1}" || exit 1 -_reproducibility "${1}" +_container_reproducibility "${1}" _set_hostname "${1}" || exit 1 _ssh_keys "${1}" || exit 1 echo "Finished container setup in ${1}." diff --git a/usr/lib/archboot/run/iso.sh b/usr/lib/archboot/run/iso.sh index 3dd04b411..bc88af4ce 100755 --- a/usr/lib/archboot/run/iso.sh +++ b/usr/lib/archboot/run/iso.sh @@ -26,9 +26,9 @@ if echo "${_BASENAME}" | rg -qw 'aarch64' || echo "${_BASENAME}" | rg -qw 'x86_6 _prepare_memtest || exit 1 fi _prepare_background || exit 1 - _reproducibility + _reproducibility "${_ISODIR}" _prepare_uefi_image || exit 1 - _reproducibility + _reproducibility "${_ISODIR}" _grub_mkrescue || exit 1 _unify_gpt_partitions || exit 1 else @@ -36,7 +36,7 @@ else echo "Starting Image creation..." _prepare_kernel_initrd_files || exit 1 _prepare_extlinux_conf || exit 1 - _reproducibility + _reproducibility "${_ISODIR}" _uboot || exit 1 fi _create_cksum || exit 1 diff --git a/usr/lib/archboot/run/uki.sh b/usr/lib/archboot/run/uki.sh index a6c44b767..a9d042ff0 100755 --- a/usr/lib/archboot/run/uki.sh +++ b/usr/lib/archboot/run/uki.sh @@ -12,9 +12,9 @@ _config echo "Starting UKI creation..." _prepare_kernel_initramfs || exit 1 _prepare_ucode || exit 1 -_prepare_background || exit 1 +_prepare_splash || exit 1 _prepare_osrelease || exit 1 -_reproducibility || exit 1 +_reproducibility "${_UKIDIR}" _systemd_ukify || exit 1 _create_cksum || exit 1 _cleanup_uki || exit 1 diff --git a/usr/lib/archboot/uki.sh b/usr/lib/archboot/uki.sh index 6dfca7d31..e67ff386f 100644 --- a/usr/lib/archboot/uki.sh +++ b/usr/lib/archboot/uki.sh @@ -2,11 +2,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later # created by Tobias Powalowski . /etc/archboot/defaults -_AMD_UCODE="/boot/amd-ucode.img" -_INTEL_UCODE="/boot/intel-ucode.img" _SPLASH="/usr/share/archboot/uki/archboot-background.bmp" _OSREL="/usr/share/archboot/base/etc/os-release" -_CONFIG_DIR="/etc/archboot" _UKIDIR="$(mktemp -d UKIDIR.XXX)" _usage () { @@ -72,7 +69,7 @@ _prepare_ucode() { cp "${_AMD_UCODE}" "${_UKIDIR}/" } -_prepare_background() { +_prepare_splash() { echo "Preparing UKI splash..." cp "${_SPLASH}" "${_UKIDIR}/splash.bmp" } @@ -82,11 +79,6 @@ _prepare_osrelease() { cp "${_OSREL}" "${_UKIDIR}/os-release" } -_reproducibility() { - # Reproducibility: set all timestamps to 0 - fd . "${_UKIDIR}" -u --min-depth 1 -X touch -hcd "@0" -} - _systemd_ukify() { echo "Generating ${_ARCH} UKI image..." pushd "${_UKIDIR}" &>"${_NO_LOG}" || exit 1