aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kbuild61
1 files changed, 55 insertions, 6 deletions
diff --git a/bin/kbuild b/bin/kbuild
index df1bed8..d3758ca 100755
--- a/bin/kbuild
+++ b/bin/kbuild
@@ -199,21 +199,38 @@ fi
##
# Copy files into filesystem and generate initramfs.
+# Regular installs.
cp -rv usr /
cp -rv boot /
+# Some environments like 'update-initramfs' on Ubuntu expect files to be placed
+# under a special directory in /usr/lib/firmware. Pull this trick now.
+mkdir -p /usr/lib/firmware/$name/device-tree/
+cp -rv boot/dtbs/$name/* /usr/lib/firmware/$name/device-tree/
+
+# And run dracut/update-initramfs.
export PATH=/sbin:\$PATH
if command -v dracut &> /dev/null
then
dracut --kver=$name -f
else
+ # 'update-initramfs' might fail when trying to run 'flash' on Ubuntu, which
+ # is done as a post update script. This is expected, so ignore it.
+ set +e
update-initramfs -k $name -u
+ set -e
fi
##
-# Configure /boot/extlinux/extlinux.conf by providing a default
+# Provide hints on how to configure the bootloader.
+
-cat <<EXT >>/boot/extlinux/extlinux.conf
+if [ -z "\$EDITOR" ]; then
+ EDITOR=vi
+fi
+
+if [ -f /boot/extlinux/extlinux.conf ]; then
+ cat <<EXT >>/boot/extlinux/extlinux.conf
###
### NOTE: generated by kbuild.
@@ -236,10 +253,36 @@ label l1r
append root=/dev/nvme0n1p4 rw console=tty0 console=ttyS0,115200 earlycon rootwait single debug
EXT
-if [ -z "\$EDITOR" ]; then
- EDITOR=vi
+ \$EDITOR /boot/extlinux/extlinux.conf
+else
+ # The other possibility is Grub. If that is not available, then do nothing.
+ if [ -f /boot/grub/grub.cfg ]; then
+ cat <<EXT >/etc/grub.d/40_custom
+#!/bin/sh
+exec tail -n +3 \\\$0
+
+###
+### NOTE: generated by kbuild.
+###
+
+menuentry 'Ubuntu on Linux $name' --class ubuntu --class gnu-linux --class gnu --class os {
+ load_video
+ insmod gzio
+ if [ x\\\$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
+ insmod part_gpt
+ insmod ext2
+ search --no-floppy --fs-uuid --set=root b68f5a83-3f28-4178-b0f5-195a309eef3a
+ echo 'Loading Linux $name ...'
+ linux /boot/vmlinuz-$name root=UUID=b68f5a83-3f28-4178-b0f5-195a309eef3a rw console=tty0 console=ttyS0,115200 earlycon rootwait debug
+ echo 'Loading initial ramdisk ...'
+ initrd /boot/initrd.img-$name
+ echo 'Loading device tree blob...'
+ devicetree /boot/dtbs/$name/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb
+}
+EXT
+ update-grub
+ fi
fi
-\$EDITOR /boot/extlinux/extlinux.conf
SCRIPT
# And the uninstall script.
@@ -261,12 +304,18 @@ fi
xargs rm -f < files.txt
rm -r /usr/lib/modules/$name
rm -r /boot/dtbs/$name
+rm -r /usr/lib/firmware/$name
rm /boot/initrd.img-$name
if [ -z "\$EDITOR" ]; then
EDITOR=vi
fi
-\$EDITOR /boot/extlinux/extlinux.conf
+if [ -f /boot/extlinux/extlinux.conf ]; then
+ \$EDITOR /boot/extlinux/extlinux.conf
+else
+ \$EDITOR /etc/grub.d/40_custom
+ update-grub
+fi
SCRIPT
##