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

Diff of /eclass/webapp.eclass

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

Revision 1.7 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.8 2004/04/23 14:19:35 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"
22DEPEND="$DEPEND net-www/webapp-config" 23DEPEND="$DEPEND >=net-www/webapp-config-1.3"
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
64# 65#
65# ------------------------------------------------------------------------ 66# ------------------------------------------------------------------------
66 67
67function webapp_strip_appdir () 68function webapp_strip_appdir ()
68{ 69{
69 echo "$1" | sed -e "s|${MY_APPDIR}/||g;" 70 echo "$1" | sed -e "s|${D}${MY_APPDIR}/||g;"
70} 71}
71 72
72function webapp_strip_d () 73function webapp_strip_d ()
73{ 74{
74 echo "$1" | sed -e "s|${D}||g;" 75 echo "$1" | sed -e "s|${D}||g;"
91{ 92{
92 webapp_checkfileexists "$1" "$D" 93 webapp_checkfileexists "$1" "$D"
93 local MY_FILE="`webapp_strip_appdir $1`" 94 local MY_FILE="`webapp_strip_appdir $1`"
94 95
95 einfo "(config) $MY_FILE" 96 einfo "(config) $MY_FILE"
96 echo "$MY_FILE" >> $WA_CONFIGLIST 97 echo "$MY_FILE" >> ${D}${WA_CONFIGLIST}
97} 98}
98 99
99# ------------------------------------------------------------------------ 100# ------------------------------------------------------------------------
100# EXPORTED FUNCTION - FOR USE IN EBUILDS 101# EXPORTED FUNCTION - FOR USE IN EBUILDS
101# 102#
108function webapp_postinst_txt 109function webapp_postinst_txt
109{ 110{
110 webapp_checkfileexists "$2" 111 webapp_checkfileexists "$2"
111 112
112 einfo "(rtfm) $2 (lang: $1)" 113 einfo "(rtfm) $2 (lang: $1)"
113 cp "$2" "${MY_APPDIR}/postinst-$1.txt" 114 cp "$2" "${D}${MY_APPDIR}/postinst-$1.txt"
114} 115}
115 116
116# ------------------------------------------------------------------------ 117# ------------------------------------------------------------------------
117# EXPORTED FUNCTION - FOR USE IN EBUILDS 118# EXPORTED FUNCTION - FOR USE IN EBUILDS
118# 119#
131 webapp_checkfileexists "$2" "$D" 132 webapp_checkfileexists "$2" "$D"
132 local MY_FILE="`webapp_strip_appdir $2`" 133 local MY_FILE="`webapp_strip_appdir $2`"
133 MY_FILE="`webapp_strip_cwd $MY_FILE`" 134 MY_FILE="`webapp_strip_cwd $MY_FILE`"
134 135
135 einfo "(cgi-bin) $1 - $MY_FILE" 136 einfo "(cgi-bin) $1 - $MY_FILE"
136 echo "$1 $MY_FILE" >> $WA_RUNBYCGIBINLIST 137 echo "$1 $MY_FILE" >> ${D}${WA_RUNBYCGIBINLIST}
137} 138}
138 139
139# ------------------------------------------------------------------------ 140# ------------------------------------------------------------------------
140# EXPORTED FUNCTION - FOR USE IN EBUILDS 141# EXPORTED FUNCTION - FOR USE IN EBUILDS
141# 142#
153{ 154{
154 webapp_checkfileexists "$1" "$D" 155 webapp_checkfileexists "$1" "$D"
155 local MY_FILE="`webapp_strip_appdir $1`" 156 local MY_FILE="`webapp_strip_appdir $1`"
156 157
157 einfo "(server owned) $MY_FILE" 158 einfo "(server owned) $MY_FILE"
158 echo "$MY_FILE" >> $WA_SOLIST 159 echo "$MY_FILE" >> ${D}${WA_SOLIST}
159} 160}
160 161
161# ------------------------------------------------------------------------ 162# ------------------------------------------------------------------------
162# EXPORTED FUNCTION - FOR USE IN EBUILDS 163# EXPORTED FUNCTION - FOR USE IN EBUILDS
163# 164#
178 # create the directory where this script will go 179 # create the directory where this script will go
179 # 180 #
180 # scripts for specific database engines go into their own subdirectory 181 # scripts for specific database engines go into their own subdirectory
181 # just to keep things readable on the filesystem 182 # just to keep things readable on the filesystem
182 183
183 if [ ! -d "${MY_SQLSCRIPTSDIR}/$1" ]; then 184 if [ ! -d "${D}${MY_SQLSCRIPTSDIR}/$1" ]; then
184 mkdir -p "${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${MY_SQLSCRIPTSDIR}/$1" 185 mkdir -p "${D}${MY_SQLSCRIPTSDIR}/$1" || libsh_die "unable to create directory ${D}${MY_SQLSCRIPTSDIR}/$1"
185 fi 186 fi
186 187
187 # warning: 188 # warning:
188 # 189 #
189 # do NOT change the naming convention used here without changing all 190 # do NOT change the naming convention used here without changing all
191 192
192 # are we dealing with an 'upgrade'-type script? 193 # are we dealing with an 'upgrade'-type script?
193 if [ -n "$3" ]; then 194 if [ -n "$3" ]; then
194 # yes we are 195 # yes we are
195 einfo "($1) upgrade script from ${PN}-${PVR} to $3" 196 einfo "($1) upgrade script from ${PN}-${PVR} to $3"
196 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql 197 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${3}_to_${PVR}.sql
197 else 198 else
198 # no, we are not 199 # no, we are not
199 einfo "($1) create script for ${PN}-${PVR}" 200 einfo "($1) create script for ${PN}-${PVR}"
200 cp $2 ${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql 201 cp $2 ${D}${MY_SQLSCRIPTSDIR}/$1/${PVR}_create.sql
201 fi 202 fi
202} 203}
203 204
204# ------------------------------------------------------------------------ 205# ------------------------------------------------------------------------
205# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER 206# EXPORTED FUNCTION - call from inside your ebuild's src_install AFTER
229# 230#
230# ------------------------------------------------------------------------ 231# ------------------------------------------------------------------------
231 232
232function webapp_pkg_setup () 233function webapp_pkg_setup ()
233{ 234{
234 if [ -f /etc/vhosts/webapp-config ] ; then 235 # pull in the shared configuration file
235 . /etc/vhosts/webapp-config 236
236 else 237 . /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 238
240 # are we emerging something that is already installed? 239 # are we emerging something that is already installed?
241 240
242 if [ -d "${MY_APPROOT}/${MY_APPSUFFIX}" ]; then 241 if [ -d "${D}${MY_APPROOT}/${MY_APPSUFFIX}" ]; then
243 # yes we are 242 # yes we are
244 ewarn "Removing existing copy of ${PN}-${PVR}" 243 ewarn "Removing existing copy of ${PN}-${PVR}"
245 rm -rf "${MY_APPROOT}/${MY_APPSUFFIX}" 244 rm -rf "${D}${MY_APPROOT}/${MY_APPSUFFIX}"
246 fi 245 fi
247 246
248 # create the directories that we need 247 # create the directories that we need
249 248
250 mkdir -p ${MY_HTDOCSDIR} 249 mkdir -p ${D}${MY_HTDOCSDIR}
251 mkdir -p ${MY_HOSTROOTDIR} 250 mkdir -p ${D}${MY_HOSTROOTDIR}
252 mkdir -p ${MY_CGIBINDIR} 251 mkdir -p ${D}${MY_CGIBINDIR}
253 mkdir -p ${MY_ICONSDIR} 252 mkdir -p ${D}${MY_ICONSDIR}
254 mkdir -p ${MY_ERRORSDIR} 253 mkdir -p ${D}${MY_ERRORSDIR}
255 mkdir -p ${MY_SQLSCRIPTSDIR} 254 mkdir -p ${D}${MY_SQLSCRIPTSDIR}
256} 255}
257 256
258function webapp_pkg_postinst () 257function webapp_pkg_postinst ()
259{ 258{
260 G_HOSTNAME="${VHOST_HOSTNAME}" 259 G_HOSTNAME="localhost"
260 . /etc/vhosts/webapp-config
261
261 use vhosts || /usr/sbin/webapp-config -I -u root -d "${VHOST_ROOT}/htdocs/${PN}/" ${PN} ${PVR} 262 use vhosts || /usr/sbin/webapp-config -I -u root -d "${VHOST_ROOT}/htdocs/${PN}/" ${PN} ${PVR}
262} 263}

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

  ViewVC Help
Powered by ViewVC 1.1.20