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

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

  ViewVC Help
Powered by ViewVC 1.1.20