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

Diff of /eclass/webapp.eclass

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

Revision 1.62 Revision 1.70
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2011 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.62 2008/03/04 18:54:41 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.70 2011/12/27 17:55:12 fauli 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 13# @ECLASS-VARIABLE: WEBAPP_DEPEND
14# @DESCRIPTION: 14# @DESCRIPTION:
15# An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be build, most 15# An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most
16# notably in combination with WEBAPP_OPTIONAL. 16# notably in combination with WEBAPP_OPTIONAL.
17WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15" 17WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15"
18 18
19# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL 19# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL
20# @DESCRIPTION: 20# @DESCRIPTION:
57 debug-print-function $FUNCNAME $* 57 debug-print-function $FUNCNAME $*
58 58
59 if has_version '>=app-admin/webapp-config-1.50'; then 59 if has_version '>=app-admin/webapp-config-1.50'; then
60 ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" 60 ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!"
61 eval ${ENVVAR} 61 eval ${ENVVAR}
62 else 62 elif [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then
63 # ETC_CONFIG might not be available
64 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
65 elif [[ -f "${ETC_CONFIG}" ]]; then
66 # WEBAPP_OPTIONAL is set to yes
67 # and this must run only if ETC_CONFIG actually exists
63 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" 68 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
64 fi 69 fi
65} 70}
66 71
67# Check whether a specified file exists in the given directory (`.' by default) 72# Check whether a specified file exists in the given directory (`.' by default)
119 124
120 if [[ "${my_pn}" == "${PN}" ]]; then 125 if [[ "${my_pn}" == "${PN}" ]]; then
121 if [[ "${my_pvr}" != "${PVR}" ]]; then 126 if [[ "${my_pvr}" != "${PVR}" ]]; then
122 elog "This is an upgrade" 127 elog "This is an upgrade"
123 IS_UPGRADE=1 128 IS_UPGRADE=1
129 # for binpkgs, reset status, var declared in global scope
130 IS_REPLACE=0
124 else 131 else
125 elog "This is a re-installation" 132 elog "This is a re-installation"
126 IS_REPLACE=1 133 IS_REPLACE=1
134 # for binpkgs, reset status, var declared in global scope
135 IS_UPGRADE=0
127 fi 136 fi
128 else 137 else
129 elog "${my_output} is installed there" 138 elog "${my_output} is installed there"
130 fi 139 fi
131 else 140 else
141 # for binpkgs, reset status, var declared in global scope
142 IS_REPLACE=0
143 IS_UPGRADE=0
132 elog "This is an installation" 144 elog "This is an installation"
133 fi 145 fi
134} 146}
135 147
136# ============================================================================== 148# ==============================================================================
137# PUBLIC FUNCTIONS 149# PUBLIC FUNCTIONS
138# ============================================================================== 150# ==============================================================================
139 151
140# @FUNCTION: need_httpd 152# @FUNCTION: need_httpd
141# @DESCRIPTION: 153# @DESCRIPTION:
142# Call this function AFTER your ebuild's DEPEND line if any of the available 154# Call this function AFTER your ebuilds DEPEND line if any of the available
143# webservers are able to run this application. 155# webservers are able to run this application.
144need_httpd() { 156need_httpd() {
145 DEPEND="${DEPEND} 157 DEPEND="${DEPEND}
146 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )" 158 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )"
147} 159}
148 160
149# @FUNCTION: need_httpd_cgi 161# @FUNCTION: need_httpd_cgi
150# @DESCRIPTION: 162# @DESCRIPTION:
151# Call this function AFTER your ebuild's DEPEND line if any of the available 163# Call this function AFTER your ebuilds DEPEND line if any of the available
152# CGI-capable webservers are able to run this application. 164# CGI-capable webservers are able to run this application.
153need_httpd_cgi() { 165need_httpd_cgi() {
154 DEPEND="${DEPEND} 166 DEPEND="${DEPEND}
155 || ( virtual/httpd-cgi virtual/httpd-fastcgi )" 167 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
156} 168}
157 169
158# @FUNCTION: need_httpd_fastcgi 170# @FUNCTION: need_httpd_fastcgi
159# @DESCRIPTION: 171# @DESCRIPTION:
160# Call this function AFTER your ebuild's DEPEND line if any of the available 172# Call this function AFTER your ebuilds DEPEND line if any of the available
161# FastCGI-capabale webservers are able to run this application. 173# FastCGI-capabale webservers are able to run this application.
162need_httpd_fastcgi() { 174need_httpd_fastcgi() {
163 DEPEND="${DEPEND} 175 DEPEND="${DEPEND}
164 virtual/httpd-fastcgi" 176 virtual/httpd-fastcgi"
165} 177}
319# You need to call this function in src_install() BEFORE anything else has run. 331# You need to call this function in src_install() BEFORE anything else has run.
320# For now we just create required webapp-config directories. 332# For now we just create required webapp-config directories.
321webapp_src_preinst() { 333webapp_src_preinst() {
322 debug-print-function $FUNCNAME $* 334 debug-print-function $FUNCNAME $*
323 335
336 # sanity checks, to catch bugs in the ebuild
337 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
338 eerror
339 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
340 eerror "of the pkg_setup() function"
341 eerror
342 eerror "Please log a bug on http://bugs.gentoo.org"
343 eerror
344 eerror "You should use emerge -C to remove this package, as the"
345 eerror "installation is incomplete"
346 eerror
347 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
348 fi
349
350 # Hint, see the webapp_read_config() function to find where these are
351 # defined.
324 dodir "${MY_HTDOCSDIR}" 352 dodir "${MY_HTDOCSDIR}"
325 dodir "${MY_HOSTROOTDIR}" 353 dodir "${MY_HOSTROOTDIR}"
326 dodir "${MY_CGIBINDIR}" 354 dodir "${MY_CGIBINDIR}"
327 dodir "${MY_ICONSDIR}" 355 dodir "${MY_ICONSDIR}"
328 dodir "${MY_ERRORSDIR}" 356 dodir "${MY_ERRORSDIR}"
413 # 441 #
414 # we used to just set a variable in the shell script, but we can 442 # we used to just set a variable in the shell script, but we can
415 # no longer rely on Portage calling both webapp_src_install() and 443 # no longer rely on Portage calling both webapp_src_install() and
416 # webapp_pkg_postinst() within the same shell process 444 # webapp_pkg_postinst() within the same shell process
417 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 445 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
418
419 # sanity checks, to catch bugs in the ebuild
420 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
421 eerror
422 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
423 eerror "of the pkg_setup() function"
424 eerror
425 eerror "Please log a bug on http://bugs.gentoo.org"
426 eerror
427 eerror "You should use emerge -C to remove this package, as the"
428 eerror "installation is incomplete"
429 eerror
430 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
431 fi
432 446
433 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 447 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
434 chmod -R u-s "${D}/" 448 chmod -R u-s "${D}/"
435 chmod -R g-s "${D}/" 449 chmod -R g-s "${D}/"
436 450
490 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" 504 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
491 elog "Running ${my_cmd}" 505 elog "Running ${my_cmd}"
492 ${my_cmd} 506 ${my_cmd}
493 507
494 echo 508 echo
495 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" 509 local cleaner="${WEBAPP_CLEANER} -p -C /${PN}"
496 einfo "Running ${cleaner}" 510 einfo "Running ${cleaner}"
497 ${cleaner} 511 ${cleaner}
498 else 512 else
499 elog 513 elog
500 elog "The 'vhosts' USE flag is switched ON" 514 elog "The 'vhosts' USE flag is switched ON"
537 if has vhosts ${IUSE} && ! use vhosts; then 551 if has vhosts ${IUSE} && ! use vhosts; then
538 echo "${my_output}" | while read x; do 552 echo "${my_output}" | while read x; do
539 if [[ -f "${x}"/.webapp ]]; then 553 if [[ -f "${x}"/.webapp ]]; then
540 . "${x}"/.webapp 554 . "${x}"/.webapp
541 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then 555 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then
542 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 556 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} ${PN} ${PVR}
543 fi 557 fi
544 else 558 else
545 ewarn "Cannot find file ${x}/.webapp" 559 ewarn "Cannot find file ${x}/.webapp"
546 fi 560 fi
547 done 561 done

Legend:
Removed from v.1.62  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.20