1 |
hollow 08/02/22 09:33:45 |
2 |
|
3 |
Modified: webapp.eclass |
4 |
Log: |
5 |
convert to standard documentation syntax |
6 |
|
7 |
Revision Changes Path |
8 |
1.49 eclass/webapp.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/webapp.eclass?rev=1.49&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/webapp.eclass?rev=1.49&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/webapp.eclass?r1=1.48&r2=1.49 |
13 |
|
14 |
Index: webapp.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v |
17 |
retrieving revision 1.48 |
18 |
retrieving revision 1.49 |
19 |
diff -u -r1.48 -r1.49 |
20 |
--- webapp.eclass 3 Jan 2007 20:16:39 -0000 1.48 |
21 |
+++ webapp.eclass 22 Feb 2008 09:33:45 -0000 1.49 |
22 |
@@ -1,26 +1,14 @@ |
23 |
# Copyright 1999-2006 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.48 2007/01/03 20:16:39 rl03 Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.49 2008/02/22 09:33:45 hollow Exp $ |
27 |
# |
28 |
-# eclass/webapp.eclass |
29 |
-# Eclass for installing applications to run under a web server |
30 |
-# |
31 |
-# Part of the implementation of GLEP #11 |
32 |
-# |
33 |
-# Author(s) Stuart Herbert |
34 |
-# Renat Lumpau <rl03@g.o> |
35 |
-# Gunnar Wrobel <wrobel@g.o> |
36 |
-# |
37 |
-# ------------------------------------------------------------------------ |
38 |
-# |
39 |
-# The master copy of this eclass is held in our subversion repository. |
40 |
-# http://svn.gnqs.org/projects/vhost-tools/browser/ |
41 |
-# |
42 |
-# If you make changes to this file and don't tell us, chances are that |
43 |
-# your changes will be overwritten the next time we release a new version |
44 |
-# of webapp-config. |
45 |
-# |
46 |
-# ------------------------------------------------------------------------ |
47 |
+# @ECLASS: webapp.eclass |
48 |
+# @MAINTAINER: |
49 |
+# web-apps@g.o |
50 |
+# @BLURB: functions for installing applications to run under a web server |
51 |
+# @DESCRIPTION: |
52 |
+# The webapp eclass contains functions to handle web applications with |
53 |
+# webapp-config. Part of the implementation of GLEP #11 |
54 |
|
55 |
SLOT="${PVR}" |
56 |
IUSE="vhosts" |
57 |
@@ -39,17 +27,13 @@ |
58 |
WEBAPP_CONFIG="${ROOT}/usr/sbin/webapp-config" |
59 |
WEBAPP_CLEANER="${ROOT}/usr/sbin/webapp-cleaner" |
60 |
|
61 |
-# ------------------------------------------------------------------------ |
62 |
-# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
63 |
-# |
64 |
+# ============================================================================== |
65 |
+# INTERNAL FUNCTIONS |
66 |
+# ============================================================================== |
67 |
+ |
68 |
# Load the config file /etc/vhosts/webapp-config |
69 |
-# |
70 |
# Supports both the old bash version, and the new python version |
71 |
-# |
72 |
-# ------------------------------------------------------------------------ |
73 |
- |
74 |
-function webapp_read_config () |
75 |
-{ |
76 |
+webapp_read_config() { |
77 |
if has_version '>=app-admin/webapp-config-1.50'; then |
78 |
ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" |
79 |
eval ${ENVVAR} |
80 |
@@ -58,19 +42,9 @@ |
81 |
fi |
82 |
} |
83 |
|
84 |
-# ------------------------------------------------------------------------ |
85 |
-# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
86 |
-# |
87 |
-# Check whether a specified file exists within the image/ directory |
88 |
+# Check whether a specified file exists in the given directory (`.' by default) |
89 |
# or not. |
90 |
-# |
91 |
-# @param $1 - file to look for |
92 |
-# @param $2 - prefix directory to use |
93 |
-# @return 0 on success, never returns on an error |
94 |
-# ------------------------------------------------------------------------ |
95 |
- |
96 |
-function webapp_checkfileexists () |
97 |
-{ |
98 |
+webapp_checkfileexists() { |
99 |
local my_prefix |
100 |
|
101 |
[ -n "${2}" ] && my_prefix="${2}/" || my_prefix= |
102 |
@@ -83,49 +57,33 @@ |
103 |
fi |
104 |
} |
105 |
|
106 |
-# ------------------------------------------------------------------------ |
107 |
-# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
108 |
-# ------------------------------------------------------------------------ |
109 |
- |
110 |
-function webapp_check_installedat |
111 |
-{ |
112 |
- local my_output |
113 |
- |
114 |
+webapp_check_installedat() { |
115 |
${WEBAPP_CONFIG} --show-installed -h localhost -d "${INSTALL_DIR}" 2> /dev/null |
116 |
} |
117 |
|
118 |
-# ------------------------------------------------------------------------ |
119 |
-# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY |
120 |
-# |
121 |
-# ------------------------------------------------------------------------ |
122 |
- |
123 |
-function webapp_strip_appdir () |
124 |
-{ |
125 |
+webapp_strip_appdir() { |
126 |
local my_stripped="${1}" |
127 |
echo "${1}" | sed -e "s|${MY_APPDIR}/||g;" |
128 |
} |
129 |
|
130 |
-function webapp_strip_d () |
131 |
-{ |
132 |
+webapp_strip_d() { |
133 |
echo "${1}" | sed -e "s|${D}||g;" |
134 |
} |
135 |
|
136 |
-function webapp_strip_cwd () |
137 |
-{ |
138 |
+webapp_strip_cwd() { |
139 |
local my_stripped="${1}" |
140 |
echo "${1}" | sed -e 's|/./|/|g;' |
141 |
} |
142 |
|
143 |
-# ------------------------------------------------------------------------ |
144 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
145 |
-# |
146 |
-# Identify a config file for a web-based application. |
147 |
-# |
148 |
-# @param $1 - config file |
149 |
-# ------------------------------------------------------------------------ |
150 |
- |
151 |
-function webapp_configfile () |
152 |
-{ |
153 |
+# ============================================================================== |
154 |
+# PUBLIC FUNCTIONS |
155 |
+# ============================================================================== |
156 |
+ |
157 |
+# @FUNCTION: webapp_configfile |
158 |
+# @USAGE: <file> [more files ...] |
159 |
+# @DESCRIPTION: |
160 |
+# Mark a file config-protected for a web-based application. |
161 |
+webapp_configfile() { |
162 |
local m="" |
163 |
for m in "$@" ; do |
164 |
webapp_checkfileexists "${m}" "${D}" |
165 |
@@ -138,17 +96,12 @@ |
166 |
done |
167 |
} |
168 |
|
169 |
-# ------------------------------------------------------------------------ |
170 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
171 |
-# |
172 |
+# @FUNCTION: webapp_hook_script |
173 |
+# @USAGE: <file> |
174 |
+# @DESCRIPTION: |
175 |
# Install a script that will run after a virtual copy is created, and |
176 |
-# before a virtual copy has been removed |
177 |
-# |
178 |
-# @param $1 - the script to run |
179 |
-# ------------------------------------------------------------------------ |
180 |
- |
181 |
-function webapp_hook_script () |
182 |
-{ |
183 |
+# before a virtual copy has been removed. |
184 |
+webapp_hook_script() { |
185 |
webapp_checkfileexists "${1}" |
186 |
|
187 |
elog "(hook) ${1}" |
188 |
@@ -156,55 +109,35 @@ |
189 |
chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" |
190 |
} |
191 |
|
192 |
-# ------------------------------------------------------------------------ |
193 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
194 |
-# |
195 |
+# @FUNCTION: webapp_postinst_txt |
196 |
+# @USAGE: <lang> <file> |
197 |
+# @DESCRIPTION: |
198 |
# Install a text file containing post-installation instructions. |
199 |
-# |
200 |
-# @param $1 - language code (use 'en' for now) |
201 |
-# @param $2 - the file to install |
202 |
-# ------------------------------------------------------------------------ |
203 |
- |
204 |
-function webapp_postinst_txt () |
205 |
-{ |
206 |
+webapp_postinst_txt() { |
207 |
webapp_checkfileexists "${2}" |
208 |
|
209 |
elog "(info) ${2} (lang: ${1})" |
210 |
cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" |
211 |
} |
212 |
|
213 |
-# ------------------------------------------------------------------------ |
214 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
215 |
-# |
216 |
+# @FUNCTION: webapp_postupgrade_txt |
217 |
+# @USAGE: <lang> <file> |
218 |
+# @DESCRIPTION: |
219 |
# Install a text file containing post-upgrade instructions. |
220 |
-# |
221 |
-# @param $1 - language code (use 'en' for now) |
222 |
-# @param $2 - the file to install |
223 |
-# ------------------------------------------------------------------------ |
224 |
- |
225 |
-function webapp_postupgrade_txt () |
226 |
-{ |
227 |
+webapp_postupgrade_txt() { |
228 |
webapp_checkfileexists "${2}" |
229 |
|
230 |
elog "(info) ${2} (lang: ${1})" |
231 |
cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" |
232 |
} |
233 |
|
234 |
-# ------------------------------------------------------------------------ |
235 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
236 |
-# |
237 |
-# Identify a file which must be owned by the webserver's user:group |
238 |
-# settings. |
239 |
-# |
240 |
-# The ownership of the file is NOT set until the application is installed |
241 |
-# using the webapp-config tool. |
242 |
-# |
243 |
-# @param $1 - file to be owned by the webserver user:group combo |
244 |
-# |
245 |
-# ------------------------------------------------------------------------ |
246 |
- |
247 |
-function webapp_serverowned () |
248 |
-{ |
249 |
+# @FUNCTION: webapp_serverowned |
250 |
+# @USAGE: [-R] <file> [more files ...] |
251 |
+# @DESCRIPTION: |
252 |
+# Identify a file which must be owned by the webserver's user:group settings. |
253 |
+# The ownership of the file is NOT set until the application is installed using |
254 |
+# the webapp-config tool. If -R is given directories are handled recursively. |
255 |
+webapp_serverowned() { |
256 |
local a="" |
257 |
local m="" |
258 |
if [ "${1}" = "-R" ]; then |
259 |
@@ -232,22 +165,14 @@ |
260 |
fi |
261 |
} |
262 |
|
263 |
-# ------------------------------------------------------------------------ |
264 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
265 |
-# |
266 |
-# @param $1 - the webserver to install the config file for |
267 |
-# (one of apache1, apache2, cherokee) |
268 |
-# @param $2 - the config file to install |
269 |
-# @param $3 - new name for the config file (default is `basename $2`) |
270 |
-# this is an optional parameter |
271 |
-# |
272 |
-# NOTE: |
273 |
-# this function will automagically prepend $1 to the front of your |
274 |
-# config file's name |
275 |
-# ------------------------------------------------------------------------ |
276 |
- |
277 |
-function webapp_server_configfile () |
278 |
-{ |
279 |
+# @FUNCTION: webapp_server_configfile |
280 |
+# @USAGE: <server> <file> [new name] |
281 |
+# @DESCRIPTION: |
282 |
+# Install a configuration file for the webserver. You need to specify a |
283 |
+# webapp-config supported <server>. if no new name is given `basename $2' is |
284 |
+# used by default. Note: this function will automagically prepend $1 to the |
285 |
+# front of your config file's name. |
286 |
+webapp_server_configfile() { |
287 |
webapp_checkfileexists "${2}" |
288 |
|
289 |
# sort out what the name will be of the config file |
290 |
@@ -269,20 +194,14 @@ |
291 |
cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" |
292 |
} |
293 |
|
294 |
-# ------------------------------------------------------------------------ |
295 |
-# EXPORTED FUNCTION - FOR USE IN EBUILDS |
296 |
-# |
297 |
-# @param $1 - the db engine that the script is for |
298 |
-# (one of: mysql|postgres) |
299 |
-# @param $2 - the sql script to be installed |
300 |
-# @param $3 - the older version of the app that this db script |
301 |
-# will upgrade from |
302 |
-# (do not pass this option if your SQL script only creates |
303 |
-# a new db from scratch) |
304 |
-# ------------------------------------------------------------------------ |
305 |
- |
306 |
-function webapp_sqlscript () |
307 |
-{ |
308 |
+# @FUNCTION: webapp_sqlscript |
309 |
+# @USAGE: <db> <file> [version] |
310 |
+# @DESCRIPTION: |
311 |
+# Install a SQL script that creates/upgrades a database schema for the web |
312 |
+# application. Currently supported database engines are mysql and postgres. |
313 |
+# If a version is given the script should upgrade the database schema from |
314 |
+# the given version to $PVR. |
315 |
+webapp_sqlscript() { |
316 |
webapp_checkfileexists "${2}" |
317 |
|
318 |
# create the directory where this script will go |
319 |
@@ -313,16 +232,16 @@ |
320 |
fi |
321 |
} |
322 |
|
323 |
-# ------------------------------------------------------------------------ |
324 |
-# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER |
325 |
-# everything else has run |
326 |
-# |
327 |
-# For now, we just make sure that root owns everything, and that there |
328 |
-# are no setuid files. |
329 |
-# ------------------------------------------------------------------------ |
330 |
- |
331 |
-function webapp_src_install () |
332 |
-{ |
333 |
+# ============================================================================== |
334 |
+# EXPORTED FUNCTIONS |
335 |
+# ============================================================================== |
336 |
+ |
337 |
+# @FUNCTION: webapp_src_install |
338 |
+# @DESCRIPTION: |
339 |
+# You need to call this function in src_install() AFTER everything else has run. |
340 |
+# For now, we just make sure that root owns everything, and that there are no |
341 |
+# setuid files. |
342 |
+webapp_src_install() { |
343 |
chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" |
344 |
chmod -R u-s "${D}/" |
345 |
chmod -R g-s "${D}/" |
346 |
@@ -341,16 +260,11 @@ |
347 |
touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" |
348 |
} |
349 |
|
350 |
-# ------------------------------------------------------------------------ |
351 |
-# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER |
352 |
-# everything else has run |
353 |
-# |
354 |
-# If 'vhosts' USE flag is not set, auto-install this app |
355 |
-# |
356 |
-# ------------------------------------------------------------------------ |
357 |
- |
358 |
-function webapp_pkg_setup () |
359 |
-{ |
360 |
+# @FUNCTION: webapp_pkg_setup |
361 |
+# @DESCRIPTION: |
362 |
+# You need to call this function in pkg_config() AFTER everything else has run. |
363 |
+# If 'vhosts' USE flag is not set, auto-install this app. |
364 |
+webapp_pkg_setup() { |
365 |
# add sanity checks here |
366 |
|
367 |
# special case - some ebuilds *do* need to overwride the SLOT |
368 |
@@ -391,8 +305,7 @@ |
369 |
fi |
370 |
} |
371 |
|
372 |
-function webapp_getinstalltype () |
373 |
-{ |
374 |
+webapp_getinstalltype() { |
375 |
# or are we upgrading? |
376 |
|
377 |
if ! use vhosts ; then |
378 |
@@ -429,8 +342,7 @@ |
379 |
fi |
380 |
} |
381 |
|
382 |
-function webapp_src_preinst () |
383 |
-{ |
384 |
+webapp_src_preinst() { |
385 |
# create the directories that we need |
386 |
|
387 |
dodir "${MY_HTDOCSDIR}" |
388 |
@@ -443,8 +355,7 @@ |
389 |
dodir "${MY_SERVERCONFIGDIR}" |
390 |
} |
391 |
|
392 |
-function webapp_pkg_postinst () |
393 |
-{ |
394 |
+webapp_pkg_postinst() { |
395 |
webapp_read_config |
396 |
|
397 |
# sanity checks, to catch bugs in the ebuild |
398 |
@@ -514,8 +425,7 @@ |
399 |
return 0 |
400 |
} |
401 |
|
402 |
-function webapp_pkg_prerm () |
403 |
-{ |
404 |
+webapp_pkg_prerm() { |
405 |
# remove any virtual installs that there are |
406 |
|
407 |
local my_output |
408 |
|
409 |
|
410 |
|
411 |
-- |
412 |
gentoo-commits@l.g.o mailing list |