mkimg: add options to specify alternative kernel and additional cmdline (to build imgs for [unsupported] boards (#18)

This commit is contained in:
Felix Yan 2024-01-03 16:30:47 +02:00 committed by GitHub
parent e5bbb17401
commit b18ac49ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

31
mkimg
View file

@ -13,6 +13,9 @@ build_firmware=1
varbose_arg= varbose_arg=
rootfs="archriscv-$(date --rfc-3339=date).tar.zst" rootfs="archriscv-$(date --rfc-3339=date).tar.zst"
fstype=ext4 fstype=ext4
kernel=linux
kernel_suffix=""
cmdline=""
uboot_version=v2023.10 uboot_version=v2023.10
opensbi_version=v1.3.1 opensbi_version=v1.3.1
@ -32,13 +35,15 @@ Create Arch RISC-V distro image.
-p PASSWORD set root password to PASSWORD instead of passwd in rootfs -p PASSWORD set root password to PASSWORD instead of passwd in rootfs
-r ROOTFS specify rootfs file name -r ROOTFS specify rootfs file name
-t FSTYPE specify rootfs filesystem type (default: ext4) -t FSTYPE specify rootfs filesystem type (default: ext4)
-k KERNEL specify kernel package name (default: linux)
-c CMDLINE append CMDLINE to kernel command line
-v verbose mode -v verbose mode
EOF EOF
} }
parse-args() { parse-args() {
local OPTIND=1 local OPTIND=1
while getopts 'hvfdr:t:p:' opt; do while getopts 'hvfdr:t:p:k:c:' opt; do
case $opt in case $opt in
h) show_help h) show_help
exit 0 exit 0
@ -56,6 +61,10 @@ parse-args() {
;; ;;
t) fstype=$OPTARG t) fstype=$OPTARG
;; ;;
k) kernel=$OPTARG
;;
c) cmdline=$OPTARG
;;
*) show_help >&2 *) show_help >&2
exit 1 exit 1
;; ;;
@ -165,9 +174,15 @@ popd
msg "Install kernel package..." msg "Install kernel package..."
if [[ $kernel != linux ]]
then
kernel_suffix="${kernel#linux}"
echo -e "[unsupported]\nInclude = /etc/pacman.d/mirrorlist" | sudo tee -a mnt/etc/pacman.conf
fi
sudo systemd-nspawn -D mnt pacman \ sudo systemd-nspawn -D mnt pacman \
--noconfirm --needed \ --noconfirm --needed \
-Syu linux linux-firmware -Syu $kernel linux-firmware
sudo mkdir -p mnt/boot/extlinux sudo mkdir -p mnt/boot/extlinux
cat << EOF | sudo tee mnt/boot/extlinux/extlinux.conf cat << EOF | sudo tee mnt/boot/extlinux/extlinux.conf
@ -177,15 +192,15 @@ default linux-fallback
label linux label linux
menu label Linux linux menu label Linux linux
kernel /boot/vmlinuz-linux kernel /boot/vmlinuz-linux$kernel_suffix
initrd /boot/initramfs-linux.img initrd /boot/initramfs-linux$kernel_suffix.img
append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0 append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0,115200 $cmdline
label linux-fallback label linux-fallback
menu label Linux linux (fallback initramfs) menu label Linux linux (fallback initramfs)
kernel /boot/vmlinuz-linux kernel /boot/vmlinuz-linux$kernel_suffix
initrd /boot/initramfs-linux-fallback.img initrd /boot/initramfs-linux$kernel_suffix-fallback.img
append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0 append earlyprintk rw root=UUID=$uuid rootwait console=ttyS0,115200 $cmdline
EOF EOF
cat << EOF | sudo tee mnt/etc/systemd/network/default.network cat << EOF | sudo tee mnt/etc/systemd/network/default.network