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

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

  ViewVC Help
Powered by ViewVC 1.1.20