[arch-releng] [PATCH 2/3] Mount special filesystems during grub actions

Thomas Hebb tommyhebb at gmail.com
Sun May 20 21:57:39 EDT 2012


Break grub actions on the target system out into separate functions in
lib-software.sh and make sure we mount special filesystems (FS#29928).
Also fix a pathname bug causing grub errors to go undetected.

Signed-off-by: Thomas Hebb <tommyhebb at gmail.com>
---
 src/core/libs/lib-blockdevices-filesystems.sh |   12 -----------
 src/core/libs/lib-software.sh                 |   27 +++++++++++++++++++++++++
 src/core/libs/lib-ui-interactive.sh           |   14 +++++--------
 3 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 70805c8..1d101c5 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -346,18 +346,6 @@ dev_is_in_softraid_or_lvmpv () {
 	grep -qsw "${dev##*/}" /proc/mdstat || { pvscan -s 2>/dev/null | grep -q "$dev"; }
 }
 -
-# generate the grub device map, which is a translation table between grub devicenames and linux devicenames
-# hard disks get entries, but not their partitions
-get_grub_map() {
-	inform "Generating GRUB device map...\nThis could take a while.\n\n Please be patient."
-	chroot $var_TARGET_DIR grub --no-floppy --device-map /boot/grub/device.map &>$TMP_GRUB_LOG <<EOF
-quit
-EOF
-	cp $var_TARGET_DIR/boot/grub/device.map $TMP_DEV_MAP
-}
-
-
 # for given blockdevice, echo grub notation in this form: (hd0) or (hd0,0) (if it's a partition)
 # $1 : blockdevice
 # returns 0 on success. 1 otherwise.
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index 942d312..909219e 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -120,3 +120,30 @@ target_configure_initcpio () {
 	fi
 	return $ret
 }
+
+# generate the grub device map, which is a translation table between grub devicenames and linux devicenames
+# hard disks get entries, but not their partitions
+target_grub_devicemap () {
+	inform "Generating GRUB device map...\nThis could take a while.\n\n Please be patient."
+	target_special_fs on
+	chroot $var_TARGET_DIR grub --no-floppy --device-map /boot/grub/device.map &>$TMP_GRUB_LOG <<EOF
+quit
+EOF
+	target_special_fs off
+	cp $var_TARGET_DIR/boot/grub/device.map $TMP_DEV_MAP
+}
+
+# install grub
+# $1: boot partition (grub notation)
+# $2: device to install to (grub notation)
+# $3: device to install to (linux notation)
+target_grub_install () {
+	target_special_fs on
+	chroot $var_TARGET_DIR grub --no-floppy --batch &>$TMP_GRUB_LOG <<EOF
+device $2 $3
+root $1
+setup $2
+quit
+EOF
+	target_special_fs off
+}
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 36483c1..a9362a2 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -897,7 +897,7 @@ interactive_install_bootloader () {
 }
  interactive_grub() {
-	get_grub_map
+	target_grub_devicemap
 	[ ! -f $grubmenu ] && show_warning "No grub?" "Error: Couldn't find $grubmenu.  Is GRUB installed?" && return 1
  	debug FS "starting interactive_grub"
@@ -1139,14 +1139,10 @@ interactive_grub_install () {
 	debug FS "bootdev: $bootdev"
 	debug FS "boothd: $boothd"
 -	chroot $var_TARGET_DIR grub --no-floppy --batch &>$TMP_GRUB_LOG <<EOF
-device $bootdev $boothd
-root $bootpart
-setup $bootdev
-quit
-EOF
-	cat $var_TARGET_DIR/$TMP_GRUB_LOG >$LOG
-	if grep -q "Error [0-9]*: " $var_TARGET_DIR/$TMP_GRUB_LOG; then
+	target_grub_install "$bootpart" "$bootdev" "$boothd"
+
+	cat $TMP_GRUB_LOG >$LOG
+	if grep -q "Error [0-9]*: " $TMP_GRUB_LOG; then
 		notify "Error installing GRUB. (see $LOG for output)"
 		return 1
 	fi
-- 
1.7.10.2



More information about the arch-releng mailing list