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

Diff of /eclass/webapp.eclass

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

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

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.72

  ViewVC Help
Powered by ViewVC 1.1.20