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

Diff of /eclass/webapp.eclass

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

Revision 1.61 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.61 2008/03/04 18:44:01 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
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
13# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL 19# @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL
14# @DESCRIPTION: 20# @DESCRIPTION:
15# An ebuild sets this to `yes' if an automatic installation and/or upgrade is 21# An ebuild sets this to `yes' if an automatic installation and/or upgrade is
16# not possible. The ebuild should overwrite pkg_postinst() and explain the 22# not possible. The ebuild should overwrite pkg_postinst() and explain the
17# reason for this BEFORE calling webapp_pkg_postinst(). 23# reason for this BEFORE calling webapp_pkg_postinst().
22# you also need to take care of USE-flags and dependencies. 28# you also need to take care of USE-flags and dependencies.
23 29
24if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then 30if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then
25 [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts" 31 [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts"
26 SLOT="${PVR}" 32 SLOT="${PVR}"
27 DEPEND=">=app-admin/webapp-config-1.50.15" 33 DEPEND="${WEBAPP_DEPEND}"
28 RDEPEND="${DEPEND}" 34 RDEPEND="${DEPEND}"
29fi 35fi
30 36
31EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 37EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
32 38
51 debug-print-function $FUNCNAME $* 57 debug-print-function $FUNCNAME $*
52 58
53 if has_version '>=app-admin/webapp-config-1.50'; then 59 if has_version '>=app-admin/webapp-config-1.50'; then
54 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!"
55 eval ${ENVVAR} 61 eval ${ENVVAR}
56 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
57 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" 68 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
58 fi 69 fi
59} 70}
60 71
61# 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)
113 124
114 if [[ "${my_pn}" == "${PN}" ]]; then 125 if [[ "${my_pn}" == "${PN}" ]]; then
115 if [[ "${my_pvr}" != "${PVR}" ]]; then 126 if [[ "${my_pvr}" != "${PVR}" ]]; then
116 elog "This is an upgrade" 127 elog "This is an upgrade"
117 IS_UPGRADE=1 128 IS_UPGRADE=1
129 # for binpkgs, reset status, var declared in global scope
130 IS_REPLACE=0
118 else 131 else
119 elog "This is a re-installation" 132 elog "This is a re-installation"
120 IS_REPLACE=1 133 IS_REPLACE=1
134 # for binpkgs, reset status, var declared in global scope
135 IS_UPGRADE=0
121 fi 136 fi
122 else 137 else
123 elog "${my_output} is installed there" 138 elog "${my_output} is installed there"
124 fi 139 fi
125 else 140 else
141 # for binpkgs, reset status, var declared in global scope
142 IS_REPLACE=0
143 IS_UPGRADE=0
126 elog "This is an installation" 144 elog "This is an installation"
127 fi 145 fi
128} 146}
129 147
130# ============================================================================== 148# ==============================================================================
131# PUBLIC FUNCTIONS 149# PUBLIC FUNCTIONS
132# ============================================================================== 150# ==============================================================================
133 151
134# @FUNCTION: need_httpd 152# @FUNCTION: need_httpd
135# @DESCRIPTION: 153# @DESCRIPTION:
136# 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
137# webservers are able to run this application. 155# webservers are able to run this application.
138need_httpd() { 156need_httpd() {
139 DEPEND="${DEPEND} 157 DEPEND="${DEPEND}
140 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )" 158 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )"
141} 159}
142 160
143# @FUNCTION: need_httpd_cgi 161# @FUNCTION: need_httpd_cgi
144# @DESCRIPTION: 162# @DESCRIPTION:
145# 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
146# CGI-capable webservers are able to run this application. 164# CGI-capable webservers are able to run this application.
147need_httpd_cgi() { 165need_httpd_cgi() {
148 DEPEND="${DEPEND} 166 DEPEND="${DEPEND}
149 || ( virtual/httpd-cgi virtual/httpd-fastcgi )" 167 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
150} 168}
151 169
152# @FUNCTION: need_httpd_fastcgi 170# @FUNCTION: need_httpd_fastcgi
153# @DESCRIPTION: 171# @DESCRIPTION:
154# 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
155# FastCGI-capabale webservers are able to run this application. 173# FastCGI-capabale webservers are able to run this application.
156need_httpd_fastcgi() { 174need_httpd_fastcgi() {
157 DEPEND="${DEPEND} 175 DEPEND="${DEPEND}
158 virtual/httpd-fastcgi" 176 virtual/httpd-fastcgi"
159} 177}
313# 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.
314# For now we just create required webapp-config directories. 332# For now we just create required webapp-config directories.
315webapp_src_preinst() { 333webapp_src_preinst() {
316 debug-print-function $FUNCNAME $* 334 debug-print-function $FUNCNAME $*
317 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.
318 dodir "${MY_HTDOCSDIR}" 352 dodir "${MY_HTDOCSDIR}"
319 dodir "${MY_HOSTROOTDIR}" 353 dodir "${MY_HOSTROOTDIR}"
320 dodir "${MY_CGIBINDIR}" 354 dodir "${MY_CGIBINDIR}"
321 dodir "${MY_ICONSDIR}" 355 dodir "${MY_ICONSDIR}"
322 dodir "${MY_ERRORSDIR}" 356 dodir "${MY_ERRORSDIR}"
407 # 441 #
408 # 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
409 # no longer rely on Portage calling both webapp_src_install() and 443 # no longer rely on Portage calling both webapp_src_install() and
410 # webapp_pkg_postinst() within the same shell process 444 # webapp_pkg_postinst() within the same shell process
411 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 445 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
412
413 # sanity checks, to catch bugs in the ebuild
414 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
415 eerror
416 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
417 eerror "of the pkg_setup() function"
418 eerror
419 eerror "Please log a bug on http://bugs.gentoo.org"
420 eerror
421 eerror "You should use emerge -C to remove this package, as the"
422 eerror "installation is incomplete"
423 eerror
424 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
425 fi
426 446
427 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 447 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
428 chmod -R u-s "${D}/" 448 chmod -R u-s "${D}/"
429 chmod -R g-s "${D}/" 449 chmod -R g-s "${D}/"
430 450
484 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}"
485 elog "Running ${my_cmd}" 505 elog "Running ${my_cmd}"
486 ${my_cmd} 506 ${my_cmd}
487 507
488 echo 508 echo
489 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" 509 local cleaner="${WEBAPP_CLEANER} -p -C /${PN}"
490 einfo "Running ${cleaner}" 510 einfo "Running ${cleaner}"
491 ${cleaner} 511 ${cleaner}
492 else 512 else
493 elog 513 elog
494 elog "The 'vhosts' USE flag is switched ON" 514 elog "The 'vhosts' USE flag is switched ON"
531 if has vhosts ${IUSE} && ! use vhosts; then 551 if has vhosts ${IUSE} && ! use vhosts; then
532 echo "${my_output}" | while read x; do 552 echo "${my_output}" | while read x; do
533 if [[ -f "${x}"/.webapp ]]; then 553 if [[ -f "${x}"/.webapp ]]; then
534 . "${x}"/.webapp 554 . "${x}"/.webapp
535 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then 555 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then
536 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 556 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} ${PN} ${PVR}
537 fi 557 fi
538 else 558 else
539 ewarn "Cannot find file ${x}/.webapp" 559 ewarn "Cannot find file ${x}/.webapp"
540 fi 560 fi
541 done 561 done

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

  ViewVC Help
Powered by ViewVC 1.1.20