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