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

Diff of /eclass/webapp.eclass

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

Revision 1.49 Revision 1.50
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.49 2008/02/22 09:33:45 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.50 2008/02/22 10:03:55 hollow 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
41 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" 41 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
42 fi 42 fi
43} 43}
44 44
45# Check whether a specified file exists in the given directory (`.' by default) 45# Check whether a specified file exists in the given directory (`.' by default)
46# or not.
47webapp_checkfileexists() { 46webapp_checkfileexists() {
48 local my_prefix 47 local my_prefix
49 48
50 [ -n "${2}" ] && my_prefix="${2}/" || my_prefix= 49 [ -n "${2}" ] && my_prefix="${2}/" || my_prefix=
51 50
71} 70}
72 71
73webapp_strip_cwd() { 72webapp_strip_cwd() {
74 local my_stripped="${1}" 73 local my_stripped="${1}"
75 echo "${1}" | sed -e 's|/./|/|g;' 74 echo "${1}" | sed -e 's|/./|/|g;'
75}
76
77webapp_getinstalltype() {
78 # or are we upgrading?
79
80 if ! use vhosts ; then
81 # we only run webapp-config if vhosts USE flag is not set
82
83 local my_output
84
85 my_output="$(webapp_check_installedat)"
86
87 if [ "${?}" = "0" ] ; then
88 # something is already installed there
89 #
90 # make sure it isn't the same version
91
92 local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
93 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
94
95 REMOVE_PKG="${my_pn}-${my_pvr}"
96
97 if [ "${my_pn}" == "${PN}" ]; then
98 if [ "${my_pvr}" != "${PVR}" ]; then
99 elog "This is an upgrade"
100 IS_UPGRADE=1
101 else
102 elog "This is a re-installation"
103 IS_REPLACE=1
104 fi
105 else
106 elog "${my_output} is installed there"
107 fi
108 else
109 elog "This is an installation"
110 fi
111 fi
76} 112}
77 113
78# ============================================================================== 114# ==============================================================================
79# PUBLIC FUNCTIONS 115# PUBLIC FUNCTIONS
80# ============================================================================== 116# ==============================================================================
230 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 266 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
231 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 267 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
232 fi 268 fi
233} 269}
234 270
271# @FUNCTION: webapp_src_preinst
272# @DESCRIPTION:
273# You need to call this function in src_install() BEFORE anything else has run.
274# For now we just create required webapp-config directories.
275webapp_src_preinst() {
276 dodir "${MY_HTDOCSDIR}"
277 dodir "${MY_HOSTROOTDIR}"
278 dodir "${MY_CGIBINDIR}"
279 dodir "${MY_ICONSDIR}"
280 dodir "${MY_ERRORSDIR}"
281 dodir "${MY_SQLSCRIPTSDIR}"
282 dodir "${MY_HOOKSCRIPTSDIR}"
283 dodir "${MY_SERVERCONFIGDIR}"
284}
285
235# ============================================================================== 286# ==============================================================================
236# EXPORTED FUNCTIONS 287# EXPORTED FUNCTIONS
237# ============================================================================== 288# ==============================================================================
238 289
239# @FUNCTION: webapp_src_install 290# @FUNCTION: webapp_src_install
240# @DESCRIPTION: 291# @DESCRIPTION:
292# This is the default src_install(). For now, we just make sure that root owns
293# everything, and that there are no setuid files.
294#
241# You need to call this function in src_install() AFTER everything else has run. 295# You need to call this function AFTER everything else has run in your custom
242# For now, we just make sure that root owns everything, and that there are no 296# src_install().
243# setuid files.
244webapp_src_install() { 297webapp_src_install() {
245 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 298 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
246 chmod -R u-s "${D}/" 299 chmod -R u-s "${D}/"
247 chmod -R g-s "${D}/" 300 chmod -R g-s "${D}/"
248 301
260 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" 313 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
261} 314}
262 315
263# @FUNCTION: webapp_pkg_setup 316# @FUNCTION: webapp_pkg_setup
264# @DESCRIPTION: 317# @DESCRIPTION:
265# You need to call this function in pkg_config() AFTER everything else has run. 318# The default pkg_setup() for this eclass. This will gather required variables
266# If 'vhosts' USE flag is not set, auto-install this app. 319# from webapp-config and check if there is an application installed to
320# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set.
321#
322# You need to call this function BEFORE anything else has run in your custom
323# pkg_setup().
267webapp_pkg_setup() { 324webapp_pkg_setup() {
268 # add sanity checks here 325 # add sanity checks here
269 326
270 # special case - some ebuilds *do* need to overwride the SLOT 327 # special case - some ebuilds *do* need to overwride the SLOT
271 if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then 328 if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then
303 fi 360 fi
304 fi 361 fi
305 fi 362 fi
306} 363}
307 364
308webapp_getinstalltype() { 365# @FUNCTION: webapp_pkg_postinst
309 # or are we upgrading? 366# @DESCRIPTION:
310 367# The default pkg_postinst() for this eclass. This installs the web application to
311 if ! use vhosts ; then 368# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set. Otherwise
312 # we only run webapp-config if vhosts USE flag is not set 369# display a short notice how to install this application with webapp-config.
313 370#
314 local my_output 371# You need to call this function AFTER everything else has run in your custom
315 372# pkg_postinst().
316 my_output="$(webapp_check_installedat)"
317
318 if [ "${?}" = "0" ] ; then
319 # something is already installed there
320 #
321 # make sure it isn't the same version
322
323 local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
324 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
325
326 REMOVE_PKG="${my_pn}-${my_pvr}"
327
328 if [ "${my_pn}" == "${PN}" ]; then
329 if [ "${my_pvr}" != "${PVR}" ]; then
330 elog "This is an upgrade"
331 IS_UPGRADE=1
332 else
333 elog "This is a re-installation"
334 IS_REPLACE=1
335 fi
336 else
337 elog "${my_output} is installed there"
338 fi
339 else
340 elog "This is an installation"
341 fi
342 fi
343}
344
345webapp_src_preinst() {
346 # create the directories that we need
347
348 dodir "${MY_HTDOCSDIR}"
349 dodir "${MY_HOSTROOTDIR}"
350 dodir "${MY_CGIBINDIR}"
351 dodir "${MY_ICONSDIR}"
352 dodir "${MY_ERRORSDIR}"
353 dodir "${MY_SQLSCRIPTSDIR}"
354 dodir "${MY_HOOKSCRIPTSDIR}"
355 dodir "${MY_SERVERCONFIGDIR}"
356}
357
358webapp_pkg_postinst() { 373webapp_pkg_postinst() {
359 webapp_read_config 374 webapp_read_config
360 375
361 # sanity checks, to catch bugs in the ebuild 376 # sanity checks, to catch bugs in the ebuild
362 377
423 fi 438 fi
424 439
425 return 0 440 return 0
426} 441}
427 442
443# @FUNCTION: webapp_pkg_prerm
444# @DESCRIPTION:
445# This is the default pkg_prerm() for this eclass. If USE=vhosts is not set
446# remove all installed copies of this web application. Otherwise instruct the
447# user to manually remove those copies.
428webapp_pkg_prerm() { 448webapp_pkg_prerm() {
429 # remove any virtual installs that there are 449 # remove any virtual installs that there are
430 450
431 local my_output 451 local my_output
432 local x 452 local x

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.20