summaryrefslogtreecommitdiffstats
path: root/build_tools/larch8/larch0/buildscripts/larch-grub-install
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2010-12-02 22:37:23 (GMT)
committerJames Meyer <james.meyer@operamail.com>2010-12-02 22:37:34 (GMT)
commit8b94d7f39c71234712bead363526a0283efeb9fa (patch)
tree23f1dbd6458dc39a2c1b08bcdd4cbf768a60d84d /build_tools/larch8/larch0/buildscripts/larch-grub-install
parent338af567e74d08cbd357079941208e494463d61e (diff)
downloadlinhes_dev-8b94d7f39c71234712bead363526a0283efeb9fa.zip
larch8: first checkin, still needs some work
Diffstat (limited to 'build_tools/larch8/larch0/buildscripts/larch-grub-install')
-rwxr-xr-xbuild_tools/larch8/larch0/buildscripts/larch-grub-install67
1 files changed, 67 insertions, 0 deletions
diff --git a/build_tools/larch8/larch0/buildscripts/larch-grub-install b/build_tools/larch8/larch0/buildscripts/larch-grub-install
new file mode 100755
index 0000000..76921a4
--- /dev/null
+++ b/build_tools/larch8/larch0/buildscripts/larch-grub-install
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# larch-grub-install - Set up a grub boot
+#
+#2010.08.09
+
+# $1: path to system to be used as chroot for running grub
+# ("/" if no chroot is to be used)
+# $2: larch partition, e.g. /dev/sdb1
+# $3: 'MBR', if to be installed to MBR
+
+INSTLDIR="$1"
+if [ "${INSTLDIR}" = "/" ]; then
+ INSTLDIR=""
+fi
+DEVICE="$2"
+mbr="$3"
+
+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 ))
+ gdst="${gdev},${gpart}"
+ [[ ${mbr} != 'MBR' ]] && gdev=${gdst}
+ echo "#Installing GRUB to (${gdev}), root (${gst})"
+}
+
+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 (${gdst})
+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 (${gdst})
+setup (${gdev})
+quit
+EOT
+fi
+rm -f ${INSTLDIR}${dmap}
+
+
+
+