/[gentoo-x86]/eclass/webapp.eclass
Gentoo

Diff of /eclass/webapp.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.57 Revision 1.66
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 Gentoo Foundation
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.57 2008/02/22 14:59:07 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.66 2011/05/19 12:05:13 scarabeus Exp $
4# 4
5# @ECLASS: webapp.eclass 5# @ECLASS: webapp.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# web-apps@gentoo.org 7# web-apps@gentoo.org
8# @BLURB: functions for installing applications to run under a web server 8# @BLURB: functions for installing applications to run under a web server
9# @DESCRIPTION: 9# @DESCRIPTION:
10# The webapp eclass contains functions to handle web applications with 10# The webapp eclass contains functions to handle web applications with
11# webapp-config. Part of the implementation of GLEP #11 11# webapp-config. Part of the implementation of GLEP #11
12 12
13# @ECLASS-VARIABLE: WEBAPP_DEPEND
14# @DESCRIPTION:
15# An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most
16# notably in combination with WEBAPP_OPTIONAL.
17WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15"
18
19# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL
20# @DESCRIPTION:
21# An ebuild sets this to `yes' if an automatic installation and/or upgrade is
22# not possible. The ebuild should overwrite pkg_postinst() and explain the
23# reason for this BEFORE calling webapp_pkg_postinst().
24
25# @ECLASS-VARIABLE: WEBAPP_OPTIONAL
26# @DESCRIPTION:
27# An ebuild sets this to `yes' to make webapp support optional, in which case
28# you also need to take care of USE-flags and dependencies.
29
30if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then
31 [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts"
13SLOT="${PVR}" 32 SLOT="${PVR}"
14IUSE="vhosts" 33 DEPEND="${WEBAPP_DEPEND}"
15DEPEND=">=app-admin/webapp-config-1.50.15"
16RDEPEND="${DEPEND}" 34 RDEPEND="${DEPEND}"
35fi
17 36
18EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 37EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
19 38
20INSTALL_DIR="/${PN}" 39INSTALL_DIR="/${PN}"
21IS_UPGRADE=0 40IS_UPGRADE=0
79 echo "${1/#.\///}" 98 echo "${1/#.\///}"
80} 99}
81 100
82webapp_getinstalltype() { 101webapp_getinstalltype() {
83 debug-print-function $FUNCNAME $* 102 debug-print-function $FUNCNAME $*
84 use vhosts && return 103
104 if ! has vhosts ${IUSE} || use vhosts; then
105 return
106 fi
85 107
86 local my_output 108 local my_output
87 my_output="$(webapp_check_installedat)" 109 my_output="$(webapp_check_installedat)"
88 110
89 if [[ $? -eq 0 ]]; then 111 if [[ $? -eq 0 ]]; then
113 135
114# ============================================================================== 136# ==============================================================================
115# PUBLIC FUNCTIONS 137# PUBLIC FUNCTIONS
116# ============================================================================== 138# ==============================================================================
117 139
140# @FUNCTION: need_httpd
141# @DESCRIPTION:
142# Call this function AFTER your ebuilds DEPEND line if any of the available
143# webservers are able to run this application.
144need_httpd() {
145 DEPEND="${DEPEND}
146 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )"
147}
148
149# @FUNCTION: need_httpd_cgi
150# @DESCRIPTION:
151# Call this function AFTER your ebuilds DEPEND line if any of the available
152# CGI-capable webservers are able to run this application.
153need_httpd_cgi() {
154 DEPEND="${DEPEND}
155 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
156}
157
158# @FUNCTION: need_httpd_fastcgi
159# @DESCRIPTION:
160# Call this function AFTER your ebuilds DEPEND line if any of the available
161# FastCGI-capabale webservers are able to run this application.
162need_httpd_fastcgi() {
163 DEPEND="${DEPEND}
164 virtual/httpd-fastcgi"
165}
166
118# @FUNCTION: webapp_configfile 167# @FUNCTION: webapp_configfile
119# @USAGE: <file> [more files ...] 168# @USAGE: <file> [more files ...]
120# @DESCRIPTION: 169# @DESCRIPTION:
121# Mark a file config-protected for a web-based application. 170# Mark a file config-protected for a web-based application.
122webapp_configfile() { 171webapp_configfile() {
270# You need to call this function in src_install() BEFORE anything else has run. 319# You need to call this function in src_install() BEFORE anything else has run.
271# For now we just create required webapp-config directories. 320# For now we just create required webapp-config directories.
272webapp_src_preinst() { 321webapp_src_preinst() {
273 debug-print-function $FUNCNAME $* 322 debug-print-function $FUNCNAME $*
274 323
324 # sanity checks, to catch bugs in the ebuild
325 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
326 eerror
327 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
328 eerror "of the pkg_setup() function"
329 eerror
330 eerror "Please log a bug on http://bugs.gentoo.org"
331 eerror
332 eerror "You should use emerge -C to remove this package, as the"
333 eerror "installation is incomplete"
334 eerror
335 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
336 fi
337
338 # Hint, see the webapp_read_config() function to find where these are
339 # defined.
275 dodir "${MY_HTDOCSDIR}" 340 dodir "${MY_HTDOCSDIR}"
276 dodir "${MY_HOSTROOTDIR}" 341 dodir "${MY_HOSTROOTDIR}"
277 dodir "${MY_CGIBINDIR}" 342 dodir "${MY_CGIBINDIR}"
278 dodir "${MY_ICONSDIR}" 343 dodir "${MY_ICONSDIR}"
279 dodir "${MY_ERRORSDIR}" 344 dodir "${MY_ERRORSDIR}"
315 webapp_read_config 380 webapp_read_config
316 381
317 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" 382 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
318 383
319 # if USE=vhosts is enabled OR no application is installed we're done here 384 # if USE=vhosts is enabled OR no application is installed we're done here
320 use vhosts || [[ ! -d "${my_dir}" ]] && return 385 if ! has vhosts ${IUSE} || use vhosts || [[ ! -d "${my_dir}" ]]; then
386 return
387 fi
321 388
322 local my_output 389 local my_output
323 my_output="$(webapp_check_installedat)" 390 my_output="$(webapp_check_installedat)"
324 391
325 if [[ $? -ne 0 ]]; then 392 if [[ $? -ne 0 ]]; then
363 # we used to just set a variable in the shell script, but we can 430 # we used to just set a variable in the shell script, but we can
364 # no longer rely on Portage calling both webapp_src_install() and 431 # no longer rely on Portage calling both webapp_src_install() and
365 # webapp_pkg_postinst() within the same shell process 432 # webapp_pkg_postinst() within the same shell process
366 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 433 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
367 434
368 # sanity checks, to catch bugs in the ebuild
369 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
370 eerror
371 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
372 eerror "of the pkg_setup() function"
373 eerror
374 eerror "Please log a bug on http://bugs.gentoo.org"
375 eerror
376 eerror "You should use emerge -C to remove this package, as the"
377 eerror "installation is incomplete"
378 eerror
379 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
380 fi
381
382 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 435 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
383 chmod -R u-s "${D}/" 436 chmod -R u-s "${D}/"
384 chmod -R g-s "${D}/" 437 chmod -R g-s "${D}/"
385 438
386 keepdir "${MY_PERSISTDIR}" 439 keepdir "${MY_PERSISTDIR}"
413 eerror "installation is incomplete" 466 eerror "installation is incomplete"
414 eerror 467 eerror
415 die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org" 468 die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org"
416 fi 469 fi
417 470
471 if has vhosts ${IUSE}; then
418 if ! use vhosts; then 472 if ! use vhosts; then
419 echo 473 echo
420 elog "vhosts USE flag not set - auto-installing using webapp-config" 474 elog "vhosts USE flag not set - auto-installing using webapp-config"
421 475
422 G_HOSTNAME="localhost" 476 G_HOSTNAME="localhost"
423 webapp_read_config 477 webapp_read_config
424 478
425 local my_mode=-I 479 local my_mode=-I
426 webapp_getinstalltype 480 webapp_getinstalltype
427 481
428 if [[ "${IS_REPLACE}" == "1" ]]; then 482 if [[ "${IS_REPLACE}" == "1" ]]; then
429 elog "${PN}-${PVR} is already installed - replacing" 483 elog "${PN}-${PVR} is already installed - replacing"
430 my_mode=-I 484 my_mode=-I
431 elif [[ "${IS_UPGRADE}" == "1" ]]; then 485 elif [[ "${IS_UPGRADE}" == "1" ]]; then
432 elog "${REMOVE_PKG} is already installed - upgrading" 486 elog "${REMOVE_PKG} is already installed - upgrading"
433 my_mode=-U 487 my_mode=-U
488 else
489 elog "${PN}-${PVR} is not installed - using install mode"
490 fi
491
492 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
493 elog "Running ${my_cmd}"
494 ${my_cmd}
495
496 echo
497 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}"
498 einfo "Running ${cleaner}"
499 ${cleaner}
434 else 500 else
435 elog "${PN}-${PVR} is not installed - using install mode" 501 elog
502 elog "The 'vhosts' USE flag is switched ON"
503 elog "This means that Portage will not automatically run webapp-config to"
504 elog "complete the installation."
505 elog
506 elog "To install ${PN}-${PVR} into a virtual host, run the following command:"
507 elog
508 elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
509 elog
510 elog "For more details, see the webapp-config(8) man page"
436 fi 511 fi
437
438 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
439 elog "Running ${my_cmd}"
440 ${my_cmd}
441
442 echo
443 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}"
444 einfo "Running ${cleaner}"
445 ${cleaner}
446 else 512 else
447 elog 513 elog
448 elog "The 'vhosts' USE flag is switched ON" 514 elog "This ebuild does not support the 'vhosts' USE flag."
449 elog "This means that Portage will not automatically run webapp-config to" 515 elog "This means that Portage will not automatically run webapp-config to"
450 elog "complete the installation." 516 elog "complete the installation."
451 elog 517 elog
452 elog "To install ${PN}-${PVR} into a virtual host, run the following command:" 518 elog "To install ${PN}-${PVR} into a virtual host, run the following command:"
453 elog 519 elog
468 local my_output= 534 local my_output=
469 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})" 535 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})"
470 [[ $? -ne 0 ]] && return 536 [[ $? -ne 0 ]] && return
471 537
472 local x 538 local x
473 if ! use vhosts; then 539 if has vhosts ${IUSE} && ! use vhosts; then
474 echo "${my_output}" | while read x; do 540 echo "${my_output}" | while read x; do
475 if [[ -f "${x}"/.webapp ]]; then 541 if [[ -f "${x}"/.webapp ]]; then
476 . "${x}"/.webapp 542 . "${x}"/.webapp
477 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then 543 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then
478 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 544 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR}

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.66

  ViewVC Help
Powered by ViewVC 1.1.20