summaryrefslogtreecommitdiff
blob: 62482f465f3768425ac387b5304912c7e683ef6f (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/open-iscsi-0.5.485.ebuild,v 1.2 2006/02/02 10:08:03 robbat2 Exp $

inherit versionator linux-mod eutils flag-o-matic

DESCRIPTION="Open-iSCSI project is a high performance, transport independent, multi-platform implementation of RFC3720."
HOMEPAGE="http://www.open-iscsi.org/"
#SRC_URI="http://www.open-iscsi.org/bits/${MY_P}.tar.gz"
#SRC_URI="mirror://gentoo/${P}.tar.gz"
SRC_URI="mirror://gentoo/${P}.tar.gz http://dev.gentoo.org/~robbat2/distfiles/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="debug"
DEPEND="virtual/libc
		virtual/linux-sources
		=sys-libs/db-4*"
RDEPEND="${DEPEND}
		virtual/modutils
		sys-apps/util-linux"

MODULE_NAMES_ARG="kernel/drivers/scsi:${S}/kernel"
MODULE_NAMES="iscsi_tcp(${MODULE_NAMES_ARG}) scsi_transport_iscsi(${MODULE_NAMES_ARG})"
BUILD_TARGETS="all"
CONFIG_CHECK="CRYPTO_MD5 CRYPTO_CRC32C"
ERROR_CFG="open-iscsi needs both MD5 and CRC32C support in your kernel."

src_unpack() {
	unpack ${A}
	#export EPATCH_OPTS="-d${S}/kernel -p0"
	export EPATCH_OPTS="-d${S}"
	if [ $KV_PATCH -lt 11 ]; then
		die "Sorry, your kernel must be 2.6.11 or newer!"
	elif [ $KV_PATCH -eq 11 ]; then
		einfo "2.6.11 found"
		epatch ${S}/kernel/2.6.11-compat.patch
	elif [ $KV_PATCH -eq 12 ]; then
		einfo "2.6.12 found"
		epatch ${S}/kernel/2.6.12-compat.patch
	elif [ $KV_PATCH -eq 13 ]; then
		einfo "2.6.13 found"
		epatch ${S}/kernel/2.6.13-compat.patch
	elif [ $KV_PATCH -eq 14 ]; then
		einfo "2.6.14 found"
		epatch ${S}/kernel/2.6.14-and-2.6.15-compat.patch
	elif [ $KV_PATCH -eq 15 ]; then
		einfo "2.6.15 found"
		epatch ${S}/kernel/2.6.14-and-2.6.15-compat.patch
	else
		einfo "2.6.16 or newer found."
		einfo "Please file a bug if this does not compile."
	fi
}

src_compile() {
	einfo "Building kernel modules"
	export KSRC="${KERNEL_DIR}"
	use debug && append-flags -DDEBUG_TCP -DDEBUG_SCSI
	linux-mod_src_compile || die "failed to build modules"
	einfo "Building userspace"
	cd ${S}/usr && CFLAGS="" emake OPTFLAGS="${CFLAGS}" || die "emake failed"
}

src_install() {
	einfo "Installing kernel modules"
	export KSRC="${KERNEL_DIR}"
	#S=${S}/kernel 
	linux-mod_src_install

	einfo "Installing userspace"
	dosbin usr/iscsid usr/iscsiadm

	doman doc/*[1-8]
	dodoc README THANKS
	docinto test
	dodoc test/*

	insinto /etc
	doins etc/iscsid.conf
	doins ${FILESDIR}/initiatorname.iscsi
	newinitd ${FILESDIR}/iscsid-init.d iscsid

	# security
	keepdir /var/db/iscsi
	fperms 700 /var/db/iscsi
	fperms 600 /etc/iscsid.conf
}

pkg_postinst() {
	linux-mod_pkg_postinst
	[ -d /var/db/iscsi ] && chmod 700 /var/db/iscsi
	[ -f /etc/iscsid.conf ] && chmod 600 /etc/iscsid.conf
}