summaryrefslogtreecommitdiff
blob: 7767d6a6bb8fb73463de99a11840b8ae526c2271 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

inherit eutils

DESCRIPTION="rEFInd Extensible Firmware Interface boot manager binary install"
HOMEPAGE="http://www.rodsbooks.com/refind/index.html"
SRC_URI="mirror://sourceforge/refind/${PV}/${P}.zip"
#MERGE_TYPE="binary"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~ia64 ~x86"
IUSE=""

RDEPEND="sys-boot/efibootmgr"
DEPEND=""

PROVIDE="virtual/bootloader"

src_install() {
	einfo "Installing rEFInd on Linux"
	# FindLinuxESP
	EspLine=$(df /boot/efi | grep boot)
	InstallPart=$(echo $EspLine | cut -d " " -f 6)
	EspFilesystem=$(grep $InstallPart /etc/mtab | cut -d " " -f 3)
	if [[ $EspFilesystem != 'vfat' ]] ; then
		eerror "/boot/efi doesn't seem to be on a VFAT filesystem. The ESP must be mounted"
		eerror "at /boot or /boot/efi and it must be VFAT! Aborting!"
		die "Unable to find a VFAT file system at /boot or /boot/efi."
	fi
	einfo "ESP was found at $InstallPart using $EspFilesystem"

	# InstallOnLinux
	CpuType=$(uname -m)
	if [[ $CpuType == 'x86_64' ]] ; then
		Platform="EFI64"
	elif [[ $CpuType == 'i386' || $CpuType == 'i486' || $CpuType == 'i586' || $CpuType == 'i686' ]] ; then
		Platform="EFI32"
		ewarn "CAUTION: This Linux installation uses a 32-bit kernel. 32-bit EFI-based"
		ewarn "computers are VERY RARE. If you've installed a 32-bit version of Linux"
		ewarn "on a 64-bit computer, you should manually install the 64-bit version of"
		ewarn "rEFInd. Installation will now proceed presuming a 32-bit EFI."
	else
		die "Unknown CPU type '$CpuType'; aborting!"
	fi

	# CopyRefindFiles
	RefindDir="${S}/refind"
	TargetDir="/EFI/refind"
	exeinto ${InstallPart}/${TargetDir}
	if [[ $Platform == 'EFI32' ]] ; then
		doexe $RefindDir/refind_ia32.efi
		Refind="refind_ia32.efi"
	elif [[ $Platform == 'EFI64' ]] ; then
		doexe $RefindDir/refind_x64.efi
		Refind="refind_x64.efi"
	else
		die "Unknown platform! Aborting!"
	fi
	einfo "Copied rEFInd binary file $Refind"

	insinto ${InstallPart}/${TargetDir}
	doins -r $RefindDir/icons
	einfo "Copied rEFInd icons directory"

	doins $RefindDir/refind.conf-sample
	einfo "Copied sample rEFInd configuration file"
}