diff --git a/.gitattributes b/.gitattributes index 4981a65851..9eb82cdfc0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -README.md linguist-generated=true +/README.md linguist-generated=true diff --git a/.github/workflows/gen-images.yml b/.github/workflows/gen-images.yml index b057249f2a..e69a54d4d9 100644 --- a/.github/workflows/gen-images.yml +++ b/.github/workflows/gen-images.yml @@ -14,7 +14,7 @@ on: type: boolean live_archs: description: "Archs to build live ISOs for" - default: "x86_64 x86_64-musl i686" + default: "x86_64 x86_64-musl i686 aarch64 aarch64-musl" required: false type: string live_flavors: @@ -69,6 +69,11 @@ jobs: datecode: ${{ steps.prep.outputs.datecode }} revision: ${{ steps.prep.outputs.revision }} mirror: ${{ steps.prep.outputs.mirror }} + live_archs: ${{ steps.prep.outputs.live_archs }} + live_flavors: ${{ steps.prep.outputs.live_flavors }} + rootfs: ${{ steps.prep.outputs.rootfs }} + platformfs: ${{ steps.prep.outputs.platformfs }} + sbc_imgs: ${{ steps.prep.outputs.sbc_imgs }} steps: - name: Prepare Environment @@ -82,12 +87,28 @@ jobs: echo "revision=${GITHUB_SHA:0:8}" >> $GITHUB_OUTPUT echo "mirror=https://repo-ci.voidlinux.org/current" >> $GITHUB_OUTPUT + jsonify() { + sed 's/\s\+/ /g' | jq -Rrc 'split(" ")' + } + + echo "live_archs=$(echo "${{ inputs.live_archs }}" | jsonify)" >> $GITHUB_OUTPUT + echo "live_flavors=$(echo "${{ inputs.live_flavors }}" | jsonify)" >> $GITHUB_OUTPUT + + echo "rootfs=$(echo "${{ inputs.rootfs }}" | jsonify)" >> $GITHUB_OUTPUT + echo "platformfs=$(echo "${{ inputs.platformfs }}" | jsonify)" >> $GITHUB_OUTPUT + echo "sbc_imgs=$(echo "${{ inputs.sbc_imgs }}" | jsonify)" >> $GITHUB_OUTPUT + build-live-isos: name: Build Live ISOs runs-on: ubuntu-latest needs: prepare if: ${{ inputs.live_iso_flag }} + strategy: + matrix: + arch: ${{ fromJson(needs.prepare.outputs.live_archs) }} + flavor: ${{ fromJson(needs.prepare.outputs.live_flavors) }} + container: image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' options: --privileged @@ -105,12 +126,8 @@ jobs: mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ /etc/xbps.d/*-repository-*.conf - # Sync and upgrade once, assume error comes from xbps update - xbps-install -Syu || xbps-install -yu xbps - # Upgrade again (in case there was a xbps update) - xbps-install -yu - # Install depedencies - xbps-install -yu bash make git kmod xz lzo qemu-user-static outils dosfstools e2fsprogs + xbps-install -Syu xbps && xbps-install -yu + xbps-install -yu bash make git kmod xz lzo qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -119,7 +136,7 @@ jobs: make live-iso-all-print live-iso-all \ SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \ DATECODE="${{ needs.prepare.outputs.datecode }}" \ - LIVE_ARCHS="${{ inputs.live_archs }}" LIVE_FLAVORS="${{ inputs.live_flavors }}" + LIVE_ARCHS="${{ matrix.arch }}" LIVE_FLAVORS="${{ matrix.flavor }}" - name: Prepare artifacts for upload run: | @@ -127,7 +144,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: void-iso-${{ needs.prepare.outputs.datecode }} + name: void-iso-${{ matrix.arch }}-${{ matrix.flavor }}-${{ needs.prepare.outputs.datecode }} path: | distdir-${{ needs.prepare.outputs.datecode }}/* if-no-files-found: error @@ -138,6 +155,10 @@ jobs: needs: prepare if: ${{ inputs.rootfs_flag }} + strategy: + matrix: + arch: ${{ fromJson(needs.prepare.outputs.rootfs) }} + container: image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' options: --privileged @@ -155,12 +176,8 @@ jobs: mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ /etc/xbps.d/*-repository-*.conf - # Sync and upgrade once, assume error comes from xbps update - xbps-install -Syu || xbps-install -yu xbps - # Upgrade again (in case there was a xbps update) - xbps-install -yu - # Install depedencies - xbps-install -yu bash make git kmod xz lzo qemu-user-static outils dosfstools e2fsprogs + xbps-install -Syu xbps && xbps-install -yu + xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -169,7 +186,7 @@ jobs: make rootfs-all-print rootfs-all \ SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \ DATECODE="${{ needs.prepare.outputs.datecode }}" \ - ARCHS="${{ inputs.rootfs }}" + ARCHS="${{ matrix.arch }}" - name: Prepare artifacts for upload run: | @@ -177,7 +194,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: void-rootfs-${{ needs.prepare.outputs.datecode }} + name: void-rootfs-${{ matrix.arch }}-${{ needs.prepare.outputs.datecode }} path: | distdir-${{ needs.prepare.outputs.datecode }}/* if-no-files-found: error @@ -188,6 +205,10 @@ jobs: needs: prepare if: ${{ inputs.platformfs_flag }} + strategy: + matrix: + platform: ${{ fromJson(needs.prepare.outputs.platformfs) }} + container: image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' options: --privileged @@ -205,12 +226,8 @@ jobs: mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ /etc/xbps.d/*-repository-*.conf - # Sync and upgrade once, assume error comes from xbps update - xbps-install -Syu || xbps-install -yu xbps - # Upgrade again (in case there was a xbps update) - xbps-install -yu - # Install depedencies - xbps-install -yu bash make git kmod xz lzo qemu-user-static outils dosfstools e2fsprogs + xbps-install -Syu xbps && xbps-install -yu + xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -219,7 +236,7 @@ jobs: make platformfs-all-print platformfs-all \ SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \ DATECODE="${{ needs.prepare.outputs.datecode }}" \ - PLATFORMS="${{ inputs.platformfs }}" + PLATFORMS="${{ matrix.platform }}" - name: Prepare artifacts for upload run: | @@ -227,7 +244,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: void-platformfs-${{ needs.prepare.outputs.datecode }} + name: void-platformfs-${{ matrix.platform }}-${{ needs.prepare.outputs.datecode }} path: | distdir-${{ needs.prepare.outputs.datecode }}/* !distdir-${{ needs.prepare.outputs.datecode }}/*ROOTFS* @@ -239,6 +256,10 @@ jobs: needs: prepare if: ${{ inputs.sbc_img_flag }} + strategy: + matrix: + platform: ${{ fromJson(needs.prepare.outputs.sbc_imgs) }} + container: image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' options: --privileged @@ -256,12 +277,8 @@ jobs: mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ /etc/xbps.d/*-repository-*.conf - # Sync and upgrade once, assume error comes from xbps update - xbps-install -Syu || xbps-install -yu xbps - # Upgrade again (in case there was a xbps update) - xbps-install -yu - # Install depedencies - xbps-install -yu bash make git kmod xz lzo qemu-user-static outils dosfstools e2fsprogs + xbps-install -Syu xbps && xbps-install -yu + xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -270,7 +287,7 @@ jobs: make images-all-sbc-print images-all-sbc \ SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \ DATECODE="${{ needs.prepare.outputs.datecode }}" \ - SBC_IMGS="${{ inputs.sbc_imgs }}" + SBC_IMGS="${{ matrix.platform }}" - name: Prepare artifacts for upload run: | @@ -278,7 +295,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: void-sbc-img-${{ needs.prepare.outputs.datecode }} + name: void-sbc-img-${{ matrix.platform }}-${{ needs.prepare.outputs.datecode }} path: | distdir-${{ needs.prepare.outputs.datecode }}/* !distdir-${{ needs.prepare.outputs.datecode }}/*ROOTFS* diff --git a/.gitignore b/.gitignore index 538c33fbd5..fb75b6b65f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ distdir-*/ release/ packer/cloud-*/ packer/vagrant-*/ +mklive-build*/ diff --git a/Makefile b/Makefile index 447c06af94..0a547a5f51 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ DATECODE:=$(shell date -u "+%Y%m%d") SHELL=/bin/bash -T_LIVE_ARCHS=i686 x86_64{,-musl} +T_LIVE_ARCHS=i686 x86_64{,-musl} aarch64{,-musl} T_PLATFORMS=rpi-{armv{6,7}l,aarch64}{,-musl} GCP{,-musl} pinebookpro{,-musl} T_ARCHS=i686 x86_64{,-musl} armv{6,7}l{,-musl} aarch64{,-musl} @@ -13,6 +13,7 @@ T_PXE_ARCHS=x86_64{,-musl} LIVE_ARCHS:=$(shell echo $(T_LIVE_ARCHS)) LIVE_FLAVORS:=base enlightenment xfce mate cinnamon gnome kde lxde lxqt +LIVE_PLATFORMS:=pinebookpro x13s ARCHS:=$(shell echo $(T_ARCHS)) PLATFORMS:=$(shell echo $(T_PLATFORMS)) SBC_IMGS:=$(shell echo $(T_SBC_IMGS)) @@ -34,16 +35,16 @@ COMPRESSOR_THREADS:=$(shell nproc) all: -README.md: README.md.in build-x86-images.sh mklive.sh mkrootfs.sh mkplatformfs.sh mkimage.sh mknet.sh +README.md: README.md.in mkiso.sh mklive.sh mkrootfs.sh mkplatformfs.sh mkimage.sh mknet.sh printf '\n\n' > README.md cat README.md.in >> README.md - for script in build-x86-images mklive mkrootfs mkplatformfs mkimage mknet; do \ + for script in mkiso mklive mkrootfs mkplatformfs mkimage mknet; do \ printf '### %s.sh\n\n```\n' "$${script}" >> README.md ; \ "./$${script}.sh" -h 2>/dev/null >> README.md ; \ printf '```\n\n' >> README.md ; \ done -build-x86-images.sh: mklive.sh +mkiso.sh: mklive.sh checksum: distdir-$(DATECODE) cd distdir-$(DATECODE)/ && sha256 * > sha256sum.txt @@ -59,9 +60,9 @@ live-iso-all: $(ALL_LIVE_ISO) live-iso-all-print: @echo $(ALL_LIVE_ISO) | sed "s: :\n:g" -void-live-%.iso: build-x86-images.sh +void-live-%.iso: mkiso.sh @[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true - $(SUDO) ./build-x86-images.sh -r $(REPOSITORY) -t $* + $(SUDO) ./mkiso.sh -r $(REPOSITORY) -t $* -- -P "$(LIVE_PLATFORMS)" @[ -n "${CI}" ] && printf '::endgroup::\n' || true rootfs-all: $(ALL_ROOTFS) diff --git a/README.md b/README.md index ee5615b311..00c29d2ed9 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ This repository contains several utilities: * [*mklive.sh*](#mklivesh) - The Void Linux live image generator for x86 -* [*build-x86-images.sh*](#build-x86-imagessh) - Wrapper script to generate bootable - and installable live images for x86 +* [*mkiso.sh*](#mkisosh) - Wrapper script to generate bootable and installable live + images for i686, x86_64, and aarch64. * [*mkrootfs.sh*](#mkrootfssh) - The Void Linux rootfs generator for all platforms * [*mkplatformfs.sh*](#mkplatformfssh) - The Void Linux filesystem tool to produce a rootfs for a particular platform @@ -22,7 +22,7 @@ This repository contains several utilities: #### Generating x86 live ISOs To generate a live ISO like the officially-published ones, use -[*build-x86-images.sh*](#build-x86-imagessh). To generate a more basic live ISO +[*mkiso.sh*](#mkisosh). To generate a more basic live ISO (which does not include things like `void-installer`), use [*mklive.sh*](#mklivesh). #### Generating ROOTFS tarballs @@ -90,10 +90,10 @@ that can change the behavior of the live system: ## Usage -### build-x86-images.sh +### mkiso.sh ``` -Usage: build-x86-images.sh [options ...] [-- mklive options ...] +Usage: mkiso.sh [options ...] [-- mklive options ...] Wrapper script around mklive.sh for several standard flavors of live images. Adds void-installer and other helpful utilities to the generated images. @@ -122,7 +122,7 @@ Usage: mklive.sh [options] Generates a basic live ISO image of Void Linux. This ISO image can be written to a CD/DVD-ROM or any USB stick. -To generate a more complete live ISO image, use build-x86-images.sh. +To generate a more complete live ISO image, use mkiso.sh. OPTIONS -a Set XBPS_ARCH in the ISO image @@ -139,9 +139,14 @@ OPTIONS -g " ..." Ignore packages when building the ISO image -I Include directory structure under given path in the ROOTFS -S " ..." Enable services in the ISO image + -e Default shell of the root user (must be absolute path). + Set the live.shell kernel argument to change the default shell of anon. -C " ..." Add additional kernel command line arguments + -P " ..." + Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s) -T Modify the bootloader title (default: Void Linux) - -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage) + -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage). + Also accepts linux metapackages (linux-mainline, linux-lts). -K Do not remove builddir -h Show this help and exit -V Show version and exit @@ -160,6 +165,7 @@ Supported architectures: aarch64, aarch64-musl, mipsel, mipsel-musl, ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl + riscv64, riscv64-musl OPTIONS -b <system-pkg> Set an alternative base-system package (default: base-container-full) @@ -182,7 +188,7 @@ generated by mkrootfs.sh. Supported platforms: i686, x86_64, GCP, rpi-armv6l, rpi-armv7l, rpi-aarch64, - pinebookpro, pinephone, rock64 + pinebookpro, pinephone, rock64, rockpro64 OPTIONS -b <system-pkg> Set an alternative base-system package (default: base-system) @@ -212,7 +218,7 @@ OPTIONS -b <fstype> /boot filesystem type (default: vfat) -B <bsize> /boot filesystem size (default: 256MiB) -r <fstype> / filesystem type (default: ext4) - -s <totalsize> Total image size (default: 2GiB) + -s <totalsize> Total image size (default: 768MiB) -o <output> Image filename (default: guessed automatically) -x <num> Number of threads to use for image compression (default: dynamic) -h Show this help and exit diff --git a/README.md.in b/README.md.in index b6dfb65f3a..2b37a0f60d 100644 --- a/README.md.in +++ b/README.md.in @@ -5,8 +5,8 @@ This repository contains several utilities: * [*mklive.sh*](#mklivesh) - The Void Linux live image generator for x86 -* [*build-x86-images.sh*](#build-x86-imagessh) - Wrapper script to generate bootable - and installable live images for x86 +* [*mkiso.sh*](#mkisosh) - Wrapper script to generate bootable and installable live + images for i686, x86_64, and aarch64. * [*mkrootfs.sh*](#mkrootfssh) - The Void Linux rootfs generator for all platforms * [*mkplatformfs.sh*](#mkplatformfssh) - The Void Linux filesystem tool to produce a rootfs for a particular platform @@ -20,7 +20,7 @@ This repository contains several utilities: #### Generating x86 live ISOs To generate a live ISO like the officially-published ones, use -[*build-x86-images.sh*](#build-x86-imagessh). To generate a more basic live ISO +[*mkiso.sh*](#mkisosh). To generate a more basic live ISO (which does not include things like `void-installer`), use [*mklive.sh*](#mklivesh). #### Generating ROOTFS tarballs diff --git a/grub/grub_void.cfg.in b/grub/grub_void.cfg.in deleted file mode 100644 index 50bde11411..0000000000 --- a/grub/grub_void.cfg.in +++ /dev/null @@ -1,114 +0,0 @@ - -set pager="1" -set locale_dir="(${voidlive})/boot/grub/locale" - -if [ -e "${prefix}/${grub_cpu}-${grub_platform}/all_video.mod" ]; then - insmod all_video -else - insmod efi_gop - insmod efi_uga - insmod video_bochs - insmod video_cirrus -fi - -insmod font - -if loadfont "(${voidlive})/boot/grub/fonts/unicode.pf2" ; then - insmod gfxterm - set gfxmode="auto" - - terminal_input console - terminal_output gfxterm - - insmod png - background_image "(${voidlive})/boot/isolinux/@@SPLASHIMAGE@@" -fi - -# Set default menu entry -default=linux -timeout=15 -timeout_style=menu - -# GRUB init tune for accessibility -play 600 988 1 1319 4 - -if [ cpuid -l ]; then - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@)" --id "linux" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ - initrd (${voidlive})/boot/initrd - } - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) (RAM)" --id "linuxram" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ rd.live.ram - initrd (${voidlive})/boot/initrd - } - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) (graphics disabled)" --id "linuxnogfx" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ nomodeset - initrd (${voidlive})/boot/initrd - } - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) with speech" --hotkey s --id "linuxa11y" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin - initrd (${voidlive})/boot/initrd - } - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) with speech (RAM)" --hotkey r --id "linuxa11yram" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin rd.live.ram - initrd (${voidlive})/boot/initrd - } - menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) (graphics disabled)" --hotkey g --id "linuxa11ynogfx" { - set gfxpayload="keep" - linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ - vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \ - locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin nomodeset - initrd (${voidlive})/boot/initrd - } - if [ "${grub_platform}" == "efi" ]; then - menuentry "Run Memtest86+ (RAM test)" --hotkey m --id memtest { - set gfxpayload="keep" - linux (${voidlive})/boot/memtest.efi - } - menuentry 'UEFI Firmware Settings' --hotkey f --id uefifw { - fwsetup - } - else - menuentry "Run Memtest86+ (RAM test)" --id memtest { - set gfxpayload="keep" - linux (${voidlive})/boot/memtest.bin - } - fi - - menuentry "System restart" --hotkey b --id restart { - echo "System rebooting..." - reboot - } - - menuentry "System shutdown" --hotkey p --id poweroff { - echo "System shutting down..." - halt - } -fi diff --git a/grub/grub_void.cfg.post b/grub/grub_void.cfg.post new file mode 100644 index 0000000000..81b91623e1 --- /dev/null +++ b/grub/grub_void.cfg.post @@ -0,0 +1 @@ +fi # for if [ cpuid -l ] in grub_void.cfg.pre diff --git a/grub/grub_void.cfg.pre b/grub/grub_void.cfg.pre new file mode 100644 index 0000000000..dc59be7b16 --- /dev/null +++ b/grub/grub_void.cfg.pre @@ -0,0 +1,36 @@ +export voidlive + +set pager="1" +set locale_dir="(${voidlive})/boot/grub/locale" + +if [ -e "${prefix}/${grub_cpu}-${grub_platform}/all_video.mod" ]; then + insmod all_video +else + insmod efi_gop + insmod efi_uga + insmod video_bochs + insmod video_cirrus +fi + +insmod font + +if loadfont "(${voidlive})/boot/grub/fonts/unicode.pf2" ; then + insmod gfxterm + set gfxmode="auto" + + terminal_input console + terminal_output gfxterm + + insmod png + background_image "(${voidlive})/boot/isolinux/@@SPLASHIMAGE@@" +fi + +# Set default menu entry +default=linux +timeout=15 +timeout_style=menu + +# GRUB init tune for accessibility +play 600 988 1 1319 4 + +if [ cpuid -l ]; then diff --git a/isolinux/isolinux.cfg.in b/isolinux/isolinux.cfg.in index 5849e9f90b..6094bd561a 100644 --- a/isolinux/isolinux.cfg.in +++ b/isolinux/isolinux.cfg.in @@ -8,7 +8,7 @@ MENU AUTOBOOT BIOS default device boot in # second{,s}... MENU BACKGROUND @@SPLASHIMAGE@@ MENU WIDTH 78 MENU MARGIN 1 -MENU ROWS 9 +MENU ROWS 12 MENU VSHIFT 2 MENU TIMEOUTROW 13 MENU TABMSGROW 2 diff --git a/lib.sh b/lib.sh index 43d7329e32..d76495e888 100755 --- a/lib.sh +++ b/lib.sh @@ -210,52 +210,39 @@ register_binfmt() { return fi _cpu=arm - _magic="\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" ;; aarch64) _cpu=aarch64 - _magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" ;; ppc64le) _cpu=ppc64le - _magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00" ;; ppc64) _cpu=ppc64 - _magic="\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" ;; ppc) if [ "$_hostarch" = "ppc64" ] ; then return fi _cpu=ppc - _magic="\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" ;; mipsel) if [ "$_hostarch" = "mips64el" ] ; then return fi _cpu=mipsel - _magic="\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00" - _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" ;; x86_64) _cpu=x86_64 - _magic="\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" - _mask="\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" ;; i686) if [ "$_hostarch" = "x86_64" ] ; then return fi _cpu=i386 - _magic="\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00" - _mask="\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" + ;; + riscv64) + _cpu=riscv64 ;; *) die "Unknown target architecture!" @@ -264,7 +251,7 @@ register_binfmt() { # For builds that do not match the host architecture, the correct # qemu binary will be required. - QEMU_BIN="qemu-${_cpu}-static" + QEMU_BIN="qemu-${_cpu}" if ! $QEMU_BIN -version >/dev/null 2>&1; then die "$QEMU_BIN binary is missing in your system, exiting." fi @@ -278,7 +265,10 @@ register_binfmt() { # Only register if the map is incomplete if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then - echo ":qemu-$_cpu:M::$_magic:$_mask:/usr/bin/$QEMU_BIN:F" > /proc/sys/fs/binfmt_misc/register 2>/dev/null + if ! command -v update-binfmts >/dev/null 2>&1; then + die "could not add binfmt: update-binfmts binary is missing in your system" + fi + update-binfmts --import "qemu-$_cpu" fi } @@ -333,8 +323,6 @@ rk33xx_flash_uboot() { --repository=https://repo-default.voidlinux.org/current/musl \ --repository=https://repo-default.voidlinux.org/current/aarch64}" - - # This library is the authoritative source of the platform map, # because of this we may need to get this information from the command # line. This select allows us to get that information out. This diff --git a/build-x86-images.sh b/mkiso.sh similarity index 83% rename from build-x86-images.sh rename to mkiso.sh index d09ae99737..db5bf22c58 100755 --- a/build-x86-images.sh +++ b/mkiso.sh @@ -56,6 +56,19 @@ cleanup() { rm -rf "$INCLUDEDIR" } +include_installer() { + if [ -x installer.sh ]; then + MKLIVE_VERSION="$(PROGNAME='' version)" + installer=$(mktemp) + sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer" + install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer + rm "$installer" + else + echo installer.sh not found >&2 + exit 1 + fi +} + setup_pipewire() { PKGS="$PKGS pipewire alsa-pipewire" mkdir -p "$INCLUDEDIR"/etc/xdg/autostart @@ -72,7 +85,16 @@ build_variant() { variant="$1" shift IMG=void-live-${ARCH}-${DATE}-${variant}.iso - GRUB_PKGS="grub-i386-efi grub-x86_64-efi" + + # el-cheapo installer is unsupported on arm because arm doesn't install a kernel by default + # and to work around that would add too much complexity to it + # thus everyone should just do a chroot install anyways + WANT_INSTALLER=no + case "$ARCH" in + x86_64*|i686*) GRUB_PKGS="grub-i386-efi grub-x86_64-efi"; WANT_INSTALLER=yes ;; + aarch64*) GRUB_PKGS="grub-arm64-efi" ;; + esac + A11Y_PKGS="espeakup void-live-audio brltty" PKGS="dialog cryptsetup lvm2 mdadm void-docs-browse xtools-minimal xmirror chrony tmux $A11Y_PKGS $GRUB_PKGS" XORG_PKGS="xorg-minimal xorg-input-drivers xorg-video-drivers setxkbmap xauth font-misc-misc terminus-font dejavu-fonts-ttf orca" @@ -137,6 +159,14 @@ indicators = ~host;~spacer;~clock;~spacer;~layout;~session;~a11y;~power EOF fi + if [ "$WANT_INSTALLER" = yes ]; then + include_installer + else + mkdir -p "$INCLUDEDIR"/usr/bin + printf "#!/bin/sh\necho 'void-installer is not supported on this live image'\n" > "$INCLUDEDIR"/usr/bin/void-installer + chmod 755 "$INCLUDEDIR"/usr/bin/void-installer + fi + if [ "$variant" != base ]; then setup_pipewire fi @@ -151,17 +181,6 @@ if [ ! -x mklive.sh ]; then exit 1 fi -if [ -x installer.sh ]; then - MKLIVE_VERSION="$(PROGNAME='' version)" - installer=$(mktemp) - sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer" - install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer - rm "$installer" -else - echo installer.sh not found >&2 - exit 1 -fi - if [ -n "$TRIPLET" ]; then VARIANT="${TRIPLET##*-}" REST="${TRIPLET%-*}" diff --git a/mklive.sh b/mklive.sh index fe87e13520..ab327d311e 100755 --- a/mklive.sh +++ b/mklive.sh @@ -28,28 +28,32 @@ umask 022 . ./lib.sh -readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-i386-efi grub-x86_64-efi memtest86+ squashfs-tools xorriso" -readonly INITRAMFS_PKGS="binutils xz device-mapper dhclient dracut-network openresolv" -readonly PROGNAME=$(basename "$0") +REQUIRED_PKGS=(base-files libgcc dash coreutils sed tar gawk squashfs-tools xorriso) +TARGET_PKGS=(base-files) +INITRAMFS_PKGS=(binutils xz device-mapper dhclient dracut-network openresolv) +PACKAGE_LIST=() +IGNORE_PKGS=() +PLATFORMS=() +readonly PROGNAME="$(basename "$0")" declare -a INCLUDE_DIRS=() -info_msg() { - printf "\033[1m$@\n\033[m" -} die() { - info_msg "ERROR: $@" + info_msg "ERROR: $*" error_out 1 $LINENO } + print_step() { CURRENT_STEP=$((CURRENT_STEP+1)) - info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $@" + info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $*" } + mount_pseudofs() { for f in sys dev proc; do mkdir -p "$ROOTFS"/$f mount --rbind /$f "$ROOTFS"/$f done } + umount_pseudofs() { for f in sys dev proc; do if [ -d "$ROOTFS/$f" ] && ! umount -R -f "$ROOTFS/$f"; then @@ -58,6 +62,7 @@ umount_pseudofs() { fi done } + error_out() { trap - INT TERM 0 umount_pseudofs || exit "${1:-0}" @@ -72,8 +77,8 @@ usage() { Generates a basic live ISO image of Void Linux. This ISO image can be written to a CD/DVD-ROM or any USB stick. - To generate a more complete live ISO image, use build-x86-images.sh. - + To generate a more complete live ISO image, use mkiso.sh. + OPTIONS -a <arch> Set XBPS_ARCH in the ISO image -b <system-pkg> Set an alternative base package (default: base-system) @@ -92,6 +97,8 @@ usage() { -e <shell> Default shell of the root user (must be absolute path). Set the live.shell kernel argument to change the default shell of anon. -C "<arg> ..." Add additional kernel command line arguments + -P "<platform> ..." + Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s) -T <title> Modify the bootloader title (default: Void Linux) -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage). Also accepts linux metapackages (linux-mainline, linux-lts). @@ -117,8 +124,14 @@ copy_autoinstaller_files() { } install_prereqs() { - XBPS_ARCH=$ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \ - -c "$XBPS_HOST_CACHEDIR" -y $REQUIRED_PKGS + XBPS_ARCH=$HOST_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \ + -c "$XBPS_HOST_CACHEDIR" -y "${REQUIRED_PKGS[@]}" + [ $? -ne 0 ] && die "Failed to install required software, exiting..." +} + +install_target_pkgs() { + XBPS_ARCH=$TARGET_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} \ + -c "$XBPS_HOST_CACHEDIR" -y "${TARGET_PKGS[@]}" [ $? -ne 0 ] && die "Failed to install required software, exiting..." } @@ -134,15 +147,15 @@ post_install_packages() { } install_packages() { - XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \ - ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn $PACKAGE_LIST $INITRAMFS_PKGS + XBPS_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \ + ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}" [ $? -ne 0 ] && die "Missing required binary packages, exiting..." mount_pseudofs - LANG=C XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \ - ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y $PACKAGE_LIST $INITRAMFS_PKGS - [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST" + LANG=C XBPS_TARGET_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \ + ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}" + [ $? -ne 0 ] && die "Failed to install ${PACKAGE_LIST[*]} ${INITRAMFS_PKGS[*]}" xbps-reconfigure -r "$ROOTFS" -f base-files >/dev/null 2>&1 chroot "$ROOTFS" env -i xbps-reconfigure -f base-files @@ -151,19 +164,27 @@ install_packages() { if [ -f "$ROOTFS"/etc/default/libc-locales ]; then sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i "$ROOTFS"/etc/default/libc-locales fi + if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dkms >/dev/null 2>&1; then # dkms modules alphabetically before dkms can't configure # if dkms hasn't configured beforehand to create /var/lib/dkms chroot "$ROOTFS" env -i xbps-reconfigure dkms fi + chroot "$ROOTFS" env -i xbps-reconfigure -a + if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dash >/dev/null 2>&1; then + # bash configures alphabetically before dash, + # so if it's installed we should ensure it's /bin/sh + chroot "$ROOTFS" env -i xbps-alternatives -s dash + fi + post_install_packages } ignore_packages() { mkdir -p "$ROOTFS"/etc/xbps.d - for pkg in $IGNORE_PKGS; do + for pkg in "${IGNORE_PKGS[@]}"; do echo "ignorepkg=$pkg" >> "$ROOTFS"/etc/xbps.d/mklive-ignore.conf done } @@ -200,11 +221,14 @@ generate_initramfs() { [ $? -ne 0 ] && die "Failed to generate the initramfs" mv "$ROOTFS"/boot/initrd "$BOOT_DIR" - cp "$ROOTFS"/boot/vmlinuz-$KERNELVERSION "$BOOT_DIR"/vmlinuz + case "$TARGET_ARCH" in + i686*|x86_64*) cp "$ROOTFS/boot/vmlinuz-$KERNELVERSION" "$BOOT_DIR"/vmlinuz ;; + aarch64*) cp "$ROOTFS/boot/vmlinux-$KERNELVERSION" "$BOOT_DIR"/vmlinux ;; + esac } cleanup_rootfs() { - for f in ${INITRAMFS_PKGS}; do + for f in "${INITRAMFS_PKGS[@]}"; do revdeps=$(xbps-query -r "$ROOTFS" -X $f) if [ -n "$revdeps" ]; then xbps-pkgdb -r "$ROOTFS" -m auto $f @@ -231,27 +255,122 @@ generate_isolinux_boot() { sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \ -e "s|@@KERNVER@@|${KERNELVERSION}|" \ -e "s|@@KEYMAP@@|${KEYMAP}|" \ - -e "s|@@ARCH@@|$BASE_ARCH|" \ + -e "s|@@ARCH@@|$TARGET_ARCH|" \ -e "s|@@LOCALE@@|${LOCALE}|" \ -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \ -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \ "$ISOLINUX_DIR"/isolinux.cfg # include memtest86+ - cp -f "$VOIDHOSTDIR"/boot/memtest86+/memtest.bin "$BOOT_DIR" + if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin ]; then + cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin "$BOOT_DIR" + fi } generate_grub_efi_boot() { cp -f grub/grub.cfg "$GRUB_DIR" - cp -f grub/grub_void.cfg.in "$GRUB_DIR"/grub_void.cfg - sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \ - -e "s|@@KERNVER@@|${KERNELVERSION}|" \ - -e "s|@@KEYMAP@@|${KEYMAP}|" \ - -e "s|@@ARCH@@|$BASE_ARCH|" \ - -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \ - -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \ - -e "s|@@LOCALE@@|${LOCALE}|" "$GRUB_DIR"/grub_void.cfg + cp -f "${SPLASH_IMAGE}" "$ISOLINUX_DIR" + cp -f grub/grub_void.cfg.pre "$GRUB_DIR"/grub_void.cfg + + case "$TARGET_ARCH" in + i686*|x86_64*) KERNEL_IMG=vmlinuz; WANT_MEMTEST=yes ;; + aarch64*) KERNEL_IMG=vmlinux; WANT_MEMTEST=no ;; + esac + + write_entry() { + local entrytitle="$1" id="$2" cmdline="$3" dtb="$4" hotkey="$5" + cat << EOF >> "$GRUB_DIR"/grub_void.cfg +menuentry "${entrytitle}" --id "${id}" ${hotkey:+--hotkey $hotkey} { + set gfxpayload="keep" + linux (\${voidlive})/boot/${KERNEL_IMG} \\ + root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \\ + rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \\ + vconsole.unicode=1 vconsole.keymap=${KEYMAP} locale.LANG=${LOCALE} ${cmdline} + initrd (\${voidlive})/boot/initrd +EOF + if [ -n "${dtb}" ]; then + printf ' devicetree (${voidlive})/boot/dtbs/%s\n' "${dtb}" >> "$GRUB_DIR"/grub_void.cfg + fi + printf '}\n' >> "$GRUB_DIR"/grub_void.cfg + } + + write_entries() { + local title_sfx="$1" id_sfx="$2" cmdline="$3" dtb="$4" + + ENTRY_TITLE="${BOOT_TITLE} ${KERNELVERSION} ${title_sfx}(${TARGET_ARCH})" + + write_entry "${ENTRY_TITLE}" "linux${id_sfx}" \ + "$BOOT_CMDLINE $cmdline" "$dtb" + write_entry "${ENTRY_TITLE} (RAM)" "linuxram${id_sfx}" \ + "rd.live.ram $BOOT_CMDLINE $cmdline" "$dtb" + write_entry "${ENTRY_TITLE} (graphics disabled)" "linuxnogfx${id_sfx}" \ + "nomodeset $BOOT_CMDLINE $cmdline" "$dtb" + write_entry "${ENTRY_TITLE} with speech" "linuxa11y${id_sfx}" \ + "live.accessibility live.autologin $BOOT_CMDLINE $cmdline" "$dtb" 's' + write_entry "${ENTRY_TITLE} with speech (RAM)" "linuxa11yram${id_sfx}" \ + "live.accessibility live.autologin rd.live.ram $BOOT_CMDLINE $cmdline" "$dtb" 'r' + write_entry "${ENTRY_TITLE} with speech (graphics disabled)" "linuxa11ynogfx${id_sfx}" \ + "live.accessibility live.autologin nomodeset $BOOT_CMDLINE $cmdline" "$dtb" 'g' + + } + + write_entries + + for platform in "${PLATFORMS[@]}"; do + ( + . "platforms/${platform}.sh" + + if [ -n "$PLATFORM_DTB" ]; then + mkdir -p "${BOOT_DIR}/dtbs/${PLATFORM_DTB%/*}" + cp "${ROOTFS}/boot/dtbs/dtbs-${KERNVER}"*/"${PLATFORM_DTB}" "${BOOT_DIR}/dtbs/${PLATFORM_DTB}" + fi + + printf 'submenu "%s" --id platform-%s {\n' \ + "${BOOT_TITLE} for ${PLATFORM_NAME:-$platform} >" "${platform}" >> "$GRUB_DIR"/grub_void.cfg + write_entries "for ${PLATFORM_NAME:-$platform} " "-$platform" "$PLATFORM_CMDLINE" "${PLATFORM_DTB}" + printf '}\n' >> "$GRUB_DIR"/grub_void.cfg + ) + done + + if [ "$WANT_MEMTEST" = yes ]; then + cat << 'EOF' >> "$GRUB_DIR"/grub_void.cfg + if [ "${grub_platform}" == "efi" ]; then + menuentry "Run Memtest86+ (RAM test)" --id memtest { + set gfxpayload="keep" + linux (${voidlive})/boot/memtest.efi + } + else + menuentry "Run Memtest86+ (RAM test)" --id memtest { + set gfxpayload="keep" + linux (${voidlive})/boot/memtest.bin + } + fi +EOF + fi + + cat << 'EOF' >> "$GRUB_DIR"/grub_void.cfg +if [ "${grub_platform}" == "efi" ]; then + menuentry 'UEFI Firmware Settings' --hotkey f --id uefifw { + fwsetup + } +fi + +menuentry "System restart" --hotkey b --id restart { + echo "System rebooting..." + reboot +} + +menuentry "System shutdown" --hotkey p --id poweroff { + echo "System shutting down..." + halt +} +EOF + cat grub/grub_void.cfg.post >> "$GRUB_DIR"/grub_void.cfg + + sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" "$GRUB_DIR"/grub_void.cfg + mkdir -p "$GRUB_DIR"/fonts + cp -f "$GRUB_DATADIR"/unicode.pf2 "$GRUB_DIR"/fonts modprobe -q loop || : @@ -260,40 +379,45 @@ generate_grub_efi_boot() { truncate -s 32M "$GRUB_DIR"/efiboot.img >/dev/null 2>&1 mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1 - GRUB_EFI_TMPDIR="$(mktemp --tmpdir="$HOME" -d)" + GRUB_EFI_TMPDIR="$(mktemp --tmpdir="$BUILDDIR" -dt grub-efi.XXXXX)" LOOP_DEVICE="$(losetup --show --find "${GRUB_DIR}"/efiboot.img)" mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1 - cp -a "$IMAGEDIR"/boot "$VOIDHOSTDIR" - xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \ - --directory="/usr/lib/grub/i386-efi" \ - --format="i386-efi" \ - --output="/tmp/bootia32.efi" \ - "boot/grub/grub.cfg" - if [ $? -ne 0 ]; then - umount "$GRUB_EFI_TMPDIR" - losetup --detach "${LOOP_DEVICE}" - die "Failed to generate EFI loader" - fi - mkdir -p "${GRUB_EFI_TMPDIR}"/EFI/BOOT - cp -f "$VOIDHOSTDIR"/tmp/bootia32.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTIA32.EFI - xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \ - --directory="/usr/lib/grub/x86_64-efi" \ - --format="x86_64-efi" \ - --output="/tmp/bootx64.efi" \ - "boot/grub/grub.cfg" - if [ $? -ne 0 ]; then - umount "$GRUB_EFI_TMPDIR" - losetup --detach "${LOOP_DEVICE}" - die "Failed to generate EFI loader" - fi - cp -f "$VOIDHOSTDIR"/tmp/bootx64.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTX64.EFI + build_grub_image() { + local GRUB_ARCH="$1" EFI_ARCH="$2" + xbps-uchroot "$VOIDTARGETDIR" grub-mkstandalone -- \ + --directory="/usr/lib/grub/${GRUB_ARCH}-efi" \ + --format="${GRUB_ARCH}-efi" \ + --output="/tmp/boot${EFI_ARCH,,}.efi" \ + "boot/grub/grub.cfg" + if [ $? -ne 0 ]; then + umount "$GRUB_EFI_TMPDIR" + losetup --detach "${LOOP_DEVICE}" + die "Failed to generate EFI loader" + fi + mkdir -p "${GRUB_EFI_TMPDIR}"/EFI/BOOT + cp -f "$VOIDTARGETDIR/tmp/boot${EFI_ARCH,,}.efi" "${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOT${EFI_ARCH^^}.EFI" + } + + cp -a "$IMAGEDIR"/boot "$VOIDTARGETDIR" + + case "$TARGET_ARCH" in + i686*|x86_64*) + # XXX: why are both built on both arches? + build_grub_image i386 ia32 + build_grub_image x86_64 x64 + # include memtest86+ + if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi ]; then + cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi "$BOOT_DIR" + fi + ;; + aarch64*) + build_grub_image arm64 aa64 + ;; + esac umount "$GRUB_EFI_TMPDIR" losetup --detach "${LOOP_DEVICE}" rm -rf "$GRUB_EFI_TMPDIR" - - # include memtest86+ - cp -f "$VOIDHOSTDIR"/boot/memtest86+/memtest.efi "$BOOT_DIR" } generate_squashfs() { @@ -320,29 +444,59 @@ generate_squashfs() { } generate_iso_image() { - "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs \ - -iso-level 3 -rock -joliet \ - -max-iso9660-filenames -omit-period \ - -omit-version-number -relaxed-filenames -allow-lowercase \ - -volid "VOID_LIVE" \ - -eltorito-boot boot/isolinux/isolinux.bin \ - -eltorito-catalog boot/isolinux/boot.cat \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ - -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \ - -isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \ - -output "$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image" + local bootloader n + XORRISO_ARGS=( + -iso-level 3 -rock -joliet -joliet-long -max-iso9660-filenames -omit-period + -omit-version-number -relaxed-filenames -allow-lowercase + -volid VOID_LIVE + ) + + if [ "$IMAGE_TYPE" = hybrid ]; then + XORRISO_ARGS+=(-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin) + fi + + n=1 + for bootloader in "${BOOTLOADERS[@]}"; do + if (( n > 1 )); then + XORRISO_ARGS+=(-eltorito-alt-boot) + fi + + case "${bootloader}" in + grub) + XORRISO_ARGS+=( + -e boot/grub/efiboot.img -no-emul-boot + -isohybrid-gpt-basdat -isohybrid-apm-hfsplus + ) + ;; + syslinux) + XORRISO_ARGS+=( + -eltorito-boot boot/isolinux/isolinux.bin + -eltorito-catalog boot/isolinux/boot.cat + -no-emul-boot -boot-load-size 4 -boot-info-table + ) + ;; + esac + + n=$(( n + 1 )) + done + + XORRISO_ARGS+=( + -output "$OUTPUT_FILE" "$IMAGEDIR" + ) + + "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs "${XORRISO_ARGS[@]}" || die "Failed to generate ISO image" } # # main() # -while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:Vh" opt; do +while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:P:Vh" opt; do case $opt in - a) BASE_ARCH="$OPTARG";; + a) TARGET_ARCH="$OPTARG";; b) BASE_SYSTEM_PKG="$OPTARG";; r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";; c) XBPS_CACHEDIR="$OPTARG";; - g) IGNORE_PKGS="$IGNORE_PKGS $OPTARG" ;; + g) IGNORE_PKGS+=($OPTARG) ;; K) readonly KEEP_BUILDDIR=1;; k) KEYMAP="$OPTARG";; l) LOCALE="$OPTARG";; @@ -352,7 +506,8 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:Vh" opt; do e) ROOT_SHELL="$OPTARG";; s) SQUASHFS_COMPRESSION="$OPTARG";; o) OUTPUT_FILE="$OPTARG";; - p) PACKAGE_LIST="$PACKAGE_LIST $OPTARG";; + p) PACKAGE_LIST+=($OPTARG);; + P) PLATFORMS+=($OPTARG) ;; C) BOOT_CMDLINE="$OPTARG";; T) BOOT_TITLE="$OPTARG";; v) LINUX_VERSION="$OPTARG";; @@ -362,17 +517,17 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:Vh" opt; do esac done shift $((OPTIND - 1)) -XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=https://repo-default.voidlinux.org/current --repository=https://repo-default.voidlinux.org/current/musl" +XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=https://repo-default.voidlinux.org/current --repository=https://repo-default.voidlinux.org/current/musl --repository=https://repo-default.voidlinux.org/current/aarch64" # Configure dracut to use overlayfs for the writable overlay. BOOT_CMDLINE="$BOOT_CMDLINE rd.live.overlay.overlayfs=1 " -ARCH=$(xbps-uhelper arch) +HOST_ARCH=$(xbps-uhelper arch) # Set defaults -: ${BASE_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)} -: ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${BASE_ARCH}} -: ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${ARCH}} +: ${TARGET_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)} +: ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${TARGET_ARCH}} +: ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${HOST_ARCH}} : ${KEYMAP:=us} : ${LOCALE:=en_US.UTF-8} : ${INITRAMFS_COMPRESSION:=xz} @@ -381,13 +536,35 @@ ARCH=$(xbps-uhelper arch) : ${BOOT_TITLE:="Void Linux"} : ${LINUX_VERSION:=linux} -case $BASE_ARCH in - x86_64*|i686*) ;; - *) >&2 echo architecture $BASE_ARCH not supported by mklive.sh; exit 1;; +XBPS_TARGET_ARCH="$TARGET_ARCH" register_binfmt + +case "$TARGET_ARCH" in + x86_64*|i686*) + BOOTLOADERS=(syslinux grub) + IMAGE_TYPE='hybrid' + TARGET_PKGS+=(syslinux grub-i386-efi grub-x86_64-efi memtest86+) + PLATFORMS=() # arm only + ;; + aarch64*) + BOOTLOADERS=(grub) + IMAGE_TYPE='efi' + TARGET_PKGS+=(grub-arm64-efi) + for platform in "${PLATFORMS[@]}"; do + if [ -r "platforms/${platform}.sh" ]; then + . "platforms/${platform}.sh" + else + die "unknown platform: ${platform}" + fi + PACKAGE_LIST+=("${PLATFORM_PKGS[@]}") + unset PLATFORM_PKGS PLATFORM_CMDLINE PLATFORM_DTB + done + + ;; + *) >&2 echo "architecture $TARGET_ARCH not supported by mklive.sh"; exit 1;; esac # Required packages in the image for a working system. -PACKAGE_LIST="$BASE_SYSTEM_PKG $PACKAGE_LIST" +PACKAGE_LIST+=("$BASE_SYSTEM_PKG") # Check for root permissions. if [ "$(id -u)" -ne 0 ]; then @@ -397,25 +574,27 @@ fi trap 'error_out $? $LINENO' INT TERM 0 if [ -n "$ROOTDIR" ]; then - BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d) + BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -dt mklive-build.XXXXX) else - BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -d) + BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -dt mklive-build.XXXXX) fi BUILDDIR=$(readlink -f "$BUILDDIR") IMAGEDIR="$BUILDDIR/image" ROOTFS="$IMAGEDIR/rootfs" VOIDHOSTDIR="$BUILDDIR/void-host" +VOIDTARGETDIR="$BUILDDIR/void-target" BOOT_DIR="$IMAGEDIR/boot" ISOLINUX_DIR="$BOOT_DIR/isolinux" GRUB_DIR="$BOOT_DIR/grub" CURRENT_STEP=0 STEP_COUNT=10 +[ "${IMAGE_TYPE}" = hybrid ] && STEP_COUNT=$((STEP_COUNT+1)) [ "${#INCLUDE_DIRS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1)) -[ -n "${IGNORE_PKGS}" ] && STEP_COUNT=$((STEP_COUNT+1)) +[ "${#IGNORE_PKGS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1)) [ -n "$ROOT_SHELL" ] && STEP_COUNT=$((STEP_COUNT+1)) -: ${SYSLINUX_DATADIR:="$VOIDHOSTDIR"/usr/lib/syslinux} -: ${GRUB_DATADIR:="$VOIDHOSTDIR"/usr/share/grub} +: ${SYSLINUX_DATADIR:="$VOIDTARGETDIR"/usr/lib/syslinux} +: ${GRUB_DATADIR:="$VOIDTARGETDIR"/usr/share/grub} : ${SPLASH_IMAGE:=data/splash.png} : ${XBPS_INSTALL_CMD:=xbps-install} : ${XBPS_REMOVE_CMD:=xbps-remove} @@ -424,30 +603,32 @@ STEP_COUNT=10 : ${XBPS_UHELPER_CMD:=xbps-uhelper} : ${XBPS_RECONFIGURE_CMD:=xbps-reconfigure} -mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$ISOLINUX_DIR" "$GRUB_DIR" +mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$VOIDTARGETDIR" "$GRUB_DIR" "$ISOLINUX_DIR" print_step "Synchronizing XBPS repository data..." copy_void_keys "$ROOTFS" +XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S copy_void_keys "$VOIDHOSTDIR" -XBPS_ARCH=$BASE_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S -XBPS_ARCH=$ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -S +XBPS_ARCH=$HOST_ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -S +copy_void_keys "$VOIDTARGETDIR" +XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} -S # Get linux version for ISO # If linux version option specified use shopt -s extglob case "$LINUX_VERSION" in linux+([0-9.])) - IGNORE_PKGS+=" linux" - PACKAGE_LIST+=" $LINUX_VERSION linux-base" + IGNORE_PKGS+=(linux) + PACKAGE_LIST+=("$LINUX_VERSION" linux-base) ;; linux-@(mainline|lts)) - IGNORE_PKGS+=" linux" - PACKAGE_LIST+=" $LINUX_VERSION" - LINUX_VERSION="$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x "$LINUX_VERSION" | grep 'linux[0-9._]\+')" + IGNORE_PKGS+=(linux) + PACKAGE_LIST+=("$LINUX_VERSION") + LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x "$LINUX_VERSION" | grep 'linux[0-9._]\+')" ;; linux) - PACKAGE_LIST+=" linux" - LINUX_VERSION="$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux | grep 'linux[0-9._]\+')" + PACKAGE_LIST+=(linux) + LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux | grep 'linux[0-9._]\+')" ;; *) die "-v option must be in format linux<version> or linux-<series>" @@ -455,28 +636,31 @@ case "$LINUX_VERSION" in esac shopt -u extglob -_kver="$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver $LINUX_VERSION)" +_kver="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver $LINUX_VERSION)" KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver}) if [ "$?" -ne "0" ]; then die "Failed to find kernel package version" fi -: ${OUTPUT_FILE="void-live-${BASE_ARCH}-${KERNELVERSION}-$(date -u +%Y%m%d).iso"} +: ${OUTPUT_FILE="void-live-${TARGET_ARCH}-${KERNELVERSION}-$(date -u +%Y%m%d).iso"} + +print_step "Installing software to generate the image: ${REQUIRED_PKGS[*]} ..." +install_prereqs "${REQUIRED_PKGS[@]}" -print_step "Installing software to generate the image: ${REQUIRED_PKGS} ..." -install_prereqs +print_step "Installing software to generate the image: ${TARGET_PKGS[*]} ..." +install_target_pkgs "${TARGET_PKGS[@]}" mkdir -p "$ROOTFS"/etc [ -s data/motd ] && cp data/motd "$ROOTFS"/etc [ -s data/issue ] && cp data/issue "$ROOTFS"/etc -if [ -n "$IGNORE_PKGS" ]; then - print_step "Ignoring packages in the rootfs: ${IGNORE_PKGS} ..." +if [ "${#IGNORE_PKGS[@]}" -gt 0 ]; then + print_step "Ignoring packages in the rootfs: ${IGNORE_PKGS[*]} ..." ignore_packages fi -print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST} ..." +print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST[*]} ..." install_packages : ${DEFAULT_SERVICE_LIST:=agetty-tty1 agetty-tty2 agetty-tty3 agetty-tty4 agetty-tty5 agetty-tty6 udevd} @@ -496,8 +680,10 @@ fi print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..." generate_initramfs -print_step "Generating isolinux support for PC-BIOS systems..." -generate_isolinux_boot +if [ "$IMAGE_TYPE" = hybrid ]; then + print_step "Generating isolinux support for PC-BIOS systems..." + generate_isolinux_boot +fi print_step "Generating GRUB support for EFI systems..." generate_grub_efi_boot diff --git a/mkrootfs.sh b/mkrootfs.sh index dbdd693013..54e101b7ef 100755 --- a/mkrootfs.sh +++ b/mkrootfs.sh @@ -57,6 +57,7 @@ usage() { aarch64, aarch64-musl, mipsel, mipsel-musl, ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl + riscv64, riscv64-musl OPTIONS -b <system-pkg> Set an alternative base-system package (default: base-container-full) diff --git a/platforms/README.md b/platforms/README.md new file mode 100644 index 0000000000..aa8a8d1153 --- /dev/null +++ b/platforms/README.md @@ -0,0 +1,22 @@ +## mklive platforms + +To allow for platform-specific customization (and platform-specific/generic +images all-in-one) on aarch64, `mklive.sh -P "platform1 platform2 ..."` can be +used. That will, in turn, source `platform1.sh` and `platform2.sh` from this +directory to do a few things: + +1. add packages to the image +2. add menu entries in GRUB + +### File format + +```bash +# an optional pretty name +PLATFORM_NAME="Thinkpad X13s" +# any additional packages to add (bash array) +PLATFORM_PKGS=(x13s-base) +# any special kernel cmdline arguments +PLATFORM_CMDLINE="rd.driver.blacklist=qcom_q6v5_pas arm64.nopauth clk_ignore_unused pd_ignore_unused" +# device tree (path relative to /boot/dtbs/dtbs-$version/) +PLATFORM_DTB="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb" +``` diff --git a/platforms/pinebookpro.sh b/platforms/pinebookpro.sh new file mode 100644 index 0000000000..ddca53e602 --- /dev/null +++ b/platforms/pinebookpro.sh @@ -0,0 +1,4 @@ +PLATFORM_NAME="Pinebook Pro" +PLATFORM_PKGS=(pinebookpro-base) +PLATFORM_CMDLINE="console=ttyS2,115200 video=eDP-1:1920x1080x60" +PLATFORM_DTB="rockchip/rk3399-pinebook-pro.dtb" diff --git a/platforms/x13s.sh b/platforms/x13s.sh new file mode 100644 index 0000000000..081eb01a25 --- /dev/null +++ b/platforms/x13s.sh @@ -0,0 +1,4 @@ +PLATFORM_NAME="Thinkpad X13s" +PLATFORM_PKGS=(x13s-base) +PLATFORM_CMDLINE="rd.driver.blacklist=qcom_q6v5_pas arm64.nopauth clk_ignore_unused pd_ignore_unused" +PLATFORM_DTB="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb"