| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2006 Gentoo Foundation |
| 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.65 2011/05/19 12:03:41 scarabeus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.66 2011/05/19 12:05:13 scarabeus Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: webapp.eclass |
5 | # @ECLASS: webapp.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # web-apps@gentoo.org |
7 | # web-apps@gentoo.org |
| 8 | # @BLURB: functions for installing applications to run under a web server |
8 | # @BLURB: functions for installing applications to run under a web server |
| 9 | # @DESCRIPTION: |
9 | # @DESCRIPTION: |
| 10 | # The webapp eclass contains functions to handle web applications with |
10 | # The webapp eclass contains functions to handle web applications with |
| 11 | # webapp-config. Part of the implementation of GLEP #11 |
11 | # webapp-config. Part of the implementation of GLEP #11 |
| 12 | |
12 | |
| 13 | # @ECLASS-VARIABLE: WABAPP_MINIMAL |
|
|
| 14 | # @DESCRIPTION: |
|
|
| 15 | # Minimal version of webapp-config the package requires for sucessfull install. |
|
|
| 16 | : ${WEBAPP_MINIMAL:=1.50.15} |
|
|
| 17 | |
|
|
| 18 | # @ECLASS-VARIABLE: WEBAPP_DEPEND |
13 | # @ECLASS-VARIABLE: WEBAPP_DEPEND |
| 19 | # @DESCRIPTION: |
14 | # @DESCRIPTION: |
| 20 | # An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most |
15 | # An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most |
| 21 | # notably in combination with WEBAPP_OPTIONAL. |
16 | # notably in combination with WEBAPP_OPTIONAL. |
| 22 | : ${WEBAPP_DEPEND:=">=app-admin/webapp-config-${WEBAPP_MINIMAL}"} |
17 | WEBAPP_DEPEND=">=app-admin/webapp-config-1.50.15" |
| 23 | |
18 | |
| 24 | # @ECLASS-VARIABLE: WEBAPP_AUTO_INSTALL |
19 | # @ECLASS-VARIABLE: WEBAPP_NO_AUTO_INSTALL |
| 25 | # @DESCRIPTION: |
20 | # @DESCRIPTION: |
| 26 | # An ebuild sets this to `no' if an automatic installation and/or upgrade is |
21 | # An ebuild sets this to `yes' if an automatic installation and/or upgrade is |
| 27 | # not possible. The ebuild should overwrite pkg_postinst() and explain the |
22 | # not possible. The ebuild should overwrite pkg_postinst() and explain the |
| 28 | # reason for this BEFORE calling webapp_pkg_postinst(). |
23 | # reason for this BEFORE calling webapp_pkg_postinst(). |
| 29 | : ${WEBAPP_AUTO_INSTALL:=yes} |
|
|
| 30 | if [[ -n ${WEBAPP_NO_AUTO_INSTALL} ]]; then |
|
|
| 31 | WEBAPP_AUTO_INSTALL=no |
|
|
| 32 | ewarn "QA: using deprecated variable \"WEBAPP_NO_AUTO_INSTALL\"." |
|
|
| 33 | ewarn "QA: please migrate to WEBAPP_AUTO_INSTALL with inverse logic" |
|
|
| 34 | ewarn "QA: that defaults to yes." |
|
|
| 35 | fi |
|
|
| 36 | |
24 | |
| 37 | # @ECLASS-VARIABLE: WEBAPP_OPTIONAL |
25 | # @ECLASS-VARIABLE: WEBAPP_OPTIONAL |
| 38 | # @DESCRIPTION: |
26 | # @DESCRIPTION: |
| 39 | # An ebuild sets this to `yes' to make webapp support optional, in which case |
27 | # An ebuild sets this to `yes' to make webapp support optional, in which case |
| 40 | # you also need to take care of USE-flags and dependencies. |
28 | # you also need to take care of USE-flags and dependencies. |
|
|
29 | |
| 41 | if [[ ${WEBAPP_OPTIONAL} != yes ]]; then |
30 | if [[ "${WEBAPP_OPTIONAL}" != "yes" ]]; then |
| 42 | [[ ${WEBAPP_AUTO_INSTALL} == yes ]] && IUSE="vhosts" |
31 | [[ "${WEBAPP_NO_AUTO_INSTALL}" == "yes" ]] || IUSE="vhosts" |
| 43 | : ${SLOT:=${PVR}} |
32 | SLOT="${PVR}" |
| 44 | DEPEND="${WEBAPP_DEPEND}" |
33 | DEPEND="${WEBAPP_DEPEND}" |
| 45 | RDEPEND="${DEPEND}" |
34 | RDEPEND="${DEPEND}" |
| 46 | fi |
35 | fi |
| 47 | |
36 | |
| 48 | EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm |
37 | EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm |
| … | |
… | |
| 65 | # Load the config file /etc/vhosts/webapp-config |
54 | # Load the config file /etc/vhosts/webapp-config |
| 66 | # Supports both the old bash version, and the new python version |
55 | # Supports both the old bash version, and the new python version |
| 67 | webapp_read_config() { |
56 | webapp_read_config() { |
| 68 | debug-print-function $FUNCNAME $* |
57 | debug-print-function $FUNCNAME $* |
| 69 | |
58 | |
|
|
59 | if has_version '>=app-admin/webapp-config-1.50'; then |
| 70 | ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" |
60 | ENVVAR=$(${WEBAPP_CONFIG} --query ${PN} ${PVR}) || die "Could not read settings from webapp-config!" |
| 71 | eval ${ENVVAR} || die |
61 | eval ${ENVVAR} |
|
|
62 | else |
|
|
63 | . ${ETC_CONFIG} || die "Unable to read ${ETC_CONFIG}" |
|
|
64 | fi |
| 72 | } |
65 | } |
| 73 | |
66 | |
| 74 | # Check whether a specified file exists in the given directory (`.' by default) |
67 | # Check whether a specified file exists in the given directory (`.' by default) |
| 75 | webapp_checkfileexists() { |
68 | webapp_checkfileexists() { |
| 76 | debug-print-function $FUNCNAME $* |
69 | debug-print-function $FUNCNAME $* |
| 77 | |
70 | |
| 78 | local msg my_prefix=${2:+${2}/} |
71 | local my_prefix=${2:+${2}/} |
| 79 | |
72 | |
| 80 | if [[ ! -e "${my_prefix}${1}" ]]; then |
73 | if [[ ! -e "${my_prefix}${1}" ]]; then |
| 81 | msg="ebuild error: file '${1}' not found" |
74 | msg="ebuild fault: file '${1}' not found" |
| 82 | eerror "$msg" |
75 | eerror "$msg" |
| 83 | eerror "Please report this as a bug at http://bugs.gentoo.org/" |
76 | eerror "Please report this as a bug at http://bugs.gentoo.org/" |
| 84 | die "$msg" |
77 | die "$msg" |
| 85 | fi |
78 | fi |
| 86 | } |
79 | } |
| … | |
… | |
| 106 | } |
99 | } |
| 107 | |
100 | |
| 108 | webapp_getinstalltype() { |
101 | webapp_getinstalltype() { |
| 109 | debug-print-function $FUNCNAME $* |
102 | debug-print-function $FUNCNAME $* |
| 110 | |
103 | |
| 111 | local my_output my_pn my_pvr |
|
|
| 112 | |
|
|
| 113 | if ! has vhosts ${IUSE} || use vhosts; then |
104 | if ! has vhosts ${IUSE} || use vhosts; then |
| 114 | return |
105 | return |
| 115 | fi |
106 | fi |
| 116 | |
107 | |
|
|
108 | local my_output |
| 117 | my_output="$(webapp_check_installedat)" |
109 | my_output="$(webapp_check_installedat)" |
| 118 | |
110 | |
| 119 | if [[ $? -eq 0 ]]; then |
111 | if [[ $? -eq 0 ]]; then |
| 120 | # something is already installed there |
112 | # something is already installed there |
| 121 | # make sure it isn't the same version |
113 | # make sure it isn't the same version |
| 122 | |
114 | |
| 123 | my_pn="$(echo ${my_output} | awk '{ print $1 }')" |
115 | local my_pn="$(echo ${my_output} | awk '{ print $1 }')" |
| 124 | my_pvr="$(echo ${my_output} | awk '{ print $2 }')" |
116 | local my_pvr="$(echo ${my_output} | awk '{ print $2 }')" |
| 125 | |
117 | |
| 126 | REMOVE_PKG="${my_pn}-${my_pvr}" |
118 | REMOVE_PKG="${my_pn}-${my_pvr}" |
| 127 | |
119 | |
| 128 | if [[ "${my_pn}" == "${PN}" ]]; then |
120 | if [[ "${my_pn}" == "${PN}" ]]; then |
| 129 | if [[ "${my_pvr}" != "${PVR}" ]]; then |
121 | if [[ "${my_pvr}" != "${PVR}" ]]; then |
| … | |
… | |
| 139 | else |
131 | else |
| 140 | elog "This is an installation" |
132 | elog "This is an installation" |
| 141 | fi |
133 | fi |
| 142 | } |
134 | } |
| 143 | |
135 | |
| 144 | # helper for webapp_serverowned() |
|
|
| 145 | _webapp_serverowned() { |
|
|
| 146 | debug-print-function $FUNCNAME $* |
|
|
| 147 | |
|
|
| 148 | webapp_checkfileexists "${1}" "${D}" |
|
|
| 149 | local my_file="$(webapp_strip_appdir "${1}")" |
|
|
| 150 | my_file="$(webapp_strip_cwd "${my_file}")" |
|
|
| 151 | |
|
|
| 152 | elog "(server owned) ${my_file}" |
|
|
| 153 | echo "${my_file}" >> "${D}/${WA_SOLIST}" |
|
|
| 154 | } |
|
|
| 155 | |
|
|
| 156 | # ============================================================================== |
136 | # ============================================================================== |
| 157 | # PUBLIC FUNCTIONS |
137 | # PUBLIC FUNCTIONS |
| 158 | # ============================================================================== |
138 | # ============================================================================== |
| 159 | |
139 | |
| 160 | # @FUNCTION: need_httpd |
140 | # @FUNCTION: need_httpd |
| … | |
… | |
| 189 | # @DESCRIPTION: |
169 | # @DESCRIPTION: |
| 190 | # Mark a file config-protected for a web-based application. |
170 | # Mark a file config-protected for a web-based application. |
| 191 | webapp_configfile() { |
171 | webapp_configfile() { |
| 192 | debug-print-function $FUNCNAME $* |
172 | debug-print-function $FUNCNAME $* |
| 193 | |
173 | |
| 194 | [[ $# -lt 1 ]] && die "${FUNCNAME}: I require at least 1 argument. Please read eclass documentation." |
|
|
| 195 | |
|
|
| 196 | local m |
174 | local m |
| 197 | for m in "$@"; do |
175 | for m in "$@"; do |
| 198 | webapp_checkfileexists "${m}" "${D}" |
176 | webapp_checkfileexists "${m}" "${D}" |
| 199 | |
177 | |
| 200 | local my_file="$(webapp_strip_appdir "${m}")" |
178 | local my_file="$(webapp_strip_appdir "${m}")" |
| 201 | my_file="$(webapp_strip_cwd "${my_file}")" |
179 | my_file="$(webapp_strip_cwd "${my_file}")" |
| 202 | |
180 | |
| 203 | elog "[webapp-config] ${my_file}" |
181 | elog "(config) ${my_file}" |
| 204 | echo "${my_file}" >> ${D}/${WA_CONFIGLIST} |
182 | echo "${my_file}" >> ${D}/${WA_CONFIGLIST} |
| 205 | done |
183 | done |
| 206 | } |
184 | } |
| 207 | |
185 | |
| 208 | # @FUNCTION: webapp_hook_script |
186 | # @FUNCTION: webapp_hook_script |
| 209 | # @USAGE: <file> [more files ...] |
187 | # @USAGE: <file> |
| 210 | # @DESCRIPTION: |
188 | # @DESCRIPTION: |
| 211 | # Install a script that will run after a virtual copy is created, and |
189 | # Install a script that will run after a virtual copy is created, and |
| 212 | # before a virtual copy has been removed. |
190 | # before a virtual copy has been removed. |
| 213 | webapp_hook_script() { |
191 | webapp_hook_script() { |
| 214 | debug-print-function $FUNCNAME $* |
192 | debug-print-function $FUNCNAME $* |
| 215 | |
193 | |
| 216 | [[ $# -lt 1 ]] && die "${FUNCNAME}: I require at least 1 argument. Please read eclass documentation." |
|
|
| 217 | |
|
|
| 218 | local m |
|
|
| 219 | for m in "$@"; do |
|
|
| 220 | webapp_checkfileexists "${m}" |
194 | webapp_checkfileexists "${1}" |
| 221 | |
195 | |
| 222 | elog "[webapp-hook] ${m}" |
196 | elog "(hook) ${1}" |
| 223 | cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into \"${D}/${MY_HOOKSCRIPTSDIR}/\"" |
197 | cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/" |
| 224 | chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" |
198 | chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" |
| 225 | done |
|
|
| 226 | } |
199 | } |
| 227 | |
200 | |
| 228 | # @FUNCTION: webapp_postinst_txt |
201 | # @FUNCTION: webapp_postinst_txt |
| 229 | # @USAGE: <lang> <file> [more files ...] |
202 | # @USAGE: <lang> <file> |
| 230 | # @DESCRIPTION: |
203 | # @DESCRIPTION: |
| 231 | # Install a text file containing post-installation instructions. |
204 | # Install a text file containing post-installation instructions. |
| 232 | webapp_postinst_txt() { |
205 | webapp_postinst_txt() { |
| 233 | debug-print-function $FUNCNAME $* |
206 | debug-print-function $FUNCNAME $* |
| 234 | |
207 | |
| 235 | local lang m |
|
|
| 236 | |
|
|
| 237 | [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation." |
|
|
| 238 | |
|
|
| 239 | lang=${1} |
|
|
| 240 | shift |
|
|
| 241 | |
|
|
| 242 | local m |
|
|
| 243 | for m in "$@"; do |
|
|
| 244 | webapp_checkfileexists "${m}" |
208 | webapp_checkfileexists "${2}" |
| 245 | |
209 | |
| 246 | elog "[webapp-info] \"${m}\" (lang: ${lang})" |
210 | elog "(info) ${2} (lang: ${1})" |
| 247 | cp "${m}" "${D}/${MY_APPDIR}/${m}-postinst-${lang}.txt" || die |
211 | cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" |
| 248 | done |
|
|
| 249 | } |
212 | } |
| 250 | |
213 | |
| 251 | # @FUNCTION: webapp_postupgrade_txt |
214 | # @FUNCTION: webapp_postupgrade_txt |
| 252 | # @USAGE: <lang> <file> [more files ...] |
215 | # @USAGE: <lang> <file> |
| 253 | # @DESCRIPTION: |
216 | # @DESCRIPTION: |
| 254 | # Install a text file containing post-upgrade instructions. |
217 | # Install a text file containing post-upgrade instructions. |
| 255 | webapp_postupgrade_txt() { |
218 | webapp_postupgrade_txt() { |
| 256 | debug-print-function $FUNCNAME $* |
219 | debug-print-function $FUNCNAME $* |
| 257 | |
220 | |
| 258 | local lang m |
|
|
| 259 | |
|
|
| 260 | [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation." |
|
|
| 261 | |
|
|
| 262 | lang=${1} |
|
|
| 263 | shift |
|
|
| 264 | |
|
|
| 265 | local m |
|
|
| 266 | for m in "$@"; do |
|
|
| 267 | webapp_checkfileexists "${m}" |
221 | webapp_checkfileexists "${2}" |
| 268 | |
222 | |
| 269 | elog "[webapp-info] \"${m}\" (lang: ${lang})" |
223 | elog "(info) ${2} (lang: ${1})" |
| 270 | cp "${m}" "${D}/${MY_APPDIR}/${m}-postupgrade-${lang}.txt" || die |
224 | cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" |
| 271 | done |
225 | } |
|
|
226 | |
|
|
227 | # helper for webapp_serverowned() |
|
|
228 | _webapp_serverowned() { |
|
|
229 | debug-print-function $FUNCNAME $* |
|
|
230 | |
|
|
231 | webapp_checkfileexists "${1}" "${D}" |
|
|
232 | local my_file="$(webapp_strip_appdir "${1}")" |
|
|
233 | my_file="$(webapp_strip_cwd "${my_file}")" |
|
|
234 | |
|
|
235 | elog "(server owned) ${my_file}" |
|
|
236 | echo "${my_file}" >> "${D}/${WA_SOLIST}" |
| 272 | } |
237 | } |
| 273 | |
238 | |
| 274 | # @FUNCTION: webapp_serverowned |
239 | # @FUNCTION: webapp_serverowned |
| 275 | # @USAGE: [-R] <file> [more files ...] |
240 | # @USAGE: [-R] <file> [more files ...] |
| 276 | # @DESCRIPTION: |
241 | # @DESCRIPTION: |
| … | |
… | |
| 304 | # used by default. Note: this function will automagically prepend $1 to the |
269 | # used by default. Note: this function will automagically prepend $1 to the |
| 305 | # front of your config file's name. |
270 | # front of your config file's name. |
| 306 | webapp_server_configfile() { |
271 | webapp_server_configfile() { |
| 307 | debug-print-function $FUNCNAME $* |
272 | debug-print-function $FUNCNAME $* |
| 308 | |
273 | |
| 309 | [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation." |
|
|
| 310 | |
|
|
| 311 | webapp_checkfileexists "${2}" |
274 | webapp_checkfileexists "${2}" |
| 312 | |
275 | |
| 313 | # WARNING: |
276 | # WARNING: |
| 314 | # |
277 | # |
| 315 | # do NOT change the naming convention used here without changing all |
278 | # do NOT change the naming convention used here without changing all |
| 316 | # the other scripts that also rely upon these names |
279 | # the other scripts that also rely upon these names |
| 317 | |
280 | |
| 318 | local my_file="${1}-${3:-$(basename "${2}")}" |
281 | local my_file="${1}-${3:-$(basename "${2}")}" |
| 319 | |
282 | |
| 320 | elog "[webapp] Server \"${1}\" config file \"${my_file}\"" |
283 | elog "(${1}) config file '${my_file}'" |
| 321 | cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" |
284 | cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" |
| 322 | } |
285 | } |
| 323 | |
286 | |
| 324 | # @FUNCTION: webapp_sqlscript |
287 | # @FUNCTION: webapp_sqlscript |
| 325 | # @USAGE: <db> <file> [version] |
288 | # @USAGE: <db> <file> [version] |
| … | |
… | |
| 329 | # If a version is given the script should upgrade the database schema from |
292 | # If a version is given the script should upgrade the database schema from |
| 330 | # the given version to $PVR. |
293 | # the given version to $PVR. |
| 331 | webapp_sqlscript() { |
294 | webapp_sqlscript() { |
| 332 | debug-print-function $FUNCNAME $* |
295 | debug-print-function $FUNCNAME $* |
| 333 | |
296 | |
| 334 | [[ $# -lt 2 ]] && die "${FUNCNAME}: I require at least 2 arguments. Please read eclass documentation." |
|
|
| 335 | |
|
|
| 336 | webapp_checkfileexists "${2}" |
297 | webapp_checkfileexists "${2}" |
|
|
298 | |
|
|
299 | dodir "${MY_SQLSCRIPTSDIR}/${1}" |
| 337 | |
300 | |
| 338 | # WARNING: |
301 | # WARNING: |
| 339 | # |
302 | # |
| 340 | # do NOT change the naming convention used here without changing all |
303 | # do NOT change the naming convention used here without changing all |
| 341 | # the other scripts that also rely upon these names |
304 | # the other scripts that also rely upon these names |
| 342 | |
305 | |
| 343 | insinto "${MY_SQLSCRIPTSDIR}/${1}" |
|
|
| 344 | insopts -m0600 |
|
|
| 345 | if [[ -n ${3} ]]; then |
306 | if [[ -n "${3}" ]]; then |
| 346 | elog "[webapp] DB: \"${1}\" upgrade script for ${PN}-${3} to ${PVR}" |
307 | elog "(${1}) upgrade script for ${PN}-${3} to ${PVR}" |
| 347 | newins "${2}" "${3}_to_${PVR}.sql" || die |
308 | cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" |
|
|
309 | chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" |
| 348 | else |
310 | else |
| 349 | elog "[webapp] DB: \"${1}\" create script for ${PN}-${PVR}" |
311 | elog "(${1}) create script for ${PN}-${PVR}" |
| 350 | newins "${2}" "${PVR}_create.sql" |
312 | cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" |
|
|
313 | chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" |
| 351 | fi |
314 | fi |
| 352 | } |
315 | } |
| 353 | |
316 | |
| 354 | # @FUNCTION: webapp_src_preinst |
317 | # @FUNCTION: webapp_src_preinst |
| 355 | # @DESCRIPTION: |
318 | # @DESCRIPTION: |
| … | |
… | |
| 357 | # For now we just create required webapp-config directories. |
320 | # For now we just create required webapp-config directories. |
| 358 | webapp_src_preinst() { |
321 | webapp_src_preinst() { |
| 359 | debug-print-function $FUNCNAME $* |
322 | debug-print-function $FUNCNAME $* |
| 360 | |
323 | |
| 361 | # sanity checks, to catch bugs in the ebuild |
324 | # sanity checks, to catch bugs in the ebuild |
| 362 | if [[ ! -f ${T}/${SETUP_CHECK_FILE} ]]; then |
325 | if [[ ! -f "${T}/${SETUP_CHECK_FILE}" ]]; then |
| 363 | eerror |
326 | eerror |
| 364 | eerror "This ebuild did not call webapp_pkg_setup() at the beginning" |
327 | eerror "This ebuild did not call webapp_pkg_setup() at the beginning" |
| 365 | eerror "of the pkg_setup() function" |
328 | eerror "of the pkg_setup() function" |
| 366 | eerror |
329 | eerror |
| 367 | eerror "Please log a bug on http://bugs.gentoo.org" |
330 | eerror "Please log a bug on http://bugs.gentoo.org" |
| … | |
… | |
| 406 | # no longer rely on Portage calling both webapp_pkg_setup() and |
369 | # no longer rely on Portage calling both webapp_pkg_setup() and |
| 407 | # webapp_src_install() within the same shell process |
370 | # webapp_src_install() within the same shell process |
| 408 | touch "${T}/${SETUP_CHECK_FILE}" |
371 | touch "${T}/${SETUP_CHECK_FILE}" |
| 409 | |
372 | |
| 410 | # special case - some ebuilds *do* need to overwride the SLOT |
373 | # special case - some ebuilds *do* need to overwride the SLOT |
| 411 | [[ ${SLOT} != ${PVR} && ${WEBAPP_MANUAL_SLOT} != yes ]] && \ |
374 | if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then |
| 412 | die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually" |
375 | die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually" |
|
|
376 | fi |
| 413 | |
377 | |
| 414 | # pull in the shared configuration file |
378 | # pull in the shared configuration file |
| 415 | G_HOSTNAME="localhost" |
379 | G_HOSTNAME="localhost" |
| 416 | webapp_read_config |
380 | webapp_read_config |
| 417 | |
381 | |
| … | |
… | |
| 425 | local my_output |
389 | local my_output |
| 426 | my_output="$(webapp_check_installedat)" |
390 | my_output="$(webapp_check_installedat)" |
| 427 | |
391 | |
| 428 | if [[ $? -ne 0 ]]; then |
392 | if [[ $? -ne 0 ]]; then |
| 429 | # okay, whatever is there, it isn't webapp-config-compatible |
393 | # okay, whatever is there, it isn't webapp-config-compatible |
|
|
394 | echo |
| 430 | ewarn |
395 | ewarn |
| 431 | ewarn "You already have something installed in ${my_dir}" |
396 | ewarn "You already have something installed in ${my_dir}" |
| 432 | ewarn |
397 | ewarn |
| 433 | ewarn "Whatever is in \"${my_dir}\", it's not" |
398 | ewarn "Whatever is in ${my_dir}, it's not" |
| 434 | ewarn "compatible with webapp-config." |
399 | ewarn "compatible with webapp-config." |
| 435 | ewarn |
400 | ewarn |
| 436 | ewarn "This ebuild may be overwriting important files." |
401 | ewarn "This ebuild may be overwriting important files." |
| 437 | ewarn |
402 | ewarn |
|
|
403 | echo |
|
|
404 | ebeep 10 |
| 438 | elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then |
405 | elif [[ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]]; then |
| 439 | echo |
406 | echo |
| 440 | eerror "You already have ${my_output} installed in ${my_dir}" |
407 | eerror "You already have ${my_output} installed in ${my_dir}" |
| 441 | eerror |
408 | eerror |
| 442 | eerror "I cannot upgrade a different application" |
409 | eerror "I cannot upgrade a different application" |
| 443 | eerror |
410 | eerror |
| 444 | echo |
411 | echo |
| 445 | die "Cannot upgrade contents of ${my_dir}" |
412 | die "Cannot upgrade contents of ${my_dir}" |
| 446 | fi |
413 | fi |
|
|
414 | |
| 447 | } |
415 | } |
| 448 | |
416 | |
| 449 | # @FUNCTION: webapp_src_install |
417 | # @FUNCTION: webapp_src_install |
| 450 | # @DESCRIPTION: |
418 | # @DESCRIPTION: |
| 451 | # This is the default src_install(). For now, we just make sure that root owns |
419 | # This is the default src_install(). For now, we just make sure that root owns |
| … | |
… | |
| 509 | webapp_read_config |
477 | webapp_read_config |
| 510 | |
478 | |
| 511 | local my_mode=-I |
479 | local my_mode=-I |
| 512 | webapp_getinstalltype |
480 | webapp_getinstalltype |
| 513 | |
481 | |
| 514 | if [[ ${IS_REPLACE} == 1 ]]; then |
482 | if [[ "${IS_REPLACE}" == "1" ]]; then |
| 515 | elog "[webapp] ${PN}-${PVR} is already installed - replacing" |
483 | elog "${PN}-${PVR} is already installed - replacing" |
|
|
484 | my_mode=-I |
| 516 | elif [[ ${IS_UPGRADE} == 1 ]]; then |
485 | elif [[ "${IS_UPGRADE}" == "1" ]]; then |
| 517 | elog "[webapp] ${REMOVE_PKG} is already installed - upgrading" |
486 | elog "${REMOVE_PKG} is already installed - upgrading" |
| 518 | my_mode=-U |
487 | my_mode=-U |
| 519 | else |
488 | else |
| 520 | elog "[webapp] ${PN}-${PVR} is not installed - using install mode" |
489 | elog "${PN}-${PVR} is not installed - using install mode" |
| 521 | fi |
490 | fi |
| 522 | |
491 | |
| 523 | my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" |
492 | my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" |
| 524 | elog "[webapp] Running ${my_cmd}" |
493 | elog "Running ${my_cmd}" |
| 525 | ${my_cmd} |
494 | ${my_cmd} |
| 526 | |
495 | |
| 527 | echo |
496 | echo |
| 528 | local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" |
497 | local cleaner="${WEBAPP_CLEANER} -p -C ${PN}" |
| 529 | einfo "[webapp] Running ${cleaner}" |
498 | einfo "Running ${cleaner}" |
| 530 | ${cleaner} |
499 | ${cleaner} |
| 531 | else |
500 | else |
| 532 | elog |
501 | elog |
| 533 | elog "The 'vhosts' USE flag is switched ON" |
502 | elog "The 'vhosts' USE flag is switched ON" |
| 534 | elog "This means that Portage will not automatically run webapp-config to" |
503 | elog "This means that Portage will not automatically run webapp-config to" |
| … | |
… | |
| 573 | . "${x}"/.webapp |
542 | . "${x}"/.webapp |
| 574 | if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then |
543 | if [[ -n "${WEB_HOSTNAME}" && -n "${WEB_INSTALLDIR}" ]]; then |
| 575 | ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} |
544 | ${WEBAPP_CONFIG} -C -h ${WEB_HOSTNAME} -d ${WEB_INSTALLDIR} |
| 576 | fi |
545 | fi |
| 577 | else |
546 | else |
| 578 | ewarn "[webapp] Cannot find file ${x}/.webapp" |
547 | ewarn "Cannot find file ${x}/.webapp" |
| 579 | fi |
548 | fi |
| 580 | done |
549 | done |
| 581 | elif [[ -n ${my_output} ]]; then |
550 | elif [[ "${my_output}" != "" ]]; then |
| 582 | echo |
551 | echo |
| 583 | ewarn |
552 | ewarn |
| 584 | ewarn "Don't forget to use webapp-config to remove any copies of" |
553 | ewarn "Don't forget to use webapp-config to remove any copies of" |
| 585 | ewarn "${PN}-${PVR} installed in" |
554 | ewarn "${PN}-${PVR} installed in" |
| 586 | ewarn |
555 | ewarn |
| 587 | |
556 | |
| 588 | echo "${my_output}" | while read x; do |
557 | echo "${my_output}" | while read x; do |
| 589 | if [[ -f "${x}"/.webapp ]]; then |
558 | if [[ -f "${x}"/.webapp ]]; then |
| 590 | ewarn "[webapp] ${x}" |
559 | ewarn " ${x}" |
| 591 | else |
560 | else |
| 592 | ewarn "[webapp] Cannot find file ${x}/.webapp" |
561 | ewarn "Cannot find file ${x}/.webapp" |
| 593 | fi |
562 | fi |
| 594 | done |
563 | done |
| 595 | |
564 | |
| 596 | ewarn |
565 | ewarn |
| 597 | echo |
566 | echo |