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

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

  ViewVC Help
Powered by ViewVC 1.1.20