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

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

  ViewVC Help
Powered by ViewVC 1.1.20