summaryrefslogtreecommitdiffstats
path: root/build_tools/l7/larch0/buildscripts/larch-mbr-grub
diff options
context:
space:
mode:
authorCecil Hugh Watson <knoppmyth@gmail.com>2010-08-28 21:23:23 (GMT)
committerCecil Hugh Watson <knoppmyth@gmail.com>2010-08-28 21:23:23 (GMT)
commitf83117d46d8fc1f6192783371a68607a192c3276 (patch)
tree21bf30aeb943fe6cb23eb9c62a0ba899de2af0d7 /build_tools/l7/larch0/buildscripts/larch-mbr-grub
parent69a0137390be9816d5ec5dc9e81d48817a817758 (diff)
downloadlinhes_dev-f83117d46d8fc1f6192783371a68607a192c3276.zip
Larch 7
Diffstat (limited to 'build_tools/l7/larch0/buildscripts/larch-mbr-grub')
-rwxr-xr-xbuild_tools/l7/larch0/buildscripts/larch-mbr-grub63
1 files changed, 63 insertions, 0 deletions
diff --git a/build_tools/l7/larch0/buildscripts/larch-mbr-grub b/build_tools/l7/larch0/buildscripts/larch-mbr-grub
new file mode 100755
index 0000000..7197ef2
--- /dev/null
+++ b/build_tools/l7/larch0/buildscripts/larch-mbr-grub
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# larch-mbr-grub - Set up a grub boot
+#
+#2009.08.12
+
+
+# $1: path to system to be larchified ("/" if running system)
+# $2: larch partition
+
+INSTLDIR="$1"
+if [ "${INSTLDIR}" = "/" ]; then
+ INSTLDIR=""
+fi
+DEVICE="$2"
+
+dev=${DEVICE:0:8}
+part=${DEVICE:8}
+
+# Convert the device and partion to grub syntax
+grubdevice ()
+{
+ ## The contents of DEVICE.map look something like this:
+ #(fd0) /dev/fd0
+ #(hd0) /dev/hda
+ #(hd1) /dev/sda
+ gdev="$( cat ${INSTLDIR}${dmap} | grep "${dev}" | cut -f1 | tr -d "()" )"
+ gpart=$(( ${part} - 1 ))
+ echo "#Installing GRUB to (${gdev}), root (${gdev},${gpart})"
+}
+
+dmap=/tmp/DEVICE.map
+rm -f ${INSTLDIR}${dmap}
+if [ -n "${INSTLDIR}" ]; then
+ # First try to get a device mapping
+ mount --bind /dev ${INSTLDIR}/dev
+ echo "quit" | chroot ${INSTLDIR} grub --no-floppy --device-map=${dmap} --batch
+ grubdevice
+ # Now actually install grub
+ # As far as I can tell, the extra options to grub are not needed here
+ chroot ${INSTLDIR} grub --batch <<EOT
+root (${gdev},${gpart})
+setup (${gdev})
+quit
+EOT
+ umount ${INSTLDIR}/dev
+else
+ # First try to get a device mapping
+ echo "quit" | grub --no-floppy --device-map=${dmap} --batch
+ grubdevice
+ # Now actually install grub
+ # As far as I can tell, the extra options to grub are not needed here
+ grub --batch <<EOT
+root (${gdev},${gpart})
+setup (${gdev})
+quit
+EOT
+fi
+rm -f ${INSTLDIR}${dmap}
+
+
+
+