| 1 |
chriswhite |
1.1.1.1 |
# Copyright 1999-2004 Gentoo Foundation
|
| 2 |
|
|
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
|
|
# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.11 2005/07/06 20:23:20 agriffis Exp $
|
| 4 |
|
|
#
|
| 5 |
|
|
# If the live system has a separate /boot partition configured, then this
|
| 6 |
|
|
# function tries to ensure that it's mounted in rw mode, exiting with an
|
| 7 |
|
|
# error if it cant. It does nothing if /boot isn't a separate partition.
|
| 8 |
|
|
|
| 9 |
|
|
|
| 10 |
|
|
EXPORT_FUNCTIONS pkg_preinst
|
| 11 |
|
|
|
| 12 |
|
|
mount-boot_mount_boot_partition(){
|
| 13 |
|
|
# note that /dev/BOOT is in the Gentoo default /etc/fstab file
|
| 14 |
|
|
local fstabstate="$(cat /etc/fstab | awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' | egrep "^/boot$" )"
|
| 15 |
|
|
local procstate="$(cat /proc/mounts | awk '{print $2}' | egrep "^/boot$" )"
|
| 16 |
|
|
local proc_ro="$(cat /proc/mounts | awk '{ print $2, $4 }' | sed -n '/\/boot/{ /[ ,]\?ro[ ,]\?/p }' )"
|
| 17 |
woodchip |
1.1 |
|
| 18 |
|
|
if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
|
| 19 |
chriswhite |
1.1.1.1 |
if [ -n "${proc_ro}" ]; then
|
| 20 |
|
|
einfo
|
| 21 |
|
|
einfo "Your boot partition, detected as being mounted as /boot, is read-only."
|
| 22 |
|
|
einfo "Remounting it in read-write mode ..."
|
| 23 |
|
|
einfo
|
| 24 |
woodchip |
1.1 |
mount -o remount,rw /boot &>/dev/null
|
| 25 |
|
|
if [ "$?" -ne 0 ]; then
|
| 26 |
chriswhite |
1.1.1.1 |
eerror
|
| 27 |
|
|
eerror "Unable to remount in rw mode. Please do it manually!"
|
| 28 |
|
|
eerror
|
| 29 |
|
|
die "Can't remount in rw mode. Please do it manually!"
|
| 30 |
woodchip |
1.1 |
fi
|
| 31 |
|
|
else
|
| 32 |
chriswhite |
1.1.1.1 |
einfo
|
| 33 |
woodchip |
1.1 |
einfo "Your boot partition was detected as being mounted as /boot."
|
| 34 |
|
|
einfo "Files will be installed there for ${PN} to function correctly."
|
| 35 |
chriswhite |
1.1.1.1 |
einfo
|
| 36 |
woodchip |
1.1 |
fi
|
| 37 |
|
|
elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
|
| 38 |
chriswhite |
1.1.1.1 |
mount /boot -o rw &>/dev/null
|
| 39 |
woodchip |
1.1 |
if [ "$?" -eq 0 ]; then
|
| 40 |
chriswhite |
1.1.1.1 |
einfo
|
| 41 |
|
|
einfo "Your boot partition was not mounted as /boot, but portage"
|
| 42 |
|
|
einfo "was able to mount it without additional intervention."
|
| 43 |
woodchip |
1.1 |
einfo "Files will be installed there for ${PN} to function correctly."
|
| 44 |
chriswhite |
1.1.1.1 |
einfo
|
| 45 |
woodchip |
1.1 |
else
|
| 46 |
chriswhite |
1.1.1.1 |
eerror
|
| 47 |
|
|
eerror "Cannot automatically mount your /boot partition."
|
| 48 |
|
|
eerror "Your boot partition has to be mounted rw before the installation"
|
| 49 |
woodchip |
1.1 |
eerror "can continue. ${PN} needs to install important files there."
|
| 50 |
chriswhite |
1.1.1.1 |
eerror
|
| 51 |
|
|
die "Please mount your /boot partition manually!"
|
| 52 |
woodchip |
1.1 |
fi
|
| 53 |
|
|
else
|
| 54 |
chriswhite |
1.1.1.1 |
einfo
|
| 55 |
woodchip |
1.1 |
einfo "Assuming you do not have a separate /boot partition."
|
| 56 |
chriswhite |
1.1.1.1 |
einfo
|
| 57 |
woodchip |
1.1 |
fi
|
| 58 |
|
|
}
|
| 59 |
|
|
|
| 60 |
chriswhite |
1.1.1.1 |
mount-boot_pkg_preinst(){
|
| 61 |
|
|
mount-boot_mount_boot_partition
|
| 62 |
|
|
}
|