code cleanup, movr common paramters to common.sh

This commit is contained in:
Tobias Powalowski 2024-09-06 20:29:40 +02:00
parent 5931918d8f
commit 0c6e6c6448
8 changed files with 22 additions and 30 deletions

View file

@ -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"
}

View file

@ -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

View file

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
. /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

View file

@ -2,8 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
. /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

View file

@ -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}."

View file

@ -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

View file

@ -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

View file

@ -2,11 +2,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
. /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