-
Notifications
You must be signed in to change notification settings - Fork 132
Build the ISO for the host architecture, adding aarch64 support #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oceanapplications
wants to merge
11
commits into
omacom:quattro
Choose a base branch
from
oceanapplications:aarch64-build-system
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c90ad3a
builder: build for the host architecture instead of hardcoding x86_64
oceanapplications d1fd5d2
configs: filter x86-only repositories out of the pacman config on aar…
oceanapplications 98bba10
boot: make the live ISO bootable on aarch64
oceanapplications ca64a86
installer: fix the phases that assume an x86 target
oceanapplications ff59434
configs: add an aarch64 package list for the live environment
oceanapplications fd8dd8e
boot: fail the build when the live initramfs is not produced
oceanapplications adf5a1f
boot: document what customize_airootfs.sh is actually responsible for
oceanapplications b69ef01
builder: filter GRUB modules not built for the target platform
oceanapplications 1ce48df
builder: define _filter_grubmodules in the carried archiso patch
oceanapplications 019297c
installer: keep the distribution's mirrorlist on aarch64
oceanapplications 7f003b3
builder: enumerate offline mirror packages before repo-add
oceanapplications File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Filter archiso's hardcoded GRUB module list to what the target platform | ||
| # provides. at_keyboard (PS/2), keylayouts, usb and the usbserial_* drivers | ||
| # are not built for arm64-efi, so grub-mkstandalone aborts without this. | ||
| # | ||
| # Generated against the vendored archiso (v87). Belongs upstream in archiso; | ||
| # carried here until it lands there. build-iso.sh applies it with --forward, | ||
| # so it becomes a no-op once the submodule is bumped past the fix. | ||
| --- a/archiso/mkarchiso | ||
| +++ b/archiso/mkarchiso | ||
| @@ -669,6 +669,31 @@ | ||
| fi | ||
| } | ||
|
|
||
| +# Filter a GRUB module list down to what a platform actually provides. | ||
| +# Not every module archiso asks for is built everywhere: at_keyboard is PS/2 and | ||
| +# the usbserial_* drivers are x86-oriented, so none of them exist for arm64-efi | ||
| +# and grub-mkstandalone aborts on the first one it cannot find. | ||
| +# $1: GRUB target (e.g. arm64-efi) | ||
| +# $@: module names | ||
| +# Prints the available modules, one per line. | ||
| +_filter_grubmodules() { | ||
| + local _target="${1}" | ||
| + shift | ||
| + local _module _available=() _missing=() | ||
| + for _module in "$@"; do | ||
| + if [[ -e "/usr/lib/grub/${_target}/${_module}.mod" ]]; then | ||
| + _available+=("${_module}") | ||
| + else | ||
| + _missing+=("${_module}") | ||
| + fi | ||
| + done | ||
| + if (( ${#_missing[@]} )); then | ||
| + # stdout carries the module list, so this has to go to stderr. | ||
| + _msg_info "Skipping GRUB module(s) not built for ${_target}: ${_missing[*]}" >&2 | ||
| + fi | ||
| + printf '%s\n' "${_available[@]}" | ||
| +} | ||
| + | ||
| # Prepare GRUB | ||
| _make_bootmode_uefi.grub() { | ||
| local grub_target grubmodules=() files_to_copy=() | ||
| @@ -691,6 +716,7 @@ | ||
| minicmd normal ntfs ntfscomp part_apple part_gpt part_msdos png read reboot regexp search \ | ||
| search_fs_file search_fs_uuid search_label serial sleep tpm udf usb usbserial_common usbserial_ftdi \ | ||
| usbserial_pl2303 usbserial_usbdebug video xfs zstd) | ||
| + mapfile -t grubmodules < <(_filter_grubmodules "$grub_target" "${grubmodules[@]}") | ||
| grub-mkstandalone -O "$grub_target" \ | ||
| --modules="${grubmodules[*]}" \ | ||
| --locales="en@quot" \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/usr/bin/env bash | ||
| # Runs inside the live-ISO chroot after packages are installed. | ||
| # | ||
| # WHAT THIS IS FOR | ||
| # ---------------- | ||
| # Arch Linux ARM's kernel packages name things differently from Arch's, and | ||
| # archiso and GRUB both look for the Arch names. This reconciles the two. | ||
| # | ||
| # It is deliberately *not* responsible for generating the initramfs. On Arch | ||
| # that happens by itself: the kernel package installs | ||
| # usr/lib/modules/<ver>/{vmlinuz,pkgbase}, 90-mkinitcpio-install.hook triggers | ||
| # on the former, and /usr/share/libalpm/scripts/mkinitcpio reads the latter to | ||
| # learn the kernel's name. ALARM installs neither file, so the hook never fires | ||
| # -- proposed upstream as archlinuxarm/PKGBUILDs#2215. With that applied the | ||
| # hook does run, but two naming gaps remain and are what this script closes: | ||
| # | ||
| # * ALARM's preset is PRESETS=('default') writing /boot/initramfs-linux.img, | ||
| # while the GRUB entries load initramfs-linux-aarch64.img. | ||
| # * Nothing creates /boot/vmlinuz-*, and mkarchiso copies the kernel with | ||
| # `install -- "${pacstrap_dir}/boot/vmlinuz-"*`, which would match nothing. | ||
| # | ||
| # It also sets archiso_config in the preset, which is how x86's linux-t2.preset | ||
| # keeps an installed system's HOOKS out of the live initramfs. | ||
| # | ||
| # NOTE: mkarchiso prints a deprecation warning for customize_airootfs.sh. There | ||
| # is currently no replacement hook that runs inside the chroot after packages | ||
| # install, which is required here because the kernel image only exists then. | ||
| # Shipping the preset in airootfs/ does not work either: the overlay is copied | ||
| # before pacstrap, so linux-aarch64's own preset overwrites it. | ||
| set -uo pipefail | ||
|
|
||
| # Everything here addresses differences in Arch Linux ARM's kernel packaging. | ||
| # On any other architecture this script is a no-op. | ||
| if [[ $(uname -m) != aarch64 ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Omarchy forces the thunderbolt module; ALARM's aarch64 kernel does not build | ||
| # it, and mkinitcpio treats an unresolvable MODULES entry as an error. | ||
| if [[ -f /etc/mkinitcpio.conf.d/thunderbolt_module.conf ]]; then | ||
| sed -i 's/^MODULES+=(thunderbolt)/#MODULES+=(thunderbolt) # not built for aarch64/' \ | ||
| /etc/mkinitcpio.conf.d/thunderbolt_module.conf | ||
| fi | ||
|
|
||
| # ALARM installs the kernel as /boot/Image. mkarchiso copies /boot/vmlinuz-* | ||
| # into the ISO, so without this name the kernel never reaches the image. | ||
| if [[ ! -e /boot/vmlinuz-linux-aarch64 ]]; then | ||
| if [[ -e /boot/Image ]]; then | ||
| cp -a /boot/Image /boot/vmlinuz-linux-aarch64 | ||
| else | ||
| echo "customize_airootfs: no kernel image at /boot/Image or /boot/vmlinuz-linux-aarch64" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Drop presets whose kernel image is absent: `mkinitcpio -P` aborts on them. | ||
| for preset in /etc/mkinitcpio.d/*.preset; do | ||
| [[ -e $preset ]] || continue | ||
| kname="$(basename "$preset" .preset)" | ||
| if [[ $kname != linux-aarch64 && ! -e /boot/vmlinuz-$kname ]]; then | ||
| echo "customize_airootfs: dropping $kname.preset (no kernel image)" | ||
| rm -f "$preset" | ||
| fi | ||
| done | ||
|
|
||
| # Replace ALARM's preset, which writes /boot/initramfs-linux.img, with one that | ||
| # writes the name the GRUB entries load. archiso_config additionally makes | ||
| # mkinitcpio read archiso.conf as its configuration, bypassing | ||
| # /etc/mkinitcpio.conf.d entirely -- the same trick x86's linux-t2.preset uses | ||
| # to keep omarchy_hooks.conf, which describes an *installed* system, out of the | ||
| # *live* initramfs. | ||
| cat > /etc/mkinitcpio.d/linux-aarch64.preset <<'PRESET' | ||
| # Live-ISO preset for Arch Linux ARM's linux-aarch64. | ||
| PRESETS=('archiso') | ||
|
|
||
| ALL_kver='/boot/vmlinuz-linux-aarch64' | ||
| archiso_config='/etc/mkinitcpio.conf.d/archiso.conf' | ||
|
|
||
| archiso_image="/boot/initramfs-linux-aarch64.img" | ||
| PRESET | ||
|
|
||
| echo "customize_airootfs: building the live initramfs from archiso.conf" | ||
| rm -f /boot/initramfs-linux*.img | ||
|
|
||
| # mkinitcpio exits non-zero on this platform even when it produces a complete | ||
| # image: archiso's memdisk hook wants the phram module and the memdiskfind | ||
| # binary, and neither exists for aarch64 (memdiskfind ships in syslinux, which | ||
| # is x86-only). Judge the result on the artefact rather than the exit status. | ||
| mkinitcpio -p linux-aarch64 || \ | ||
| echo "customize_airootfs: mkinitcpio reported errors; checking for the image" | ||
|
|
||
| # The GRUB entries boot this file by name. If it is missing the ISO builds | ||
| # cleanly and then fails to boot, so fail the build here instead. | ||
| if [[ ! -s /boot/initramfs-linux-aarch64.img ]]; then | ||
| echo "customize_airootfs: no live initramfs was produced; the ISO would not boot" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "customize_airootfs: initramfs present ($(stat -c %s /boot/initramfs-linux-aarch64.img) bytes)" | ||
|
|
||
| exit 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # The live ISO boots linux-aarch64 (/boot/Image). A stock linux.preset points at | ||
| # /boot/vmlinuz-linux, which does not exist here, and `mkinitcpio -P` fails with | ||
| # ERROR: Invalid option -k -- '/boot/vmlinuz-linux' must be readable | ||
| # An empty PRESETS array makes this preset a no-op. | ||
| PRESETS=() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Live-ISO overrides. Sorts last in /etc/mkinitcpio.conf.d, so it has the final | ||
| # word, and is unowned by any package so pacman cannot clobber it. | ||
| # | ||
| # WHY THIS EXISTS | ||
| # --------------- | ||
| # archiso.conf sets the HOOKS needed to boot a live ISO: | ||
| # base udev microcode modconf kms memdisk archiso archiso_loop_mnt | ||
| # archiso_pxe_* block filesystems keyboard | ||
| # omarchy-settings then ships omarchy_hooks.conf, which sets the HOOKS for an | ||
| # *installed* system (autodetect, encrypt, fsck, btrfs-overlayfs...). | ||
| # | ||
| # "omarchy_hooks.conf" sorts after "archiso.conf", so it wins -- and the live | ||
| # initramfs ends up with no `archiso` hook. The ISO then boots the kernel and | ||
| # panics in the initramfs: | ||
| # ERROR: Failed to mount '' on real root | ||
| # Restore the live hooks, keeping Omarchy's plymouth (the ISO installs | ||
| # omarchy-settings specifically so its plymouthd.conf lands before mkinitcpio). | ||
| # | ||
| # `microcode` is omitted: on aarch64 that hook only emits | ||
| # WARNING: architecture 'aarch64' not supported, skipping hook | ||
| HOOKS=(base udev plymouth modconf kms memdisk archiso archiso_loop_mnt | ||
| archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs | ||
| block filesystems keyboard) | ||
|
|
||
| # thunderbolt is x86-oriented hardware; ALARM's aarch64 kernel does not build | ||
| # the module, and a missing MODULES entry is fatal to mkinitcpio. | ||
| _keep=() | ||
| for _m in "${MODULES[@]:-}"; do | ||
| [[ $_m == "thunderbolt" || -z $_m ]] || _keep+=("$_m") | ||
| done | ||
| MODULES=("${_keep[@]}") | ||
| unset _keep _m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.