aboutsummaryrefslogtreecommitdiff
blob: bcfc00433de7d5e03f396b17cf2857d9b8286dc5 (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
73
74
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

inherit flag-o-matic mount-boot

DESCRIPTION="A module that uses Intel(R) Trusted Execution Technology to perform a measured and verified boot"
HOMEPAGE="http://sourceforge.net/projects/tboot/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86 -*"
IUSE="custom-cflags"

RESTRICT="test" # test is restricted because it requires patching the kernel src

DEPEND="app-crypt/trousers
app-crypt/tpm-tools"

RDEPEND="${DEPEND}
sys-boot/grub:2"

DOCS=(README COPYING CHANGELOG)

src_prepare() {
	epatch "${FILESDIR}/tboot-1.8.2-genkernel_arch.patch"
	epatch "${FILESDIR}/tboot-1.8.2-stack-check-no.patch" # breaks with ssp
	epatch "${FILESDIR}/tboot-1.8.2-disable-pcid.patch" # PaX enables pcid
	sed -i 's/ -Werror//g' Config.mk || die
	sed -i 's/^INSTALL_STRIP = -s$//' Config.mk || die # QA Errors

	# the version number is wrong in the grub files
	sed -i 's/tboot_version="1.8.1"/tboot_version="1.8.2"/' tboot/20_linux*tboot

	epatch_user
}

src_compile() {
	use custom-cflags && export TBOOT_CFLAGS=${CFLAGS} || unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS

	if use amd64; then
		MAKEARGS="TARGET_ARCH=x86_64"
	else
		MAKEARGS="TARGET_ARCH=i686"
	fi

	emake debug=y ${MAKEARGS} build
}

src_install() {
	emake DISTDIR="${D}" install

	dodoc "${DOCS[@]}"
	dodoc docs/*.txt lcptools/*.{txt,pdf} || die "docs failed"

	cd "${D}"
	mkdir -p usr/lib/tboot/ || die
	mv boot usr/lib/tboot/ || die
}

pkg_postinst() {
	mount-boot_mount_boot_partition

	cp ${ROOT%/}/usr/lib/tboot/boot/* ${ROOT%/}/boot/

	mount-boot_pkg_postinst

	ewarn "Please remember to download the SINIT AC Module relevant"
	ewarn "for your platform from:"
	ewarn "http://software.intel.com/en-us/articles/intel-trusted-execution-technology/"
}