diff --git a/buildiso.sh b/buildiso.sh index 8b1ddfb..289b65b 100755 --- a/buildiso.sh +++ b/buildiso.sh @@ -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 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 diff --git a/buildpxe.sh b/buildpxe.sh index 00f88c1..9b53d77 100755 --- a/buildpxe.sh +++ b/buildpxe.sh @@ -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 diff --git a/templates/install.sh b/templates/install.sh index 68f3e1b..714f144 100755 --- a/templates/install.sh +++ b/templates/install.sh @@ -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" diff --git a/templates/installer.list.chroot b/templates/installer.list.chroot index dab77f8..0dc0206 100644 --- a/templates/installer.list.chroot +++ b/templates/installer.list.chroot @@ -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 diff --git a/templates/installer_amd64.list.chroot b/templates/installer_amd64.list.chroot new file mode 100644 index 0000000..e953904 --- /dev/null +++ b/templates/installer_amd64.list.chroot @@ -0,0 +1 @@ +linux-image-amd64 grub-pc-bin grub-efi-amd64 diff --git a/templates/installer_arm64.list.chroot b/templates/installer_arm64.list.chroot new file mode 100644 index 0000000..1775a53 --- /dev/null +++ b/templates/installer_arm64.list.chroot @@ -0,0 +1 @@ +linux-image-arm64 grub-efi-arm64