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

Diff of /eclass/webapp.eclass

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

Revision 1.58 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.58 2008/02/22 15:33:32 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
115# PUBLIC FUNCTIONS 137# PUBLIC FUNCTIONS
116# ============================================================================== 138# ==============================================================================
117 139
118# @FUNCTION: need_httpd 140# @FUNCTION: need_httpd
119# @DESCRIPTION: 141# @DESCRIPTION:
120# Call this function AFTER your ebuild's DEPEND line if any of the available 142# Call this function AFTER your ebuilds DEPEND line if any of the available
121# webservers are able to run this application. 143# webservers are able to run this application.
122need_httpd() { 144need_httpd() {
123 DEPEND="${DEPEND} 145 DEPEND="${DEPEND}
124 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )" 146 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )"
125} 147}
126 148
127# @FUNCTION: need_httpd_cgi 149# @FUNCTION: need_httpd_cgi
128# @DESCRIPTION: 150# @DESCRIPTION:
129# Call this function AFTER your ebuild's DEPEND line if any of the available 151# Call this function AFTER your ebuilds DEPEND line if any of the available
130# CGI-capable webservers are able to run this application. 152# CGI-capable webservers are able to run this application.
131need_httpd_cgi() { 153need_httpd_cgi() {
132 DEPEND="${DEPEND} 154 DEPEND="${DEPEND}
133 || ( virtual/httpd-cgi virtual/httpd-fastcgi )" 155 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
134} 156}
135 157
136# @FUNCTION: need_httpd_fastcgi 158# @FUNCTION: need_httpd_fastcgi
137# @DESCRIPTION: 159# @DESCRIPTION:
138# Call this function AFTER your ebuild's DEPEND line if any of the available 160# Call this function AFTER your ebuilds DEPEND line if any of the available
139# FastCGI-capabale webservers are able to run this application. 161# FastCGI-capabale webservers are able to run this application.
140need_httpd_fastcgi() { 162need_httpd_fastcgi() {
141 DEPEND="${DEPEND} 163 DEPEND="${DEPEND}
142 virtual/httpd-fastcgi" 164 virtual/httpd-fastcgi"
143} 165}
297# 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.
298# For now we just create required webapp-config directories. 320# For now we just create required webapp-config directories.
299webapp_src_preinst() { 321webapp_src_preinst() {
300 debug-print-function $FUNCNAME $* 322 debug-print-function $FUNCNAME $*
301 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.
302 dodir "${MY_HTDOCSDIR}" 340 dodir "${MY_HTDOCSDIR}"
303 dodir "${MY_HOSTROOTDIR}" 341 dodir "${MY_HOSTROOTDIR}"
304 dodir "${MY_CGIBINDIR}" 342 dodir "${MY_CGIBINDIR}"
305 dodir "${MY_ICONSDIR}" 343 dodir "${MY_ICONSDIR}"
306 dodir "${MY_ERRORSDIR}" 344 dodir "${MY_ERRORSDIR}"
342 webapp_read_config 380 webapp_read_config
343 381
344 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" 382 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
345 383
346 # 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
347 use vhosts || [[ ! -d "${my_dir}" ]] && return 385 if ! has vhosts ${IUSE} || use vhosts || [[ ! -d "${my_dir}" ]]; then
386 return
387 fi
348 388
349 local my_output 389 local my_output
350 my_output="$(webapp_check_installedat)" 390 my_output="$(webapp_check_installedat)"
351 391
352 if [[ $? -ne 0 ]]; then 392 if [[ $? -ne 0 ]]; then
390 # 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
391 # no longer rely on Portage calling both webapp_src_install() and 431 # no longer rely on Portage calling both webapp_src_install() and
392 # webapp_pkg_postinst() within the same shell process 432 # webapp_pkg_postinst() within the same shell process
393 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 433 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
394 434
395 # sanity checks, to catch bugs in the ebuild
396 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
397 eerror
398 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
399 eerror "of the pkg_setup() function"
400 eerror
401 eerror "Please log a bug on http://bugs.gentoo.org"
402 eerror
403 eerror "You should use emerge -C to remove this package, as the"
404 eerror "installation is incomplete"
405 eerror
406 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
407 fi
408
409 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 435 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
410 chmod -R u-s "${D}/" 436 chmod -R u-s "${D}/"
411 chmod -R g-s "${D}/" 437 chmod -R g-s "${D}/"
412 438
413 keepdir "${MY_PERSISTDIR}" 439 keepdir "${MY_PERSISTDIR}"
440 eerror "installation is incomplete" 466 eerror "installation is incomplete"
441 eerror 467 eerror
442 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"
443 fi 469 fi
444 470
471 if has vhosts ${IUSE}; then
445 if ! use vhosts; then 472 if ! use vhosts; then
446 echo 473 echo
447 elog "vhosts USE flag not set - auto-installing using webapp-config" 474 elog "vhosts USE flag not set - auto-installing using webapp-config"
448 475
449 G_HOSTNAME="localhost" 476 G_HOSTNAME="localhost"
450 webapp_read_config 477 webapp_read_config
451 478
452 local my_mode=-I 479 local my_mode=-I
453 webapp_getinstalltype 480 webapp_getinstalltype
454 481
455 if [[ "${IS_REPLACE}" == "1" ]]; then 482 if [[ "${IS_REPLACE}" == "1" ]]; then
456 elog "${PN}-${PVR} is already installed - replacing" 483 elog "${PN}-${PVR} is already installed - replacing"
457 my_mode=-I 484 my_mode=-I
458 elif [[ "${IS_UPGRADE}" == "1" ]]; then 485 elif [[ "${IS_UPGRADE}" == "1" ]]; then
459 elog "${REMOVE_PKG} is already installed - upgrading" 486 elog "${REMOVE_PKG} is already installed - upgrading"
460 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}
461 else 500 else
462 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"
463 fi 511 fi
464
465 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
466 elog "Running ${my_cmd}"
467 ${my_cmd}
468
469 echo
470 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}"
471 einfo "Running ${cleaner}"
472 ${cleaner}
473 else 512 else
474 elog 513 elog
475 elog "The 'vhosts' USE flag is switched ON" 514 elog "This ebuild does not support the 'vhosts' USE flag."
476 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"
477 elog "complete the installation." 516 elog "complete the installation."
478 elog 517 elog
479 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:"
480 elog 519 elog
495 local my_output= 534 local my_output=
496 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})" 535 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})"
497 [[ $? -ne 0 ]] && return 536 [[ $? -ne 0 ]] && return
498 537
499 local x 538 local x
500 if ! use vhosts; then 539 if has vhosts ${IUSE} && ! use vhosts; then
501 echo "${my_output}" | while read x; do 540 echo "${my_output}" | while read x; do
502 if [[ -f "${x}"/.webapp ]]; then 541 if [[ -f "${x}"/.webapp ]]; then
503 . "${x}"/.webapp 542 . "${x}"/.webapp
504 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then 543 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then
505 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 544 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR}

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

  ViewVC Help
Powered by ViewVC 1.1.20