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

Contents of /eclass/mount-boot.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download)
Fri Oct 9 20:57:08 2009 UTC (5 years, 2 months ago) by vapier
Branch: MAIN
Changes since 1.16: +9 -3 lines
fix from Lars Wendler (Polynomial-C) to make sure /boot has a .keep file so portage doesnt go deleting the "empty" /boot mount point #274130 by Jochums Johannes

1 vapier 1.14 # Copyright 1999-2008 Gentoo Foundation
2 vapier 1.5 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.17 # $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.16 2009/02/27 01:53:34 vapier Exp $
4 vapier 1.12 #
5     # This eclass is really only useful for bootloaders.
6 vapier 1.8 #
7     # If the live system has a separate /boot partition configured, then this
8     # function tries to ensure that it's mounted in rw mode, exiting with an
9     # error if it cant. It does nothing if /boot isn't a separate partition.
10 vapier 1.12 #
11     # MAINTAINER: base-system@gentoo.org
12 woodchip 1.1
13 vapier 1.17 EXPORT_FUNCTIONS pkg_preinst pkg_prerm
14 woodchip 1.1
15 vapier 1.13 mount-boot_mount_boot_partition() {
16     if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
17     return
18     else
19 vapier 1.14 elog
20 vapier 1.17 elog "To avoid automounting and auto(un)installing with /boot,"
21 vapier 1.14 elog "just export the DONT_MOUNT_BOOT variable."
22     elog
23 vapier 1.13 fi
24    
25 woodchip 1.7 # note that /dev/BOOT is in the Gentoo default /etc/fstab file
26 vapier 1.13 local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
27     local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
28 vapier 1.16 local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts | sed -n '/\/boot .*,ro,/p')
29 woodchip 1.1
30     if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
31 woodchip 1.3 if [ -n "${proc_ro}" ]; then
32 woodchip 1.7 einfo
33     einfo "Your boot partition, detected as being mounted as /boot, is read-only."
34     einfo "Remounting it in read-write mode ..."
35     einfo
36 vapier 1.15 mount -o remount,rw /boot
37 woodchip 1.1 if [ "$?" -ne 0 ]; then
38 woodchip 1.7 eerror
39     eerror "Unable to remount in rw mode. Please do it manually!"
40     eerror
41     die "Can't remount in rw mode. Please do it manually!"
42 woodchip 1.1 fi
43     else
44 woodchip 1.7 einfo
45 woodchip 1.1 einfo "Your boot partition was detected as being mounted as /boot."
46     einfo "Files will be installed there for ${PN} to function correctly."
47 woodchip 1.7 einfo
48 woodchip 1.1 fi
49     elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
50 vapier 1.15 mount /boot -o rw
51 woodchip 1.1 if [ "$?" -eq 0 ]; then
52 woodchip 1.7 einfo
53 woodchip 1.3 einfo "Your boot partition was not mounted as /boot, but portage"
54     einfo "was able to mount it without additional intervention."
55 woodchip 1.1 einfo "Files will be installed there for ${PN} to function correctly."
56 woodchip 1.7 einfo
57 woodchip 1.1 else
58 woodchip 1.7 eerror
59     eerror "Cannot automatically mount your /boot partition."
60     eerror "Your boot partition has to be mounted rw before the installation"
61 woodchip 1.1 eerror "can continue. ${PN} needs to install important files there."
62 woodchip 1.7 eerror
63     die "Please mount your /boot partition manually!"
64 woodchip 1.1 fi
65     else
66 woodchip 1.7 einfo
67 woodchip 1.1 einfo "Assuming you do not have a separate /boot partition."
68 woodchip 1.7 einfo
69 woodchip 1.1 fi
70     }
71    
72 vapier 1.13 mount-boot_pkg_preinst() {
73 woodchip 1.7 mount-boot_mount_boot_partition
74     }
75 vapier 1.17
76     mount-boot_pkg_prerm() {
77     touch "${ROOT}"/boot/.keep 2>/dev/null
78     mount-boot_mount_boot_partition
79     touch "${ROOT}"/boot/.keep 2>/dev/null
80     }

  ViewVC Help
Powered by ViewVC 1.1.20