2010-11-12 19:49:50 +01:00
|
|
|
# Copyright 1999-2008 Gentoo Foundation
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
# $Header: /var/cvsroot/gentoo-x86/eclass/mount-efi.eclass,v 1.17 2009/10/09 20:57:08 vapier Exp $
|
|
|
|
#
|
|
|
|
# This eclass is really only useful for efi bootloaders.
|
|
|
|
#
|
|
|
|
# If the live system has a separate /efi 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 /efi isn't a separate partition.
|
|
|
|
#
|
|
|
|
# MAINTAINER: base-system@gentoo.org
|
|
|
|
|
2010-11-12 20:23:59 +01:00
|
|
|
inherit mount-boot
|
|
|
|
|
2010-11-12 19:49:50 +01:00
|
|
|
EXPORT_FUNCTIONS pkg_preinst pkg_prerm
|
|
|
|
|
|
|
|
mount-efi_mount_efi_partition() {
|
|
|
|
if [[ -n ${DONT_MOUNT_EFI} ]] ; then
|
|
|
|
return
|
|
|
|
else
|
|
|
|
elog
|
2010-11-12 20:23:59 +01:00
|
|
|
elog "To avoid automounting and auto(un)installing with /boot/efi,"
|
2010-11-12 19:49:50 +01:00
|
|
|
elog "just export the DONT_MOUNT_EFI variable."
|
|
|
|
elog
|
|
|
|
fi
|
|
|
|
|
|
|
|
# note that /dev/EFI is in the Gentoo default /etc/fstab file
|
2010-11-12 20:23:59 +01:00
|
|
|
local fstabstate=$(awk '!/^#|^[[:blank:]]+#|^\/dev\/EFI/ {print $2}' /etc/fstab | egrep "^/boot/efi$" )
|
|
|
|
local procstate=$(awk '$2 ~ /^\/boot\/efi$/ {print $2}' /proc/mounts)
|
|
|
|
local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts | sed -n '/\/boot\/efi .*,ro,/p')
|
2010-11-12 19:49:50 +01:00
|
|
|
|
|
|
|
if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
|
|
|
|
if [ -n "${proc_ro}" ]; then
|
|
|
|
einfo
|
2010-11-12 20:23:59 +01:00
|
|
|
einfo "Your efi partition, detected as being mounted as /boot/efi, is read-only."
|
2010-11-12 19:49:50 +01:00
|
|
|
einfo "Remounting it in read-write mode ..."
|
|
|
|
einfo
|
2010-11-12 20:23:59 +01:00
|
|
|
mount -o remount,rw /boot/efi
|
2010-11-12 19:49:50 +01:00
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
eerror
|
|
|
|
eerror "Unable to remount in rw mode. Please do it manually!"
|
|
|
|
eerror
|
|
|
|
die "Can't remount in rw mode. Please do it manually!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
einfo
|
2010-11-12 20:23:59 +01:00
|
|
|
einfo "Your efi partition was detected as being mounted as /boot/efi."
|
2010-11-12 19:49:50 +01:00
|
|
|
einfo "Files will be installed there for ${PN} to function correctly."
|
|
|
|
einfo
|
|
|
|
fi
|
|
|
|
elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
|
2010-11-12 20:23:59 +01:00
|
|
|
mount /boot/efi -o rw
|
2010-11-12 19:49:50 +01:00
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
einfo
|
2010-11-12 20:23:59 +01:00
|
|
|
einfo "Your efi partition was not mounted as /boot/efi, but portage"
|
2010-11-12 19:49:50 +01:00
|
|
|
einfo "was able to mount it without additional intervention."
|
|
|
|
einfo "Files will be installed there for ${PN} to function correctly."
|
|
|
|
einfo
|
|
|
|
else
|
|
|
|
eerror
|
2010-11-12 20:23:59 +01:00
|
|
|
eerror "Cannot automatically mount your /boot/efi partition."
|
2010-11-12 19:49:50 +01:00
|
|
|
eerror "Your efi partition has to be mounted rw before the installation"
|
|
|
|
eerror "can continue. ${PN} needs to install important files there."
|
|
|
|
eerror
|
2010-11-12 20:23:59 +01:00
|
|
|
die "Please mount your /boot/efi partition manually!"
|
2010-11-12 19:49:50 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
einfo
|
2010-11-12 20:23:59 +01:00
|
|
|
einfo "Assuming you do not have a separate /boot/efi partition."
|
2010-11-12 19:49:50 +01:00
|
|
|
einfo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
mount-efi_pkg_preinst() {
|
2010-11-12 20:23:59 +01:00
|
|
|
mount-boot_pkg_preinst
|
2010-11-12 19:49:50 +01:00
|
|
|
mount-efi_mount_efi_partition
|
|
|
|
}
|
|
|
|
|
|
|
|
mount-efi_pkg_prerm() {
|
2010-11-12 20:23:59 +01:00
|
|
|
mount-boot_pkg_prerm
|
|
|
|
touch "${ROOT}"/boot/efi/.keep 2>/dev/null
|
2010-11-12 19:49:50 +01:00
|
|
|
mount-efi_mount_efi_partition
|
2010-11-12 20:23:59 +01:00
|
|
|
touch "${ROOT}"/boot/efi/.keep 2>/dev/null
|
2010-11-12 19:49:50 +01:00
|
|
|
}
|