about summary refs log tree commit diff stats
path: root/tools/iso
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-01-01 19:38:50 -0800
committerKartik Agaram <vc@akkartik.com>2020-01-01 19:40:28 -0800
commitf4bef91bd97d7dee60a7718df7b77f8e24b24846 (patch)
tree9c91a254851e5335c891e8b224fdc70d54c84795 /tools/iso
parent65409d2312e702a48d3cf5b32479d25266bda3c3 (diff)
downloadmu-f4bef91bd97d7dee60a7718df7b77f8e24b24846.tar.gz
5859
Move script to create a Linux-based boot image into a sub-directory.
Diffstat (limited to 'tools/iso')
-rwxr-xr-xtools/iso/linux61
-rw-r--r--tools/iso/syslinux.cfg6
2 files changed, 67 insertions, 0 deletions
diff --git a/tools/iso/linux b/tools/iso/linux
new file mode 100755
index 00000000..ac0f720b
--- /dev/null
+++ b/tools/iso/linux
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Build one or more .subx files into an ELF binary, and package it up into a
+# bootable ISO image with a Linux kernel.
+#
+# Must be run on Linux, and from the top-level mu/ directory.
+#
+# Dependencies:
+#   apt install build-essential flex bison wget libelf-dev libssl-dev xorriso
+#
+# Based on http://minimal.linux-bg.org (GPLv3)
+
+set -e
+
+if [ $# -eq 0 ]
+then
+  echo "Usage: `basename $0` file.subx ..."
+  exit 1
+fi
+
+echo "=== building SubX binary"
+./translate_subx $*
+mv a.elf init
+
+echo "=== constructing initramfs out of SubX binary"
+rm -rf tmp_linux/isoimage
+mkdir -p tmp_linux/isoimage/boot
+echo init | cpio -R root:root -H newc -o | xz -9 --check=none > tmp_linux/isoimage/boot/rootfs.xz
+
+if [ ! -d kernel.linux ]
+then
+  echo "=== cloning linux kernel"
+  git clone https://github.com/akkartik/kernel kernel.linux
+fi
+
+echo "=== building linux kernel"
+( cd kernel.linux
+  make bzImage -j $(grep ^processor /proc/cpuinfo | wc -l)
+)
+cp *.linux/arch/x86/boot/bzImage tmp_linux/isoimage/boot/kernel.xz
+
+echo "=== downloading syslinux"
+test -f tmp_linux/syslinux-6.03.tar.xz  ||  wget https://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz -P tmp_linux
+echo "=== unpacking syslinux"
+tar xf tmp_linux/syslinux-*.tar.xz -C tmp_linux
+
+mkdir -p tmp_linux/isoimage/boot/syslinux
+cp tools/iso/syslinux.cfg \
+   tmp_linux/syslinux-*/bios/core/isolinux.bin \
+   tmp_linux/syslinux-*/bios/com32/elflink/ldlinux/ldlinux.c32 \
+   tmp_linux/isoimage/boot/syslinux
+
+echo "=== generating mu_linux.iso"
+# 'hybrid' ISO can also be used on non-optical media such as a disk or USB stick
+xorriso -as mkisofs \
+  -isohybrid-mbr tmp_linux/syslinux-*/bios/mbr/isohdpfx.bin \
+  -c boot/syslinux/boot.cat \
+  -b boot/syslinux/isolinux.bin \
+    -no-emul-boot \
+    -boot-load-size 4 \
+    -boot-info-table \
+  tmp_linux/isoimage -o mu_linux.iso
diff --git a/tools/iso/syslinux.cfg b/tools/iso/syslinux.cfg
new file mode 100644
index 00000000..ae2eee79
--- /dev/null
+++ b/tools/iso/syslinux.cfg
@@ -0,0 +1,6 @@
+DEFAULT mu
+
+LABEL mu
+        LINUX /boot/kernel.xz
+        APPEND vga=nomodeset
+        INITRD /boot/rootfs.xz