summaryrefslogtreecommitdiff
blob: f3b1605127c684aa7c19c2d8ca1eb264bc0ef145 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-crypt/truecrypt/truecrypt-4.2-r1.ebuild,v 1.1 2006/06/06 12:05:42 dragonheart Exp $

inherit linux-mod toolchain-funcs

DESCRIPTION="Free open-source disk encryption software for Windows XP/2000/2003 and Linux"
HOMEPAGE="http://www.truecrypt.org/"
SRC_URI="http://www.truecrypt.org/downloads/truecrypt-${PV}-source-code.tar.gz"

LICENSE="truecrypt-2.0"
SLOT="0"
KEYWORDS="~x86"
IUSE=""

DEPEND="virtual/linux-sources
	sys-fs/device-mapper"

RDEPEND="sys-fs/device-mapper"

BUILD_PARAMS="KSRC=${KV_DIR} NO_WARNINGS=1"
BUILD_TARGETS="truecrypt"
MODULE_NAMES="truecrypt(block:${S}/Linux/Kernel)"

pkg_setup() {
	linux-info_pkg_setup
	dmcrypt_check
	kernel_is lt 2 6 5 && die 'requires at least 2.6.5 kernel version'
}

src_unpack() {
	unpack ${A}
	cd "${S}"
	linux-mod_pkg_setup
	epatch "${FILESDIR}/${P}-makefile.patch"
	epatch "${FILESDIR}/${P}-nosectorformat.patch"
}

src_compile() {
	linux-mod_src_compile || die "Truecrypt module compilation failed."
	cd "${S}/Linux/Cli"
	einfo "Building truecrypt utility"
	tc-export CC
	# remove kernel linked crypt stuff
	emake clean || die "make clean failed"
	emake truecrypt || die "Compile and/or linking of TrueCrypt Linux CLI application failed."
}

src_test() {
	"${S}/Linux/Cli/truecrypt" --test
}

pkg_preinst() {
	# unload truecrypt modules if already loaded
	/sbin/rmmod truecrypt >&- 2>&-
	if grep -q "^truecrypt" /proc/modules
	then
		die "Please dismount all mounted TrueCrypt volumes"
	fi
}

src_install() {
	# installing files
	dobin Linux/Cli/truecrypt
	doman Linux/Cli/Man/truecrypt.1
	dodoc Readme.txt 'Release/Setup Files/TrueCrypt User Guide.pdf'

	# installing kernel module
	linux-mod_src_install
}

pkg_postinst() {
	linux-mod_pkg_postinst
	einfo " For TrueCrypt 4.2 to work you have to load a "
	einfo " kernel module. This can be done in three ways: "
	einfo
	einfo " 1. Loading the module automatically by the running kernel. "
	einfo "    For this 'Automatic kernel module loading' needs to be "
	einfo "    enabled (CONFIG_KMOD=y). "
	einfo " 2. Loading the module manually before mounting the volume. "
	einfo "    Try 'modprobe truecrypt' as root to load the module. "
	einfo " 3. Load the module during boot by listing it in "
	einfo "    '/etc/modules.autoload.d/kernel-2.6' "
}

dmcrypt_check() {
	ebegin "Checking for Device mapper support (BLK_DEV_DM)"
	linux_chkconfig_present BLK_DEV_DM
	eend $?

	if [[ $? -ne 0 ]] ; then
		ewarn "TrueCrypt requires Device mapper support!"
		ewarn "Please enable Device mapper support in your kernel config, found at:"
		ewarn "(for 2.6 kernels)"
		ewarn
		ewarn "  Device Drivers"
		ewarn "    Multi-Device Support"
		ewarn "      <*> Device mapper support"
		ewarn
		ewarn "and recompile your kernel if you want this package to work."
		epause 10
	fi
}