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

Diff of /eclass/webapp.eclass

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

Revision 1.53 Revision 1.54
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.53 2008/02/22 14:06:05 hollow Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.54 2008/02/22 14:27:17 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
78 echo "${1/#.\///}" 78 echo "${1/#.\///}"
79} 79}
80 80
81webapp_getinstalltype() { 81webapp_getinstalltype() {
82 debug-print-function $FUNCNAME $* 82 debug-print-function $FUNCNAME $*
83 use vhosts && return
83 84
84 if ! use vhosts; then
85 local my_output 85 local my_output
86
87 my_output="$(webapp_check_installedat)" 86 my_output="$(webapp_check_installedat)"
88 87
89 if [[ $? -eq 0 ]]; then 88 if [[ $? -eq 0 ]]; then
90 # something is already installed there 89 # something is already installed there
91 # make sure it isn't the same version 90 # make sure it isn't the same version
92 91
93 local my_pn="$(echo ${my_output} | awk '{ print $1 }')" 92 local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
94 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')" 93 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
95 94
96 REMOVE_PKG="${my_pn}-${my_pvr}" 95 REMOVE_PKG="${my_pn}-${my_pvr}"
97 96
98 if [[ "${my_pn}" == "${PN}" ]]; then 97 if [[ "${my_pn}" == "${PN}" ]]; then
99 if [[ "${my_pvr}" != "${PVR}" ]]; then 98 if [[ "${my_pvr}" != "${PVR}" ]]; then
100 elog "This is an upgrade" 99 elog "This is an upgrade"
101 IS_UPGRADE=1 100 IS_UPGRADE=1
102 else
103 elog "This is a re-installation"
104 IS_REPLACE=1
105 fi
106 else 101 else
107 elog "${my_output} is installed there" 102 elog "This is a re-installation"
103 IS_REPLACE=1
108 fi 104 fi
109 else 105 else
110 elog "This is an installation" 106 elog "${my_output} is installed there"
111 fi 107 fi
108 else
109 elog "This is an installation"
112 fi 110 fi
113} 111}
114 112
115# ============================================================================== 113# ==============================================================================
116# PUBLIC FUNCTIONS 114# PUBLIC FUNCTIONS
121# @DESCRIPTION: 119# @DESCRIPTION:
122# Mark a file config-protected for a web-based application. 120# Mark a file config-protected for a web-based application.
123webapp_configfile() { 121webapp_configfile() {
124 debug-print-function $FUNCNAME $* 122 debug-print-function $FUNCNAME $*
125 123
126 local m="" 124 local m
127 for m in "$@"; do 125 for m in "$@"; do
128 webapp_checkfileexists "${m}" "${D}" 126 webapp_checkfileexists "${m}" "${D}"
129 127
130 local MY_FILE="$(webapp_strip_appdir "${m}")" 128 local my_file="$(webapp_strip_appdir "${m}")"
131 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 129 my_file="$(webapp_strip_cwd "${my_file}")"
132 130
133 elog "(config) ${MY_FILE}" 131 elog "(config) ${my_file}"
134 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST} 132 echo "${my_file}" >> ${D}/${WA_CONFIGLIST}
135 done 133 done
136} 134}
137 135
138# @FUNCTION: webapp_hook_script 136# @FUNCTION: webapp_hook_script
139# @USAGE: <file> 137# @USAGE: <file>
183# The ownership of the file is NOT set until the application is installed using 181# The ownership of the file is NOT set until the application is installed using
184# the webapp-config tool. If -R is given directories are handled recursively. 182# the webapp-config tool. If -R is given directories are handled recursively.
185webapp_serverowned() { 183webapp_serverowned() {
186 debug-print-function $FUNCNAME $* 184 debug-print-function $FUNCNAME $*
187 185
188 local a="" 186 local a m
189 local m=""
190 if [[ "${1}" == "-R" ]]; then 187 if [[ "${1}" == "-R" ]]; then
191 shift 188 shift
192 for m in "$@"; do 189 for m in "$@"; do
193 for a in $(find ${D}/${m}); do 190 for a in $(find ${D}/${m}); do
194 a=${a/${D}\/\///} 191 a=${a/${D}\/\///}
195 webapp_checkfileexists "${a}" "$D" 192 webapp_checkfileexists "${a}" "$D"
196 local MY_FILE="$(webapp_strip_appdir "${a}")" 193 local my_file="$(webapp_strip_appdir "${a}")"
197 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 194 my_file="$(webapp_strip_cwd "${my_file}")"
198 195
199 elog "(server owned) ${MY_FILE}" 196 elog "(server owned) ${my_file}"
200 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 197 echo "${my_file}" >> "${D}/${WA_SOLIST}"
201 done 198 done
202 done 199 done
203 else 200 else
204 for m in "$@"; do 201 for m in "$@"; do
205 webapp_checkfileexists "${m}" "$D" 202 webapp_checkfileexists "${m}" "$D"
206 local MY_FILE="$(webapp_strip_appdir "${m}")" 203 local my_file="$(webapp_strip_appdir "${m}")"
207 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 204 my_file="$(webapp_strip_cwd "${my_file}")"
208 205
209 elog "(server owned) ${MY_FILE}" 206 elog "(server owned) ${my_file}"
210 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 207 echo "${my_file}" >> "${D}/${WA_SOLIST}"
211 done 208 done
212 fi 209 fi
213} 210}
214 211
215# @FUNCTION: webapp_server_configfile 212# @FUNCTION: webapp_server_configfile
245webapp_sqlscript() { 242webapp_sqlscript() {
246 debug-print-function $FUNCNAME $* 243 debug-print-function $FUNCNAME $*
247 244
248 webapp_checkfileexists "${2}" 245 webapp_checkfileexists "${2}"
249 246
250 if [[ ! -d "${D}/${MY_SQLSCRIPTSDIR}/${1}" ]]; then 247 dodir "${MY_SQLSCRIPTSDIR}/${1}"
251 mkdir -p "${D}/${MY_SQLSCRIPTSDIR}/${1}" || die "unable to create directory ${D}/${MY_SQLSCRIPTSDIR}/${1}"
252 fi
253 248
254 # WARNING: 249 # WARNING:
255 # 250 #
256 # do NOT change the naming convention used here without changing all 251 # do NOT change the naming convention used here without changing all
257 # the other scripts that also rely upon these names 252 # the other scripts that also rely upon these names
334 329
335 # pull in the shared configuration file 330 # pull in the shared configuration file
336 G_HOSTNAME="localhost" 331 G_HOSTNAME="localhost"
337 webapp_read_config 332 webapp_read_config
338 333
339 # are we installing a webapp-config solution over the top of a
340 # non-webapp-config solution?
341 if ! use vhosts; then
342 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" 334 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
335
336 # if USE=vhosts is enabled OR no application is installed we're done here
337 use vhosts || [[ ! -d "${my_dir}" ]] && return
338
343 local my_output 339 local my_output
344
345 if [[ -d "${my_dir}" ]]; then
346 my_output="$(webapp_check_installedat)" 340 my_output="$(webapp_check_installedat)"
347 341
348 if [[ $? -ne 0 ]]; then 342 if [[ $? -ne 0 ]]; then
349 # okay, whatever is there, it isn't webapp-config-compatible 343 # okay, whatever is there, it isn't webapp-config-compatible
350 ewarn "You already have something installed in ${my_dir}" 344 ewarn "You already have something installed in ${my_dir}"
351 ewarn 345 ewarn
352 ewarn "Whatever is in ${my_dir}, it's not" 346 ewarn "Whatever is in ${my_dir}, it's not"
353 ewarn "compatible with webapp-config." 347 ewarn "compatible with webapp-config."
354 ewarn 348 ewarn
355 ewarn "This ebuild may be overwriting important files." 349 ewarn "This ebuild may be overwriting important files."
356 ewarn 350 ewarn
357 elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then 351 elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then
358 eerror "${my_dir} contains ${my_output}" 352 eerror "${my_dir} contains ${my_output}"
359 eerror "I cannot upgrade that" 353 eerror "I cannot upgrade that"
360 die "Cannot upgrade contents of ${my_dir}" 354 die "Cannot upgrade contents of ${my_dir}"
361 fi
362 fi
363 fi 355 fi
364} 356}
365 357
366# @FUNCTION: webapp_pkg_postinst 358# @FUNCTION: webapp_pkg_postinst
367# @DESCRIPTION: 359# @DESCRIPTION:

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

  ViewVC Help
Powered by ViewVC 1.1.20