/[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.1.1 Revision 1.18
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
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.1.1.1 2005/11/30 09:59:20 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.18 2011/01/09 03:18:38 vapier Exp $
4#
5# This eclass is really only useful for bootloaders.
4# 6#
5# If the live system has a separate /boot partition configured, then this 7# 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 8# 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. 9# error if it cant. It does nothing if /boot isn't a separate partition.
10#
11# MAINTAINER: base-system@gentoo.org
8 12
13EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
9 14
10EXPORT_FUNCTIONS pkg_preinst 15mount-boot_mount_boot_partition() {
16 if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
17 return
18 else
19 elog
20 elog "To avoid automounting and auto(un)installing with /boot,"
21 elog "just export the DONT_MOUNT_BOOT variable."
22 elog
23 fi
11 24
12mount-boot_mount_boot_partition(){
13 # note that /dev/BOOT is in the Gentoo default /etc/fstab file 25 # note that /dev/BOOT is in the Gentoo default /etc/fstab file
14 local fstabstate="$(cat /etc/fstab | awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' | egrep "^/boot$" )" 26 local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
15 local procstate="$(cat /proc/mounts | awk '{print $2}' | egrep "^/boot$" )" 27 local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
16 local proc_ro="$(cat /proc/mounts | awk '{ print $2, $4 }' | sed -n '/\/boot/{ /[ ,]\?ro[ ,]\?/p }' )" 28 local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts | sed -n '/\/boot .*,ro,/p')
17 29
18 if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then 30 if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
19 if [ -n "${proc_ro}" ]; then 31 if [ -n "${proc_ro}" ]; then
20 einfo 32 einfo
21 einfo "Your boot partition, detected as being mounted as /boot, is read-only." 33 einfo "Your boot partition, detected as being mounted as /boot, is read-only."
22 einfo "Remounting it in read-write mode ..." 34 einfo "Remounting it in read-write mode ..."
23 einfo 35 einfo
24 mount -o remount,rw /boot &>/dev/null 36 mount -o remount,rw /boot
25 if [ "$?" -ne 0 ]; then 37 if [ "$?" -ne 0 ]; then
26 eerror 38 eerror
27 eerror "Unable to remount in rw mode. Please do it manually!" 39 eerror "Unable to remount in rw mode. Please do it manually!"
28 eerror 40 eerror
29 die "Can't remount in rw mode. Please do it manually!" 41 die "Can't remount in rw mode. Please do it manually!"
30 fi 42 fi
43 touch /boot/.e.remount
31 else 44 else
32 einfo 45 einfo
33 einfo "Your boot partition was detected as being mounted as /boot." 46 einfo "Your boot partition was detected as being mounted as /boot."
34 einfo "Files will be installed there for ${PN} to function correctly." 47 einfo "Files will be installed there for ${PN} to function correctly."
35 einfo 48 einfo
36 fi 49 fi
37 elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then 50 elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
38 mount /boot -o rw &>/dev/null 51 mount /boot -o rw
39 if [ "$?" -eq 0 ]; then 52 if [ "$?" -eq 0 ]; then
40 einfo 53 einfo
41 einfo "Your boot partition was not mounted as /boot, but portage" 54 einfo "Your boot partition was not mounted as /boot, but portage"
42 einfo "was able to mount it without additional intervention." 55 einfo "was able to mount it without additional intervention."
43 einfo "Files will be installed there for ${PN} to function correctly." 56 einfo "Files will be installed there for ${PN} to function correctly."
48 eerror "Your boot partition has to be mounted rw before the installation" 61 eerror "Your boot partition has to be mounted rw before the installation"
49 eerror "can continue. ${PN} needs to install important files there." 62 eerror "can continue. ${PN} needs to install important files there."
50 eerror 63 eerror
51 die "Please mount your /boot partition manually!" 64 die "Please mount your /boot partition manually!"
52 fi 65 fi
66 touch /boot/.e.mount
53 else 67 else
54 einfo 68 einfo
55 einfo "Assuming you do not have a separate /boot partition." 69 einfo "Assuming you do not have a separate /boot partition."
56 einfo 70 einfo
57 fi 71 fi
58} 72}
59 73
60mount-boot_pkg_preinst(){ 74mount-boot_pkg_preinst() {
61 mount-boot_mount_boot_partition 75 mount-boot_mount_boot_partition
62} 76}
77
78mount-boot_pkg_prerm() {
79 touch "${ROOT}"/boot/.keep 2>/dev/null
80 mount-boot_mount_boot_partition
81 touch "${ROOT}"/boot/.keep 2>/dev/null
82}
83
84mount-boot_umount_boot_partition() {
85 if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
86 return
87 fi
88
89 if [ -e /boot/.e.remount ] ; then
90 einfo
91 einfo "Automatically remounting /boot as ro"
92 einfo
93 rm -f /boot/.e.remount
94 mount -o remount,ro /boot
95 elif [ -e /boot/.e.mount ] ; then
96 einfo
97 einfo "Automatically unmounting /boot"
98 einfo
99 rm -f /boot/.e.mount
100 umount /boot
101 fi
102}
103
104mount-boot_pkg_postinst() {
105 mount-boot_umount_boot_partition
106}
107
108mount-boot_pkg_postrm() {
109 mount-boot_umount_boot_partition
110}

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

  ViewVC Help
Powered by ViewVC 1.1.20