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

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

  ViewVC Help
Powered by ViewVC 1.1.20