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

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20