aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-04-04 11:19:55 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-04-04 11:19:55 +0200
commit2a99c6259d54e6b5278b49ee248ba2ac66a7a56a (patch)
tree3fd96721f2a4a65c2e7893b23e61d1920f72216d /tools
Create repository
Diffstat (limited to 'tools')
-rwxr-xr-xtools/gen_syslinux_floppy.sh62
-rwxr-xr-xtools/load_bringelle.sh36
2 files changed, 98 insertions, 0 deletions
diff --git a/tools/gen_syslinux_floppy.sh b/tools/gen_syslinux_floppy.sh
new file mode 100755
index 0000000..cae607a
--- /dev/null
+++ b/tools/gen_syslinux_floppy.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+# Ensure to abort on error
+set -e
+
+wai=$(dirname $(readlink -f "$0")) # Current script directory
+outdir="${wai}/../"
+floppy="${outdir}/floppy.img"
+mountp="$(mktemp -d)" # Mount point (where the floppy will be mounted temporally
+sysbios="/usr/lib/syslinux/bios/" # Syslinux bios and ui locations
+
+check_for () {
+ command -v "$1" &>/dev/null || { echo "Command $1 not found!"; exit 1; }
+}
+
+check_for parted
+check_for losetup
+check_for extlinux
+check_for mkfs.ext4
+[ -d "$sysbios" ] || { echo "Syslinux bios \"$sysbios\" not found!"; exit 1; }
+
+# Create drive
+dd if=/dev/zero of=${floppy} bs=512 count=50000 # Change count to change floppy size :)
+parted -s $floppy mklabel gpt
+parted -s $floppy mkpart linux ext4 0 100%
+parted -s $floppy set 1 legacy_boot on # Require for syslinux according to https://wiki.gentoo.org/wiki/Syslinux#GPT
+
+# Initiate loop devices
+loop=$(sudo losetup -f)
+part="${loop}p1" # Disk partition
+sudo losetup -Pf $floppy
+
+# Prepare disk partition
+sudo mkfs.ext4 $part
+sudo mount $part "$mountp"
+sudo mkdir -p $mountp/boot/syslinux/
+
+# Configuring syslinux
+sudo chown -R loic $mountp/boot/
+cfg=$(mktemp)
+cat > "$cfg" <<EOF
+TIMEOUT 30
+UI vesamenu.c32
+
+MENU TITLE Syslinux
+ LABEL Bringelle
+ KERNEL /boot/bringelle.bs
+EOF
+mv "$cfg" "$mountp/boot/syslinux/syslinux.cfg"
+cp $sysbios/*.c32 $mountp/boot/syslinux/
+sudo extlinux --install $mountp/boot/syslinux
+
+# Umount floppy
+sync
+sudo umount "$mountp"
+rmdir "$mountp"
+
+# Install MBR
+sudo dd bs=440 count=1 conv=notrunc if=$sysbios/gptmbr.bin of=${loop}
+
+# Cleanup
+sudo losetup -D
diff --git a/tools/load_bringelle.sh b/tools/load_bringelle.sh
new file mode 100755
index 0000000..ad360cc
--- /dev/null
+++ b/tools/load_bringelle.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Ensure to abort on error
+set -e
+
+wai=$(dirname $(readlink -f "$0")) # Current script directory
+outdir="${wai}/../"
+floppy="${outdir}/floppy.img"
+mountp="$(mktemp -d)" # Mount point (where the floppy will be mounted temporally
+kernel="${outdir}/src/bringelle"
+
+check_for () {
+ command -v "$1" &>/dev/null || { echo "Command $1 not found!"; exit 1; }
+}
+
+check_for losetup
+[ ! -e "$floppy" ] && { echo "Floppy drive \"$floppy\" not found!"; exit 1; }
+[ ! -e "$kernel" ] && { echo "Kernel \"$kernel\" not found!"; exit 1; }
+
+# Initiate loop devices
+loop=$(sudo losetup -f)
+part="${loop}p1" # Disk partition
+sudo losetup -Pf $floppy
+
+# Prepare disk partition
+sudo mount $part "$mountp"
+cp $kernel $mountp/boot/bringelle.bs
+
+# Umount floppy
+sync
+sudo umount "$mountp"
+rmdir "$mountp"
+
+# Cleanup
+sudo losetup -D
+