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

Diff of /eclass/webapp.eclass

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20