summaryrefslogtreecommitdiff
blob: 81fe56942afc992b573a1387af046af71173e2ba (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-fs/cvmfs/cvmfs-2.0.19.ebuild,v 1.1 2012/10/30 14:44:26 bicatali Exp $

EAPI=4

inherit eutils autotools toolchain-funcs linux-mod

DESCRIPTION="HTTP read-only file system for distributing software"
HOMEPAGE="http://cernvm.cern.ch/portal/filesystem"
SRC_URI="https://ecsft.cern.ch/dist/${PN}/${P}/${P}.tar.gz"

LICENSE="BSD"
SLOT="0"

KEYWORDS="~amd64 ~x86"
IUSE="+client doc openmp server"

CDEPEND="dev-db/sqlite:3
	dev-libs/openssl
	sys-libs/zlib
	client? (
		dev-libs/jemalloc
		net-misc/curl
		sys-fs/fuse )
	server? ( >=sys-fs/redirfs-0.10.20120313 )"

RDEPEND="${CDEPEND}
	client? ( net-fs/autofs )"

DEPEND="${CDEPEND}
	virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] )"

# either client or server is required and are mutually exclusive
REQUIRED_USE="^^ ( client server )"

pkg_setup() {
	if use server && use openmp && [[ $(tc-getCC) == *gcc* ]] && ! tc-has-openmp
	then
		ewarn "You are using a gcc without OpenMP capabilities"
		die "Need an OpenMP capable compiler"
	fi
	if use server; then
		MODULE_NAMES="cvmfsflt(misc:${S}/kernel/cvmfsflt/src)"
		BUILD_PARAMS="-C ${KERNEL_DIR} M=${S}/kernel/cvmfsflt/src"
		BUILD_TARGETS="cvmfsflt.ko"
		linux-mod_pkg_setup
	fi
}

src_prepare() {
	#	"${FILESDIR}"/${P}-system-redirfs.patch \
	epatch \
		"${FILESDIR}"/${P}-autotools.patch \
		"${FILESDIR}"/${P}-no-redhat-init.patch \
		"${FILESDIR}"/${P}-spinlock.patch \
		"${FILESDIR}"/${P}-openrc.patch
	eautoreconf
}

src_configure() {
	econf \
		--disable-sqlite3-builtin \
		--disable-libcurl-builtin \
		--disable-zlib-builtin \
		--disable-jemalloc-builtin \
		$(use_enable client cvmfs) \
		$(use_enable client mount-scripts) \
		$(use_enable openmp) \
		$(use_enable server)
}

src_compile() {
	emake
	if use server; then
		ln -s "${EROOT}"/usr/include/redirfs.h "${S}"/kernel/cvmfsflt/src
		linux-mod_src_compile
	fi
	use doc && doxygen doc/cvmfs.doxy
}

src_install() {
	default
	# NEWS file is empty
	rm "${ED}"/usr/share/doc/${PF}/{INSTALL,NEWS,COPYING}

	use client && newinitd "${FILESDIR}"/${PN}.initd ${PN}
	if use server; then
		linux-mod_src_install
		newinitd "${FILESDIR}"/${PN}d.initd ${PN}d
		newconfd "${FILESDIR}"/${PN}d.confd ${PN}d
	fi
	use doc && dohtml -r doc/html/*
}

pkg_preinst() {
	use server && linux-mod_pkg_preinst
}

pkg_postinst() {
	use server && linux-mod_pkg_postinst
}

pkg_postrm() {
	use server && linux-mod_pkg_postrm
}

pkg_config() {
	if use client; then
		einfo "Setting up CernVM-FS client"
		cvmfs_config setup
		cat > "${EROOT}"/etc/cvmfs/default.local <<-EOF
			# Repositories to fetch example is for ATLAS
			CVMFS_REPOSITORIES=atlas.cern.ch,atlas-condb.cern.ch,grid.cern.ch
			# Local proxy settings, ex: http://cernvm.cern.ch/config/proxy.cgi
			CVMFS_HTTP_PROXY="DIRECT"
			# Where to keep the cvmfs cache
			CVMFS_CACHE_BASE=${EROOT}/var/scratch/cvmfs
			# Quota limit in Mb
			CVMFS_QUOTA_LIMIT=10000
		EOF
		einfo "Now edit ${EROOT}/etc/cvmfs/default.local and run"
		einfo "  ${EROOT}/usr/init.d/cvmfs restart"
	fi
}