7cbfb644df1eef40eaedebd2e370bc3cb2c57fdf
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

1) # Copyright 1999-2006 Gentoo Foundation
2) # Distributed under the terms of the GNU General Public License v2
3) # $Header: $
4) 
5) #
6) # Original Author: Lars Strojny <lars@strojny.net>
7) # Purpose: Providing macros to handle installation and setup of the py-transport
8) # family
9) #
10) inherit eutils python
11) ECLASS="pytransport"
12) INHERITED="$INHERITED $ECLASS"
Lars Strojny x

Lars Strojny authored 17 years ago

13) EXPORT_FUNCTIONS src_install pkg_postinst
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

14) 
15) LICENSE="GPL-2"
16) 
17) pytransport_is_subversion() {
Lars Strojny x

Lars Strojny authored 17 years ago

18) 	[[ "${PV}" = 9999 ]] && return 0 || return 1
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

19) }
20) 
21) pytransport_is_subversion && S=${WORKDIR}/${PN}
22) 
23) if pytransport_is_subversion; then
24) 	inherit subversion
Lars Strojny x

Lars Strojny authored 17 years ago

25) 	[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="http://svn.blathersource.org/${PN}/trunk"
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

26) 	SRC_URI=""
27) else
Lars Strojny x

Lars Strojny authored 17 years ago

28) 	SRC_URI="http://www.blathersource.org/download.php/${PN}/${P}.tar.gz"
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

29) fi
30) 
Lars Strojny x

Lars Strojny authored 17 years ago

31) HOMEPAGE="http://${PN}.blathersource.org/"
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

32) 
33) DEPEND=">=net-im/jabber-base-0.0
34) 	>=dev-lang/python-2.3"
35) 	
Lars Strojny x

Lars Strojny authored 17 years ago

36) RDEPEND="<dev-python/twisted-2.4
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

37) 	>=dev-python/twisted-words-0.1.0
Lars Strojny Upgrade to ejabberd-1.1.3

Lars Strojny authored 17 years ago

38) 	<dev-python/twisted-words-0.4
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

39) 	>=dev-python/twisted-xish-0.1.0
Lars Strojny Upgrade to ejabberd-1.1.3

Lars Strojny authored 17 years ago

40) 	=dev-python/twisted-web-0.5*
41) 	<dev-python/nevow-0.8
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

42) 	>=dev-python/imaging-1.1"
43) 
Lars Strojny Restructuring

Lars Strojny authored 17 years ago

44) PYTRANSPORT_LIB_DIR=${PYTRANSPORT_LIB_DIR:=tools data src}
Lars Strojny x

Lars Strojny authored 17 years ago

45) PYTRANSPORT_CONFIG=config_example.xml
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

46) 
47) # Create the minimal token name from the package name
48) #
49) # Example: pyicq-t-svn
50) #
51) pytransport_get_human_name() {
Lars Strojny x

Lars Strojny authored 17 years ago

52) 	echo "${PN}" \
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

53) 		| sed -e "s:^py\([a-z]*\)-t$:\1:g" \
54) 		| tr [:lower:] [:upper:]
55) }
56) 
57) #
58) # Guess the script name
59) #
60) pytransport_get_script_name() {
61) 	echo "Py$(pytransport_get_human_name ${PN})t.py"
62) }
63) 
Lars Strojny x

Lars Strojny authored 17 years ago

64) #
65) # Adjust configuration file defaults
66) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

67) pytransport_adjust_configfile() {
68) 	local configfile="$1"
69) 	dosed \
70) 		"s:<spooldir>[^\<]*</spooldir>:<spooldir>/var/spool/jabber/</spooldir>:" \
71) 		"${configfile}" || die "Could not sed ${configfile}"
72) 	dosed \
73) 		"s:<pid>[^\<]*</pid>:<pid>/var/run/jabber/${PN}.pid</pid>:" \
74) 		"${configfile}" || die "Could not sed ${configfile}"
75) 	return 0
76) }
77) 
Lars Strojny x

Lars Strojny authored 17 years ago

78) #
79) # Get python version
80) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

81) pytransport_get_python_version() {
82) 	[ -z "${PYVER}" ] && python_version
83) 	echo "${PYVER}"
84) }
85) 
Lars Strojny x

Lars Strojny authored 17 years ago

86) #
87) # Install transport libraries
88) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

89) pytransport_install_libs() {
90) 	insinto /usr/lib/python$(pytransport_get_python_version)/site-packages/${PN}/
Lars Strojny D net-im/pyicq-t/files/p...

Lars Strojny authored 17 years ago

91) 	doins -r ${PYTRANSPORT_LIB_DIR} || \
92) 		die "Could not install library"
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

93) 	newins $(pytransport_get_script_name) ${PN}.py || \
94) 		die "Could not find initial .py-scripts"
95) 	return 0
96) }
97) 
Lars Strojny x

Lars Strojny authored 17 years ago

98) #
99) # Install configuration
100) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

101) pytransport_install_config() {
102) 	insinto /etc/jabber
103) 	newins "${PYTRANSPORT_CONFIG}" ${PN}.xml
104) 	fperms 600 /etc/jabber/${PN}.xml || die "Could not adjust perms"
Lars Strojny x

Lars Strojny authored 17 years ago

105) 	pytransport_adjust_configfile /etc/jabber/${PN}.xml || die "Could not adjust config"
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

106) 	fowners jabber:jabber /etc/jabber/${PN}.xml || die "Could not adjust perms"
107) 	return 0
108) }
109) 
Lars Strojny x

Lars Strojny authored 17 years ago

110) #
111) # Generate init.d-script
112) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

113) pytransport_generate_initd() {
114) 	pytransport_is_subversion && local suffix=" (Subversion)"
Lars Strojny M eclass/pytransport.ecl...

Lars Strojny authored 17 years ago

115) 	echo "#!/sbin/runscript
116) 
117) 
118) depend() {
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

119) 	need net
120) 	use jabber-server
121) }
122) 
123) start() {
124) 	ebegin \"Starting $(pytransport_get_human_name) Jabber Transport${suffix}\"
125) 	start-stop-daemon --start --quiet \\
126) 	--background --name \"${PN}\" --chuid jabber:jabber \\
Lars Strojny

Lars Strojny authored 17 years ago

127) 		--exec /usr/bin/python$(pytransport_get_python_version) \\
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

128) 		/usr/lib/python$(pytransport_get_python_version)/site-packages/${PN}/${PN}.py \\
129) 		-c /etc/jabber/${PN}.xml \\
130) 		-l /var/log/jabber/${PN}.log
Lars Strojny x

Lars Strojny authored 17 years ago

131) 	eend 0
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

132) }
133) 
134) stop() {
135) 	ebegin \"Stopping $(pytransport_get_human_name) Jabber Transport${suffix}\"
136) 	start-stop-daemon --stop --quiet --pidfile /var/run/jabber/pyicq-t-svn.pid
137) 	sleep 3
138) 	eend \$?
139) }"
140) }
141) 
Lars Strojny x

Lars Strojny authored 17 years ago

142) #
143) # Exported install function
144) #
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

145) pytransport_src_install() {
146) 	einfo "Installing library files ..."
147) 	pytransport_install_libs || die "Failed installing libs"
148) 
149) 	einfo "Installing config file: /etc/jabber/${PN}.xml"
150) 	pytransport_install_config || die "Failed installing configuration"
151) 
152) 	einfo "Generating init script: /etc/init.d/${PN}"
153) 	exeinto /etc/init.d
154) 	pytransport_generate_initd > myinitd
155) 	newexe myinitd ${PN}
156) }
157) 
Lars Strojny Restructuring

Lars Strojny authored 17 years ago

158) #
159) # Show postinst information
160) #