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

Diff of /eclass/webapp.eclass

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

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20