1 |
rl03 |
1.39 |
# Copyright 1999-2006 Gentoo Foundation |
2 |
stuart |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
hollow |
1.53 |
# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.52 2008/02/22 13:53:38 hollow Exp $ |
4 |
stuart |
1.1 |
# |
5 |
hollow |
1.49 |
# @ECLASS: webapp.eclass |
6 |
|
|
# @MAINTAINER: |
7 |
|
|
# web-apps@gentoo.org |
8 |
|
|
# @BLURB: functions for installing applications to run under a web server |
9 |
|
|
# @DESCRIPTION: |
10 |
|
|
# The webapp eclass contains functions to handle web applications with |
11 |
|
|
# webapp-config. Part of the implementation of GLEP #11 |
12 |
stuart |
1.1 |
|
13 |
|
|
SLOT="${PVR}" |
14 |
swegener |
1.36 |
IUSE="vhosts" |
15 |
rl03 |
1.47 |
DEPEND=">=app-admin/webapp-config-1.50.15" |
16 |
stuart |
1.37 |
RDEPEND="${DEPEND}" |
17 |
stuart |
1.1 |
|
18 |
stuart |
1.18 |
EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm |
19 |
stuart |
1.1 |
|
20 |
stuart |
1.37 |
INSTALL_DIR="/${PN}" |
21 |
stuart |
1.14 |
IS_UPGRADE=0 |
22 |
|
|
IS_REPLACE=0 |
23 |
|
|
|
24 |
stuart |
1.19 |
INSTALL_CHECK_FILE="installed_by_webapp_eclass" |
25 |
|
|
|
26 |
hollow |
1.51 |
ETC_CONFIG="${ROOT}etc/vhosts/webapp-config" |
27 |
|
|
WEBAPP_CONFIG="${ROOT}usr/sbin/webapp-config" |
28 |
|
|
WEBAPP_CLEANER="${ROOT}usr/sbin/webapp-cleaner" |
29 |
stuart |
1.37 |
|
30 |
hollow |
1.49 |
# ============================================================================== |
31 |
|
|
# INTERNAL FUNCTIONS |
32 |
|
|
# ============================================================================== |
33 |
|
|
|
34 |
stuart |
1.37 |
# Load the config file /etc/vhosts/webapp-config |
35 |
|
|
# Supports both the old bash version, and the new python version |
36 |
hollow |
1.49 |
webapp_read_config() { |
37 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
38 |
|
|
|
39 |
stuart |
1.37 |
if has_version '>=app-admin/webapp-config-1.50'; then |
40 |
|
|
ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" |
41 |
|
|
eval ${ENVVAR} |
42 |
|
|
else |
43 |
|
|
. ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" |
44 |
|
|
fi |
45 |
|
|
} |
46 |
stuart |
1.21 |
|
47 |
hollow |
1.49 |
# Check whether a specified file exists in the given directory (`.' by default) |
48 |
|
|
webapp_checkfileexists() { |
49 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
50 |
|
|
|
51 |
hollow |
1.52 |
local my_prefix=${2:+${2}/} |
52 |
stuart |
1.9 |
|
53 |
hollow |
1.53 |
if [[ ! -e "${my_prefix}${1}" ]]; then |
54 |
stuart |
1.37 |
msg="ebuild fault: file '${1}' not found" |
55 |
stuart |
1.1 |
eerror "$msg" |
56 |
|
|
eerror "Please report this as a bug at http://bugs.gentoo.org/" |
57 |
|
|
die "$msg" |
58 |
|
|
fi |
59 |
|
|
} |
60 |
|
|
|
61 |
hollow |
1.49 |
webapp_check_installedat() { |
62 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
63 |
stuart |
1.37 |
${WEBAPP_CONFIG} --show-installed -h localhost -d "${INSTALL_DIR}" 2> /dev/null |
64 |
stuart |
1.3 |
} |
65 |
|
|
|
66 |
hollow |
1.49 |
webapp_strip_appdir() { |
67 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
68 |
hollow |
1.52 |
echo "${1#${MY_APPDIR}/}" |
69 |
stuart |
1.3 |
} |
70 |
|
|
|
71 |
hollow |
1.49 |
webapp_strip_d() { |
72 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
73 |
hollow |
1.52 |
echo "${1#${D}}" |
74 |
stuart |
1.3 |
} |
75 |
|
|
|
76 |
hollow |
1.49 |
webapp_strip_cwd() { |
77 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
78 |
hollow |
1.52 |
echo "${1/#.\///}" |
79 |
stuart |
1.1 |
} |
80 |
|
|
|
81 |
hollow |
1.50 |
webapp_getinstalltype() { |
82 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
83 |
hollow |
1.50 |
|
84 |
hollow |
1.53 |
if ! use vhosts; then |
85 |
hollow |
1.50 |
local my_output |
86 |
|
|
|
87 |
|
|
my_output="$(webapp_check_installedat)" |
88 |
|
|
|
89 |
hollow |
1.53 |
if [[ $? -eq 0 ]]; then |
90 |
hollow |
1.50 |
# something is already installed there |
91 |
|
|
# make sure it isn't the same version |
92 |
|
|
|
93 |
|
|
local my_pn="$(echo ${my_output} | awk '{ print $1 }')" |
94 |
|
|
local my_pvr="$(echo ${my_output} | awk '{ print $2 }')" |
95 |
|
|
|
96 |
|
|
REMOVE_PKG="${my_pn}-${my_pvr}" |
97 |
|
|
|
98 |
hollow |
1.53 |
if [[ "${my_pn}" == "${PN}" ]]; then |
99 |
|
|
if [[ "${my_pvr}" != "${PVR}" ]]; then |
100 |
hollow |
1.50 |
elog "This is an upgrade" |
101 |
|
|
IS_UPGRADE=1 |
102 |
|
|
else |
103 |
|
|
elog "This is a re-installation" |
104 |
|
|
IS_REPLACE=1 |
105 |
|
|
fi |
106 |
|
|
else |
107 |
|
|
elog "${my_output} is installed there" |
108 |
|
|
fi |
109 |
|
|
else |
110 |
|
|
elog "This is an installation" |
111 |
|
|
fi |
112 |
|
|
fi |
113 |
|
|
} |
114 |
|
|
|
115 |
hollow |
1.49 |
# ============================================================================== |
116 |
|
|
# PUBLIC FUNCTIONS |
117 |
|
|
# ============================================================================== |
118 |
|
|
|
119 |
|
|
# @FUNCTION: webapp_configfile |
120 |
|
|
# @USAGE: <file> [more files ...] |
121 |
|
|
# @DESCRIPTION: |
122 |
|
|
# Mark a file config-protected for a web-based application. |
123 |
|
|
webapp_configfile() { |
124 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
125 |
|
|
|
126 |
rl03 |
1.39 |
local m="" |
127 |
hollow |
1.53 |
for m in "$@"; do |
128 |
rl03 |
1.39 |
webapp_checkfileexists "${m}" "${D}" |
129 |
stuart |
1.27 |
|
130 |
wrobel |
1.40 |
local MY_FILE="$(webapp_strip_appdir "${m}")" |
131 |
|
|
MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" |
132 |
stuart |
1.3 |
|
133 |
rl03 |
1.43 |
elog "(config) ${MY_FILE}" |
134 |
rl03 |
1.39 |
echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST} |
135 |
|
|
done |
136 |
stuart |
1.1 |
} |
137 |
|
|
|
138 |
hollow |
1.49 |
# @FUNCTION: webapp_hook_script |
139 |
|
|
# @USAGE: <file> |
140 |
|
|
# @DESCRIPTION: |
141 |
stuart |
1.18 |
# Install a script that will run after a virtual copy is created, and |
142 |
hollow |
1.49 |
# before a virtual copy has been removed. |
143 |
|
|
webapp_hook_script() { |
144 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
145 |
|
|
|
146 |
stuart |
1.37 |
webapp_checkfileexists "${1}" |
147 |
stuart |
1.18 |
|
148 |
rl03 |
1.43 |
elog "(hook) ${1}" |
149 |
wrobel |
1.40 |
cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/" |
150 |
|
|
chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" |
151 |
stuart |
1.18 |
} |
152 |
|
|
|
153 |
hollow |
1.49 |
# @FUNCTION: webapp_postinst_txt |
154 |
|
|
# @USAGE: <lang> <file> |
155 |
|
|
# @DESCRIPTION: |
156 |
stuart |
1.5 |
# Install a text file containing post-installation instructions. |
157 |
hollow |
1.49 |
webapp_postinst_txt() { |
158 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
159 |
|
|
|
160 |
stuart |
1.37 |
webapp_checkfileexists "${2}" |
161 |
stuart |
1.5 |
|
162 |
rl03 |
1.43 |
elog "(info) ${2} (lang: ${1})" |
163 |
stuart |
1.37 |
cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" |
164 |
stuart |
1.5 |
} |
165 |
|
|
|
166 |
hollow |
1.49 |
# @FUNCTION: webapp_postupgrade_txt |
167 |
|
|
# @USAGE: <lang> <file> |
168 |
|
|
# @DESCRIPTION: |
169 |
stuart |
1.31 |
# Install a text file containing post-upgrade instructions. |
170 |
hollow |
1.49 |
webapp_postupgrade_txt() { |
171 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
172 |
|
|
|
173 |
stuart |
1.37 |
webapp_checkfileexists "${2}" |
174 |
stuart |
1.31 |
|
175 |
rl03 |
1.43 |
elog "(info) ${2} (lang: ${1})" |
176 |
stuart |
1.37 |
cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" |
177 |
stuart |
1.3 |
} |
178 |
|
|
|
179 |
hollow |
1.49 |
# @FUNCTION: webapp_serverowned |
180 |
|
|
# @USAGE: [-R] <file> [more files ...] |
181 |
|
|
# @DESCRIPTION: |
182 |
|
|
# Identify a file which must be owned by the webserver's user:group settings. |
183 |
|
|
# The ownership of the file is NOT set until the application is installed using |
184 |
|
|
# the webapp-config tool. If -R is given directories are handled recursively. |
185 |
|
|
webapp_serverowned() { |
186 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
187 |
|
|
|
188 |
rl03 |
1.39 |
local a="" |
189 |
|
|
local m="" |
190 |
hollow |
1.53 |
if [[ "${1}" == "-R" ]]; then |
191 |
rl03 |
1.39 |
shift |
192 |
hollow |
1.53 |
for m in "$@"; do |
193 |
rl03 |
1.39 |
for a in $(find ${D}/${m}); do |
194 |
|
|
a=${a/${D}\/\///} |
195 |
|
|
webapp_checkfileexists "${a}" "$D" |
196 |
wrobel |
1.40 |
local MY_FILE="$(webapp_strip_appdir "${a}")" |
197 |
|
|
MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" |
198 |
rl03 |
1.39 |
|
199 |
rl03 |
1.43 |
elog "(server owned) ${MY_FILE}" |
200 |
rl03 |
1.39 |
echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" |
201 |
|
|
done |
202 |
|
|
done |
203 |
|
|
else |
204 |
hollow |
1.53 |
for m in "$@"; do |
205 |
rl03 |
1.39 |
webapp_checkfileexists "${m}" "$D" |
206 |
wrobel |
1.40 |
local MY_FILE="$(webapp_strip_appdir "${m}")" |
207 |
|
|
MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" |
208 |
rl03 |
1.39 |
|
209 |
rl03 |
1.43 |
elog "(server owned) ${MY_FILE}" |
210 |
rl03 |
1.39 |
echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" |
211 |
|
|
done |
212 |
|
|
fi |
213 |
stuart |
1.3 |
} |
214 |
|
|
|
215 |
hollow |
1.49 |
# @FUNCTION: webapp_server_configfile |
216 |
|
|
# @USAGE: <server> <file> [new name] |
217 |
|
|
# @DESCRIPTION: |
218 |
|
|
# Install a configuration file for the webserver. You need to specify a |
219 |
|
|
# webapp-config supported <server>. if no new name is given `basename $2' is |
220 |
|
|
# used by default. Note: this function will automagically prepend $1 to the |
221 |
|
|
# front of your config file's name. |
222 |
|
|
webapp_server_configfile() { |
223 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
224 |
|
|
|
225 |
stuart |
1.37 |
webapp_checkfileexists "${2}" |
226 |
stuart |
1.18 |
|
227 |
hollow |
1.51 |
# WARNING: |
228 |
|
|
# |
229 |
|
|
# do NOT change the naming convention used here without changing all |
230 |
|
|
# the other scripts that also rely upon these names |
231 |
stuart |
1.18 |
|
232 |
hollow |
1.52 |
local my_file="${1}-${3:-$(basename "${2}")}" |
233 |
stuart |
1.18 |
|
234 |
rl03 |
1.43 |
elog "(${1}) config file '${my_file}'" |
235 |
stuart |
1.37 |
cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" |
236 |
stuart |
1.18 |
} |
237 |
|
|
|
238 |
hollow |
1.49 |
# @FUNCTION: webapp_sqlscript |
239 |
|
|
# @USAGE: <db> <file> [version] |
240 |
|
|
# @DESCRIPTION: |
241 |
|
|
# Install a SQL script that creates/upgrades a database schema for the web |
242 |
|
|
# application. Currently supported database engines are mysql and postgres. |
243 |
|
|
# If a version is given the script should upgrade the database schema from |
244 |
|
|
# the given version to $PVR. |
245 |
|
|
webapp_sqlscript() { |
246 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
247 |
|
|
|
248 |
stuart |
1.37 |
webapp_checkfileexists "${2}" |
249 |
stuart |
1.3 |
|
250 |
hollow |
1.53 |
if [[ ! -d "${D}/${MY_SQLSCRIPTSDIR}/${1}" ]]; then |
251 |
stuart |
1.37 |
mkdir -p "${D}/${MY_SQLSCRIPTSDIR}/${1}" || die "unable to create directory ${D}/${MY_SQLSCRIPTSDIR}/${1}" |
252 |
stuart |
1.3 |
fi |
253 |
|
|
|
254 |
hollow |
1.51 |
# WARNING: |
255 |
stuart |
1.3 |
# |
256 |
|
|
# do NOT change the naming convention used here without changing all |
257 |
|
|
# the other scripts that also rely upon these names |
258 |
swegener |
1.38 |
|
259 |
hollow |
1.53 |
if [[ -n "${3}" ]]; then |
260 |
|
|
elog "(${1}) upgrade script for ${PN}-${3} to ${PVR}" |
261 |
stuart |
1.37 |
cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" |
262 |
|
|
chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" |
263 |
stuart |
1.3 |
else |
264 |
rl03 |
1.43 |
elog "(${1}) create script for ${PN}-${PVR}" |
265 |
stuart |
1.37 |
cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" |
266 |
|
|
chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" |
267 |
stuart |
1.3 |
fi |
268 |
stuart |
1.1 |
} |
269 |
|
|
|
270 |
hollow |
1.50 |
# @FUNCTION: webapp_src_preinst |
271 |
|
|
# @DESCRIPTION: |
272 |
|
|
# You need to call this function in src_install() BEFORE anything else has run. |
273 |
|
|
# For now we just create required webapp-config directories. |
274 |
|
|
webapp_src_preinst() { |
275 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
276 |
|
|
|
277 |
hollow |
1.50 |
dodir "${MY_HTDOCSDIR}" |
278 |
|
|
dodir "${MY_HOSTROOTDIR}" |
279 |
|
|
dodir "${MY_CGIBINDIR}" |
280 |
|
|
dodir "${MY_ICONSDIR}" |
281 |
|
|
dodir "${MY_ERRORSDIR}" |
282 |
|
|
dodir "${MY_SQLSCRIPTSDIR}" |
283 |
|
|
dodir "${MY_HOOKSCRIPTSDIR}" |
284 |
|
|
dodir "${MY_SERVERCONFIGDIR}" |
285 |
|
|
} |
286 |
|
|
|
287 |
hollow |
1.49 |
# ============================================================================== |
288 |
|
|
# EXPORTED FUNCTIONS |
289 |
|
|
# ============================================================================== |
290 |
|
|
|
291 |
|
|
# @FUNCTION: webapp_src_install |
292 |
|
|
# @DESCRIPTION: |
293 |
hollow |
1.50 |
# This is the default src_install(). For now, we just make sure that root owns |
294 |
|
|
# everything, and that there are no setuid files. |
295 |
|
|
# |
296 |
|
|
# You need to call this function AFTER everything else has run in your custom |
297 |
|
|
# src_install(). |
298 |
hollow |
1.49 |
webapp_src_install() { |
299 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
300 |
|
|
|
301 |
stuart |
1.22 |
chown -R "${VHOST_DEFAULT_UID}:${VHOST_DEFAULT_GID}" "${D}/" |
302 |
|
|
chmod -R u-s "${D}/" |
303 |
|
|
chmod -R g-s "${D}/" |
304 |
|
|
|
305 |
|
|
keepdir "${MY_PERSISTDIR}" |
306 |
flameeyes |
1.41 |
fowners "root:0" "${MY_PERSISTDIR}" |
307 |
stuart |
1.22 |
fperms 755 "${MY_PERSISTDIR}" |
308 |
stuart |
1.15 |
|
309 |
stuart |
1.19 |
# to test whether or not the ebuild has correctly called this function |
310 |
|
|
# we add an empty file to the filesystem |
311 |
|
|
# |
312 |
|
|
# we used to just set a variable in the shell script, but we can |
313 |
|
|
# no longer rely on Portage calling both webapp_src_install() and |
314 |
|
|
# webapp_pkg_postinst() within the same shell process |
315 |
|
|
|
316 |
stuart |
1.22 |
touch "${D}/${MY_APPDIR}/${INSTALL_CHECK_FILE}" |
317 |
stuart |
1.1 |
} |
318 |
|
|
|
319 |
hollow |
1.49 |
# @FUNCTION: webapp_pkg_setup |
320 |
|
|
# @DESCRIPTION: |
321 |
hollow |
1.50 |
# The default pkg_setup() for this eclass. This will gather required variables |
322 |
|
|
# from webapp-config and check if there is an application installed to |
323 |
|
|
# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set. |
324 |
|
|
# |
325 |
|
|
# You need to call this function BEFORE anything else has run in your custom |
326 |
|
|
# pkg_setup(). |
327 |
hollow |
1.49 |
webapp_pkg_setup() { |
328 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
329 |
stuart |
1.15 |
|
330 |
rl03 |
1.44 |
# special case - some ebuilds *do* need to overwride the SLOT |
331 |
|
|
if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then |
332 |
|
|
die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually" |
333 |
stuart |
1.15 |
fi |
334 |
|
|
|
335 |
stuart |
1.8 |
# pull in the shared configuration file |
336 |
stuart |
1.18 |
G_HOSTNAME="localhost" |
337 |
stuart |
1.37 |
webapp_read_config |
338 |
stuart |
1.18 |
|
339 |
swegener |
1.34 |
# are we installing a webapp-config solution over the top of a |
340 |
stuart |
1.18 |
# non-webapp-config solution? |
341 |
hollow |
1.53 |
if ! use vhosts; then |
342 |
stuart |
1.37 |
local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" |
343 |
stuart |
1.18 |
local my_output |
344 |
|
|
|
345 |
hollow |
1.53 |
if [[ -d "${my_dir}" ]]; then |
346 |
stuart |
1.37 |
my_output="$(webapp_check_installedat)" |
347 |
stuart |
1.18 |
|
348 |
hollow |
1.53 |
if [[ $? -ne 0 ]]; then |
349 |
stuart |
1.18 |
# okay, whatever is there, it isn't webapp-config-compatible |
350 |
swegener |
1.45 |
ewarn "You already have something installed in ${my_dir}" |
351 |
stuart |
1.18 |
ewarn |
352 |
stuart |
1.37 |
ewarn "Whatever is in ${my_dir}, it's not" |
353 |
stuart |
1.18 |
ewarn "compatible with webapp-config." |
354 |
|
|
ewarn |
355 |
stuart |
1.20 |
ewarn "This ebuild may be overwriting important files." |
356 |
|
|
ewarn |
357 |
hollow |
1.53 |
elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then |
358 |
stuart |
1.37 |
eerror "${my_dir} contains ${my_output}" |
359 |
stuart |
1.18 |
eerror "I cannot upgrade that" |
360 |
stuart |
1.37 |
die "Cannot upgrade contents of ${my_dir}" |
361 |
stuart |
1.18 |
fi |
362 |
|
|
fi |
363 |
|
|
fi |
364 |
stuart |
1.14 |
} |
365 |
stuart |
1.6 |
|
366 |
hollow |
1.50 |
# @FUNCTION: webapp_pkg_postinst |
367 |
|
|
# @DESCRIPTION: |
368 |
|
|
# The default pkg_postinst() for this eclass. This installs the web application to |
369 |
|
|
# `${ROOT}/var/www/localhost/htdocs/${PN}/' if USE=vhosts is not set. Otherwise |
370 |
|
|
# display a short notice how to install this application with webapp-config. |
371 |
|
|
# |
372 |
|
|
# You need to call this function AFTER everything else has run in your custom |
373 |
|
|
# pkg_postinst(). |
374 |
hollow |
1.49 |
webapp_pkg_postinst() { |
375 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
376 |
|
|
|
377 |
stuart |
1.37 |
webapp_read_config |
378 |
stuart |
1.21 |
|
379 |
stuart |
1.15 |
# sanity checks, to catch bugs in the ebuild |
380 |
hollow |
1.53 |
if [[ ! -f "${ROOT}${MY_APPDIR}/${INSTALL_CHECK_FILE}" ]]; then |
381 |
stuart |
1.15 |
eerror |
382 |
|
|
eerror "This ebuild did not call webapp_src_install() at the end" |
383 |
|
|
eerror "of the src_install() function" |
384 |
|
|
eerror |
385 |
|
|
eerror "Please log a bug on http://bugs.gentoo.org" |
386 |
|
|
eerror |
387 |
|
|
eerror "You should use emerge -C to remove this package, as the" |
388 |
|
|
eerror "installation is incomplete" |
389 |
|
|
eerror |
390 |
|
|
die "Ebuild did not call webapp_src_install() - report to http://bugs.gentoo.org" |
391 |
|
|
fi |
392 |
|
|
|
393 |
hollow |
1.53 |
if ! use vhosts; then |
394 |
stuart |
1.14 |
echo |
395 |
rl03 |
1.43 |
elog "vhosts USE flag not set - auto-installing using webapp-config" |
396 |
stuart |
1.11 |
|
397 |
stuart |
1.14 |
webapp_getinstalltype |
398 |
|
|
|
399 |
stuart |
1.10 |
G_HOSTNAME="localhost" |
400 |
|
|
local my_mode=-I |
401 |
stuart |
1.37 |
webapp_read_config |
402 |
stuart |
1.10 |
|
403 |
hollow |
1.53 |
if [[ "${IS_REPLACE}" == "1" ]]; then |
404 |
rl03 |
1.43 |
elog "${PN}-${PVR} is already installed - replacing" |
405 |
stuart |
1.27 |
my_mode=-I |
406 |
hollow |
1.53 |
elif [[ "${IS_UPGRADE}" == "1" ]]; then |
407 |
rl03 |
1.43 |
elog "${REMOVE_PKG} is already installed - upgrading" |
408 |
stuart |
1.14 |
my_mode=-U |
409 |
stuart |
1.11 |
else |
410 |
rl03 |
1.43 |
elog "${PN}-${PVR} is not installed - using install mode" |
411 |
stuart |
1.10 |
fi |
412 |
swegener |
1.38 |
|
413 |
stuart |
1.37 |
my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" |
414 |
rl03 |
1.43 |
elog "Running ${my_cmd}" |
415 |
stuart |
1.37 |
${my_cmd} |
416 |
stuart |
1.14 |
|
417 |
rl03 |
1.47 |
echo |
418 |
|
|
local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" |
419 |
|
|
einfo "Running ${cleaner}" |
420 |
|
|
${cleaner} |
421 |
stuart |
1.18 |
else |
422 |
rl03 |
1.43 |
elog |
423 |
|
|
elog "The 'vhosts' USE flag is switched ON" |
424 |
|
|
elog "This means that Portage will not automatically run webapp-config to" |
425 |
|
|
elog "complete the installation." |
426 |
|
|
elog |
427 |
|
|
elog "To install ${PN}-${PVR} into a virtual host, run the following command:" |
428 |
|
|
elog |
429 |
|
|
elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" |
430 |
|
|
elog |
431 |
|
|
elog "For more details, see the webapp-config(8) man page" |
432 |
stuart |
1.10 |
fi |
433 |
stuart |
1.2 |
} |
434 |
stuart |
1.18 |
|
435 |
hollow |
1.50 |
# @FUNCTION: webapp_pkg_prerm |
436 |
|
|
# @DESCRIPTION: |
437 |
|
|
# This is the default pkg_prerm() for this eclass. If USE=vhosts is not set |
438 |
|
|
# remove all installed copies of this web application. Otherwise instruct the |
439 |
hollow |
1.51 |
# user to manually remove those copies. See bug #136959. |
440 |
hollow |
1.49 |
webapp_pkg_prerm() { |
441 |
hollow |
1.51 |
debug-print-function $FUNCNAME $* |
442 |
stuart |
1.18 |
|
443 |
hollow |
1.53 |
local my_output= |
444 |
stuart |
1.37 |
my_output="$(${WEBAPP_CONFIG} --list-installs ${PN} ${PVR})" |
445 |
hollow |
1.53 |
[[ $? -ne 0 ]] && return |
446 |
stuart |
1.18 |
|
447 |
hollow |
1.53 |
local x |
448 |
|
|
if ! use vhosts; then |
449 |
stuart |
1.18 |
|
450 |
hollow |
1.53 |
for x in ${my_output}; do |
451 |
|
|
[[ -f ${x}/.webapp ]] && . ${x}/.webapp || ewarn "Cannot find file ${x}/.webapp" |
452 |
|
|
if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then |
453 |
rl03 |
1.48 |
${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} |
454 |
|
|
fi |
455 |
|
|
done |
456 |
hollow |
1.51 |
else |
457 |
stuart |
1.18 |
|
458 |
rl03 |
1.48 |
ewarn "Don't forget to use webapp-config to remove any copies of" |
459 |
|
|
ewarn "${PN}-${PVR} installed in" |
460 |
|
|
ewarn |
461 |
stuart |
1.18 |
|
462 |
hollow |
1.53 |
for x in ${my_output}; do |
463 |
|
|
[[ -f ${x}/.webapp ]] && . ${x}/.webapp || ewarn "Cannot find file ${x}/.webapp" |
464 |
rl03 |
1.48 |
ewarn " ${x}" |
465 |
|
|
done |
466 |
|
|
fi |
467 |
stuart |
1.18 |
} |