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

Diff of /eclass/webapp.eclass

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

Revision 1.6 Revision 1.9
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.9 2004/04/23 22:02:27 stuart Exp $
3# 4#
4# eclass/webapp.eclass 5# eclass/webapp.eclass
5# Eclass for installing applications to run under a web server 6# Eclass for installing applications to run under a web server
6# 7#
7# Part of the implementation of GLEP #11 8# Part of the implementation of GLEP #11
17 18
18ECLASS=webapp 19ECLASS=webapp
19INHERITED="$INHERITED $ECLASS" 20INHERITED="$INHERITED $ECLASS"
20SLOT="${PVR}" 21SLOT="${PVR}"
21IUSE="$IUSE vhosts" 22IUSE="$IUSE vhosts"
22 23DEPEND="$DEPEND >=net-www/webapp-config-1.4"
23 24
24EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install 25EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install
25 26
26# ------------------------------------------------------------------------ 27# ------------------------------------------------------------------------
27# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 28# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
34# @return 0 on success, never returns on an error 35# @return 0 on success, never returns on an error
35# ------------------------------------------------------------------------ 36# ------------------------------------------------------------------------
36 37
37function webapp_checkfileexists () 38function webapp_checkfileexists ()
38{ 39{
40 local my_prefix
41
42 [ -n "$2" ] && my_prefix="$2/" || my_prefix=
43
39 if [ ! -e $1 ]; then 44 if [ ! -e ${my_prefix}$1 ]; then
40 msg="ebuild fault: file $1 not found" 45 msg="ebuild fault: file $1 not found"
41 eerror "$msg" 46 eerror "$msg"
42 eerror "Please report this as a bug at http://bugs.gentoo.org/" 47 eerror "Please report this as a bug at http://bugs.gentoo.org/"
43 die "$msg" 48 die "$msg"
44 fi 49 fi
64# 69#
65# ------------------------------------------------------------------------ 70# ------------------------------------------------------------------------
66 71
67function webapp_strip_appdir () 72function webapp_strip_appdir ()
68{ 73{
69 echo "$1" | sed -e "s|${MY_APPDIR}/||g;" 74 echo "$1" | sed -e "s|${D}${MY_APPDIR}/||g;"
70} 75}
71 76
72function webapp_strip_d () 77function webapp_strip_d ()
73{ 78{
74 echo "$1" | sed -e "s|${D}||g;" 79 echo "$1" | sed -e "s|${D}||g;"
91{ 96{
92 webapp_checkfileexists "$1" "$D" 97 webapp_checkfileexists "$1" "$D"
93 local MY_FILE="`webapp_strip_appdir $1`" 98 local MY_FILE="`webapp_strip_appdir $1`"
94 99
95 einfo "(config) $MY_FILE" 100 einfo "(config) $MY_FILE"
96 echo "$MY_FILE" >> $WA_CONFIGLIST 101 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST}
97} 102}
98 103
99# ------------------------------------------------------------------------ 104# ------------------------------------------------------------------------
100# EXPORTED FUNCTION - FOR USE IN EBUILDS 105# EXPORTED FUNCTION - FOR USE IN EBUILDS
101# 106#
108function webapp_postinst_txt 113function webapp_postinst_txt
109{ 114{
110 webapp_checkfileexists "$2" 115 webapp_checkfileexists "$2"
111 116
112 einfo "(rtfm) $2 (lang: $1)" 117 einfo "(rtfm) $2 (lang: $1)"
113 cp "$2" "${MY_APPDIR}/postinst-$1.txt" 118 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt"
114} 119}
115 120
116# ------------------------------------------------------------------------ 121# ------------------------------------------------------------------------
117# EXPORTED FUNCTION - FOR USE IN EBUILDS 122# EXPORTED FUNCTION - FOR USE IN EBUILDS
118# 123#
131 webapp_checkfileexists "$2" "$D" 136 webapp_checkfileexists "$2" "$D"
132 local MY_FILE="`webapp_strip_appdir $2`" 137 local MY_FILE="`webapp_strip_appdir $2`"
133 MY_FILE="`webapp_strip_cwd $MY_FILE`" 138 MY_FILE="`webapp_strip_cwd $MY_FILE`"
134 139
135 einfo "(cgi-bin) $1 - $MY_FILE" 140 einfo "(cgi-bin) $1 - $MY_FILE"
136 echo "$1 $MY_FILE" >> $WA_RUNBYCGIBINLIST 141 echo "$1 $MY_FILE" >> ${D}${WA_RUNBYCGIBINLIST}
137} 142}
138 143
139# ------------------------------------------------------------------------ 144# ------------------------------------------------------------------------
140# EXPORTED FUNCTION - FOR USE IN EBUILDS 145# EXPORTED FUNCTION - FOR USE IN EBUILDS
141# 146#
153{ 158{
154 webapp_checkfileexists "$1" "$D" 159 webapp_checkfileexists "$1" "$D"
155 local MY_FILE="`webapp_strip_appdir $1`" 160 local MY_FILE="`webapp_strip_appdir $1`"
156 161
157 einfo "(server owned) $MY_FILE" 162 einfo "(server owned) $MY_FILE"
158 echo "$MY_FILE" >> $WA_SOLIST 163 echo "$MY_FILE" >> ${D}${WA_SOLIST}
159} 164}
160 165
161# ------------------------------------------------------------------------ 166# ------------------------------------------------------------------------
162# EXPORTED FUNCTION - FOR USE IN EBUILDS 167# EXPORTED FUNCTION - FOR USE IN EBUILDS
163# 168#
178 # create the directory where this script will go 183 # create the directory where this script will go
179 # 184 #
180 # scripts for specific database engines go into their own subdirectory 185 # scripts for specific database engines go into their own subdirectory
181 # just to keep things readable on the filesystem 186 # just to keep things readable on the filesystem
182 187
183 if [ ! -d "${MY_SQLSCRIPTSDIR}/$1" ]; then 188 if [ ! -d "${D}${MY_SQLSCRIPTSDIR}/$1" ]; then
184 mkdir -p "${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${MY_SQLSCRIPTSDIR}/$1" 189 mkdir -p "${D}${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${D}${MY_SQLSCRIPTSDIR}/$1"
185 fi 190 fi
186 191
187 # warning: 192 # warning:
188 # 193 #
189 # do NOT change the naming convention used here without changing all 194 # do NOT change the naming convention used here without changing all
191 196
192 # are we dealing with an 'upgrade'-type script? 197 # are we dealing with an 'upgrade'-type script?
193 if [ -n "$3" ]; then 198 if [ -n "$3" ]; then
194 # yes we are 199 # yes we are
195 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 200 einfo "($1) upgrade script from ${PN}-${PVR} to $3"
196 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql 201 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql
197 else 202 else
198 # no, we are not 203 # no, we are not
199 einfo "($1) create script for ${PN}-${PVR}" 204 einfo "($1) create script for ${PN}-${PVR}"
200 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql 205 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql
201 fi 206 fi
202} 207}
203 208
204# ------------------------------------------------------------------------ 209# ------------------------------------------------------------------------
205# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 210# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
229# 234#
230# ------------------------------------------------------------------------ 235# ------------------------------------------------------------------------
231 236
232function webapp_pkg_setup () 237function webapp_pkg_setup ()
233{ 238{
234 if [ -f /etc/vhosts/webapp-config ] ; then 239 # pull in the shared configuration file
235 . /etc/vhosts/webapp-config 240
236 else 241 . /etc/vhosts/webapp-config || die "Unable to open /etc/vhosts/webapp-config file"
237 die "Unable to find /etc/vhosts/webapp-config"
238 fi
239 242
240 # are we emerging something that is already installed? 243 # are we emerging something that is already installed?
241 244
242 if [ -d "${MY_APPROOT}/${MY_APPSUFFIX}" ]; then 245 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
243 # yes we are 246 # yes we are
244 ewarn "Removing existing copy of ${PN}-${PVR}" 247 ewarn "Removing existing copy of ${PN}-${PVR}"
245 rm -rf "${MY_APPROOT}/${MY_APPSUFFIX}" 248 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}"
246 fi 249 fi
250}
247 251
252function webapp_src_preinst ()
253{
248 # create the directories that we need 254 # create the directories that we need
249 255
250 mkdir -p ${MY_HTDOCSDIR} 256 dodir ${MY_HTDOCSDIR}
251 mkdir -p ${MY_HOSTROOTDIR} 257 dodir ${MY_HOSTROOTDIR}
252 mkdir -p ${MY_CGIBINDIR} 258 dodir ${MY_CGIBINDIR}
253 mkdir -p ${MY_ICONSDIR} 259 dodir ${MY_ICONSDIR}
254 mkdir -p ${MY_ERRORSDIR} 260 dodir ${MY_ERRORSDIR}
255 mkdir -p ${MY_SQLSCRIPTSDIR} 261 dodir ${MY_SQLSCRIPTSDIR}
256} 262}
257 263
258function webapp_pkg_postinst () 264function webapp_pkg_postinst ()
259{ 265{
260 G_HOSTNAME="${VHOST_HOSTNAME}" 266 G_HOSTNAME="localhost"
267 . /etc/vhosts/webapp-config
268
261 use vhosts || /usr/sbin/webapp-config -I -u root -d "${VHOST_ROOT}/htdocs/${PN}/" ${PN} ${PVR} 269 use vhosts || /usr/sbin/webapp-config -I -u root -h localhost -d "${VHOST_ROOT}/htdocs/${PN}/" ${PN} ${PVR}
262} 270}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20