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

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

  ViewVC Help
Powered by ViewVC 1.1.20