/[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.23
1# Copyright 1999-2004 Gentoo Technologies, Inc. 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.21 2004/05/25 10:22:02 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.23 2004/06/14 23:35:24 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
50{ 50{
51 local my_prefix 51 local my_prefix
52 52
53 [ -n "$2" ] && my_prefix="$2/" || my_prefix= 53 [ -n "$2" ] && my_prefix="$2/" || my_prefix=
54 54
55 if [ ! -e ${my_prefix}$1 ]; then 55 if [ ! -e "${my_prefix}$1" ]; then
56 msg="ebuild fault: file $1 not found" 56 msg="ebuild fault: file '$1' not found"
57 eerror "$msg" 57 eerror "$msg"
58 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/"
59 die "$msg" 59 die "$msg"
60 fi 60 fi
61} 61}
66 66
67function webapp_check_installedat 67function webapp_check_installedat
68{ 68{
69 local my_output 69 local my_output
70 70
71 /usr/sbin/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
72} 72}
73 73
74# ------------------------------------------------------------------------ 74# ------------------------------------------------------------------------
75# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 75# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
76# ------------------------------------------------------------------------ 76# ------------------------------------------------------------------------
118 118
119function webapp_configfile () 119function webapp_configfile ()
120{ 120{
121 webapp_checkfileexists "$1" "$D" 121 webapp_checkfileexists "$1" "$D"
122 echo $1 122 echo $1
123 local MY_FILE="`webapp_strip_appdir $1`" 123 local MY_FILE="`webapp_strip_appdir \"$1\"`"
124 echo $MY_FILE 124 echo $MY_FILE
125 125
126 einfo "(config) $MY_FILE" 126 einfo "(config) $MY_FILE"
127 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} 127 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST}
128} 128}
136# @param $1 - the script to run 136# @param $1 - the script to run
137# ------------------------------------------------------------------------ 137# ------------------------------------------------------------------------
138 138
139function webapp_hook_script () 139function webapp_hook_script ()
140{ 140{
141 webapp_checkfileexists "$2" 141 webapp_checkfileexists "$1"
142 142
143 einfo "(hook) $1" 143 einfo "(hook) $1"
144 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}/"
145 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`" 145 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`"
146} 146}
176# ------------------------------------------------------------------------ 176# ------------------------------------------------------------------------
177 177
178function webapp_runbycgibin () 178function webapp_runbycgibin ()
179{ 179{
180 webapp_checkfileexists "$2" "$D" 180 webapp_checkfileexists "$2" "$D"
181 local MY_FILE="`webapp_strip_appdir $2`" 181 local MY_FILE="`webapp_strip_appdir \"$2\"`"
182 MY_FILE="`webapp_strip_cwd $MY_FILE`" 182 MY_FILE="`webapp_strip_cwd \"$MY_FILE\"`"
183 183
184 einfo "(cgi-bin) $1 - $MY_FILE" 184 einfo "(cgi-bin) $1 - $MY_FILE"
185 echo "$1 $MY_FILE" >> ${D}${WA_RUNBYCGIBINLIST} 185 echo "\"$1\" \"$MY_FILE\"" >> "${D}${WA_RUNBYCGIBINLIST}"
186} 186}
187 187
188# ------------------------------------------------------------------------ 188# ------------------------------------------------------------------------
189# EXPORTED FUNCTION - FOR USE IN EBUILDS 189# EXPORTED FUNCTION - FOR USE IN EBUILDS
190# 190#
199# ------------------------------------------------------------------------ 199# ------------------------------------------------------------------------
200 200
201function webapp_serverowned () 201function webapp_serverowned ()
202{ 202{
203 webapp_checkfileexists "$1" "$D" 203 webapp_checkfileexists "$1" "$D"
204 local MY_FILE="`webapp_strip_appdir $1`" 204 local MY_FILE="`webapp_strip_appdir \"$1\"`"
205 205
206 einfo "(server owned) $MY_FILE" 206 einfo "(server owned) $MY_FILE"
207 echo "$MY_FILE" >> ${D}${WA_SOLIST} 207 echo "$MY_FILE" >> "${D}${WA_SOLIST}"
208} 208}
209 209
210# ------------------------------------------------------------------------ 210# ------------------------------------------------------------------------
211# EXPORTED FUNCTION - FOR USE IN EBUILDS 211# EXPORTED FUNCTION - FOR USE IN EBUILDS
212# 212#
228 # sort out what the name will be of the config file 228 # sort out what the name will be of the config file
229 229
230 local my_file 230 local my_file
231 231
232 if [ -z "$3" ]; then 232 if [ -z "$3" ]; then
233 $my_file="$1-`basename $2`" 233 my_file="$1-`basename $2`"
234 else 234 else
235 $my_file="$1-$3" 235 my_file="$1-$3"
236 fi 236 fi
237 237
238 # warning: 238 # warning:
239 # 239 #
240 # do NOT change the naming convention used here without changing all 240 # do NOT change the naming convention used here without changing all
276 276
277 # are we dealing with an 'upgrade'-type script? 277 # are we dealing with an 'upgrade'-type script?
278 if [ -n "$3" ]; then 278 if [ -n "$3" ]; then
279 # yes we are 279 # yes we are
280 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 280 einfo "($1) upgrade script from ${PN}-${PVR} to $3"
281 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql 281 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql"
282 else 282 else
283 # no, we are not 283 # no, we are not
284 einfo "($1) create script for ${PN}-${PVR}" 284 einfo "($1) create script for ${PN}-${PVR}"
285 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql 285 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql"
286 fi 286 fi
287} 287}
288 288
289# ------------------------------------------------------------------------ 289# ------------------------------------------------------------------------
290# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 290# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
295# the final version! 295# the final version!
296# ------------------------------------------------------------------------ 296# ------------------------------------------------------------------------
297 297
298function webapp_src_install () 298function webapp_src_install ()
299{ 299{
300 chown -R ${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID} ${D}/ 300 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
301 chmod -R u-s ${D}/ 301 chmod -R u-s "${D}/"
302 chmod -R g-s ${D}/ 302 chmod -R g-s "${D}/"
303 303
304 keepdir ${MY_PERSISTDIR} 304 keepdir "${MY_PERSISTDIR}"
305 fowners root:root ${MY_PERSISTDIR} 305 fowners "root:root" "${MY_PERSISTDIR}"
306 fperms 755 ${MY_PERSISTDIR} 306 fperms 755 "${MY_PERSISTDIR}"
307 307
308 # 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
309 # we add an empty file to the filesystem 309 # we add an empty file to the filesystem
310 # 310 #
311 # 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
312 # no longer rely on Portage calling both webapp_src_install() and 312 # no longer rely on Portage calling both webapp_src_install() and
313 # webapp_pkg_postinst() within the same shell process 313 # webapp_pkg_postinst() within the same shell process
314 314
315 touch ${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE} 315 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
316} 316}
317 317
318# ------------------------------------------------------------------------ 318# ------------------------------------------------------------------------
319# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER 319# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER
320# everything else has run 320# everything else has run
332 fi 332 fi
333 333
334 # pull in the shared configuration file 334 # pull in the shared configuration file
335 335
336 G_HOSTNAME="localhost" 336 G_HOSTNAME="localhost"
337 . ${ETC_CONFIG} || die "Unable to open /etc/vhosts/webapp-config file" 337 . "${ETC_CONFIG}" || die "Unable to open file ${ETC_CONFIG}"
338 338
339 # 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
340 # non-webapp-config solution? 340 # non-webapp-config solution?
341 341
342 if ! use vhosts ; then 342 if ! use vhosts ; then
422 422
423function webapp_src_preinst () 423function webapp_src_preinst ()
424{ 424{
425 # create the directories that we need 425 # create the directories that we need
426 426
427 dodir ${MY_HTDOCSDIR} 427 dodir "${MY_HTDOCSDIR}"
428 dodir ${MY_HOSTROOTDIR} 428 dodir "${MY_HOSTROOTDIR}"
429 dodir ${MY_CGIBINDIR} 429 dodir "${MY_CGIBINDIR}"
430 dodir ${MY_ICONSDIR} 430 dodir "${MY_ICONSDIR}"
431 dodir ${MY_ERRORSDIR} 431 dodir "${MY_ERRORSDIR}"
432 dodir ${MY_SQLSCRIPTSDIR} 432 dodir "${MY_SQLSCRIPTSDIR}"
433} 433}
434 434
435function webapp_pkg_postinst () 435function webapp_pkg_postinst ()
436{ 436{
437 . ${ETC_CONFIG} 437 . "${ETC_CONFIG}"
438 438
439 # sanity checks, to catch bugs in the ebuild 439 # sanity checks, to catch bugs in the ebuild
440 440
441 if [ ! -f ${MY_APPDIR}/${INSTALL_CHECK_FILE} ]; then 441 if [ ! -f "${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]; then
442 eerror 442 eerror
443 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"
444 eerror "of the src_install() function" 444 eerror "of the src_install() function"
445 eerror 445 eerror
446 eerror "Please log a bug on http://bugs.gentoo.org" 446 eerror "Please log a bug on http://bugs.gentoo.org"
459 einfo "vhosts USE flag not set - auto-installing using webapp-config" 459 einfo "vhosts USE flag not set - auto-installing using webapp-config"
460 460
461 webapp_getinstalltype 461 webapp_getinstalltype
462 462
463 G_HOSTNAME="localhost" 463 G_HOSTNAME="localhost"
464 . /etc/vhosts/webapp-config 464 . "${ETC_CONFIG}"
465 465
466 local my_mode=-I 466 local my_mode=-I
467 467
468 if [ "$IS_REPLACE" = "1" ]; then 468 if [ "$IS_REPLACE" = "1" ]; then
469 einfo "${PN}-${PVR} is already installed - replacing" 469 einfo "${PN}-${PVR} is already installed - replacing"
491 # 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
492 492
493 if [ "$IS_UPGRADE" = "1" ] ; then 493 if [ "$IS_UPGRADE" = "1" ] ; then
494 einfo "Removing old version $REMOVE_PKG" 494 einfo "Removing old version $REMOVE_PKG"
495 495
496 emerge -C $CATEGORY/$REMOVE_PKG 496 emerge -C "$CATEGORY/$REMOVE_PKG"
497 fi 497 fi
498 else 498 else
499 # vhosts flag is on 499 # vhosts flag is on
500 # 500 #
501 # let's tell the administrator what to do next 501 # let's tell the administrator what to do next

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

  ViewVC Help
Powered by ViewVC 1.1.20