From ff175e3f4a924dfce7affac2c99e1f0cb03866a1 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Tue, 17 Nov 2020 23:37:52 +0000 Subject: [PATCH 1/5] disk-image.binary: actually skip building MBR image on EFI platforms. The case is for arch:subarch combo, not just arch alone even if subarch is empty. Thus currently on adm64/arm64/armhf ubuntu-cpc builds mbr image is created and then ignored, as the convert to qcow2 hook prefers the uefi image whenever available. Skipping building these correctly, should speed up the build a little bit and use slightly less disk space. --- live-build/ubuntu-cpc/hooks.d/base/disk-image.binary | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary index 96bf83a5..6468bc69 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary @@ -19,10 +19,6 @@ case $ARCH:$SUBARCH in echo "POWER disk images are handled separately" exit 0 ;; - amd64|arm64|armhf) - echo "We only create EFI images for $ARCH." - exit 0 - ;; armhf:raspi2) # matches the size of the snappy image IMAGE_SIZE=$((4*1000*1000*1000)) @@ -31,6 +27,10 @@ case $ARCH:$SUBARCH in BOOTPART_END=138M BOOT_MOUNTPOINT=/boot/firmware ;; + amd64:*|arm64:*|armhf:*) + echo "We only create EFI images for $ARCH." + exit 0 + ;; *) ;; esac From 8e548f37d944acd46622a7c4120a3f4dea02bb4c Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Tue, 17 Nov 2020 23:40:53 +0000 Subject: [PATCH 2/5] disk-image.binary: skip building MBR image on riscv64. --- live-build/ubuntu-cpc/hooks.d/base/disk-image.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary index 6468bc69..01efe866 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary @@ -27,7 +27,7 @@ case $ARCH:$SUBARCH in BOOTPART_END=138M BOOT_MOUNTPOINT=/boot/firmware ;; - amd64:*|arm64:*|armhf:*) + amd64:*|arm64:*|armhf:*|riscv64:*) echo "We only create EFI images for $ARCH." exit 0 ;; From e8f53aabdf49c6ad2b0c0a2ed6da593963bf0d1b Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Wed, 18 Nov 2020 00:05:46 +0000 Subject: [PATCH 3/5] disk-image.binary: however still build MBR image on amd64. It is used to derive vagrant and ec2 images. I do wonder, if those could be converted to derive from uefi one. --- live-build/ubuntu-cpc/hooks.d/base/disk-image.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary index 01efe866..ed383109 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary @@ -27,7 +27,7 @@ case $ARCH:$SUBARCH in BOOTPART_END=138M BOOT_MOUNTPOINT=/boot/firmware ;; - amd64:*|arm64:*|armhf:*|riscv64:*) + arm64:*|armhf:*|riscv64:*) echo "We only create EFI images for $ARCH." exit 0 ;; From 122364df65ad4ecf768b6a488058bf37a023ab55 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Tue, 17 Nov 2020 23:55:12 +0000 Subject: [PATCH 4/5] disk-image-uefi.binary: enable secureboot on the arm64 image. --- live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary index f997bb4e..4939ca97 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary @@ -81,7 +81,7 @@ install_grub() { # please file a bug against grub2 to include the affected module. case $ARCH in arm64) - chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm64 grub-efi-arm64-bin + chroot mountpoint apt-get -qqy install --no-install-recommends shim-signed grub-efi-arm64-signed efi_target=arm64-efi ;; armhf) From 914997827d6cbafbe22355ad8cd61b74d5107acb Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Tue, 17 Nov 2020 23:46:19 +0000 Subject: [PATCH 5/5] disk-image-uefi.binary: build riscv64 image without a bootloader. We want GPT image with ESP, however there is no bootloader for it yet. Build without it. --- .../hooks.d/base/disk-image-uefi.binary | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary index 4939ca97..916bc424 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary @@ -1,7 +1,7 @@ #!/bin/bash -eux case $ARCH in - amd64|arm64|armhf) + amd64|arm64|armhf|riscv64) ;; *) echo "We don't create EFI images for $ARCH." @@ -35,6 +35,15 @@ create_partitions() { --typecode=15:ef00 \ --new=1: ;; + riscv64) + # same as arm64/armhf, but set bit 2 legacy bios bootable + # on the first partition for uboot + sgdisk "${disk_image}" \ + --new=15:0:204800 \ + --typecode=15:ef00 \ + --new=1: \ + --attributes=1:set:2 + ;; amd64) sgdisk "${disk_image}" \ --new=14::+4M \ @@ -92,6 +101,22 @@ install_grub() { chroot mountpoint apt-get install -qqy grub-pc shim-signed efi_target=x86_64-efi ;; + riscv64) + # TODO does not exist yet on riscv64 + chroot mountpoint apt-get install -qqy u-boot-menu #grub-efi-riscv64 + efi_target=riscv64-efi + + chroot mountpoint u-boot-update + + ## TODO remove below once we have grub-efi-riscv64 + rm mountpoint/tmp/device.map + umount mountpoint/boot/efi + mount + umount_partition mountpoint + rmdir mountpoint + return + ## + ;; esac chroot mountpoint apt-get autoremove --purge --assume-yes