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

Diff of /eclass/webapp.eclass

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

Revision 1.20 Revision 1.31
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.20 2004/05/22 18:56:58 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.31 2005/05/30 21:44:17 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
21 21
22ECLASS=webapp 22ECLASS=webapp
23INHERITED="$INHERITED $ECLASS" 23INHERITED="$INHERITED $ECLASS"
24SLOT="${PVR}" 24SLOT="${PVR}"
25IUSE="$IUSE vhosts" 25IUSE="$IUSE vhosts"
26DEPEND="$DEPEND >=net-www/webapp-config-1.7 app-portage/gentoolkit" 26DEPEND="$DEPEND net-www/webapp-config app-portage/gentoolkit"
27 27
28EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 28EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
29 29
30INSTALL_DIR="/$PN" 30INSTALL_DIR="/$PN"
31IS_UPGRADE=0 31IS_UPGRADE=0
32IS_REPLACE=0 32IS_REPLACE=0
33 33
34INSTALL_CHECK_FILE="installed_by_webapp_eclass" 34INSTALL_CHECK_FILE="installed_by_webapp_eclass"
35 35
36ETC_CONFIG="/etc/vhosts/webapp-config"
37
36# ------------------------------------------------------------------------ 38# ------------------------------------------------------------------------
37# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 39# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
38# 40#
39# Check whether a specified file exists within the image/ directory 41# Check whether a specified file exists within the image/ directory
40# or not. 42# or not.
48{ 50{
49 local my_prefix 51 local my_prefix
50 52
51 [ -n "$2" ] && my_prefix="$2/" || my_prefix= 53 [ -n "$2" ] && my_prefix="$2/" || my_prefix=
52 54
53 if [ ! -e ${my_prefix}$1 ]; then 55 if [ ! -e "${my_prefix}$1" ]; then
54 msg="ebuild fault: file $1 not found" 56 msg="ebuild fault: file '$1' not found"
55 eerror "$msg" 57 eerror "$msg"
56 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/"
57 die "$msg" 59 die "$msg"
58 fi 60 fi
59} 61}
64 66
65function webapp_check_installedat 67function webapp_check_installedat
66{ 68{
67 local my_output 69 local my_output
68 70
69 /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
70} 72}
71 73
72# ------------------------------------------------------------------------ 74# ------------------------------------------------------------------------
73# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 75# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
74# ------------------------------------------------------------------------ 76# ------------------------------------------------------------------------
115# ------------------------------------------------------------------------ 117# ------------------------------------------------------------------------
116 118
117function webapp_configfile () 119function webapp_configfile ()
118{ 120{
119 webapp_checkfileexists "$1" "$D" 121 webapp_checkfileexists "$1" "$D"
120 echo $1 122
121 local MY_FILE="`webapp_strip_appdir $1`" 123 local MY_FILE="`webapp_strip_appdir \"$1\"`"
122 echo $MY_FILE 124 MY_FILE="`webapp_strip_cwd \"$MY_FILE\"`"
123 125
124 einfo "(config) $MY_FILE" 126 einfo "(config) $MY_FILE"
125 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST} 127 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST}
126} 128}
127 129
134# @param $1 - the script to run 136# @param $1 - the script to run
135# ------------------------------------------------------------------------ 137# ------------------------------------------------------------------------
136 138
137function webapp_hook_script () 139function webapp_hook_script ()
138{ 140{
139 webapp_checkfileexists "$2" 141 webapp_checkfileexists "$1"
140 142
141 einfo "(hook) $1" 143 einfo "(hook) $1"
142 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}/"
143 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`" 145 chmod 555 "${D}${MY_HOOKSCRIPTSDIR}/`basename $1`"
144} 146}
150# 152#
151# @param $1 - language code (use 'en' for now) 153# @param $1 - language code (use 'en' for now)
152# @param $2 - the file to install 154# @param $2 - the file to install
153# ------------------------------------------------------------------------ 155# ------------------------------------------------------------------------
154 156
155function webapp_postinst_txt 157function webapp_postinst_txt ()
156{ 158{
157 webapp_checkfileexists "$2" 159 webapp_checkfileexists "$2"
158 160
159 einfo "(rtfm) $2 (lang: $1)" 161 einfo "(rtfm) $2 (lang: $1)"
160 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt" 162 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt"
161} 163}
162 164
163# ------------------------------------------------------------------------ 165# ------------------------------------------------------------------------
164# EXPORTED FUNCTION - FOR USE IN EBUILDS 166# EXPORTED FUNCTION - FOR USE IN EBUILDS
165# 167#
166# Identify a script file (usually, but not always PHP or Perl) which is 168# Install a text file containing post-upgrade instructions.
167# 169#
168# Files in this list may be modified to #! the required CGI engine when 170# @param $1 - language code (use 'en' for now)
169# installed by webapp-config tool in the future. 171# @param $2 - the file to install
170#
171# @param $1 - the cgi engine to use
172# @param $2 - the script file that could run under a cgi-bin
173#
174# ------------------------------------------------------------------------ 172# ------------------------------------------------------------------------
173
174function webapp_postupgrade_txt ()
175{
176 webapp_checkfileexists "$2"
177
178 einfo "(rtfm) $2 (lang: $1)"
179 cp "$2" "${D}${MY_APPDIR}/postupgrade-$1.txt"
180}
181
182# ------------------------------------------------------------------------
183# DEPRECATED FUNCTION
184#
185# It never worked anyway
175 186
176function webapp_runbycgibin () 187function webapp_runbycgibin ()
177{ 188{
178 webapp_checkfileexists "$2" "$D" 189 if [ -n "$WARN_RUNBYCGIBIN" ] ; then
179 local MY_FILE="`webapp_strip_appdir $2`" 190 return
180 MY_FILE="`webapp_strip_cwd $MY_FILE`" 191 fi
181 192
182 einfo "(cgi-bin) $1 - $MY_FILE" 193 ewarn "This ebuild uses webapp.eclass's webapp_runbycgibin, which is now"
183 echo "$1 $MY_FILE" >> ${D}${WA_RUNBYCGIBINLIST} 194 ewarn "deprecated. Please file a bug about this in Bugzilla."
195 WARN_RUNBYCGIBIN=1
184} 196}
185 197
186# ------------------------------------------------------------------------ 198# ------------------------------------------------------------------------
187# EXPORTED FUNCTION - FOR USE IN EBUILDS 199# EXPORTED FUNCTION - FOR USE IN EBUILDS
188# 200#
197# ------------------------------------------------------------------------ 209# ------------------------------------------------------------------------
198 210
199function webapp_serverowned () 211function webapp_serverowned ()
200{ 212{
201 webapp_checkfileexists "$1" "$D" 213 webapp_checkfileexists "$1" "$D"
202 local MY_FILE="`webapp_strip_appdir $1`" 214 local MY_FILE="`webapp_strip_appdir \"$1\"`"
215 MY_FILE="`webapp_strip_cwd \"$MY_FILE\"`"
203 216
204 einfo "(server owned) $MY_FILE" 217 einfo "(server owned) $MY_FILE"
205 echo "$MY_FILE" >> ${D}${WA_SOLIST} 218 echo "$MY_FILE" >> "${D}${WA_SOLIST}"
206} 219}
207 220
208# ------------------------------------------------------------------------ 221# ------------------------------------------------------------------------
209# EXPORTED FUNCTION - FOR USE IN EBUILDS 222# EXPORTED FUNCTION - FOR USE IN EBUILDS
210# 223#
217# NOTE: 230# NOTE:
218# this function will automagically prepend $1 to the front of your 231# this function will automagically prepend $1 to the front of your
219# config file's name 232# config file's name
220# ------------------------------------------------------------------------ 233# ------------------------------------------------------------------------
221 234
222function webapp_server_config () 235function webapp_server_configfile ()
223{ 236{
224 webapp_checkfileexists "$2" 237 webapp_checkfileexists "$2"
225 238
226 # sort out what the name will be of the config file 239 # sort out what the name will be of the config file
227 240
228 local my_file 241 local my_file
229 242
230 if [ -z "$3" ]; then 243 if [ -z "$3" ]; then
231 $my_file="$1-`basename $2`" 244 my_file="$1-`basename $2`"
232 else 245 else
233 $my_file="$1-$3" 246 my_file="$1-$3"
234 fi 247 fi
235 248
236 # warning: 249 # warning:
237 # 250 #
238 # do NOT change the naming convention used here without changing all 251 # do NOT change the naming convention used here without changing all
274 287
275 # are we dealing with an 'upgrade'-type script? 288 # are we dealing with an 'upgrade'-type script?
276 if [ -n "$3" ]; then 289 if [ -n "$3" ]; then
277 # yes we are 290 # yes we are
278 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 291 einfo "($1) upgrade script from ${PN}-${PVR} to $3"
279 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql 292 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql"
293 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql"
280 else 294 else
281 # no, we are not 295 # no, we are not
282 einfo "($1) create script for ${PN}-${PVR}" 296 einfo "($1) create script for ${PN}-${PVR}"
283 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql 297 cp "$2" "${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql"
298 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql"
284 fi 299 fi
285} 300}
286 301
287# ------------------------------------------------------------------------ 302# ------------------------------------------------------------------------
288# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 303# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
293# the final version! 308# the final version!
294# ------------------------------------------------------------------------ 309# ------------------------------------------------------------------------
295 310
296function webapp_src_install () 311function webapp_src_install ()
297{ 312{
298 chown -R ${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID} ${D}/ 313 chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/"
299 chmod -R u-s ${D}/ 314 chmod -R u-s "${D}/"
300 chmod -R g-s ${D}/ 315 chmod -R g-s "${D}/"
301 316
302 keepdir ${MY_PERSISTDIR} 317 keepdir "${MY_PERSISTDIR}"
303 fowners root:root ${MY_PERSISTDIR} 318 fowners "root:root" "${MY_PERSISTDIR}"
304 fperms 755 ${MY_PERSISTDIR} 319 fperms 755 "${MY_PERSISTDIR}"
305 320
306 # to test whether or not the ebuild has correctly called this function 321 # to test whether or not the ebuild has correctly called this function
307 # we add an empty file to the filesystem 322 # we add an empty file to the filesystem
308 # 323 #
309 # we used to just set a variable in the shell script, but we can 324 # we used to just set a variable in the shell script, but we can
310 # no longer rely on Portage calling both webapp_src_install() and 325 # no longer rely on Portage calling both webapp_src_install() and
311 # webapp_pkg_postinst() within the same shell process 326 # webapp_pkg_postinst() within the same shell process
312 327
313 touch ${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE} 328 touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}"
314} 329}
315 330
316# ------------------------------------------------------------------------ 331# ------------------------------------------------------------------------
317# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER 332# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER
318# everything else has run 333# everything else has run
330 fi 345 fi
331 346
332 # pull in the shared configuration file 347 # pull in the shared configuration file
333 348
334 G_HOSTNAME="localhost" 349 G_HOSTNAME="localhost"
335 . /etc/vhosts/webapp-config || die "Unable to open /etc/vhosts/webapp-config file" 350 . "${ETC_CONFIG}" || die "Unable to open file ${ETC_CONFIG}"
336 351
337 # are we installing a webapp-config solution over the top of a 352 # are we installing a webapp-config solution over the top of a
338 # non-webapp-config solution? 353 # non-webapp-config solution?
339 354
340 if ! use vhosts ; then 355 if ! use vhosts ; then
420 435
421function webapp_src_preinst () 436function webapp_src_preinst ()
422{ 437{
423 # create the directories that we need 438 # create the directories that we need
424 439
425 dodir ${MY_HTDOCSDIR} 440 dodir "${MY_HTDOCSDIR}"
426 dodir ${MY_HOSTROOTDIR} 441 dodir "${MY_HOSTROOTDIR}"
427 dodir ${MY_CGIBINDIR} 442 dodir "${MY_CGIBINDIR}"
428 dodir ${MY_ICONSDIR} 443 dodir "${MY_ICONSDIR}"
429 dodir ${MY_ERRORSDIR} 444 dodir "${MY_ERRORSDIR}"
430 dodir ${MY_SQLSCRIPTSDIR} 445 dodir "${MY_SQLSCRIPTSDIR}"
446 dodir "${MY_HOOKSCRIPTSDIR}"
447 dodir "${MY_SERVERCONFIGDIR}"
431} 448}
432 449
433function webapp_pkg_postinst () 450function webapp_pkg_postinst ()
434{ 451{
452 . "${ETC_CONFIG}"
453
435 # sanity checks, to catch bugs in the ebuild 454 # sanity checks, to catch bugs in the ebuild
436 455
437 if [ ! -f ${MY_APPDIR}/${INSTALL_CHECK_FILE} ]; then 456 if [ ! -f "${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]; then
438 eerror 457 eerror
439 eerror "This ebuild did not call webapp_src_install() at the end" 458 eerror "This ebuild did not call webapp_src_install() at the end"
440 eerror "of the src_install() function" 459 eerror "of the src_install() function"
441 eerror 460 eerror
442 eerror "Please log a bug on http://bugs.gentoo.org" 461 eerror "Please log a bug on http://bugs.gentoo.org"
455 einfo "vhosts USE flag not set - auto-installing using webapp-config" 474 einfo "vhosts USE flag not set - auto-installing using webapp-config"
456 475
457 webapp_getinstalltype 476 webapp_getinstalltype
458 477
459 G_HOSTNAME="localhost" 478 G_HOSTNAME="localhost"
460 . /etc/vhosts/webapp-config 479 . "${ETC_CONFIG}"
461 480
462 local my_mode=-I 481 local my_mode=-I
463 482
464 if [ "$IS_REPLACE" = "1" ]; then 483 if [ "$IS_REPLACE" = "1" ]; then
465 einfo "${PN}-${PVR} is already installed - replacing" 484 einfo "${PN}-${PVR} is already installed - replacing"
466 /usr/sbin/webapp-config -C -d "$INSTALL_DIR" 485 my_mode=-I
467 elif [ "$IS_UPGRADE" = "1" ]; then 486 elif [ "$IS_UPGRADE" = "1" ]; then
468 einfo "$REMOVE_PKG is already installed - upgrading" 487 einfo "$REMOVE_PKG is already installed - upgrading"
469 my_mode=-U 488 my_mode=-U
470 else 489 else
471 einfo "${PN}-${PVR} is not installed - using install mode" 490 einfo "${PN}-${PVR} is not installed - using install mode"
487 # the user is relying on portage to do the magical thing for it 506 # the user is relying on portage to do the magical thing for it
488 507
489 if [ "$IS_UPGRADE" = "1" ] ; then 508 if [ "$IS_UPGRADE" = "1" ] ; then
490 einfo "Removing old version $REMOVE_PKG" 509 einfo "Removing old version $REMOVE_PKG"
491 510
492 emerge -C $CATEGORY/$REMOVE_PKG 511 emerge -C "$REMOVE_PKG"
493 fi 512 fi
494 else 513 else
495 # vhosts flag is on 514 # vhosts flag is on
496 # 515 #
497 # let's tell the administrator what to do next 516 # let's tell the administrator what to do next

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

  ViewVC Help
Powered by ViewVC 1.1.20