public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2008-11-27 18:36 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2008-11-27 18:36 UTC (permalink / raw
  To: gentoo-commits

vapier      08/11/27 18:36:29

  Modified:             mount-boot.eclass
  Log:
  dont send output to /dev/null ... if it worked, we would get no output and if it failed, we want to see the output

Revision  Changes    Path
1.15                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.15&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.15&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?r1=1.14&r2=1.15

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- mount-boot.eclass	2 Jun 2008 15:38:52 -0000	1.14
+++ mount-boot.eclass	27 Nov 2008 18:36:29 -0000	1.15
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.14 2008/06/02 15:38:52 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.15 2008/11/27 18:36:29 vapier Exp $
 #
 # This eclass is really only useful for bootloaders.
 #
@@ -33,7 +33,7 @@
 			einfo "Your boot partition, detected as being mounted as /boot, is read-only."
 			einfo "Remounting it in read-write mode ..."
 			einfo
-			mount -o remount,rw /boot &>/dev/null
+			mount -o remount,rw /boot
 			if [ "$?" -ne 0 ]; then
 				eerror
 				eerror "Unable to remount in rw mode. Please do it manually!"
@@ -47,7 +47,7 @@
 			einfo
 		fi
 	elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
-		mount /boot -o rw &>/dev/null
+		mount /boot -o rw
 		if [ "$?" -eq 0 ]; then
 			einfo
 			einfo "Your boot partition was not mounted as /boot, but portage"






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2009-02-27  1:53 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2009-02-27  1:53 UTC (permalink / raw
  To: gentoo-commits

vapier      09/02/27 01:53:34

  Modified:             mount-boot.eclass
  Log:
  make matching ro in the options field a bit more robust #260214 by Joe User

Revision  Changes    Path
1.16                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.16&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.16&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?r1=1.15&r2=1.16

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- mount-boot.eclass	27 Nov 2008 18:36:29 -0000	1.15
+++ mount-boot.eclass	27 Feb 2009 01:53:34 -0000	1.16
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.15 2008/11/27 18:36:29 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.16 2009/02/27 01:53:34 vapier Exp $
 #
 # This eclass is really only useful for bootloaders.
 #
@@ -25,7 +25,7 @@
 	# note that /dev/BOOT is in the Gentoo default /etc/fstab file
 	local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
 	local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
-	local proc_ro=$(awk '{ print $2, $4 }' /proc/mounts | sed -n '/\/boot/{ /[ ,]\?ro[ ,]\?/p }' )
+	local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts | sed -n '/\/boot .*,ro,/p')
 
 	if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
 		if [ -n "${proc_ro}" ]; then






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2009-10-09 20:57 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2009-10-09 20:57 UTC (permalink / raw
  To: gentoo-commits

vapier      09/10/09 20:57:08

  Modified:             mount-boot.eclass
  Log:
  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

Revision  Changes    Path
1.17                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.17&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?rev=1.17&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/mount-boot.eclass?r1=1.16&r2=1.17

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- mount-boot.eclass	27 Feb 2009 01:53:34 -0000	1.16
+++ mount-boot.eclass	9 Oct 2009 20:57:08 -0000	1.17
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.16 2009/02/27 01:53:34 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.17 2009/10/09 20:57:08 vapier Exp $
 #
 # This eclass is really only useful for bootloaders.
 #
@@ -10,14 +10,14 @@
 #
 # MAINTAINER: base-system@gentoo.org
 
-EXPORT_FUNCTIONS pkg_preinst
+EXPORT_FUNCTIONS pkg_preinst pkg_prerm
 
 mount-boot_mount_boot_partition() {
 	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
 		return
 	else
 		elog
-		elog "To avoid automounting and autoinstalling with /boot,"
+		elog "To avoid automounting and auto(un)installing with /boot,"
 		elog "just export the DONT_MOUNT_BOOT variable."
 		elog
 	fi
@@ -72,3 +72,9 @@
 mount-boot_pkg_preinst() {
 	mount-boot_mount_boot_partition
 }
+
+mount-boot_pkg_prerm() {
+	touch "${ROOT}"/boot/.keep 2>/dev/null
+	mount-boot_mount_boot_partition
+	touch "${ROOT}"/boot/.keep 2>/dev/null
+}






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2011-01-09  3:18 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2011-01-09  3:18 UTC (permalink / raw
  To: gentoo-commits

vapier      11/01/09 03:18:38

  Modified:             mount-boot.eclass
  Log:
  try to automatically remount/unmount /boot back to its pre-emerge state #348946 by Jaco Kroon

Revision  Changes    Path
1.18                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.18&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.18&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.17&r2=1.18

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- mount-boot.eclass	9 Oct 2009 20:57:08 -0000	1.17
+++ mount-boot.eclass	9 Jan 2011 03:18:38 -0000	1.18
@@ -1,6 +1,6 @@
-# Copyright 1999-2008 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.17 2009/10/09 20:57:08 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.18 2011/01/09 03:18:38 vapier Exp $
 #
 # This eclass is really only useful for bootloaders.
 #
@@ -10,7 +10,7 @@
 #
 # MAINTAINER: base-system@gentoo.org
 
-EXPORT_FUNCTIONS pkg_preinst pkg_prerm
+EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
 
 mount-boot_mount_boot_partition() {
 	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
@@ -40,6 +40,7 @@
 				eerror
 				die "Can't remount in rw mode. Please do it manually!"
 			fi
+			touch /boot/.e.remount
 		else
 			einfo
 			einfo "Your boot partition was detected as being mounted as /boot."
@@ -62,6 +63,7 @@
 			eerror
 			die "Please mount your /boot partition manually!"
 		fi
+		touch /boot/.e.mount
 	else
 		einfo
 		einfo "Assuming you do not have a separate /boot partition."
@@ -78,3 +80,31 @@
 	mount-boot_mount_boot_partition
 	touch "${ROOT}"/boot/.keep 2>/dev/null
 }
+
+mount-boot_umount_boot_partition() {
+	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
+		return
+	fi
+
+	if [ -e /boot/.e.remount ] ; then
+		einfo
+		einfo "Automatically remounting /boot as ro"
+		einfo
+		rm -f /boot/.e.remount
+		mount -o remount,ro /boot
+	elif [ -e /boot/.e.mount ] ; then
+		einfo
+		einfo "Automatically unmounting /boot"
+		einfo
+		rm -f /boot/.e.mount
+		umount /boot
+	fi
+}
+
+mount-boot_pkg_postinst() {
+	mount-boot_umount_boot_partition
+}
+
+mount-boot_pkg_postrm() {
+	mount-boot_umount_boot_partition
+}






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2015-07-30  6:53 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2015-07-30  6:53 UTC (permalink / raw
  To: gentoo-commits

vapier      15/07/30 06:53:02

  Modified:             mount-boot.eclass
  Log:
  add eclass docs

Revision  Changes    Path
1.19                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.19&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.19&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.18&r2=1.19

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- mount-boot.eclass	9 Jan 2011 03:18:38 -0000	1.18
+++ mount-boot.eclass	30 Jul 2015 06:53:02 -0000	1.19
@@ -1,14 +1,17 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.18 2011/01/09 03:18:38 vapier Exp $
-#
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.19 2015/07/30 06:53:02 vapier Exp $
+
+# @ECLASS: mount-boot.eclass
+# @MAINTAINER:
+# base-system@gentoo.org
+# @BLURB: functions for packages that install files into /boot
+# @DESCRIPTION:
 # This eclass is really only useful for bootloaders.
 #
 # If the live system has a separate /boot partition configured, then this
 # function tries to ensure that it's mounted in rw mode, exiting with an
-# error if it cant. It does nothing if /boot isn't a separate partition.
-#
-# MAINTAINER: base-system@gentoo.org
+# error if it can't. It does nothing if /boot isn't a separate partition.
 
 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
 





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2015-07-30  7:00 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2015-07-30  7:00 UTC (permalink / raw
  To: gentoo-commits

vapier      15/07/30 07:00:40

  Modified:             mount-boot.eclass
  Log:
  improve the output a bit: do a bit of word smithing, try to make it less spammy with empty lines, and make the mount cases consistent (output message before mounting)

Revision  Changes    Path
1.20                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.20&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.20&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.19&r2=1.20

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- mount-boot.eclass	30 Jul 2015 06:53:02 -0000	1.19
+++ mount-boot.eclass	30 Jul 2015 07:00:40 -0000	1.20
@@ -1,6 +1,6 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.19 2015/07/30 06:53:02 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.20 2015/07/30 07:00:40 vapier Exp $
 
 # @ECLASS: mount-boot.eclass
 # @MAINTAINER:
@@ -19,10 +19,8 @@
 	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
 		return
 	else
-		elog
 		elog "To avoid automounting and auto(un)installing with /boot,"
 		elog "just export the DONT_MOUNT_BOOT variable."
-		elog
 	fi
 
 	# note that /dev/BOOT is in the Gentoo default /etc/fstab file
@@ -32,45 +30,37 @@
 
 	if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
 		if [ -n "${proc_ro}" ]; then
-			einfo
-			einfo "Your boot partition, detected as being mounted as /boot, is read-only."
-			einfo "Remounting it in read-write mode ..."
-			einfo
+			echo
+			einfo "Your boot partition, detected as being mounted at /boot, is read-only."
+			einfo "It will be remounted in read-write mode temporarily."
 			mount -o remount,rw /boot
 			if [ "$?" -ne 0 ]; then
-				eerror
+				echo
 				eerror "Unable to remount in rw mode. Please do it manually!"
-				eerror
 				die "Can't remount in rw mode. Please do it manually!"
 			fi
 			touch /boot/.e.remount
 		else
-			einfo
-			einfo "Your boot partition was detected as being mounted as /boot."
+			echo
+			einfo "Your boot partition was detected as being mounted at /boot."
 			einfo "Files will be installed there for ${PN} to function correctly."
-			einfo
 		fi
 	elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
+		echo
+		einfo "Your boot partition was not mounted at /boot, so it will be automounted for you."
+		einfo "Files will be installed there for ${PN} to function correctly."
 		mount /boot -o rw
-		if [ "$?" -eq 0 ]; then
-			einfo
-			einfo "Your boot partition was not mounted as /boot, but portage"
-			einfo "was able to mount it without additional intervention."
-			einfo "Files will be installed there for ${PN} to function correctly."
-			einfo
-		else
-			eerror
+		if [ "$?" -ne 0 ]; then
+			echo
 			eerror "Cannot automatically mount your /boot partition."
 			eerror "Your boot partition has to be mounted rw before the installation"
 			eerror "can continue. ${PN} needs to install important files there."
-			eerror
 			die "Please mount your /boot partition manually!"
 		fi
 		touch /boot/.e.mount
 	else
-		einfo
+		echo
 		einfo "Assuming you do not have a separate /boot partition."
-		einfo
 	fi
 }
 
@@ -90,15 +80,11 @@
 	fi
 
 	if [ -e /boot/.e.remount ] ; then
-		einfo
-		einfo "Automatically remounting /boot as ro"
-		einfo
+		einfo "Automatically remounting /boot as ro as it was previously."
 		rm -f /boot/.e.remount
 		mount -o remount,ro /boot
 	elif [ -e /boot/.e.mount ] ; then
-		einfo
-		einfo "Automatically unmounting /boot"
-		einfo
+		einfo "Automatically unmounting /boot as it was previously."
 		rm -f /boot/.e.mount
 		umount /boot
 	fi





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2015-07-30  7:03 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2015-07-30  7:03 UTC (permalink / raw
  To: gentoo-commits

vapier      15/07/30 07:03:14

  Modified:             mount-boot.eclass
  Log:
  do not attempt to mount /boot when installing packages into a different root #532264 by Michał Górny

Revision  Changes    Path
1.21                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.21&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.21&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.20&r2=1.21

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- mount-boot.eclass	30 Jul 2015 07:00:40 -0000	1.20
+++ mount-boot.eclass	30 Jul 2015 07:03:14 -0000	1.21
@@ -1,6 +1,6 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.20 2015/07/30 07:00:40 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.21 2015/07/30 07:03:14 vapier Exp $
 
 # @ECLASS: mount-boot.eclass
 # @MAINTAINER:
@@ -16,6 +16,11 @@
 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
 
 mount-boot_mount_boot_partition() {
+	# Since this eclass only deals with /boot, skip things when ROOT is active.
+	if [[ "${ROOT:-/}" != "/" ]] ; then
+		return
+	fi
+
 	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
 		return
 	else





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2015-07-30  7:14 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2015-07-30  7:14 UTC (permalink / raw
  To: gentoo-commits

vapier      15/07/30 07:14:49

  Modified:             mount-boot.eclass
  Log:
  add a helper function to track all the ways we disable the logic so output/behavior is consistent

Revision  Changes    Path
1.22                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.22&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.22&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.21&r2=1.22

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- mount-boot.eclass	30 Jul 2015 07:03:14 -0000	1.21
+++ mount-boot.eclass	30 Jul 2015 07:14:49 -0000	1.22
@@ -1,6 +1,6 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.21 2015/07/30 07:03:14 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.22 2015/07/30 07:14:49 vapier Exp $
 
 # @ECLASS: mount-boot.eclass
 # @MAINTAINER:
@@ -15,19 +15,38 @@
 
 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
 
-mount-boot_mount_boot_partition() {
+# @FUNCTION: mount-boot_disabled
+# @INTERNAL
+# @DESCRIPTION:
+# Detect whether the current environment/build settings are such that we do not
+# want to mess with any mounts.
+mount-boot_is_disabled() {
 	# Since this eclass only deals with /boot, skip things when ROOT is active.
 	if [[ "${ROOT:-/}" != "/" ]] ; then
-		return
+		return 0
+	fi
+
+	# If we're only building a package, then there's no need to check things.
+	if [[ "${MERGE_TYPE}" == "buildonly" ]] ; then
+		return 0
 	fi
 
+	# The user wants us to leave things be.
 	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
-		return
-	else
-		elog "To avoid automounting and auto(un)installing with /boot,"
-		elog "just export the DONT_MOUNT_BOOT variable."
+		return 0
 	fi
 
+	# OK, we want to handle things ourselves.
+	return 1
+}
+
+mount-boot_mount_boot_partition() {
+	# Get out fast if possible.
+	mount-boot_is_disabled && return 0
+
+	elog "To avoid automounting and auto(un)installing with /boot,"
+	elog "just export the DONT_MOUNT_BOOT variable."
+
 	# note that /dev/BOOT is in the Gentoo default /etc/fstab file
 	local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
 	local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
@@ -80,9 +99,8 @@
 }
 
 mount-boot_umount_boot_partition() {
-	if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
-		return
-	fi
+	# Get out fast if possible.
+	mount-boot_is_disabled && return 0
 
 	if [ -e /boot/.e.remount ] ; then
 		einfo "Automatically remounting /boot as ro as it was previously."





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass
@ 2015-07-30  7:16 Mike Frysinger (vapier)
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger (vapier) @ 2015-07-30  7:16 UTC (permalink / raw
  To: gentoo-commits

vapier      15/07/30 07:16:19

  Modified:             mount-boot.eclass
  Log:
  add support for pkg_pretend and split apart the testing/message logic from the actual mount logic so we can provide better details up front #532264 by Ulrich Müller

Revision  Changes    Path
1.23                 eclass/mount-boot.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.23&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?rev=1.23&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mount-boot.eclass?r1=1.22&r2=1.23

Index: mount-boot.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- mount-boot.eclass	30 Jul 2015 07:14:49 -0000	1.22
+++ mount-boot.eclass	30 Jul 2015 07:16:19 -0000	1.23
@@ -1,6 +1,6 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.22 2015/07/30 07:14:49 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.23 2015/07/30 07:16:19 vapier Exp $
 
 # @ECLASS: mount-boot.eclass
 # @MAINTAINER:
@@ -13,7 +13,7 @@
 # function tries to ensure that it's mounted in rw mode, exiting with an
 # error if it can't. It does nothing if /boot isn't a separate partition.
 
-EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_prerm pkg_postrm
+EXPORT_FUNCTIONS pkg_pretend pkg_preinst pkg_postinst pkg_prerm pkg_postrm
 
 # @FUNCTION: mount-boot_disabled
 # @INTERNAL
@@ -40,41 +40,73 @@
 	return 1
 }
 
-mount-boot_mount_boot_partition() {
+# @FUNCTION: mount-boot_check_status
+# @INTERNAL
+# @DESCRIPTION:
+# Figure out what kind of work we need to do in order to have /boot be sane.
+# Return values are:
+# 0 - Do nothing at all!
+# 1 - It's mounted, but is currently ro, so need to remount rw.
+# 2 - It's not mounted, so need to mount it rw.
+mount-boot_check_status() {
 	# Get out fast if possible.
 	mount-boot_is_disabled && return 0
 
-	elog "To avoid automounting and auto(un)installing with /boot,"
-	elog "just export the DONT_MOUNT_BOOT variable."
-
 	# note that /dev/BOOT is in the Gentoo default /etc/fstab file
 	local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' /etc/fstab | egrep "^/boot$" )
 	local procstate=$(awk '$2 ~ /^\/boot$/ {print $2}' /proc/mounts)
 	local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts | sed -n '/\/boot .*,ro,/p')
 
-	if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
-		if [ -n "${proc_ro}" ]; then
+	if [ -n "${fstabstate}" ] && [ -n "${procstate}" ] ; then
+		if [ -n "${proc_ro}" ] ; then
 			echo
 			einfo "Your boot partition, detected as being mounted at /boot, is read-only."
 			einfo "It will be remounted in read-write mode temporarily."
-			mount -o remount,rw /boot
-			if [ "$?" -ne 0 ]; then
-				echo
-				eerror "Unable to remount in rw mode. Please do it manually!"
-				die "Can't remount in rw mode. Please do it manually!"
-			fi
-			touch /boot/.e.remount
+			return 1
 		else
 			echo
 			einfo "Your boot partition was detected as being mounted at /boot."
 			einfo "Files will be installed there for ${PN} to function correctly."
+			return 0
 		fi
-	elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
+	elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ] ; then
 		echo
 		einfo "Your boot partition was not mounted at /boot, so it will be automounted for you."
 		einfo "Files will be installed there for ${PN} to function correctly."
+		return 2
+	else
+		echo
+		einfo "Assuming you do not have a separate /boot partition."
+		return 0
+	fi
+}
+
+mount-boot_pkg_pretend() {
+	# Get out fast if possible.
+	mount-boot_is_disabled && return 0
+
+	elog "To avoid automounting and auto(un)installing with /boot,"
+	elog "just export the DONT_MOUNT_BOOT variable."
+	mount-boot_check_status
+}
+
+mount-boot_mount_boot_partition() {
+	mount-boot_check_status
+	case $? in
+	0)	# Nothing to do.
+		;;
+	1)	# Remount it rw.
+		mount -o remount,rw /boot
+		if [ $? -ne 0 ] ; then
+			echo
+			eerror "Unable to remount in rw mode. Please do it manually!"
+			die "Can't remount in rw mode. Please do it manually!"
+		fi
+		touch /boot/.e.remount
+		;;
+	2)	# Mount it rw.
 		mount /boot -o rw
-		if [ "$?" -ne 0 ]; then
+		if [ $? -ne 0 ] ; then
 			echo
 			eerror "Cannot automatically mount your /boot partition."
 			eerror "Your boot partition has to be mounted rw before the installation"
@@ -82,13 +114,16 @@
 			die "Please mount your /boot partition manually!"
 		fi
 		touch /boot/.e.mount
-	else
-		echo
-		einfo "Assuming you do not have a separate /boot partition."
-	fi
+		;;
+	esac
 }
 
 mount-boot_pkg_preinst() {
+	# Handle older EAPIs.
+	case ${EAPI:-0} in
+	[0-3]) mount-boot_pkg_pretend ;;
+	esac
+
 	mount-boot_mount_boot_partition
 }
 





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-07-30  7:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-09  3:18 [gentoo-commits] gentoo-x86 commit in eclass: mount-boot.eclass Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2015-07-30  7:16 Mike Frysinger (vapier)
2015-07-30  7:14 Mike Frysinger (vapier)
2015-07-30  7:03 Mike Frysinger (vapier)
2015-07-30  7:00 Mike Frysinger (vapier)
2015-07-30  6:53 Mike Frysinger (vapier)
2009-10-09 20:57 Mike Frysinger (vapier)
2009-02-27  1:53 Mike Frysinger (vapier)
2008-11-27 18:36 Mike Frysinger (vapier)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox