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

Diff of /eclass/webapp.eclass

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

Revision 1.13 Revision 1.14
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.13 2004/04/30 08:25:38 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.14 2004/05/01 00:45:45 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
18 18
19ECLASS=webapp 19ECLASS=webapp
20INHERITED="$INHERITED $ECLASS" 20INHERITED="$INHERITED $ECLASS"
21SLOT="${PVR}" 21SLOT="${PVR}"
22IUSE="$IUSE vhosts" 22IUSE="$IUSE vhosts"
23DEPEND="$DEPEND >=net-www/webapp-config-1.6" 23DEPEND="$DEPEND >=net-www/webapp-config-1.7"
24 24
25EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install 25EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install
26
27INSTALL_DIR="/$PN"
28IS_UPGRADE=0
29IS_REPLACE=0
26 30
27# ------------------------------------------------------------------------ 31# ------------------------------------------------------------------------
28# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 32# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
29# 33#
30# Check whether a specified file exists within the image/ directory 34# Check whether a specified file exists within the image/ directory
51 55
52# ------------------------------------------------------------------------ 56# ------------------------------------------------------------------------
53# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 57# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
54# ------------------------------------------------------------------------ 58# ------------------------------------------------------------------------
55 59
60function webapp_check_installedat
61{
62 local my_output
63
64 /usr/sbin/webapp-config --show-installed -h localhost -d $INSTALL_DIR 2> /dev/null
65}
66
67# ------------------------------------------------------------------------
68# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
69# ------------------------------------------------------------------------
70
56function webapp_import_config () 71function webapp_import_config ()
57{ 72{
58 if [ -z "${MY_HTDOCSDIR}" ]; then 73 if [ -z "${MY_HTDOCSDIR}" ]; then
59 . /etc/conf.d/webapp-config 74 . /etc/conf.d/webapp-config
60 fi 75 fi
69# 84#
70# ------------------------------------------------------------------------ 85# ------------------------------------------------------------------------
71 86
72function webapp_strip_appdir () 87function webapp_strip_appdir ()
73{ 88{
89 local my_stripped="$1"
74 echo "$1" | sed -e "s|${MY_APPDIR}/||g;" 90 echo "$1" | sed -e "s|${MY_APPDIR}/||g;"
75} 91}
76 92
77function webapp_strip_d () 93function webapp_strip_d ()
78{ 94{
79 echo "$1" | sed -e "s|${D}||g;" 95 echo "$1" | sed -e "s|${D}||g;"
80} 96}
81 97
82function webapp_strip_cwd () 98function webapp_strip_cwd ()
83{ 99{
100 local my_stripped="$1"
84 echo "$1" | sed -e 's|/./|/|g;' 101 echo "$1" | sed -e 's|/./|/|g;'
85} 102}
86 103
87# ------------------------------------------------------------------------ 104# ------------------------------------------------------------------------
88# EXPORTED FUNCTION - FOR USE IN EBUILDS 105# EXPORTED FUNCTION - FOR USE IN EBUILDS
239function webapp_pkg_setup () 256function webapp_pkg_setup ()
240{ 257{
241 # pull in the shared configuration file 258 # pull in the shared configuration file
242 259
243 . /etc/vhosts/webapp-config || die "Unable to open /etc/vhosts/webapp-config file" 260 . /etc/vhosts/webapp-config || die "Unable to open /etc/vhosts/webapp-config file"
261}
244 262
263function webapp_getinstalltype ()
264{
245 # are we emerging something that is already installed? 265 # are we emerging something that is already installed?
246 266
247 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then 267 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
248 # yes we are 268 # yes we are
249 ewarn "Removing existing copy of ${PN}-${PVR}" 269 ewarn "Removing existing copy of ${PN}-${PVR}"
250 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}" 270 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}"
271 fi
272
273 # or are we upgrading?
274
275 if ! use vhosts ; then
276 # we only run webapp-config if vhosts USE flag is not set
277
278 local my_output
279
280 my_output="`webapp_check_installedat`"
281
282 if [ "$?" = "0" ] ; then
283 # something is already installed there
284 #
285 # make sure it isn't the same version
286
287 local my_pn="`echo $my_output | awk '{ print $1 }'`"
288 local my_pvr="`echo $my_output | awk '{ print $2 }'`"
289
290 REMOVE_PKG="${my_pn}-${my_pvr}"
291
292 if [ "$my_pn" == "$PN" ]; then
293 if [ "$my_pvr" != "$PVR" ]; then
294 einfo "This is an upgrade"
295 IS_UPGRADE=1
296 else
297 einfo "This is a re-installation"
298 IS_REPLACE=1
299 fi
300 fi
301 fi
251 fi 302 fi
252} 303}
253 304
254function webapp_src_preinst () 305function webapp_src_preinst ()
255{ 306{
263 dodir ${MY_SQLSCRIPTSDIR} 314 dodir ${MY_SQLSCRIPTSDIR}
264} 315}
265 316
266function webapp_pkg_postinst () 317function webapp_pkg_postinst ()
267{ 318{
268 einfo "webapp_pkg_postinst() called"
269
270 # if 'vhosts' is not set in your USE flags, we install a copy of 319 # if 'vhosts' is not set in your USE flags, we install a copy of
271 # this application in /var/www/localhost/htdocs/${PN}/ for you 320 # this application in /var/www/localhost/htdocs/${PN}/ for you
272
273 321
274 if ! use vhosts ; then 322 if ! use vhosts ; then
323 echo
275 einfo "vhosts USE flag not set - auto-installing using webapp-config" 324 einfo "vhosts USE flag not set - auto-installing using webapp-config"
325
326 webapp_getinstalltype
276 327
277 G_HOSTNAME="localhost" 328 G_HOSTNAME="localhost"
278 . /etc/vhosts/webapp-config 329 . /etc/vhosts/webapp-config
279 330
280 local my_mode=-I 331 local my_mode=-I
281 local my_dir="/${PN}"
282 332
283 # are we installing afresh - or are we upgrading?
284 # find out by looking to see what (if anything) is installed
285 # in there already
286
287 my_cmd="/usr/sbin/webapp-config --show-installed -d $my_dir 2> /dev/null"
288 einfo "$my_cmd"
289
290 my_output="`/usr/sbin/webapp-config --show-installed -d $my_dir 2> /dev/null`"
291
292 # we can't use the exit status from webapp-config
293
294 if [ "$?" = "0" ]; then 333 if [ "$IS_REPLACE" = "1" ]; then
295 334 einfo "${PN}-${PVR} is already installed - replacing"
296 # something is in there - but the question has to be ... what?
297
298 ewarn "$my_output already installed"
299
300 if [ "`echo $my_output | awk '{ print $1 }'`" = "${PN}" ]; then
301 einfo "$my_output is a copy of ${PN}"
302 if [ "`echo $my_output | awk '{ print $2 }'`" = "${PVR}" ]; then
303 # this version is already installed
304 # we need to remove it first
305
306 /usr/sbin/webapp-config -C -d $my_dir 335 /usr/sbin/webapp-config -C -d "$INSTALL_DIR"
307 else 336 elif [ "$IS_UPGRADE" = "1" ]; then
308 # we have an older version of whatever it is our ebuild is 337 einfo "$REMOVE_PKG is already installed - upgrading"
309 # trying to install ;-)
310 #
311 # this is the situation we can deal with
312
313 einfo "selecting upgrade mode"
314 my_mode=-U 338 my_mode=-U
315 fi
316 else
317 # this should never happen - but just in case ...
318 #
319 # whatever is in that directory, it isn't the application
320 # that we are currently trying to install
321 #
322 # rather than overwrite the contents, we bail with an error
323 # instead
324
325 die "$my_output is already installed in $my_dir"
326 fi
327 else 339 else
328 einfo "${PN}-${PVR} is not installed - using install mode" 340 einfo "${PN}-${PVR} is not installed - using install mode"
329 fi 341 fi
330 342
331 my_cmd="/usr/sbin/webapp-config $my_mode -h localhost -u root -d $my_dir ${PN} ${PVR}" 343 my_cmd="/usr/sbin/webapp-config $my_mode -h localhost -u root -d $INSTALL_DIR ${PN} ${PVR}"
332 einfo "Running $my_cmd" 344 einfo "Running $my_cmd"
333 $my_cmd 345 $my_cmd
346
347 # remove the old version
348 #
349 # why do we do this? well ...
350 #
351 # normally, emerge -u installs a new version and then removes the
352 # old version. however, if the new version goes into a different
353 # slot to the old version, then the old version gets left behind
354 #
355 # if USE=-vhosts, then we want to remove the old version, because
356 # the user is relying on portage to do the magical thing for it
357
358 if [ "$IS_UPGRADE" = "1" ] ; then
359 einfo "Removing old version $REMOVE_PKG"
360
361 echo emerge -C $CATEGORY/$REMOVE_PKG
362 fi
334 fi 363 fi
335 364
336 return 0 365 return 0
337} 366}

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20