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

Diff of /eclass/webapp.eclass

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

Revision 1.18 Revision 1.38
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2005 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.18 2004/05/17 22:44:35 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.38 2006/01/01 01:14:59 swegener Exp $
4# 4#
5# eclass/webapp.eclass 5# eclass/webapp.eclass
6# Eclass for installing applications to run under a web server 6# Eclass for installing applications to run under a web server
7# 7#
8# Part of the implementation of GLEP #11 8# Part of the implementation of GLEP #11
9# 9#
10# Author(s) Stuart Herbert <stuart@gentoo.org> 10# Author(s) Stuart Herbert <stuart@gentoo.org>
11# Renat Lumpau <rl03@gentoo.org>
12# Gunnar Wrobel <php@gunnarwrobel.org>
11# 13#
12# ------------------------------------------------------------------------ 14# ------------------------------------------------------------------------
13# 15#
14# The master copy of this eclass is held in Stu's subversion repository. 16# The master copy of this eclass is held in our subversion repository.
17# http://svn.gnqs.org/projects/vhost-tools/browser/
15# 18#
16# If you make changes to this file and don't tell Stu, chances are that 19# If you make changes to this file and don't tell us, chances are that
17# your changes will be overwritten the next time Stu releases a new version 20# your changes will be overwritten the next time we release a new version
18# of webapp-config. 21# of webapp-config.
19# 22#
20# ------------------------------------------------------------------------ 23# ------------------------------------------------------------------------
21 24
22ECLASS=webapp
23INHERITED="$INHERITED $ECLASS"
24SLOT="${PVR}" 25SLOT="${PVR}"
25IUSE="$IUSE vhosts" 26IUSE="vhosts"
26DEPEND="$DEPEND >=net-www/webapp-config-1.9 app-portage/gentoolkit" 27DEPEND="app-admin/webapp-config"
28RDEPEND="${DEPEND}"
27 29
28EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 30EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
29 31
30INSTALL_DIR="/$PN" 32INSTALL_DIR="/${PN}"
31IS_UPGRADE=0 33IS_UPGRADE=0
32IS_REPLACE=0 34IS_REPLACE=0
35
36INSTALL_CHECK_FILE="installed_by_webapp_eclass"
37
38ETC_CONFIG="${ROOT}/etc/vhosts/webapp-config"
39WEBAPP_CONFIG="${ROOT}/usr/sbin/webapp-config"
40
41# ------------------------------------------------------------------------
42# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
43#
44# Load the config file /etc/vhosts/webapp-config
45#
46# Supports both the old bash version, and the new python version
47#
48# ------------------------------------------------------------------------
49
50function webapp_read_config ()
51{
52 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!"
54 eval ${ENVVAR}
55 else
56 . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}"
57 fi
58}
33 59
34# ------------------------------------------------------------------------ 60# ------------------------------------------------------------------------
35# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 61# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
36# 62#
37# Check whether a specified file exists within the image/ directory 63# Check whether a specified file exists within the image/ directory
44 70
45function webapp_checkfileexists () 71function webapp_checkfileexists ()
46{ 72{
47 local my_prefix 73 local my_prefix
48 74
49 [ -n "$2" ] && my_prefix="$2/" || my_prefix= 75 [ -n "${2}" ] && my_prefix="${2}/" || my_prefix=
50 76
51 if [ ! -e ${my_prefix}$1 ]; then 77 if [ ! -e "${my_prefix}${1}" ]; then
52 msg="ebuild fault: file $1 not found" 78 msg="ebuild fault: file '${1}' not found"
53 eerror "$msg" 79 eerror "$msg"
54 eerror "Please report this as a bug at http://bugs.gentoo.org/" 80 eerror "Please report this as a bug at http://bugs.gentoo.org/"
55 die "$msg" 81 die "$msg"
56 fi 82 fi
57} 83}
62 88
63function webapp_check_installedat 89function webapp_check_installedat
64{ 90{
65 local my_output 91 local my_output
66 92
67 /usr/sbin/webapp-config --show-installed -h localhost -d $INSTALL_DIR 2> /dev/null 93 ${WEBAPP_CONFIG} --show-installed -h localhost -d "${INSTALL_DIR}" 2> /dev/null
68} 94}
69 95
70# ------------------------------------------------------------------------ 96# ------------------------------------------------------------------------
71# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 97# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
72# ------------------------------------------------------------------------
73
74function webapp_import_config ()
75{
76 if [ -z "${MY_HTDOCSDIR}" ]; then
77 . /etc/conf.d/webapp-config
78 fi
79
80 if [ -z "${MY_HTDOCSDIR}" ]; then
81 libsh_edie "/etc/conf.d/webapp-config not imported"
82 fi
83}
84
85# ------------------------------------------------------------------------
86# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
87# 98#
88# ------------------------------------------------------------------------ 99# ------------------------------------------------------------------------
89 100
90function webapp_strip_appdir () 101function webapp_strip_appdir ()
91{ 102{
92 local my_stripped="$1" 103 local my_stripped="${1}"
93 echo "$1" | sed -e "s|${MY_APPDIR}/||g;" 104 echo "${1}" | sed -e "s|${MY_APPDIR}/||g;"
94} 105}
95 106
96function webapp_strip_d () 107function webapp_strip_d ()
97{ 108{
98 echo "$1" | sed -e "s|${D}||g;" 109 echo "${1}" | sed -e "s|${D}||g;"
99} 110}
100 111
101function webapp_strip_cwd () 112function webapp_strip_cwd ()
102{ 113{
103 local my_stripped="$1" 114 local my_stripped="${1}"
104 echo "$1" | sed -e 's|/./|/|g;' 115 echo "${1}" | sed -e 's|/./|/|g;'
105} 116}
106 117
107# ------------------------------------------------------------------------ 118# ------------------------------------------------------------------------
108# EXPORTED FUNCTION - FOR USE IN EBUILDS 119# EXPORTED FUNCTION - FOR USE IN EBUILDS
109# 120#
112# @param $1 - config file 123# @param $1 - config file
113# ------------------------------------------------------------------------ 124# ------------------------------------------------------------------------
114 125
115function webapp_configfile () 126function webapp_configfile ()
116{ 127{
117 webapp_checkfileexists "$1" "$D" 128 webapp_checkfileexists "${1}" "${D}"
118 echo $1 129
119 local MY_FILE="`webapp_strip_appdir $1`" 130 local MY_FILE="$(webapp_strip_appdir ${1})"
120 echo $MY_FILE 131 MY_FILE="$(webapp_strip_cwd ${MY_FILE})"
121 132
122 einfo "(config) $MY_FILE" 133 einfo "(config) ${MY_FILE}"
123 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} 134 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST}
124} 135}
125 136
126# ------------------------------------------------------------------------ 137# ------------------------------------------------------------------------
127# EXPORTED FUNCTION - FOR USE IN EBUILDS 138# EXPORTED FUNCTION - FOR USE IN EBUILDS
128# 139#
132# @param $1 - the script to run 143# @param $1 - the script to run
133# ------------------------------------------------------------------------ 144# ------------------------------------------------------------------------
134 145
135function webapp_hook_script () 146function webapp_hook_script ()
136{ 147{
137 webapp_checkfileexists "$2" 148 webapp_checkfileexists "${1}"
138 149
139 einfo "(hook) $1" 150 einfo "(hook) ${1}"
140 cp "$1" "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`" || die "Unable to install $1 into ${D}${MY_HOOKSCRIPTSDIR}/" 151 cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename ${1})" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/"
141 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`" 152 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename ${1})"
142} 153}
143 154
144# ------------------------------------------------------------------------ 155# ------------------------------------------------------------------------
145# EXPORTED FUNCTION - FOR USE IN EBUILDS 156# EXPORTED FUNCTION - FOR USE IN EBUILDS
146# 157#
148# 159#
149# @param $1 - language code (use 'en' for now) 160# @param $1 - language code (use 'en' for now)
150# @param $2 - the file to install 161# @param $2 - the file to install
151# ------------------------------------------------------------------------ 162# ------------------------------------------------------------------------
152 163
153function webapp_postinst_txt 164function webapp_postinst_txt ()
154{ 165{
155 webapp_checkfileexists "$2" 166 webapp_checkfileexists "${2}"
156 167
157 einfo "(rtfm) $2 (lang: $1)" 168 einfo "(info) ${2} (lang: ${1})"
158 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt" 169 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt"
159} 170}
160 171
161# ------------------------------------------------------------------------ 172# ------------------------------------------------------------------------
162# EXPORTED FUNCTION - FOR USE IN EBUILDS 173# EXPORTED FUNCTION - FOR USE IN EBUILDS
163# 174#
164# Identify a script file (usually, but not always PHP or Perl) which is 175# Install a text file containing post-upgrade instructions.
165# 176#
166# Files in this list may be modified to #! the required CGI engine when 177# @param $1 - language code (use 'en' for now)
167# installed by webapp-config tool in the future. 178# @param $2 - the file to install
168#
169# @param $1 - the cgi engine to use
170# @param $2 - the script file that could run under a cgi-bin
171#
172# ------------------------------------------------------------------------ 179# ------------------------------------------------------------------------
173 180
174function webapp_runbycgibin () 181function webapp_postupgrade_txt ()
175{ 182{
176 webapp_checkfileexists "$2" "$D" 183 webapp_checkfileexists "${2}"
177 local MY_FILE="`webapp_strip_appdir $2`"
178 MY_FILE="`webapp_strip_cwd $MY_FILE`"
179 184
180 einfo "(cgi-bin) $1 - $MY_FILE" 185 einfo "(info) ${2} (lang: ${1})"
181 echo "$1 $MY_FILE" >> ${D}${WA_RUNBYCGIBINLIST} 186 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt"
182} 187}
183 188
184# ------------------------------------------------------------------------ 189# ------------------------------------------------------------------------
185# EXPORTED FUNCTION - FOR USE IN EBUILDS 190# EXPORTED FUNCTION - FOR USE IN EBUILDS
186# 191#
187# Identify a file which must be owned by the webserver's user:group 192# Identify a file which must be owned by the webserver's user:group
188# settings. 193# settings.
189# 194#
190# The ownership of the file is NOT set until the application is installed 195# The ownership of the file is NOT set until the application is installed
191# using the webapp-config tool. 196# using the webapp-config tool.
192# 197#
193# @param $1 - file to be owned by the webserver user:group combo 198# @param $1 - file to be owned by the webserver user:group combo
194# 199#
195# ------------------------------------------------------------------------ 200# ------------------------------------------------------------------------
196 201
197function webapp_serverowned () 202function webapp_serverowned ()
198{ 203{
199 webapp_checkfileexists "$1" "$D" 204 webapp_checkfileexists "${1}" "$D"
200 local MY_FILE="`webapp_strip_appdir $1`" 205 local MY_FILE="$(webapp_strip_appdir ${1})"
201 206 MY_FILE="$(webapp_strip_cwd ${MY_FILE})"
207
202 einfo "(server owned) $MY_FILE" 208 einfo "(server owned) ${MY_FILE}"
203 echo "$MY_FILE" >> ${D}${WA_SOLIST} 209 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
204} 210}
205 211
206# ------------------------------------------------------------------------ 212# ------------------------------------------------------------------------
207# EXPORTED FUNCTION - FOR USE IN EBUILDS 213# EXPORTED FUNCTION - FOR USE IN EBUILDS
208# 214#
215# NOTE: 221# NOTE:
216# this function will automagically prepend $1 to the front of your 222# this function will automagically prepend $1 to the front of your
217# config file's name 223# config file's name
218# ------------------------------------------------------------------------ 224# ------------------------------------------------------------------------
219 225
220function webapp_server_config () 226function webapp_server_configfile ()
221{ 227{
222 webapp_checkfileexists "$2" 228 webapp_checkfileexists "${2}"
223 229
224 # sort out what the name will be of the config file 230 # sort out what the name will be of the config file
225 231
226 local my_file 232 local my_file
227 233
228 if [ -z "$3" ]; then 234 if [ -z "${3}" ]; then
229 $my_file="$1-`basename $2`" 235 my_file="${1}-$(basename ${2})"
230 else 236 else
231 $my_file="$1-$3" 237 my_file="${1}-${3}"
232 fi 238 fi
233 239
234 # warning: 240 # warning:
235 # 241 #
236 # do NOT change the naming convention used here without changing all 242 # do NOT change the naming convention used here without changing all
237 # the other scripts that also rely upon these names 243 # the other scripts that also rely upon these names
238 244
239 einfo "($1) config file '$my_file'" 245 einfo "(${1}) config file '${my_file}'"
240 cp "$2" "${D}${MY_SERVERCONFIGDIR}/${my_file}" 246 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}"
241} 247}
242 248
243# ------------------------------------------------------------------------ 249# ------------------------------------------------------------------------
244# EXPORTED FUNCTION - FOR USE IN EBUILDS 250# EXPORTED FUNCTION - FOR USE IN EBUILDS
245# 251#
252# a new db from scratch) 258# a new db from scratch)
253# ------------------------------------------------------------------------ 259# ------------------------------------------------------------------------
254 260
255function webapp_sqlscript () 261function webapp_sqlscript ()
256{ 262{
257 webapp_checkfileexists "$2" 263 webapp_checkfileexists "${2}"
258 264
259 # create the directory where this script will go 265 # create the directory where this script will go
260 # 266 #
261 # scripts for specific database engines go into their own subdirectory 267 # scripts for specific database engines go into their own subdirectory
262 # just to keep things readable on the filesystem 268 # just to keep things readable on the filesystem
263 269
264 if [ ! -d "${D}${MY_SQLSCRIPTSDIR}/$1" ]; then 270 if [ ! -d "${D}/${MY_SQLSCRIPTSDIR}/${1}" ]; then
265 mkdir -p "${D}${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${D}${MY_SQLSCRIPTSDIR}/$1" 271 mkdir -p "${D}/${MY_SQLSCRIPTSDIR}/${1}" || die "unable to create directory ${D}/${MY_SQLSCRIPTSDIR}/${1}"
266 fi 272 fi
267 273
268 # warning: 274 # warning:
269 # 275 #
270 # do NOT change the naming convention used here without changing all 276 # do NOT change the naming convention used here without changing all
271 # the other scripts that also rely upon these names 277 # the other scripts that also rely upon these names
272 278
273 # are we dealing with an 'upgrade'-type script? 279 # are we dealing with an 'upgrade'-type script?
274 if [ -n "$3" ]; then 280 if [ -n "${3}" ]; then
275 # yes we are 281 # yes we are
276 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 282 einfo "(${1}) upgrade script from ${PN}-${PVR} to ${3}"
277 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql 283 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
284 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
278 else 285 else
279 # no, we are not 286 # no, we are not
280 einfo "($1) create script for ${PN}-${PVR}" 287 einfo "(${1}) create script for ${PN}-${PVR}"
281 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql 288 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
289 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
282 fi 290 fi
283} 291}
284 292
285# ------------------------------------------------------------------------ 293# ------------------------------------------------------------------------
286# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 294# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
287# everything else has run 295# everything else has run
288# 296#
289# For now, we just make sure that root owns everything, and that there 297# For now, we just make sure that root owns everything, and that there
290# are no setuid files. I'm sure this will change significantly before 298# are no setuid files.
291# the final version!
292# ------------------------------------------------------------------------ 299# ------------------------------------------------------------------------
293 300
294function webapp_src_install () 301function webapp_src_install ()
295{ 302{
296 chown -R ${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID} ${D}/ 303 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
297 chmod -R u-s ${D}/ 304 chmod -R u-s "${D}/"
298 chmod -R g-s ${D}/ 305 chmod -R g-s "${D}/"
299 306
300 keepdir ${MY_PERSISTDIR} 307 keepdir "${MY_PERSISTDIR}"
301 fowners root:root ${MY_PERSISTDIR} 308 fowners "root:root" "${MY_PERSISTDIR}"
302 fperms 755 ${MY_PERSISTDIR} 309 fperms 755 "${MY_PERSISTDIR}"
303 310
304 HAS_webapp_src_install=1 311 # to test whether or not the ebuild has correctly called this function
312 # we add an empty file to the filesystem
313 #
314 # we used to just set a variable in the shell script, but we can
315 # no longer rely on Portage calling both webapp_src_install() and
316 # webapp_pkg_postinst() within the same shell process
317
318 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
305} 319}
306 320
307# ------------------------------------------------------------------------ 321# ------------------------------------------------------------------------
308# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER 322# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER
309# everything else has run 323# everything else has run
314 328
315function webapp_pkg_setup () 329function webapp_pkg_setup ()
316{ 330{
317 # add sanity checks here 331 # add sanity checks here
318 332
319 if [ "$SLOT+" != "${PVR}+" ]; then 333 if [ "${SLOT}+" != "${PVR}+" ]; then
334 # special case - some ebuilds *do* need to overwride the SLOT
335 if [ "${WEBAPP_MANUAL_SLOT}" != "yes" ]; then
320 die "ebuild sets SLOT, overrides webapp.eclass" 336 die "ebuild sets SLOT, overrides webapp.eclass"
337 else
338 ewarn
339 ewarn "This ebuild overrides the default SLOT behaviour for webapps"
340 ewarn "If this package installs files into the htdocs dir, this is"
341 ewarn "probably a bug in the ebuild."
342 ewarn
343 fi
321 fi 344 fi
322 345
323 # pull in the shared configuration file 346 # pull in the shared configuration file
324 347
325 G_HOSTNAME="localhost" 348 G_HOSTNAME="localhost"
326 . /etc/vhosts/webapp-config || die "Unable to open /etc/vhosts/webapp-config file" 349 webapp_read_config
327 350
328 # are we installing a webapp-config solution over the top of a 351 # are we installing a webapp-config solution over the top of a
329 # non-webapp-config solution? 352 # non-webapp-config solution?
330 353
331 if ! use vhosts ; then 354 if ! use vhosts ; then
332 local my_dir="$VHOST_ROOT/$MY_HTDOCSBASE/$PN" 355 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
333 local my_output 356 local my_output
334 357
335 if [ -d "$my_dir" ] ; then 358 if [ -d "${my_dir}" ] ; then
336 einfo "You already have something installed in $my_dir" 359 einfo "You already have something installed in ${my_dir}"
337 einfo "Are you trying to install over the top of something I cannot upgrade?" 360 einfo "Are you trying to install over the top of something I cannot upgrade?"
338 361
339 my_output="`webapp_check_installedat`" 362 my_output="$(webapp_check_installedat)"
340 363
341 if [ "$?" != "0" ]; then 364 if [ "$?" != "0" ]; then
342 365
343 # okay, whatever is there, it isn't webapp-config-compatible 366 # okay, whatever is there, it isn't webapp-config-compatible
344 ewarn 367 ewarn
345 ewarn "Whatever is in $my_dir, it's not" 368 ewarn "Whatever is in ${my_dir}, it's not"
346 ewarn "compatible with webapp-config." 369 ewarn "compatible with webapp-config."
347 ewarn 370 ewarn
348 371 ewarn "This ebuild may be overwriting important files."
349 my_output="`qpkg -nc -v -f $my_dir`" 372 ewarn
350 if [ -n "$my_output" ]; then
351 eerror "Please remove $my_output and re-emerge."
352 else
353 eerror "Please remove the contents of $my_dir, and then re-emerge."
354 fi
355 die "Cannot upgrade contents of $my_dir"
356 elif [ "`echo $my_output | awk '{ print $1 }'`" != "$PN" ]; then 373 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then
357 eerror "$my_dir contains $my_output" 374 eerror "${my_dir} contains ${my_output}"
358 eerror "I cannot upgrade that" 375 eerror "I cannot upgrade that"
359 die "Cannot upgrade contents of $my_dir" 376 die "Cannot upgrade contents of ${my_dir}"
360 else 377 else
361 einfo 378 einfo
362 einfo "I can upgrade the contents of $my_dir" 379 einfo "I can upgrade the contents of ${my_dir}"
363 einfo 380 einfo
364 fi 381 fi
365 fi 382 fi
366 fi 383 fi
367} 384}
368 385
369function webapp_someunusedfunction ()
370{
371 # are we emerging something that is already installed?
372
373 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
374 # yes we are
375 ewarn "Removing existing copy of ${PN}-${PVR}"
376 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}"
377 fi
378}
379
380function webapp_getinstalltype () 386function webapp_getinstalltype ()
381{ 387{
382 # or are we upgrading? 388 # or are we upgrading?
383 389
384 if ! use vhosts ; then 390 if ! use vhosts ; then
385 # we only run webapp-config if vhosts USE flag is not set 391 # we only run webapp-config if vhosts USE flag is not set
386 392
387 local my_output 393 local my_output
388 394
389 my_output="`webapp_check_installedat`" 395 my_output="$(webapp_check_installedat)"
390 396
391 if [ "$?" = "0" ] ; then 397 if [ "${?}" = "0" ] ; then
392 # something is already installed there 398 # something is already installed there
393 # 399 #
394 # make sure it isn't the same version 400 # make sure it isn't the same version
395 401
396 local my_pn="`echo $my_output | awk '{ print $1 }'`" 402 local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
397 local my_pvr="`echo $my_output | awk '{ print $2 }'`" 403 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
398 404
399 REMOVE_PKG="${my_pn}-${my_pvr}" 405 REMOVE_PKG="${my_pn}-${my_pvr}"
400 406
401 if [ "$my_pn" == "$PN" ]; then 407 if [ "${my_pn}" == "${PN}" ]; then
402 if [ "$my_pvr" != "$PVR" ]; then 408 if [ "${my_pvr}" != "${PVR}" ]; then
403 einfo "This is an upgrade" 409 einfo "This is an upgrade"
404 IS_UPGRADE=1 410 IS_UPGRADE=1
405 else 411 else
406 einfo "This is a re-installation" 412 einfo "This is a re-installation"
407 IS_REPLACE=1 413 IS_REPLACE=1
408 fi 414 fi
409 else 415 else
410 einfo "$my_ouptut is installed there" 416 einfo "${my_output} is installed there"
411 fi 417 fi
412 else 418 else
413 einfo "This is an installation" 419 einfo "This is an installation"
414 fi 420 fi
415 fi 421 fi
417 423
418function webapp_src_preinst () 424function webapp_src_preinst ()
419{ 425{
420 # create the directories that we need 426 # create the directories that we need
421 427
422 dodir ${MY_HTDOCSDIR} 428 dodir "${MY_HTDOCSDIR}"
423 dodir ${MY_HOSTROOTDIR} 429 dodir "${MY_HOSTROOTDIR}"
424 dodir ${MY_CGIBINDIR} 430 dodir "${MY_CGIBINDIR}"
425 dodir ${MY_ICONSDIR} 431 dodir "${MY_ICONSDIR}"
426 dodir ${MY_ERRORSDIR} 432 dodir "${MY_ERRORSDIR}"
427 dodir ${MY_SQLSCRIPTSDIR} 433 dodir "${MY_SQLSCRIPTSDIR}"
434 dodir "${MY_HOOKSCRIPTSDIR}"
435 dodir "${MY_SERVERCONFIGDIR}"
428} 436}
429 437
430function webapp_pkg_postinst () 438function webapp_pkg_postinst ()
431{ 439{
440 webapp_read_config
441
432 # sanity checks, to catch bugs in the ebuild 442 # sanity checks, to catch bugs in the ebuild
433 443
434 if [ "$HAS_webapp_src_install+" == "+" ]; then 444 if [ ! -f "${ROOT}${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]; then
435 eerror 445 eerror
436 eerror "This ebuild did not call webapp_src_install() at the end" 446 eerror "This ebuild did not call webapp_src_install() at the end"
437 eerror "of the src_install() function" 447 eerror "of the src_install() function"
438 eerror 448 eerror
439 eerror "Please log a bug on http://bugs.gentoo.org" 449 eerror "Please log a bug on http://bugs.gentoo.org"
443 eerror 453 eerror
444 die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org" 454 die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org"
445 fi 455 fi
446 456
447 # if 'vhosts' is not set in your USE flags, we install a copy of 457 # if 'vhosts' is not set in your USE flags, we install a copy of
448 # this application in /var/www/localhost/htdocs/${PN}/ for you 458 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you
449 459
450 if ! use vhosts ; then 460 if ! use vhosts ; then
451 echo 461 echo
452 einfo "vhosts USE flag not set - auto-installing using webapp-config" 462 einfo "vhosts USE flag not set - auto-installing using webapp-config"
453 463
454 webapp_getinstalltype 464 webapp_getinstalltype
455 465
456 G_HOSTNAME="localhost" 466 G_HOSTNAME="localhost"
457 . /etc/vhosts/webapp-config
458
459 local my_mode=-I 467 local my_mode=-I
468 webapp_read_config
460 469
461 if [ "$IS_REPLACE" = "1" ]; then 470 if [ "${IS_REPLACE}" = "1" ]; then
462 einfo "${PN}-${PVR} is already installed - replacing" 471 einfo "${PN}-${PVR} is already installed - replacing"
463 /usr/sbin/webapp-config -C -d "$INSTALL_DIR" 472 my_mode=-I
464 elif [ "$IS_UPGRADE" = "1" ]; then 473 elif [ "${IS_UPGRADE}" = "1" ]; then
465 einfo "$REMOVE_PKG is already installed - upgrading" 474 einfo "${REMOVE_PKG} is already installed - upgrading"
466 my_mode=-U 475 my_mode=-U
467 else 476 else
468 einfo "${PN}-${PVR} is not installed - using install mode" 477 einfo "${PN}-${PVR} is not installed - using install mode"
469 fi 478 fi
470 479
471 my_cmd="/usr/sbin/webapp-config $my_mode -h localhost -u root -d $INSTALL_DIR ${PN} ${PVR}" 480 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
472 einfo "Running $my_cmd" 481 einfo "Running ${my_cmd}"
473 $my_cmd 482 ${my_cmd}
474 483
475 # remove the old version 484 # remove the old version
476 # 485 #
477 # why do we do this? well ... 486 # why do we do this? well ...
478 # 487 #
481 # slot to the old version, then the old version gets left behind 490 # slot to the old version, then the old version gets left behind
482 # 491 #
483 # if USE=-vhosts, then we want to remove the old version, because 492 # if USE=-vhosts, then we want to remove the old version, because
484 # the user is relying on portage to do the magical thing for it 493 # the user is relying on portage to do the magical thing for it
485 494
486 if [ "$IS_UPGRADE" = "1" ] ; then 495 if [ "${IS_UPGRADE}" = "1" ] ; then
487 einfo "Removing old version $REMOVE_PKG" 496 einfo "Removing old version ${REMOVE_PKG}"
488 497
489 emerge -C $CATEGORY/$REMOVE_PKG 498 emerge -C "${REMOVE_PKG}"
490 fi 499 fi
491 else 500 else
492 # vhosts flag is on 501 # vhosts flag is on
493 # 502 #
494 # let's tell the administrator what to do next 503 # let's tell the administrator what to do next
496 einfo 505 einfo
497 einfo "The 'vhosts' USE flag is switched ON" 506 einfo "The 'vhosts' USE flag is switched ON"
498 einfo "This means that Portage will not automatically run webapp-config to" 507 einfo "This means that Portage will not automatically run webapp-config to"
499 einfo "complete the installation." 508 einfo "complete the installation."
500 einfo 509 einfo
501 einfo "To install $PN-$PVR into a virtual host, run the following command:" 510 einfo "To install ${PN}-${PVR} into a virtual host, run the following command:"
502 einfo 511 einfo
503 einfo " webapp-config -I -h <host> -d $PN $PN $PVR" 512 einfo " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
504 einfo 513 einfo
505 einfo "For more details, see the webapp-config(8) man page" 514 einfo "For more details, see the webapp-config(8) man page"
506 fi 515 fi
507 516
508 return 0 517 return 0
513 # remove any virtual installs that there are 522 # remove any virtual installs that there are
514 523
515 local my_output 524 local my_output
516 local x 525 local x
517 526
518 my_output="`webapp-config --list-installs $PN $PVR`" 527 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})"
519 528
520 if [ "$?" != "0" ]; then 529 if [ "${?}" != "0" ]; then
521 return 530 return
522 fi 531 fi
523 532
524 # the changes to IFS here are necessary to ensure that we can cope
525 # with directories that contain spaces in the file names
526
527 # OLD_IFS="$IFS"
528 # IFS=" "
529
530 for x in $my_output ; do 533 for x in ${my_output} ; do
531 # IFS="$OLD_IFS"
532
533 [ -f $x/.webapp ] && . $x/.webapp || ewarn "Cannot find file $x/.webapp" 534 [ -f ${x}/.webapp ] && . ${x}/.webapp || ewarn "Cannot find file ${x}/.webapp"
534 535
535 if [ -z "WEB_HOSTNAME" -o -z "WEB_INSTALLDIR" ]; then 536 if [ -z "${WEB_HOSTNAME}" -o -z "${WEB_INSTALLDIR}" ]; then
536 ewarn "Don't forget to use webapp-config to remove the copy of" 537 ewarn "Don't forget to use webapp-config to remove the copy of"
537 ewarn "${PN}-${PVR} installed in" 538 ewarn "${PN}-${PVR} installed in"
538 ewarn 539 ewarn
539 ewarn " $x" 540 ewarn " ${x}"
540 ewarn 541 ewarn
541 else 542 else
542 # we have enough information to remove the virtual copy ourself 543 # we have enough information to remove the virtual copy ourself
543 544
544 webapp-config -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 545 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR}
545 546
546 # if the removal fails - we carry on anyway! 547 # if the removal fails - we carry on anyway!
547 fi 548 fi
548 # IFS=" "
549 done 549 done
550
551 # IFS="$OLD_IFS"
552} 550}

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20