switch riscv64 iso to extlinux image.

This commit is contained in:
Tobias Powalowski 2022-09-16 22:14:41 +02:00
parent 335e6171a0
commit 43ce31a590
8 changed files with 88 additions and 38 deletions

View file

@ -6,16 +6,12 @@
_parameters "$@"
_root_check
_riscv64_check
_loop_check
[[ "${_GENERATE}" == "1" ]] || _usage
_config
echo "Starting ISO creation ..."
_prepare_kernel_initramfs_files || exit 1
_prepare_uefi_RISCV64 || exit 1
_prepare_background || exit 1
_prepare_kernel_initramfs_files_RISCV64 || exit 1
_reproducibility
_prepare_uefi_image || exit 1
_reproducibility
_grub_mkrescue || exit 1
_reproducibility_iso || exit 1
_create_cksum || exit 1
_cleanup_iso || exit 1

View file

@ -45,6 +45,14 @@ _riscv64_check() {
fi
}
_loop_check() {
if ! [[ -b /dev/loop0 ]]; then
modprobe loop > /dev/null 2>&1
losetup -f > /dev/null 2>&1
! [[ -b /dev/loop0 ]] && (echo "ERROR: No /dev/loop0 available, aborting."; exit 1)
fi
}
### check for tpowa's build server
_buildserver_check() {
if [[ ! "$(cat /etc/hostname)" == "T-POWA-LX" ]]; then

View file

@ -143,10 +143,21 @@ _prepare_uefi_AA64() {
cp /usr/share/archboot/bootloader/grubaa64.efi "${_ISODIR}/EFI/BOOT/"
}
# build grubXXX with all modules: http://bugs.archlinux.org/task/71382
_prepare_uefi_RISCV64() {
echo "Prepare RISCV64 Grub ..."
cp /usr/share/archboot/bootloader/BOOTRISCV64.efi "${_ISODIR}/EFI/BOOT/"
### EFI status of RISCV64:
#----------------------------------------------------
# EFI is not yet working for RISCV64!
# - grub does not allow linux command in memdisk mode
# - grub itself cannot initialize efi system partion
# - refind bails out with error
# - systemd-boot does not support loading of initrd
# - unified EFI is not possible because of this:
# https://sourceware.org/bugzilla/show_bug.cgi?id=29009
# - only left option is extlinux support in u-boot loader
_prepare_kernel_initramfs_files_RISCV64() {
echo "Prepare RISCV64 extlinux ..."
mkdir -p ${_ISODIR}/boot/extlinux
install -m644 "${ALL_kver}" "${_ISODIR}/boot/vmlinuz_${_RUNNING_ARCH}"
mkinitcpio -c "${MKINITCPIO_CONFIG}" -k "${ALL_kver}" -g "${_ISODIR}/boot/initramfs_${_RUNNING_ARCH}.img" || exit 1
}
_prepare_background() {
@ -174,6 +185,47 @@ _prepare_uefi_image() {
mcopy -m -i "${VFAT_IMAGE}" -s "${_ISODIR}"/EFI ::/
}
# https://github.com/CoelacanthusHex/archriscv-scriptlet/blob/master/mkimg
# https://checkmk.com/linux-knowledge/mounting-partition-loop-device
# calculate mountpoint offset: sector*start
# 512*2048=1048576
# https://reproducible-builds.org/docs/system-images/
# mkfs.ext4 does not allow reproducibility
_prepare_extlinux_image() {
echo "Prepare extlinux image ..."
## get size of boot files
BOOTSIZE=$(du -bc "${_ISODIR}"/boot | grep total | cut -f1)
IMGSZ=$(( (BOOTSIZE*102)/100/1024 + 1)) # image size in sectors
## Create cdefiboot.img
dd if=/dev/zero of="${_ISODIR}"/extlinux.img bs="${IMGSZ}" count=1024 status=none
EXT_IMAGE="${_ISODIR}/extlinux.img"
sfdisk "${_ISODIR}/extlinux.img" <<EOF
label: dos
label-id: 0x12345678
device: "${_ISODIR}/extlinux.img"
unit: sectors
"${_ISODIR}/extlinux.img"1 : start= 2048, type=83, bootable
EOF
mkfs.ext4 -E offset=1048576 -U clear "${_ISODIR}/extlinux.img" >/dev/null
mkdir ${_ISODIR}/mount
mount -o loop,offset=1048576 "${_ISODIR}/extlinux.img" "${_ISODIR}/mount"
mkdir -p "${_ISODIR}/mount/boot/extlinux"
cp -r "${_ISODIR}/boot" "${_ISODIR}/mount"
cat << EOF >> "${_ISODIR}/mount/boot/extlinux/extlinux.conf"
menu title Welcome to Archboot - Arch Linux RISC-V64
timeout 100
default linux
label linux
menu label Boot System (automatic boot in 10 seconds ...)
kernel /boot/vmlinuz_${_RUNNING_ARCH}"
initrd /boot/initramfs_${_RUNNING_ARCH}.img
append rootfstype=ramfs console=ttyS0,115200 console=tty0
EOF
umount "${_ISODIR}/mount"
mv "${_ISODIR}/extlinux.img" "${_IMAGENAME}.img"
}
_grub_mkrescue() {
## Generate the BIOS+ISOHYBRID+UEFI CD image
#set date for reproducibility

View file

@ -39,7 +39,7 @@ _update_riscv64_pacman_chroot() {
# update riscv64 pacman chroot
cd "${_ISO_HOME}" || exit 1
[[ -d "${_PACMAN_RISCV64}" ]] || mkdir "${_PACMAN_RISCV64}"
echo "Downloading archlinuxarm pacman RISCV64 chroot..."
echo "Downloading archlinux pacman riscv64 chroot..."
[[ -f pacman-riscv64-chroot-latest.tar.zst ]] && rm pacman-riscv64-chroot-latest.tar.zst{,.sig} 2>/dev/null
wget ${_ARCHBOOT_RISCV64_CHROOT_PUBLIC}/${_PACMAN_RISCV64_CHROOT}{,.sig} >/dev/null 2>&1
# verify download

View file

@ -78,21 +78,13 @@ function _initrd_aarch64 {
fi
}
function _initrd_riscv64 {
if [ -e /boot/initramfs_riscv64.img ]; then
initrd /boot/amd-ucode.img /boot/initramfs_riscv64.img
else
initrd /boot/amd-ucode.img /boot/initramfs_riscv64-0.img /boot/initramfs_riscv64-1.img
fi
}
if [ ${grub_platform} == "pc" ]; then
set default="Archboot Arch Linux X86_64 - BIOS Mode"
menuentry "Archboot Arch Linux x86_64 - BIOS Mode" {
set gfxpayload=keep
_menu_running
linux /boot/vmlinuz_x86_64 console=ttyS0,115200 console=tty0
linux /boot/vmlinuz_x86_64 rootfstype=ramfs console=ttyS0,115200 console=tty0
_initrd_x86_64
}
fi
@ -138,25 +130,16 @@ if [ ${grub_platform} == "efi" ]; then
submenu "UEFI Tools" {
_efi_shell
}
elif [ ${grub_cpu} == "riscv64" ]; then
set default="Archboot Arch Linux R64"
fi
menuentry "Archboot Arch Linux R64" {
set gfxpayload=keep
_menu_running
linux /boot/vmlinuz_aarch64 rootfstype=ramfs console=tty0
_initrd_riscv64
}
fi
if ! [ ${grub_cpu} == "riscv64" ]; then
submenu "UEFI Tools" {
_secure_boot_tools
}
menuentry "Enter Firmware Setup" {
_menu_running
fwsetup
}
fi
submenu "UEFI Tools" {
_secure_boot_tools
}
menuentry "Enter Firmware Setup" {
_menu_running
fwsetup
}
fi
menuentry "System reboot" {

View file

@ -0,0 +1,5 @@
title Archboot - Arch Linux RISCV64
linux /boot/vmlinuz_riscv64
initrd /boot/initramfs_riscv64-0.img
initrd /boot/initramfs_riscv64-1.img
options rootfstype=ramfs console=ttyS0,115200 console=tty0

View file

@ -0,0 +1,4 @@
title Archboot - Arch Linux RISCV64
linux /boot/vmlinuz_riscv64
initrd /boot/initramfs_riscv64.img
options rootfstype=ramfs console=ttyS0,115200 console=tty0

View file

@ -0,0 +1,2 @@
timeout 5
default archboot