Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
Date: Thu, 30 Jul 2015 07:14:57
Message-Id: 20150730071449.8D3FD111@oystercatcher.gentoo.org
1 vapier 15/07/30 07:14:49
2
3 Modified: mount-boot.eclass
4 Log:
5 add a helper function to track all the ways we disable the logic so output/behavior is consistent
6
7 Revision Changes Path
8 1.22 eclass/mount-boot.eclass
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.22&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.22&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.21&r2=1.22
13
14 Index: mount-boot.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
17 retrieving revision 1.21
18 retrieving revision 1.22
19 diff -u -r1.21 -r1.22
20 --- mount-boot.eclass 30 Jul 2015 07:03:14 -0000 1.21
21 +++ mount-boot.eclass 30 Jul 2015 07:14:49 -0000 1.22
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2015 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.21 2015/07/30 07:03:14 vapier Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.22 2015/07/30 07:14:49 vapier Exp $
27
28 # @ECLASS: mount-boot.eclass
29 # @MAINTAINER:
30 @@ -15,19 +15,38 @@
31
32 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
33
34 -mount-boot_mount_boot_partition() {
35 +# @FUNCTION: mount-boot_disabled
36 +# @INTERNAL
37 +# @DESCRIPTION:
38 +# Detect whether the current environment/build settings are such that we do not
39 +# want to mess with any mounts.
40 +mount-boot_is_disabled() {
41 # Since this eclass only deals with /boot, skip things when ROOT is active.
42 if [[ "${ROOT:-/}" != "/" ]] ; then
43 - return
44 + return 0
45 + fi
46 +
47 + # If we're only building a package, then there's no need to check things.
48 + if [[ "${MERGE_TYPE}" == "buildonly" ]] ; then
49 + return 0
50 fi
51
52 + # The user wants us to leave things be.
53 if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
54 - return
55 - else
56 - elog "To avoid automounting and auto(un)installing with /boot,"
57 - elog "just export the DONT_MOUNT_BOOT variable."
58 + return 0
59 fi
60
61 + # OK, we want to handle things ourselves.
62 + return 1
63 +}
64 +
65 +mount-boot_mount_boot_partition() {
66 + # Get out fast if possible.
67 + mount-boot_is_disabled && return 0
68 +
69 + elog "To avoid automounting and auto(un)installing with /boot,"
70 + elog "just export the DONT_MOUNT_BOOT variable."
71 +
72 # note that /dev/BOOT is in the Gentoo default /etc/fstab file
73 local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
74 local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
75 @@ -80,9 +99,8 @@
76 }
77
78 mount-boot_umount_boot_partition() {
79 - if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
80 - return
81 - fi
82 + # Get out fast if possible.
83 + mount-boot_is_disabled && return 0
84
85 if [ -e /boot/.e.remount ] ; then
86 einfo "Automatically remounting /boot as ro as it was previously."