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

Diff of /eclass/webapp.eclass

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

Revision 1.36 Revision 1.37
1# Copyright 1999-2004 Gentoo Foundation 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.36 2005/08/23 14:55:11 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.37 2005/11/20 12:26:22 stuart 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
22SLOT="${PVR}" 25SLOT="${PVR}"
23IUSE="vhosts" 26IUSE="vhosts"
24DEPEND="net-www/webapp-config app-portage/gentoolkit" 27DEPEND="app-admin/webapp-config"
28RDEPEND="${DEPEND}"
25 29
26EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 30EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
27 31
28INSTALL_DIR="/$PN" 32INSTALL_DIR="/${PN}"
29IS_UPGRADE=0 33IS_UPGRADE=0
30IS_REPLACE=0 34IS_REPLACE=0
31 35
32INSTALL_CHECK_FILE="installed_by_webapp_eclass" 36INSTALL_CHECK_FILE="installed_by_webapp_eclass"
33 37
34ETC_CONFIG="/etc/vhosts/webapp-config" 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}
35 59
36# ------------------------------------------------------------------------ 60# ------------------------------------------------------------------------
37# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 61# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
38# 62#
39# Check whether a specified file exists within the image/ directory 63# Check whether a specified file exists within the image/ directory
46 70
47function webapp_checkfileexists () 71function webapp_checkfileexists ()
48{ 72{
49 local my_prefix 73 local my_prefix
50 74
51 [ -n "$2" ] && my_prefix="$2/" || my_prefix= 75 [ -n "${2}" ] && my_prefix="${2}/" || my_prefix=
52 76
53 if [ ! -e "${my_prefix}$1" ]; then 77 if [ ! -e "${my_prefix}${1}" ]; then
54 msg="ebuild fault: file '$1' not found" 78 msg="ebuild fault: file '${1}' not found"
55 eerror "$msg" 79 eerror "$msg"
56 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/"
57 die "$msg" 81 die "$msg"
58 fi 82 fi
59} 83}
64 88
65function webapp_check_installedat 89function webapp_check_installedat
66{ 90{
67 local my_output 91 local my_output
68 92
69 /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
70} 94}
71 95
72# ------------------------------------------------------------------------ 96# ------------------------------------------------------------------------
73# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 97# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
74# ------------------------------------------------------------------------
75
76function webapp_import_config ()
77{
78 if [ -z "${MY_HTDOCSDIR}" ]; then
79 . /etc/conf.d/webapp-config
80 fi
81
82 if [ -z "${MY_HTDOCSDIR}" ]; then
83 libsh_edie "/etc/conf.d/webapp-config not imported"
84 fi
85}
86
87# ------------------------------------------------------------------------
88# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
89# 98#
90# ------------------------------------------------------------------------ 99# ------------------------------------------------------------------------
91 100
92function webapp_strip_appdir () 101function webapp_strip_appdir ()
93{ 102{
94 local my_stripped="$1" 103 local my_stripped="${1}"
95 echo "$1" | sed -e "s|${MY_APPDIR}/||g;" 104 echo "${1}" | sed -e "s|${MY_APPDIR}/||g;"
96} 105}
97 106
98function webapp_strip_d () 107function webapp_strip_d ()
99{ 108{
100 echo "$1" | sed -e "s|${D}||g;" 109 echo "${1}" | sed -e "s|${D}||g;"
101} 110}
102 111
103function webapp_strip_cwd () 112function webapp_strip_cwd ()
104{ 113{
105 local my_stripped="$1" 114 local my_stripped="${1}"
106 echo "$1" | sed -e 's|/./|/|g;' 115 echo "${1}" | sed -e 's|/./|/|g;'
107} 116}
108 117
109# ------------------------------------------------------------------------ 118# ------------------------------------------------------------------------
110# EXPORTED FUNCTION - FOR USE IN EBUILDS 119# EXPORTED FUNCTION - FOR USE IN EBUILDS
111# 120#
114# @param $1 - config file 123# @param $1 - config file
115# ------------------------------------------------------------------------ 124# ------------------------------------------------------------------------
116 125
117function webapp_configfile () 126function webapp_configfile ()
118{ 127{
119 webapp_checkfileexists "$1" "$D" 128 webapp_checkfileexists "${1}" "${D}"
120 129
121 local MY_FILE="`webapp_strip_appdir \"$1\"`" 130 local MY_FILE="$(webapp_strip_appdir ${1})"
122 MY_FILE="`webapp_strip_cwd \"$MY_FILE\"`" 131 MY_FILE="$(webapp_strip_cwd ${MY_FILE})"
123 132
124 einfo "(config) $MY_FILE" 133 einfo "(config) ${MY_FILE}"
125 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} 134 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST}
126} 135}
127 136
128# ------------------------------------------------------------------------ 137# ------------------------------------------------------------------------
129# EXPORTED FUNCTION - FOR USE IN EBUILDS 138# EXPORTED FUNCTION - FOR USE IN EBUILDS
130# 139#
134# @param $1 - the script to run 143# @param $1 - the script to run
135# ------------------------------------------------------------------------ 144# ------------------------------------------------------------------------
136 145
137function webapp_hook_script () 146function webapp_hook_script ()
138{ 147{
139 webapp_checkfileexists "$1" 148 webapp_checkfileexists "${1}"
140 149
141 einfo "(hook) $1" 150 einfo "(hook) ${1}"
142 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}/"
143 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`" 152 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename ${1})"
144} 153}
145 154
146# ------------------------------------------------------------------------ 155# ------------------------------------------------------------------------
147# EXPORTED FUNCTION - FOR USE IN EBUILDS 156# EXPORTED FUNCTION - FOR USE IN EBUILDS
148# 157#
152# @param $2 - the file to install 161# @param $2 - the file to install
153# ------------------------------------------------------------------------ 162# ------------------------------------------------------------------------
154 163
155function webapp_postinst_txt () 164function webapp_postinst_txt ()
156{ 165{
157 webapp_checkfileexists "$2" 166 webapp_checkfileexists "${2}"
158 167
159 einfo "(rtfm) $2 (lang: $1)" 168 einfo "(info) ${2} (lang: ${1})"
160 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt" 169 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt"
161} 170}
162 171
163# ------------------------------------------------------------------------ 172# ------------------------------------------------------------------------
164# EXPORTED FUNCTION - FOR USE IN EBUILDS 173# EXPORTED FUNCTION - FOR USE IN EBUILDS
165# 174#
169# @param $2 - the file to install 178# @param $2 - the file to install
170# ------------------------------------------------------------------------ 179# ------------------------------------------------------------------------
171 180
172function webapp_postupgrade_txt () 181function webapp_postupgrade_txt ()
173{ 182{
174 webapp_checkfileexists "$2" 183 webapp_checkfileexists "${2}"
175 184
176 einfo "(rtfm) $2 (lang: $1)" 185 einfo "(info) ${2} (lang: ${1})"
177 cp "$2" "${D}${MY_APPDIR}/postupgrade-$1.txt" 186 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt"
178}
179
180# ------------------------------------------------------------------------
181# DEPRECATED FUNCTION
182#
183# It never worked anyway
184
185function webapp_runbycgibin ()
186{
187 if [ -n "$WARN_RUNBYCGIBIN" ] ; then
188 return
189 fi
190
191 ewarn "This ebuild uses webapp.eclass's webapp_runbycgibin, which is now"
192 ewarn "deprecated. Please file a bug about this in Bugzilla."
193 WARN_RUNBYCGIBIN=1
194} 187}
195 188
196# ------------------------------------------------------------------------ 189# ------------------------------------------------------------------------
197# EXPORTED FUNCTION - FOR USE IN EBUILDS 190# EXPORTED FUNCTION - FOR USE IN EBUILDS
198# 191#
199# 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
200# settings. 193# settings.
201# 194#
202# 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
203# using the webapp-config tool. 196# using the webapp-config tool.
204# 197#
205# @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
206# 199#
207# ------------------------------------------------------------------------ 200# ------------------------------------------------------------------------
208 201
209function webapp_serverowned () 202function webapp_serverowned ()
210{ 203{
211 webapp_checkfileexists "$1" "$D" 204 webapp_checkfileexists "${1}" "$D"
212 local MY_FILE="`webapp_strip_appdir \"$1\"`" 205 local MY_FILE="$(webapp_strip_appdir ${1})"
213 MY_FILE="`webapp_strip_cwd \"$MY_FILE\"`" 206 MY_FILE="$(webapp_strip_cwd ${MY_FILE})"
214 207
215 einfo "(server owned) $MY_FILE" 208 einfo "(server owned) ${MY_FILE}"
216 echo "$MY_FILE" >> "${D}${WA_SOLIST}" 209 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
217} 210}
218 211
219# ------------------------------------------------------------------------ 212# ------------------------------------------------------------------------
220# EXPORTED FUNCTION - FOR USE IN EBUILDS 213# EXPORTED FUNCTION - FOR USE IN EBUILDS
221# 214#
230# config file's name 223# config file's name
231# ------------------------------------------------------------------------ 224# ------------------------------------------------------------------------
232 225
233function webapp_server_configfile () 226function webapp_server_configfile ()
234{ 227{
235 webapp_checkfileexists "$2" 228 webapp_checkfileexists "${2}"
236 229
237 # sort out what the name will be of the config file 230 # sort out what the name will be of the config file
238 231
239 local my_file 232 local my_file
240 233
241 if [ -z "$3" ]; then 234 if [ -z "${3}" ]; then
242 my_file="$1-`basename $2`" 235 my_file="${1}-$(basename ${2})"
243 else 236 else
244 my_file="$1-$3" 237 my_file="${1}-${3}"
245 fi 238 fi
246 239
247 # warning: 240 # warning:
248 # 241 #
249 # do NOT change the naming convention used here without changing all 242 # do NOT change the naming convention used here without changing all
250 # the other scripts that also rely upon these names 243 # the other scripts that also rely upon these names
251 244
252 einfo "($1) config file '$my_file'" 245 einfo "(${1}) config file '${my_file}'"
253 cp "$2" "${D}${MY_SERVERCONFIGDIR}/${my_file}" 246 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}"
254} 247}
255 248
256# ------------------------------------------------------------------------ 249# ------------------------------------------------------------------------
257# EXPORTED FUNCTION - FOR USE IN EBUILDS 250# EXPORTED FUNCTION - FOR USE IN EBUILDS
258# 251#
265# a new db from scratch) 258# a new db from scratch)
266# ------------------------------------------------------------------------ 259# ------------------------------------------------------------------------
267 260
268function webapp_sqlscript () 261function webapp_sqlscript ()
269{ 262{
270 webapp_checkfileexists "$2" 263 webapp_checkfileexists "${2}"
271 264
272 # create the directory where this script will go 265 # create the directory where this script will go
273 # 266 #
274 # scripts for specific database engines go into their own subdirectory 267 # scripts for specific database engines go into their own subdirectory
275 # just to keep things readable on the filesystem 268 # just to keep things readable on the filesystem
276 269
277 if [ ! -d "${D}${MY_SQLSCRIPTSDIR}/$1" ]; then 270 if [ ! -d "${D}/${MY_SQLSCRIPTSDIR}/${1}" ]; then
278 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}"
279 fi 272 fi
280 273
281 # warning: 274 # warning:
282 # 275 #
283 # do NOT change the naming convention used here without changing all 276 # do NOT change the naming convention used here without changing all
284 # the other scripts that also rely upon these names 277 # the other scripts that also rely upon these names
285 278
286 # are we dealing with an 'upgrade'-type script? 279 # are we dealing with an 'upgrade'-type script?
287 if [ -n "$3" ]; then 280 if [ -n "${3}" ]; then
288 # yes we are 281 # yes we are
289 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 282 einfo "(${1}) upgrade script from ${PN}-${PVR} to ${3}"
290 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql" 283 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
291 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql" 284 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
292 else 285 else
293 # no, we are not 286 # no, we are not
294 einfo "($1) create script for ${PN}-${PVR}" 287 einfo "(${1}) create script for ${PN}-${PVR}"
295 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql" 288 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
296 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql" 289 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
297 fi 290 fi
298} 291}
299 292
300# ------------------------------------------------------------------------ 293# ------------------------------------------------------------------------
301# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 294# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
302# everything else has run 295# everything else has run
303# 296#
304# 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
305# are no setuid files. I'm sure this will change significantly before 298# are no setuid files.
306# the final version!
307# ------------------------------------------------------------------------ 299# ------------------------------------------------------------------------
308 300
309function webapp_src_install () 301function webapp_src_install ()
310{ 302{
311 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" 303 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
336 328
337function webapp_pkg_setup () 329function webapp_pkg_setup ()
338{ 330{
339 # add sanity checks here 331 # add sanity checks here
340 332
341 if [ "$SLOT+" != "${PVR}+" ]; then 333 if [ "${SLOT}+" != "${PVR}+" ]; then
334 # special case - some ebuilds *do* need to overwride the SLOT
342 if [ "$WEBAPP_MANUAL_SLOT" != "yes" ]; then 335 if [ "${WEBAPP_MANUAL_SLOT}" != "yes" ]; then
343 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
344 fi 343 fi
345 fi 344 fi
346 345
347 # pull in the shared configuration file 346 # pull in the shared configuration file
348 347
349 G_HOSTNAME="localhost" 348 G_HOSTNAME="localhost"
350 . "${ETC_CONFIG}" || die "Unable to open file ${ETC_CONFIG}" 349 webapp_read_config
351 350
352 # 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
353 # non-webapp-config solution? 352 # non-webapp-config solution?
354 353
355 if ! use vhosts ; then 354 if ! use vhosts ; then
356 local my_dir="$VHOST_ROOT/$MY_HTDOCSBASE/$PN" 355 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
357 local my_output 356 local my_output
358 357
359 if [ -d "$my_dir" ] ; then 358 if [ -d "${my_dir}" ] ; then
360 einfo "You already have something installed in $my_dir" 359 einfo "You already have something installed in ${my_dir}"
361 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?"
362 361
363 my_output="`webapp_check_installedat`" 362 my_output="$(webapp_check_installedat)"
364 363
365 if [ "$?" != "0" ]; then 364 if [ "$?" != "0" ]; then
366 365
367 # okay, whatever is there, it isn't webapp-config-compatible 366 # okay, whatever is there, it isn't webapp-config-compatible
368 ewarn 367 ewarn
369 ewarn "Whatever is in $my_dir, it's not" 368 ewarn "Whatever is in ${my_dir}, it's not"
370 ewarn "compatible with webapp-config." 369 ewarn "compatible with webapp-config."
371 ewarn 370 ewarn
372 ewarn "This ebuild may be overwriting important files." 371 ewarn "This ebuild may be overwriting important files."
373 ewarn 372 ewarn
374 elif [ "`echo $my_output | awk '{ print $1 }'`" != "$PN" ]; then 373 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then
375 eerror "$my_dir contains $my_output" 374 eerror "${my_dir} contains ${my_output}"
376 eerror "I cannot upgrade that" 375 eerror "I cannot upgrade that"
377 die "Cannot upgrade contents of $my_dir" 376 die "Cannot upgrade contents of ${my_dir}"
378 else 377 else
379 einfo 378 einfo
380 einfo "I can upgrade the contents of $my_dir" 379 einfo "I can upgrade the contents of ${my_dir}"
381 einfo 380 einfo
382 fi 381 fi
383 fi 382 fi
384 fi 383 fi
385} 384}
386 385
387function webapp_someunusedfunction ()
388{
389 # are we emerging something that is already installed?
390
391 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
392 # yes we are
393 ewarn "Removing existing copy of ${PN}-${PVR}"
394 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}"
395 fi
396}
397
398function webapp_getinstalltype () 386function webapp_getinstalltype ()
399{ 387{
400 # or are we upgrading? 388 # or are we upgrading?
401 389
402 if ! use vhosts ; then 390 if ! use vhosts ; then
403 # 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
404 392
405 local my_output 393 local my_output
406 394
407 my_output="`webapp_check_installedat`" 395 my_output="$(webapp_check_installedat)"
408 396
409 if [ "$?" = "0" ] ; then 397 if [ "${?}" = "0" ] ; then
410 # something is already installed there 398 # something is already installed there
411 # 399 #
412 # make sure it isn't the same version 400 # make sure it isn't the same version
413 401
414 local my_pn="`echo $my_output | awk '{ print $1 }'`" 402 local my_pn="$(echo ${my_output} | awk '{ print $1 }')"
415 local my_pvr="`echo $my_output | awk '{ print $2 }'`" 403 local my_pvr="$(echo ${my_output} | awk '{ print $2 }')"
416 404
417 REMOVE_PKG="${my_pn}-${my_pvr}" 405 REMOVE_PKG="${my_pn}-${my_pvr}"
418 406
419 if [ "$my_pn" == "$PN" ]; then 407 if [ "${my_pn}" == "${PN}" ]; then
420 if [ "$my_pvr" != "$PVR" ]; then 408 if [ "${my_pvr}" != "${PVR}" ]; then
421 einfo "This is an upgrade" 409 einfo "This is an upgrade"
422 IS_UPGRADE=1 410 IS_UPGRADE=1
423 else 411 else
424 einfo "This is a re-installation" 412 einfo "This is a re-installation"
425 IS_REPLACE=1 413 IS_REPLACE=1
426 fi 414 fi
427 else 415 else
428 einfo "$my_ouptut is installed there" 416 einfo "${my_output} is installed there"
429 fi 417 fi
430 else 418 else
431 einfo "This is an installation" 419 einfo "This is an installation"
432 fi 420 fi
433 fi 421 fi
447 dodir "${MY_SERVERCONFIGDIR}" 435 dodir "${MY_SERVERCONFIGDIR}"
448} 436}
449 437
450function webapp_pkg_postinst () 438function webapp_pkg_postinst ()
451{ 439{
452 . "${ETC_CONFIG}" 440 webapp_read_config
453 441
454 # sanity checks, to catch bugs in the ebuild 442 # sanity checks, to catch bugs in the ebuild
455 443
456 if [ ! -f "${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]; then 444 if [ ! -f "${ROOT}${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]; then
457 eerror 445 eerror
458 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"
459 eerror "of the src_install() function" 447 eerror "of the src_install() function"
460 eerror 448 eerror
461 eerror "Please log a bug on http://bugs.gentoo.org" 449 eerror "Please log a bug on http://bugs.gentoo.org"
465 eerror 453 eerror
466 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"
467 fi 455 fi
468 456
469 # 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
470 # this application in /var/www/localhost/htdocs/${PN}/ for you 458 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you
471 459
472 if ! use vhosts ; then 460 if ! use vhosts ; then
473 echo 461 echo
474 einfo "vhosts USE flag not set - auto-installing using webapp-config" 462 einfo "vhosts USE flag not set - auto-installing using webapp-config"
475 463
476 webapp_getinstalltype 464 webapp_getinstalltype
477 465
478 G_HOSTNAME="localhost" 466 G_HOSTNAME="localhost"
479 . "${ETC_CONFIG}"
480
481 local my_mode=-I 467 local my_mode=-I
468 webapp_read_config
482 469
483 if [ "$IS_REPLACE" = "1" ]; then 470 if [ "${IS_REPLACE}" = "1" ]; then
484 einfo "${PN}-${PVR} is already installed - replacing" 471 einfo "${PN}-${PVR} is already installed - replacing"
485 my_mode=-I 472 my_mode=-I
486 elif [ "$IS_UPGRADE" = "1" ]; then 473 elif [ "${IS_UPGRADE}" = "1" ]; then
487 einfo "$REMOVE_PKG is already installed - upgrading" 474 einfo "${REMOVE_PKG} is already installed - upgrading"
488 my_mode=-U 475 my_mode=-U
489 else 476 else
490 einfo "${PN}-${PVR} is not installed - using install mode" 477 einfo "${PN}-${PVR} is not installed - using install mode"
491 fi 478 fi
492 479
493 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}"
494 einfo "Running $my_cmd" 481 einfo "Running ${my_cmd}"
495 $my_cmd 482 ${my_cmd}
496 483
497 # remove the old version 484 # remove the old version
498 # 485 #
499 # why do we do this? well ... 486 # why do we do this? well ...
500 # 487 #
503 # 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
504 # 491 #
505 # 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
506 # 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
507 494
508 if [ "$IS_UPGRADE" = "1" ] ; then 495 if [ "${IS_UPGRADE}" = "1" ] ; then
509 einfo "Removing old version $REMOVE_PKG" 496 einfo "Removing old version ${REMOVE_PKG}"
510 497
511 emerge -C "$REMOVE_PKG" 498 emerge -C "${REMOVE_PKG}"
512 fi 499 fi
513 else 500 else
514 # vhosts flag is on 501 # vhosts flag is on
515 # 502 #
516 # let's tell the administrator what to do next 503 # let's tell the administrator what to do next
518 einfo 505 einfo
519 einfo "The 'vhosts' USE flag is switched ON" 506 einfo "The 'vhosts' USE flag is switched ON"
520 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"
521 einfo "complete the installation." 508 einfo "complete the installation."
522 einfo 509 einfo
523 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:"
524 einfo 511 einfo
525 einfo " webapp-config -I -h <host> -d $PN $PN $PVR" 512 einfo " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
526 einfo 513 einfo
527 einfo "For more details, see the webapp-config(8) man page" 514 einfo "For more details, see the webapp-config(8) man page"
528 fi 515 fi
529 516
530 return 0 517 return 0
535 # remove any virtual installs that there are 522 # remove any virtual installs that there are
536 523
537 local my_output 524 local my_output
538 local x 525 local x
539 526
540 my_output="`webapp-config --list-installs $PN $PVR`" 527 my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})"
541 528
542 if [ "$?" != "0" ]; then 529 if [ "${?}" != "0" ]; then
543 return 530 return
544 fi 531 fi
545 532
546 # the changes to IFS here are necessary to ensure that we can cope
547 # with directories that contain spaces in the file names
548
549 # OLD_IFS="$IFS"
550 # IFS=" "
551
552 for x in $my_output ; do 533 for x in ${my_output} ; do
553 # IFS="$OLD_IFS"
554
555 [ -f $x/.webapp ] && . $x/.webapp || ewarn "Cannot find file $x/.webapp" 534 [ -f ${x}/.webapp ] && . ${x}/.webapp || ewarn "Cannot find file ${x}/.webapp"
556 535
557 if [ -z "WEB_HOSTNAME" -o -z "WEB_INSTALLDIR" ]; then 536 if [ -z "${WEB_HOSTNAME}" -o -z "${WEB_INSTALLDIR}" ]; then
558 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"
559 ewarn "${PN}-${PVR} installed in" 538 ewarn "${PN}-${PVR} installed in"
560 ewarn 539 ewarn
561 ewarn " $x" 540 ewarn " ${x}"
562 ewarn 541 ewarn
563 else 542 else
564 # we have enough information to remove the virtual copy ourself 543 # we have enough information to remove the virtual copy ourself
565 544
566 webapp-config -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} 545 ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR}
567 546
568 # if the removal fails - we carry on anyway! 547 # if the removal fails - we carry on anyway!
569 fi 548 fi
570 # IFS=" "
571 done 549 done
572
573 # IFS="$OLD_IFS"
574} 550}

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.20