Add support for cross-arch ISOs

Initial support for arm64 installer support, as well as supporting
building the amd64 files on arm64 (i.e. an RPi3/4)
This commit is contained in:
Joshua Boniface 2023-09-01 15:41:59 -04:00
parent 17f6cb51d1
commit 79de677a96
6 changed files with 49 additions and 7 deletions

View File

@ -18,9 +18,6 @@ sudo -n true &>/dev/null || fail "The user running this script must have sudo pr
idir=$( dirname $0 )
pushd ${idir} &>/dev/null
isofilename="pvc-installer_$(date +%Y-%m-%d).iso"
deployusername="deploy"
show_help() {
echo -e "PVC install ISO generator"
echo
@ -31,6 +28,7 @@ show_help() {
echo -e " -h: Display this help message."
echo -e " -o: Create the ISO as <output_filename> instead of the default."
echo -e " -u: Change 'deploy' user to a new username."
echo -e " -c: Change CPU architecture to a new architecture [x86_64/aarch64]."
echo -e " -a: Preserve live-build artifacts."
echo -e " -k: Preserve live-build config."
}
@ -49,6 +47,28 @@ while [ $# -gt 0 ]; do
deployusername="${2}"
shift 2
;;
-c)
current_arch=$( uname -m )
if [[ ${current_arch} != ${2} ]]; then
case ${2} in
x86_64)
arch="amd64"
arch_config_append="--architecture amd64 --bootloader grub-efi --bootstrap-qemu-arch amd64 --bootstrap-qemu-static /usr/bin/qemu-x86_64-static"
;;
aarch64)
arch="arm64"
arch_config_append="--architecture arm64 --bootloader grub-efi --bootstrap-qemu-arch arm64 --bootstrap-qemu-static /usr/bin/qemu-aarch64-static"
;;
*)
echo "Invalid arch: ${2}"
echo
show_help
exit 1
;;
esac
fi
shift 2
;;
-a)
preserve_artifacts='y'
shift
@ -66,6 +86,16 @@ while [ $# -gt 0 ]; do
esac
done
if [[ -z ${arch} ]]; then
arch="amd64"
fi
if [[ -z ${isofilename} ]]; then
isofilename="pvc-installer_$(date +%Y-%m-%d)_${arch}.iso"
fi
if [[ -z ${deployusername} ]]; then
deployusername="deploy"
fi
mkdir -p artifacts/lb
pushd artifacts/lb &>/dev/null
@ -75,12 +105,13 @@ echo
echo "Initializing config..."
# Initialize the live-build config
lb config --distribution buster --architectures amd64 --archive-areas "main contrib non-free" --apt-recommends false || fail "Failed to initialize live-build config"
lb config --distribution bullseye --archive-areas "main contrib non-free" --apt-recommends false ${arch_config_append} || fail "Failed to initialize live-build config"
echo
# Configure the package lists
echo -n "Copying package lists... "
cp ../../templates/installer.list.chroot config/package-lists/installer.list.chroot || fail "Failed to copy critical template file"
cp ../../templates/installer_${arch}.list.chroot config/package-lists/installer_${arch}.list.chroot || fail "Failed to copy critical template file"
cp ../../templates/firmware.list.chroot config/package-lists/firmware.list.chroot || fail "Failed to copy critical template file"
echo "done."
@ -151,7 +182,7 @@ echo
# Move the ISO image out
echo -n "Copying generated ISO to repository root... "
cp live-image-amd64.hybrid.iso ../../${isofilename}
cp live-image-${arch}.hybrid.iso ../../${isofilename}
echo "done."
# Clean up the artifacts

View File

@ -86,6 +86,7 @@ build_iso() {
./buildiso.sh \
-o pvc-installer_pxe-tmp.iso \
-u ${deployusername} \
-c x86_64 \
${preserve_artifacts} \
${preserve_livebuild} || fail "Failed to build ISO."
echo

View File

@ -76,7 +76,15 @@ default_debrelease="buster"
default_debmirror="http://debian.mirror.rafal.ca/debian"
# Base packages (installed by debootstrap)
basepkglist="lvm2,parted,gdisk,grub-pc,grub-efi-amd64,linux-image-amd64,sudo,vim,gpg,gpg-agent,openssh-server,vlan,ifenslave,python3,ca-certificates,curl"
basepkglist="lvm2,parted,gdisk,sudo,vim,gpg,gpg-agent,openssh-server,vlan,ifenslave,python3,ca-certificates,curl"
case $( uname -m ) in
x86_64)
basepkglist="${basepkglist},grub-pc,grub-efi-amd64,linux-image-amd64"
;;
aarch64)
basepkglist="${basepkglist},grub-efi-arm64,linux-image-arm64"
;;
esac
# Supplemental packages (installed in chroot after debootstrap)
suppkglist="firmware-linux,firmware-linux-nonfree,firmware-bnx2,firmware-bnx2x,ntp,ipmitool,acpid,acpi-support-base,lsscsi"

View File

@ -1 +1 @@
live-task-standard live-tools live-boot live-boot-initramfs-tools linux-image-amd64 psmisc mdadm lvm2 parted gdisk dosfstools debootstrap grub-pc-bin grub-efi-amd64 sipcalc vim ca-certificates vlan tftp-hpa curl ipmitool lsscsi
live-task-standard live-tools live-boot live-boot-initramfs-tools psmisc mdadm lvm2 parted gdisk dosfstools debootstrap sipcalc vim ca-certificates vlan tftp-hpa curl ipmitool lsscsi

View File

@ -0,0 +1 @@
linux-image-amd64 grub-pc-bin grub-efi-amd64

View File

@ -0,0 +1 @@
linux-image-arm64 grub-efi-arm64