64777a8a4742c51d13b6eda553403a0479d8fdff
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}
Lars Strojny slot support

Lars Strojny authored 17 years ago

22) pytransport_is_subversion && SLOT=9999
23) pytransport_is_subversion || SLOT=1
Lars Strojny M net-im/pyaim-t/Manifes...

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

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

Lars Strojny authored 17 years ago

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

31) fi
32) 
Lars Strojny x

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

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

Lars Strojny authored 17 years ago

160) #
161) # Show postinst information
162) #