# Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.1 2003/10/07 21:54:46 stuart Exp $ # # eclass/webapp.eclass # Eclass for installing applications to run under a web server # # Part of the implementation of GLEP #11 # # Author(s) Stuart Herbert # # ------------------------------------------------------------------------ # # Please do not make modifications to this file without checking with a # member of the web-apps herd first! # # ------------------------------------------------------------------------ # # THIS IS A BETA RELEASE ONLY. ALL DETAILS ARE SUBJECT TO CHANGE BEFORE # WE ARE READY TO START PORTING EVERYTHING TO THIS ECLASS # # ------------------------------------------------------------------------ ECLASS=webapp INHERITED="$INHERITED $ECLASS" #DEPEND="${DEPEND} net-www/apache" SLOT="${PVR}" IUSE="$IUSE vhosts" if [ -f /usr/share/webapp-config/settings.sh ] ; then . /usr/share/webapp-config/settings.sh fi EXPORT_FUNCTIONS pkg_setup src_install # ------------------------------------------------------------------------ # INTERNAL FUNCTION - USED BY THIS ECLASS ONLY # # Check whether a specified file exists within the image/ directory # or not. # # @param $1 - file to look for # @return 0 on success, never returns on an error # ------------------------------------------------------------------------ function webapp_checkfileexists () { if [ ! -e ${D}/$1 ]; then msg="ebuild fault: file $1 not found in ${D}" eerror "$msg" eerror "Please report this as a bug at http://bugs.gentoo.org/" die "$msg" fi } # ------------------------------------------------------------------------ # EXPORTED FUNCTION - FOR USE IN EBUILDS # # Identify a file which must be owned by the webserver's user:group # settings. # # The ownership of the file is NOT set until the application is installed # using the webapp-config tool. # # @param $1 - file to be owned by the webserver user:group combo # # ------------------------------------------------------------------------ function webapp_serverowned () { webapp_checkfileexists $1 echo "$1" >> $WA_SOLIST } # ------------------------------------------------------------------------ # EXPORTED FUNCTION - FOR USE IN EBUILDS # # Identify a config file for a web-based application. # # @param $1 - config file # ------------------------------------------------------------------------ function webapp_configfile () { webapp_checkfileexists $1 echo "$1" >> $WA_CONFIGLIST } # ------------------------------------------------------------------------ # EXPORTED FUNCTION - FOR USE IN EBUILDS # # Identify a script file (usually, but not always PHP or Perl) which is # # Files in this list may be modified to #! the required CGI engine when # installed by webapp-config tool in the future. # # @param $1 - the cgi engine to use # @param $2 - the script file that could run under a cgi-bin # # ------------------------------------------------------------------------ function webapp_runbycgibin () { webapp_checkfileexists $2 echo "$1 $2" >> $WA_RUNBYCGIBINLIST } # ------------------------------------------------------------------------ # EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER # everything else has run # # For now, we just make sure that root owns everything, and that there # are no setuid files. I'm sure this will change significantly before # the final version! # ------------------------------------------------------------------------ function webapp_src_install () { chown -R root:root ${D}/ chmod -R u-s ${D}/ chmod -R g-s ${D}/ } # ------------------------------------------------------------------------ # EXPORTED FUNCTION - call from inside your ebuild's pkg_setup AFTER # everything else has run # # If 'vhosts' USE flag is not set, auto-install this app # # ------------------------------------------------------------------------ function webapp_pkg_setup () { use vhosts || webapp-config -u root -d /var/www/localhost/htdocs/${PN}/ ${PN}