| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 Gentoo Technologies, Inc. |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.9 2004/04/23 22:02:27 stuart Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.13 2004/04/30 08:25:38 stuart Exp $ |
| 4 | # |
4 | # |
| 5 | # eclass/webapp.eclass |
5 | # eclass/webapp.eclass |
| 6 | # Eclass for installing applications to run under a web server |
6 | # Eclass for installing applications to run under a web server |
| 7 | # |
7 | # |
| 8 | # Part of the implementation of GLEP #11 |
8 | # Part of the implementation of GLEP #11 |
| … | |
… | |
| 18 | |
18 | |
| 19 | ECLASS=webapp |
19 | ECLASS=webapp |
| 20 | INHERITED="$INHERITED $ECLASS" |
20 | INHERITED="$INHERITED $ECLASS" |
| 21 | SLOT="${PVR}" |
21 | SLOT="${PVR}" |
| 22 | IUSE="$IUSE vhosts" |
22 | IUSE="$IUSE vhosts" |
| 23 | DEPEND="$DEPEND >=net-www/webapp-config-1.4" |
23 | DEPEND="$DEPEND >=net-www/webapp-config-1.6" |
| 24 | |
24 | |
| 25 | EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install |
25 | EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install |
| 26 | |
26 | |
| 27 | # ------------------------------------------------------------------------ |
27 | # ------------------------------------------------------------------------ |
| 28 | # INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
28 | # INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
| … | |
… | |
| 69 | # |
69 | # |
| 70 | # ------------------------------------------------------------------------ |
70 | # ------------------------------------------------------------------------ |
| 71 | |
71 | |
| 72 | function webapp_strip_appdir () |
72 | function webapp_strip_appdir () |
| 73 | { |
73 | { |
| 74 | echo "$1" | sed -e "s|${D}${MY_APPDIR}/||g;" |
74 | echo "$1" | sed -e "s|${MY_APPDIR}/||g;" |
| 75 | } |
75 | } |
| 76 | |
76 | |
| 77 | function webapp_strip_d () |
77 | function webapp_strip_d () |
| 78 | { |
78 | { |
| 79 | echo "$1" | sed -e "s|${D}||g;" |
79 | echo "$1" | sed -e "s|${D}||g;" |
| … | |
… | |
| 93 | # ------------------------------------------------------------------------ |
93 | # ------------------------------------------------------------------------ |
| 94 | |
94 | |
| 95 | function webapp_configfile () |
95 | function webapp_configfile () |
| 96 | { |
96 | { |
| 97 | webapp_checkfileexists "$1" "$D" |
97 | webapp_checkfileexists "$1" "$D" |
|
|
98 | echo $1 |
| 98 | local MY_FILE="`webapp_strip_appdir $1`" |
99 | local MY_FILE="`webapp_strip_appdir $1`" |
|
|
100 | echo $MY_FILE |
| 99 | |
101 | |
| 100 | einfo "(config) $MY_FILE" |
102 | einfo "(config) $MY_FILE" |
| 101 | echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} |
103 | echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} |
| 102 | } |
104 | } |
| 103 | |
105 | |
| … | |
… | |
| 261 | dodir ${MY_SQLSCRIPTSDIR} |
263 | dodir ${MY_SQLSCRIPTSDIR} |
| 262 | } |
264 | } |
| 263 | |
265 | |
| 264 | function webapp_pkg_postinst () |
266 | function webapp_pkg_postinst () |
| 265 | { |
267 | { |
|
|
268 | einfo "webapp_pkg_postinst() called" |
|
|
269 | |
|
|
270 | # if 'vhosts' is not set in your USE flags, we install a copy of |
|
|
271 | # this application in /var/www/localhost/htdocs/${PN}/ for you |
|
|
272 | |
|
|
273 | |
|
|
274 | if ! use vhosts ; then |
|
|
275 | einfo "vhosts USE flag not set - auto-installing using webapp-config" |
|
|
276 | |
| 266 | G_HOSTNAME="localhost" |
277 | G_HOSTNAME="localhost" |
| 267 | . /etc/vhosts/webapp-config |
278 | . /etc/vhosts/webapp-config |
| 268 | |
279 | |
| 269 | use vhosts || /usr/sbin/webapp-config -I -u root -h localhost -d "${VHOST_ROOT}/htdocs/${PN}/" ${PN} ${PVR} |
280 | local my_mode=-I |
|
|
281 | local my_dir="/${PN}" |
|
|
282 | |
|
|
283 | # are we installing afresh - or are we upgrading? |
|
|
284 | # find out by looking to see what (if anything) is installed |
|
|
285 | # in there already |
|
|
286 | |
|
|
287 | my_cmd="/usr/sbin/webapp-config --show-installed -d $my_dir 2> /dev/null" |
|
|
288 | einfo "$my_cmd" |
|
|
289 | |
|
|
290 | my_output="`/usr/sbin/webapp-config --show-installed -d $my_dir 2> /dev/null`" |
|
|
291 | |
|
|
292 | # we can't use the exit status from webapp-config |
|
|
293 | |
|
|
294 | if [ "$?" = "0" ]; then |
|
|
295 | |
|
|
296 | # something is in there - but the question has to be ... what? |
|
|
297 | |
|
|
298 | ewarn "$my_output already installed" |
|
|
299 | |
|
|
300 | if [ "`echo $my_output | awk '{ print $1 }'`" = "${PN}" ]; then |
|
|
301 | einfo "$my_output is a copy of ${PN}" |
|
|
302 | if [ "`echo $my_output | awk '{ print $2 }'`" = "${PVR}" ]; then |
|
|
303 | # this version is already installed |
|
|
304 | # we need to remove it first |
|
|
305 | |
|
|
306 | /usr/sbin/webapp-config -C -d $my_dir |
|
|
307 | else |
|
|
308 | # we have an older version of whatever it is our ebuild is |
|
|
309 | # trying to install ;-) |
|
|
310 | # |
|
|
311 | # this is the situation we can deal with |
|
|
312 | |
|
|
313 | einfo "selecting upgrade mode" |
|
|
314 | my_mode=-U |
|
|
315 | fi |
|
|
316 | else |
|
|
317 | # this should never happen - but just in case ... |
|
|
318 | # |
|
|
319 | # whatever is in that directory, it isn't the application |
|
|
320 | # that we are currently trying to install |
|
|
321 | # |
|
|
322 | # rather than overwrite the contents, we bail with an error |
|
|
323 | # instead |
|
|
324 | |
|
|
325 | die "$my_output is already installed in $my_dir" |
|
|
326 | fi |
|
|
327 | else |
|
|
328 | einfo "${PN}-${PVR} is not installed - using install mode" |
|
|
329 | fi |
|
|
330 | |
|
|
331 | my_cmd="/usr/sbin/webapp-config $my_mode -h localhost -u root -d $my_dir ${PN} ${PVR}" |
|
|
332 | einfo "Running $my_cmd" |
|
|
333 | $my_cmd |
|
|
334 | fi |
|
|
335 | |
|
|
336 | return 0 |
| 270 | } |
337 | } |