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

Diff of /eclass/webapp.eclass

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

Revision 1.59 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.59 2008/02/23 23:54:40 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().
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
18[[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts" 31 [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts"
19
20SLOT="${PVR}" 32 SLOT="${PVR}"
21DEPEND=">=app-admin/webapp-config-1.50.15" 33 DEPEND="${WEBAPP_DEPEND}"
22RDEPEND="${DEPEND}" 34 RDEPEND="${DEPEND}"
35fi
23 36
24EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 37EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
25 38
26INSTALL_DIR="/${PN}" 39INSTALL_DIR="/${PN}"
27IS_UPGRADE=0 40IS_UPGRADE=0
44 debug-print-function $FUNCNAME $* 57 debug-print-function $FUNCNAME $*
45 58
46 if has_version '>=app-admin/webapp-config-1.50'; then 59 if has_version '>=app-admin/webapp-config-1.50'; then
47 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!"
48 eval ${ENVVAR} 61 eval ${ENVVAR}
49 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
50 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" 68 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
51 fi 69 fi
52} 70}
53 71
54# 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)
106 124
107 if [[ "${my_pn}" == "${PN}" ]]; then 125 if [[ "${my_pn}" == "${PN}" ]]; then
108 if [[ "${my_pvr}" != "${PVR}" ]]; then 126 if [[ "${my_pvr}" != "${PVR}" ]]; then
109 elog "This is an upgrade" 127 elog "This is an upgrade"
110 IS_UPGRADE=1 128 IS_UPGRADE=1
129 # for binpkgs, reset status, var declared in global scope
130 IS_REPLACE=0
111 else 131 else
112 elog "This is a re-installation" 132 elog "This is a re-installation"
113 IS_REPLACE=1 133 IS_REPLACE=1
134 # for binpkgs, reset status, var declared in global scope
135 IS_UPGRADE=0
114 fi 136 fi
115 else 137 else
116 elog "${my_output} is installed there" 138 elog "${my_output} is installed there"
117 fi 139 fi
118 else 140 else
141 # for binpkgs, reset status, var declared in global scope
142 IS_REPLACE=0
143 IS_UPGRADE=0
119 elog "This is an installation" 144 elog "This is an installation"
120 fi 145 fi
121} 146}
122 147
123# ============================================================================== 148# ==============================================================================
124# PUBLIC FUNCTIONS 149# PUBLIC FUNCTIONS
125# ============================================================================== 150# ==============================================================================
126 151
127# @FUNCTION: need_httpd 152# @FUNCTION: need_httpd
128# @DESCRIPTION: 153# @DESCRIPTION:
129# 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
130# webservers are able to run this application. 155# webservers are able to run this application.
131need_httpd() { 156need_httpd() {
132 DEPEND="${DEPEND} 157 DEPEND="${DEPEND}
133 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )" 158 || ( virtual/httpd-basic virtual/httpd-cgi virtual/httpd-fastcgi )"
134} 159}
135 160
136# @FUNCTION: need_httpd_cgi 161# @FUNCTION: need_httpd_cgi
137# @DESCRIPTION: 162# @DESCRIPTION:
138# 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
139# CGI-capable webservers are able to run this application. 164# CGI-capable webservers are able to run this application.
140need_httpd_cgi() { 165need_httpd_cgi() {
141 DEPEND="${DEPEND} 166 DEPEND="${DEPEND}
142 || ( virtual/httpd-cgi virtual/httpd-fastcgi )" 167 || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
143} 168}
144 169
145# @FUNCTION: need_httpd_fastcgi 170# @FUNCTION: need_httpd_fastcgi
146# @DESCRIPTION: 171# @DESCRIPTION:
147# 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
148# FastCGI-capabale webservers are able to run this application. 173# FastCGI-capabale webservers are able to run this application.
149need_httpd_fastcgi() { 174need_httpd_fastcgi() {
150 DEPEND="${DEPEND} 175 DEPEND="${DEPEND}
151 virtual/httpd-fastcgi" 176 virtual/httpd-fastcgi"
152} 177}
306# 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.
307# For now we just create required webapp-config directories. 332# For now we just create required webapp-config directories.
308webapp_src_preinst() { 333webapp_src_preinst() {
309 debug-print-function $FUNCNAME $* 334 debug-print-function $FUNCNAME $*
310 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.
311 dodir "${MY_HTDOCSDIR}" 352 dodir "${MY_HTDOCSDIR}"
312 dodir "${MY_HOSTROOTDIR}" 353 dodir "${MY_HOSTROOTDIR}"
313 dodir "${MY_CGIBINDIR}" 354 dodir "${MY_CGIBINDIR}"
314 dodir "${MY_ICONSDIR}" 355 dodir "${MY_ICONSDIR}"
315 dodir "${MY_ERRORSDIR}" 356 dodir "${MY_ERRORSDIR}"
400 # 441 #
401 # 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
402 # no longer rely on Portage calling both webapp_src_install() and 443 # no longer rely on Portage calling both webapp_src_install() and
403 # webapp_pkg_postinst() within the same shell process 444 # webapp_pkg_postinst() within the same shell process
404 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 445 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
405
406 # sanity checks, to catch bugs in the ebuild
407 if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then
408 eerror
409 eerror "This ebuild did not call webapp_pkg_setup() at the beginning"
410 eerror "of the pkg_setup() function"
411 eerror
412 eerror "Please log a bug on http://bugs.gentoo.org"
413 eerror
414 eerror "You should use emerge -C to remove this package, as the"
415 eerror "installation is incomplete"
416 eerror
417 die "Ebuild did not call webapp_pkg_setup() - report to http://bugs.gentoo.org"
418 fi
419 446
420 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 447 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
421 chmod -R u-s "${D}/" 448 chmod -R u-s "${D}/"
422 chmod -R g-s "${D}/" 449 chmod -R g-s "${D}/"
423 450
477 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}"
478 elog "Running ${my_cmd}" 505 elog "Running ${my_cmd}"
479 ${my_cmd} 506 ${my_cmd}
480 507
481 echo 508 echo
482 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" 509 local cleaner="${WEBAPP_CLEANER} -p -C /${PN}"
483 einfo "Running ${cleaner}" 510 einfo "Running ${cleaner}"
484 ${cleaner} 511 ${cleaner}
485 else 512 else
486 elog 513 elog
487 elog "The 'vhosts' USE flag is switched ON" 514 elog "The 'vhosts' USE flag is switched ON"
524 if has vhosts ${IUSE} && ! use vhosts; then 551 if has vhosts ${IUSE} && ! use vhosts; then
525 echo "${my_output}" | while read x; do 552 echo "${my_output}" | while read x; do
526 if [[ -f "${x}"/.webapp ]]; then 553 if [[ -f "${x}"/.webapp ]]; then
527 . "${x}"/.webapp 554 . "${x}"/.webapp
528 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then 555 if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then
529 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 556 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} ${PN} ${PVR}
530 fi 557 fi
531 else 558 else
532 ewarn "Cannot find file ${x}/.webapp" 559 ewarn "Cannot find file ${x}/.webapp"
533 fi 560 fi
534 done 561 done

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

  ViewVC Help
Powered by ViewVC 1.1.20