summaryrefslogtreecommitdiff
blob: 0a47788a2d831e139d684d59221a0c74088d0b4d (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

EGIT_REPO_URI="https://github.com/sfabbro/cvmfs.git"
EGIT_BRANCH="devel"

inherit cmake-utils linux-info git-r3

SRC_URI=""
KEYWORDS=""

DESCRIPTION="HTTP read-only file system for distributing software"
HOMEPAGE="http://cernvm.cern.ch/portal/filesystem"

LICENSE="BSD"
SLOT="0"

IUSE="aufs debug doc server test test-programs"

CDEPEND="
	dev-cpp/gtest
	dev-db/sqlite:3=
	dev-libs/openssl:0
	net-libs/pacparser:0=
	net-misc/curl:0=[adns]
	sys-apps/attr
	sys-libs/zlib:0=
	>=dev-cpp/sparsehash-1.12
	dev-libs/leveldb:0=
	sys-fs/fuse:0=
	server? (
		>=dev-python/geoip-python-1.3.1
		>=dev-cpp/tbb-4.3:0= )"

RDEPEND="${CDEPEND}
	app-admin/sudo
	net-fs/autofs
	server? (
		aufs? ( || (
			sys-fs/aufs3
			sys-fs/aufs4
			sys-kernel/aufs-sources ) )
		www-servers/apache )"

DEPEND="${CDEPEND}
	virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] )
	test? (
		>=dev-python/geoip-python-1.3.1
		>=dev-cpp/tbb-4.3:0= )"

REQUIRED_USE="test-programs? ( server )"

pkg_setup() {
	if use server; then
		if use aufs; then
			CONFIG_CHECK="~AUFS_FS"
			ERROR_AUFS_FS="CONFIG_AUFS_FS: is required to be set with the aufs flag"
		else
			CONFIG_CHECK="~OVERLAY_FS"
			ERROR_AUFS_FS="CONFIG_OVERLAY_FS: is required to be set"
		fi
		linux-info_pkg_setup
	fi
}

src_prepare() {
	cmake-utils_src_prepare

	# gentoo stuff
	sed -i -e 's/COPYING//' CMakeLists.txt || die
	# this removal avoids all bundled packages to be configured and built
	rm bootstrap.sh || die

	sed -i \
		-e "s:cvmfs-\${CernVM-FS_VERSION_STRING}:${PF}:" \
		CMakeLists.txt || die

	# hack for bundled vjson and sha2
	# vjson and sha2 not worth unbundling upstreams are flaky/dead
	local pkg
	for pkg in vjson sha2; do
		# respect toolchain variables
		sed -i \
			-e 's/g++/$(CXX)/g' \
			-e 's/gcc/$(CC)/g' \
			-e 's/-O2/$(CFLAGS)/g' \
			-e 's/-O2/$(CXXFLAGS)/g' \
			-e 's/ar/$(AR)/' \
			-e 's/ranlib/$(RANLIB)/' \
			externals/${pkg}/src/Makefile || die
		mkdir -p "${WORKDIR}/${P}_build"/externals/build_${pkg}
		cp externals/${pkg}/src/* \
		   "${WORKDIR}/${P}_build"/externals/build_${pkg}/ || die
	done
}

src_configure() {
	local mycmakeargs=(
		-DGEOIP_BUILTIN=OFF
		-DGOOGLETEST_BUILTIN=OFF
		-DLEVELDB_BUILTIN=OFF
		-DLIBCURL_BUILTIN=OFF
		-DPACPARSER_BUILTIN=OFF
		-DSPARSEHASH_BUILTIN=OFF
		-DSQLITE3_BUILTIN=OFF
		-DTBB_PRIVATE_LIB=OFF
		-DZLIB_BUILTIN=OFF
		-DBUILD_CVMFS=ON
		-DBUILD_LIBCVMFS=ON
		-DINSTALL_MOUNT_SCRIPTS=ON
		$(cmake-utils_use doc BUILD_DOCUMENTATION)
		$(cmake-utils_use server BUILD_SERVER)
	)
	if use test || use test-programs; then
		mycmakeargs+=( -DBUILD_UNITTESTS=ON )
	fi
	use test-programs && mycmakeargs+=( -DINSTALL_UNITTESTS=ON )
	if use debug; then
		mycmakeargs+=(
			$(cmake-utils_use server BUILD_SERVER_DEBUG)
			$(cmake-utils_use test BUILD_UNITTESTS_DEBUG)
		)
	fi
	cmake-utils_src_configure
}

src_install() {
	cmake-utils_src_install
	use doc && dohtml -r doc/html/*
}

pkg_config() {
	einfo "Setting up CernVM-FS client"
	cvmfs_config setup
	einfo "Now edit ${EROOT%/}/etc/cvmfs/default.local"
	einfo "and restart the autofs service"
}