summaryrefslogtreecommitdiff
blob: be747b9c1d2d2b80b116c74be94f7dfa3f660fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mount-boot.eclass,v 1.5 2002/10/25 19:55:52 vapier Exp $

ECLASS=mount-boot
INHERITED="$INHERITED $ECLASS"

mount-boot_pkg_setup(){

[ "${ROOT}" != "/" ] && return 0

	local fstabstate="$(cat /etc/fstab | awk '!/^#|^[[:blank:]]+#|^\/dev\/BOOT/ {print $2}' | egrep "/boot" )"
	local procstate="$(cat /proc/mounts | awk '{print $2}' | egrep "/boot" )"
	local proc_ro="$(cat /proc/mounts | awk '{ print $2, $4 }' | sed -n '/\/boot/{ /[ ,]\?ro[ ,]\?/p }' )"

	if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]; then
		if [ -n "${proc_ro}" ]; then
			echo
			einfo "Your boot partition, detected as being mounted as /boot, is read-only"
			einfo "Remounting it in read-write mode"
			sleep 1; echo -ne "\a"; sleep 1; echo -e "\a"
			mount -o remount,rw /boot &>/dev/null
			if [ "$?" -ne 0 ]; then
				eerror; eerror "Unable to remount in rw mode. Please do it manually" ; eerror
				sleep 1; echo -ne "\a"; sleep 1; echo -e "\a"
				die "Can't remount in rw mode. Please do it manually"
			fi
		else
			echo
			einfo "Your boot partition was detected as being mounted as /boot."
			einfo "Files will be installed there for ${PN} to function correctly."
			sleep 1; echo -ne "\a"; sleep 1; echo -e "\a"
		fi
	elif [ -n "${fstabstate}" ] && [ -z "${procstate}" ]; then
		mount /boot -o rw &>/dev/null
		if [ "$?" -eq 0 ]; then
			echo
			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."
			sleep 1; echo -ne "\a"; sleep 1; echo -e "\a"
		else
			echo
			eerror "Cannot mount automatically your boot partition."
			eerror "Your boot partition has to be mounted on /boot before the installation"
			eerror "can continue. ${PN} needs to install important files there."
			sleep 1; echo -ne "\a"; sleep 1; echo -e "\a"
			die "Please mount your /boot partition."
		fi
	else
		echo
		einfo "Assuming you do not have a separate /boot partition."
		sleep 1; echo -ne "\a"; sleep 1; echo -e "\a";
	fi
}

EXPORT_FUNCTIONS pkg_setup