/[gentoo-x86]/eclass/mount-boot.eclass
Gentoo

Diff of /eclass/mount-boot.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.1.1

  ViewVC Help
Powered by ViewVC 1.1.20