6429a37f166a9dd721383cf0c66807a6274416c1
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) 	
Lars Strojny x

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

41) 	=dev-python/twisted-web-0.5*
Bernd Wurst broken nevow dep, 0.9 was a...

Bernd Wurst authored 17 years ago

42) 	>=dev-python/nevow-0.8
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

90) pytransport_install_libs() {
91) 	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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

159) #
160) # Show postinst information
161) #