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

Diff of /eclass/webapp.eclass

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20