summaryrefslogtreecommitdiff
blob: 236beb98ec890d6b11253c1126d1e53565dec987 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4
SCONS_MIN_VERSION=1.2.0

inherit eutils scons-utils toolchain-funcs

DESCRIPTION="ADC protocol hub made by the people behind DC++"
HOMEPAGE="http://adchpp.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${PN}_${PV}_source.tar.gz"
S="${WORKDIR}/${PN}_${PV}_source"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ia64 ~x86"
#TODOS:
#Add info on script and bloom uses
#Python use only on x86 builds
#Select languages
IUSE="+bloom debug doc +lua pch +python +ruby +script +ssl"

RDEPEND="ssl? ( dev-libs/openssl )
	python? ( || ( dev-lang/python:2.5 dev-lang/python:2.6 dev-lang/python:2.7 ) )
	ruby? ( >=dev-lang/ruby-1.9.2 dev-lang/ruby:1.9 )
	sys-libs/readline"
DEPEND="${RDEPEND}
	>=dev-lang/swig-1.3.40
	>=sys-devel/gcc-4.4
	ruby? ( >=dev-ruby/rubygems-1.8 )
	doc? ( >=app-text/asciidoc-8.6 )"

#This sets some useful variables needed for configure and install
pkg_setup() {
	if use x86; then
		export tarch=x86
	elif use amd64; then
		export tarch=x64
	elif use ia64; then
		export tarch=ia64
	else
		die "Invalid arch"
	fi

	if use debug; then
		export tmode=debug
	else
		export tmode=release
	fi
	#Shortcut for the packages library dir
	export libpath="/usr/$(get_libdir)/${P}"
	export logpath="/var/log/${PN}"
	export etcpath="/etc/${PN}"
	export sharepath="/usr/share/${P}"
	export varpath="/var/lib/${PN}"

	#Create the users
	enewgroup adchpp
	enewuser adchpp -1 -1 -1 "adchpp"
}

src_configure() {
	mylangs=""
	use lua && mylangs=$mylangs,lua
	use python && mylangs=$mylangs,python
	use ruby && mylangs=$mylangs,ruby

	myplugins=""
	use bloom && myplugins=$myplugins,Bloom
	use script && myplugins=$myplugins,Script

	myesconsargs=(
#		CC="$(tc-getCC)"
		plugins=$myplugins
		langs=$mylangs
		mode=$tmode
		$(use_scons ssl)
		$(use_scons pch gch)
		$(use_scons doc docs)
		arch=$tarch
#to use propper ruby
		ruby=ruby19
	)
}

src_prepare() {
	epatch "${FILESDIR}/${P}-allow_set_optional_features.patch"
	epatch "${FILESDIR}/${P}-fix_guide_paths.patch"
	epatch "${FILESDIR}/${P}-fix_doc_includes.patch"
	epatch "${FILESDIR}/${P}-fix_config_paths.patch"
	epatch "${FILESDIR}/${P}-fix_ruby.patch"
	epatch "${FILESDIR}/${P}-fix_python.patch"
	sed -e "s:%%ADCHPPLIB%%:$libpath:g" \
		"${FILESDIR}/adchpp_runner.sh" > adchpp_runner.sh
	sed -e "s:%%ADCHPPLIB%%:$libpath:g" \
	    -e "s:%%ADCHPPSHARE%%:$sharepath:g" \
	    -e "s:%%ADCHPPETC%%:$etcpath:g" \
	    -e "s:%%ADCHPPLOG%%:$logpath:g" \
		-i etc/adchpp.xml -i etc/Script.xml \
		-i rbutil/adchpp.rb -i pyutil/adchpp.py
}

src_compile() {
	escons || die
}

src_install() {
	if use doc; then
		newdoc build/docs/readme.html readme.txt
		dohtml -r build/docs/user_guide/
	fi
	newbin adchpp_runner.sh adchppd
	exeinto "$libpath"
	doexe "build/$tmode-default-$tarch/bin/"adchppd
	doexe "build/$tmode-default-$tarch/bin/"*.so
	keepdir "$logpath"
	fowners root:adchpp  "$logpath"
	fperms 0770 "$logpath"
	insinto "$etcpath"
	doins etc/adchpp.xml
	fowners root:adchpp  "$etcpath"
	fperms 0770 "$etcpath"
	#For some reason the core starts login here before booting
	dosym "$logpath" "$etcpath/logs"
	if use ssl; then
		exeinto "$sharepath"
		doexe linux/generate_certs.sh
		keepdir "$etcpath/certs"
		fperms 0700 "$etcpath/certs"
		fowners adchpp:adchpp  "$etcpath/certs"
		keepdir "$etcpath/certs/trusted"
		fperms 0700 "$etcpath/certs/trusted"
		fowners adchpp:adchpp  "$etcpath/certs/trusted"
	fi
	if use script; then
		insinto "$etcpath"
		doins etc/Script.xml
		insinto "$sharepath/scripts"
		doins plugins/Script/examples/*
		fperms 0750 "$sharepath/scripts"
		fowners root:adchpp  "$sharepath/scripts"
		keepdir "$etcpath/FL_DataBase"
		fowners adchpp:adchpp "$etcpath/FL_DataBase"
		fperms 0770 "$etcpath/FL_DataBase"
		dosym "$etcpath/FL_DataBase" "$sharepath/scripts/FL_DataBase"
	fi
	if use ruby; then
		insinto "$sharepath"
		doins -r rbutil
	fi
	if use python; then
		insinto "$sharepath"
		doins -r pyutil
	fi
	newinitd "${FILESDIR}/${PN}.init.d" "${PN}"
	newconfd "${FILESDIR}/${PN}.conf.d" "${PN}"
}