868a762903d6c697b03795b31401f4d20c229809
Lars Strojny

Lars Strojny authored 17 years ago

1) # Copyright 1999-2007 Gentoo Foundation
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

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}
Lars Strojny

Lars Strojny authored 17 years ago

22) SLOT=0
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

23) 
24) if pytransport_is_subversion; then
25) 	inherit subversion
Lars Strojny x

Lars Strojny authored 17 years ago

26) 	[ -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

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

Lars Strojny authored 17 years ago

29) 	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

30) fi
31) 
Lars Strojny x

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

33) 
34) DEPEND=">=net-im/jabber-base-0.0
35) 	>=dev-lang/python-2.3"
36) 	
Bernd Wurst depends

Bernd Wurst authored 16 years ago

37) RDEPEND=">dev-python/twisted-2.4
38) 	>dev-python/twisted-words-0.4
39) 	>=dev-python/twisted-web-0.5
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

40) 	>=dev-python/imaging-1.1"
Bernd Wurst depends

Bernd Wurst authored 16 years ago

41) #	>=dev-python/twisted-words-0.1.0
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

42) 
Lars Strojny Restructuring

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

88) pytransport_install_libs() {
89) 	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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

104) 	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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

157) #
158) # Show postinst information
159) #