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