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

Diff of /eclass/webapp.eclass

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

Revision 1.1 Revision 1.4
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 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.1 2003/10/07 21:54:46 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.4 2004/03/03 18:44:34 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
13# 13#
14# Please do not make modifications to this file without checking with a 14# Please do not make modifications to this file without checking with a
15# member of the web-apps herd first! 15# member of the web-apps herd first!
16# 16#
17# ------------------------------------------------------------------------ 17# ------------------------------------------------------------------------
18#
19# THIS IS A BETA RELEASE ONLY. ALL DETAILS ARE SUBJECT TO CHANGE BEFORE
20# WE ARE READY TO START PORTING EVERYTHING TO THIS ECLASS
21#
22# ------------------------------------------------------------------------
23 18
24ECLASS=webapp 19ECLASS=webapp
25INHERITED="$INHERITED $ECLASS" 20INHERITED="$INHERITED $ECLASS"
26#DEPEND="${DEPEND} net-www/apache"
27SLOT="${PVR}" 21SLOT="${PVR}"
28IUSE="$IUSE vhosts" 22IUSE="$IUSE vhosts"
23G_HASCONFIG=1
29 24
30if [ -f /usr/share/webapp-config/settings.sh ] ; then 25if [ -f /etc/conf.d/webapp-config ] ; then
31 . /usr/share/webapp-config/settings.sh 26 . /etc/conf.d/webapp-config
27else
28 G_HASCONFIG=0
32fi 29fi
33 30
34EXPORT_FUNCTIONS pkg_setup src_install 31EXPORT_FUNCTIONS pkg_config pkg_setup src_install
35 32
36# ------------------------------------------------------------------------ 33# ------------------------------------------------------------------------
37# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 34# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
38# 35#
39# Check whether a specified file exists within the image/ directory 36# Check whether a specified file exists within the image/ directory
40# or not. 37# or not.
41# 38#
42# @param $1 - file to look for 39# @param $1 - file to look for
40# @param $2 - prefix directory to use
43# @return 0 on success, never returns on an error 41# @return 0 on success, never returns on an error
44# ------------------------------------------------------------------------ 42# ------------------------------------------------------------------------
45 43
46function webapp_checkfileexists () 44function webapp_checkfileexists ()
47{ 45{
48 if [ ! -e ${D}/$1 ]; then 46 if [ ! -e $1 ]; then
49 msg="ebuild fault: file $1 not found in ${D}" 47 msg="ebuild fault: file $1 not found"
50 eerror "$msg" 48 eerror "$msg"
51 eerror "Please report this as a bug at http://bugs.gentoo.org/" 49 eerror "Please report this as a bug at http://bugs.gentoo.org/"
52 die "$msg" 50 die "$msg"
53 fi 51 fi
52}
53
54# ------------------------------------------------------------------------
55# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
56# ------------------------------------------------------------------------
57
58function webapp_import_config ()
59{
60 if [ -z "${MY_HTDOCSDIR}" ]; then
61 . /etc/conf.d/webapp-config
62 fi
63
64 if [ -z "${MY_HTDOCSDIR}" ]; then
65 libsh_edie "/etc/conf.d/webapp-config not imported"
66 fi
67}
68
69# ------------------------------------------------------------------------
70# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
71#
72# ------------------------------------------------------------------------
73
74function webapp_strip_appdir ()
75{
76 echo "$1" | sed -e "s|${MY_APPDIR}/||g;"
77}
78
79function webapp_strip_d ()
80{
81 echo "$1" | sed -e "s|${D}||g;"
82}
83
84function webapp_strip_cwd ()
85{
86 echo "$1" | sed -e 's|/./|/|g;'
87}
88
89# ------------------------------------------------------------------------
90# EXPORTED FUNCTION - FOR USE IN EBUILDS
91#
92# Identify a config file for a web-based application.
93#
94# @param $1 - config file
95# ------------------------------------------------------------------------
96
97function webapp_configfile ()
98{
99 webapp_checkfileexists "$1" "$D"
100 local MY_FILE="`webapp_strip_appdir $1`"
101
102 einfo "(config) $MY_FILE"
103 echo "$MY_FILE" >> $WA_CONFIGLIST
104}
105
106# ------------------------------------------------------------------------
107# EXPORTED FUNCTION - FOR USE IN EBUILDS
108#
109# Identify a script file (usually, but not always PHP or Perl) which is
110#
111# Files in this list may be modified to #! the required CGI engine when
112# installed by webapp-config tool in the future.
113#
114# @param $1 - the cgi engine to use
115# @param $2 - the script file that could run under a cgi-bin
116#
117# ------------------------------------------------------------------------
118
119function webapp_runbycgibin ()
120{
121 webapp_checkfileexists "$2" "$D"
122 local MY_FILE="`webapp_strip_appdir $2`"
123 MY_FILE="`webapp_strip_cwd $MY_FILE`"
124
125 einfo "(cgi-bin) $1 - $MY_FILE"
126 echo "$1 $MY_FILE" >> $WA_RUNBYCGIBINLIST
54} 127}
55 128
56# ------------------------------------------------------------------------ 129# ------------------------------------------------------------------------
57# EXPORTED FUNCTION - FOR USE IN EBUILDS 130# EXPORTED FUNCTION - FOR USE IN EBUILDS
58# 131#
66# 139#
67# ------------------------------------------------------------------------ 140# ------------------------------------------------------------------------
68 141
69function webapp_serverowned () 142function webapp_serverowned ()
70{ 143{
71 webapp_checkfileexists $1 144 webapp_checkfileexists "$1" "$D"
145 local MY_FILE="`webapp_strip_appdir $1`"
146
147 einfo "(server owned) $MY_FILE"
72 echo "$1" >> $WA_SOLIST 148 echo "$MY_FILE" >> $WA_SOLIST
73} 149}
74 150
75# ------------------------------------------------------------------------ 151# ------------------------------------------------------------------------
76# EXPORTED FUNCTION - FOR USE IN EBUILDS 152# EXPORTED FUNCTION - FOR USE IN EBUILDS
77# 153#
78# Identify a config file for a web-based application.
79# 154#
80# @param $1 - config file 155# @param $1 - the db engine that the script is for
156# (one of: mysql|postgres)
157# @param $2 - the sql script to be installed
158# @param $3 - the older version of the app that this db script
159# will upgrade from
160# (do not pass this option if your SQL script only creates
161# a new db from scratch)
81# ------------------------------------------------------------------------ 162# ------------------------------------------------------------------------
82 163
83function webapp_configfile () 164function webapp_sqlscript ()
84{ 165{
85 webapp_checkfileexists $1
86 echo "$1" >> $WA_CONFIGLIST
87}
88
89# ------------------------------------------------------------------------
90# EXPORTED FUNCTION - FOR USE IN EBUILDS
91#
92# Identify a script file (usually, but not always PHP or Perl) which is
93#
94# Files in this list may be modified to #! the required CGI engine when
95# installed by webapp-config tool in the future.
96#
97# @param $1 - the cgi engine to use
98# @param $2 - the script file that could run under a cgi-bin
99#
100# ------------------------------------------------------------------------
101
102function webapp_runbycgibin ()
103{
104 webapp_checkfileexists $2 166 webapp_checkfileexists "$2"
105 echo "$1 $2" >> $WA_RUNBYCGIBINLIST 167
168 # create the directory where this script will go
169 #
170 # scripts for specific database engines go into their own subdirectory
171 # just to keep things readable on the filesystem
172
173 if [ ! -d "${MY_SQLSCRIPTSDIR}/$1" ]; then
174 mkdir -p "${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${MY_SQLSCRIPTSDIR}/$1"
175 fi
176
177 # warning:
178 #
179 # do NOT change the naming convention used here without changing all
180 # the other scripts that also rely upon these names
181
182 # are we dealing with an 'upgrade'-type script?
183 if [ -n "$3" ]; then
184 # yes we are
185 einfo "($1) upgrade script from ${PN}-${PVR} to $3"
186 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql
187 else
188 # no, we are not
189 einfo "($1) create script for ${PN}-${PVR}"
190 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql
191 fi
106} 192}
107 193
108# ------------------------------------------------------------------------ 194# ------------------------------------------------------------------------
109# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 195# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
110# everything else has run 196# everything else has run
120 chmod -R u-s ${D}/ 206 chmod -R u-s ${D}/
121 chmod -R g-s ${D}/ 207 chmod -R g-s ${D}/
122} 208}
123 209
124# ------------------------------------------------------------------------ 210# ------------------------------------------------------------------------
125# EXPORTED FUNCTION - call from inside your ebuild's pkg_setup AFTER 211# EXPORTED FUNCTION - call from inside your ebuild's pkg_config AFTER
126# everything else has run 212# everything else has run
127# 213#
128# If 'vhosts' USE flag is not set, auto-install this app 214# If 'vhosts' USE flag is not set, auto-install this app
129# 215#
130# ------------------------------------------------------------------------ 216# ------------------------------------------------------------------------
131 217
132function webapp_pkg_setup () 218function webapp_pkg_setup ()
133{ 219{
220 # we do have the config file, right?
221
222 if [ "$G_HASCONFIG" = "0" ]; then
223 die "/etc/conf.d/webapp-config missing"
224 fi
225
226 # are we emerging something that is already installed?
227
228 if [ -d "${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
229 # yes we are
230 ewarn "Removing existing copy of ${PN}-${PVR}"
231 rm -rf "${MY_APPROOT}/${MY_APPSUFFIX}"
232 fi
233
234 # create the directories that we need
235
236 mkdir -p ${MY_HTDOCSDIR}
237 mkdir -p ${MY_HOSTROOTDIR}
238 mkdir -p ${MY_CGIBINDIR}
239 mkdir -p ${MY_ICONSDIR}
240 mkdir -p ${MY_ERRORSDIR}
241 mkdir -p ${MY_SQLSCRIPTSDIR}
242}
243
244function webapp_pkg_config ()
245{
134 use vhosts || webapp-config -u root -d /var/www/localhost/htdocs/${PN}/ ${PN} 246 use vhosts || webapp-config -u root -d /var/www/localhost/htdocs/${PN}/ ${PN}
247}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20