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

Diff of /eclass/webapp.eclass

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

Revision 1.41 Revision 1.43
1# Copyright 1999-2006 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.41 2006/05/19 19:24:21 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.43 2006/07/10 00:52:34 rl03 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
130 webapp_checkfileexists "${m}" "${D}" 130 webapp_checkfileexists "${m}" "${D}"
131 131
132 local MY_FILE="$(webapp_strip_appdir "${m}")" 132 local MY_FILE="$(webapp_strip_appdir "${m}")"
133 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 133 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
134 134
135 einfo "(config) ${MY_FILE}" 135 elog "(config) ${MY_FILE}"
136 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST} 136 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST}
137 done 137 done
138} 138}
139 139
140# ------------------------------------------------------------------------ 140# ------------------------------------------------------------------------
148 148
149function webapp_hook_script () 149function webapp_hook_script ()
150{ 150{
151 webapp_checkfileexists "${1}" 151 webapp_checkfileexists "${1}"
152 152
153 einfo "(hook) ${1}" 153 elog "(hook) ${1}"
154 cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/" 154 cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/"
155 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" 155 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")"
156} 156}
157 157
158# ------------------------------------------------------------------------ 158# ------------------------------------------------------------------------
166 166
167function webapp_postinst_txt () 167function webapp_postinst_txt ()
168{ 168{
169 webapp_checkfileexists "${2}" 169 webapp_checkfileexists "${2}"
170 170
171 einfo "(info) ${2} (lang: ${1})" 171 elog "(info) ${2} (lang: ${1})"
172 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" 172 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt"
173} 173}
174 174
175# ------------------------------------------------------------------------ 175# ------------------------------------------------------------------------
176# EXPORTED FUNCTION - FOR USE IN EBUILDS 176# EXPORTED FUNCTION - FOR USE IN EBUILDS
183 183
184function webapp_postupgrade_txt () 184function webapp_postupgrade_txt ()
185{ 185{
186 webapp_checkfileexists "${2}" 186 webapp_checkfileexists "${2}"
187 187
188 einfo "(info) ${2} (lang: ${1})" 188 elog "(info) ${2} (lang: ${1})"
189 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" 189 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt"
190} 190}
191 191
192# ------------------------------------------------------------------------ 192# ------------------------------------------------------------------------
193# EXPORTED FUNCTION - FOR USE IN EBUILDS 193# EXPORTED FUNCTION - FOR USE IN EBUILDS
213 a=${a/${D}\/\///} 213 a=${a/${D}\/\///}
214 webapp_checkfileexists "${a}" "$D" 214 webapp_checkfileexists "${a}" "$D"
215 local MY_FILE="$(webapp_strip_appdir "${a}")" 215 local MY_FILE="$(webapp_strip_appdir "${a}")"
216 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 216 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
217 217
218 einfo "(server owned) ${MY_FILE}" 218 elog "(server owned) ${MY_FILE}"
219 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 219 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
220 done 220 done
221 done 221 done
222 else 222 else
223 for m in "$@" ; do 223 for m in "$@" ; do
224 webapp_checkfileexists "${m}" "$D" 224 webapp_checkfileexists "${m}" "$D"
225 local MY_FILE="$(webapp_strip_appdir "${m}")" 225 local MY_FILE="$(webapp_strip_appdir "${m}")"
226 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 226 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
227 227
228 einfo "(server owned) ${MY_FILE}" 228 elog "(server owned) ${MY_FILE}"
229 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 229 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
230 done 230 done
231 fi 231 fi
232} 232}
233 233
262 # warning: 262 # warning:
263 # 263 #
264 # do NOT change the naming convention used here without changing all 264 # do NOT change the naming convention used here without changing all
265 # the other scripts that also rely upon these names 265 # the other scripts that also rely upon these names
266 266
267 einfo "(${1}) config file '${my_file}'" 267 elog "(${1}) config file '${my_file}'"
268 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" 268 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}"
269} 269}
270 270
271# ------------------------------------------------------------------------ 271# ------------------------------------------------------------------------
272# EXPORTED FUNCTION - FOR USE IN EBUILDS 272# EXPORTED FUNCTION - FOR USE IN EBUILDS
299 # the other scripts that also rely upon these names 299 # the other scripts that also rely upon these names
300 300
301 # are we dealing with an 'upgrade'-type script? 301 # are we dealing with an 'upgrade'-type script?
302 if [ -n "${3}" ]; then 302 if [ -n "${3}" ]; then
303 # yes we are 303 # yes we are
304 einfo "(${1}) upgrade script from ${PN}-${PVR} to ${3}" 304 elog "(${1}) upgrade script from ${PN}-${PVR} to ${3}"
305 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" 305 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
306 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" 306 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
307 else 307 else
308 # no, we are not 308 # no, we are not
309 einfo "(${1}) create script for ${PN}-${PVR}" 309 elog "(${1}) create script for ${PN}-${PVR}"
310 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 310 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
311 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 311 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
312 fi 312 fi
313} 313}
314 314
376 if ! use vhosts ; then 376 if ! use vhosts ; then
377 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" 377 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
378 local my_output 378 local my_output
379 379
380 if [ -d "${my_dir}" ] ; then 380 if [ -d "${my_dir}" ] ; then
381 einfo "You already have something installed in ${my_dir}"
382 einfo "Are you trying to install over the top of something I cannot upgrade?"
383
384 my_output="$(webapp_check_installedat)" 381 my_output="$(webapp_check_installedat)"
385 382
386 if [ "$?" != "0" ]; then 383 if [ "$?" != "0" ]; then
387
388 # okay, whatever is there, it isn't webapp-config-compatible 384 # okay, whatever is there, it isn't webapp-config-compatible
385 ewarn "You already have something installed in ${my_dir}"
389 ewarn 386 ewarn
390 ewarn "Whatever is in ${my_dir}, it's not" 387 ewarn "Whatever is in ${my_dir}, it's not"
391 ewarn "compatible with webapp-config." 388 ewarn "compatible with webapp-config."
392 ewarn 389 ewarn
393 ewarn "This ebuild may be overwriting important files." 390 ewarn "This ebuild may be overwriting important files."
394 ewarn 391 ewarn
395 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then 392 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then
396 eerror "${my_dir} contains ${my_output}" 393 eerror "${my_dir} contains ${my_output}"
397 eerror "I cannot upgrade that" 394 eerror "I cannot upgrade that"
398 die "Cannot upgrade contents of ${my_dir}" 395 die "Cannot upgrade contents of ${my_dir}"
399 else
400 einfo
401 einfo "I can upgrade the contents of ${my_dir}"
402 einfo
403 fi 396 fi
404 fi 397 fi
405 fi 398 fi
406} 399}
407 400
426 419
427 REMOVE_PKG="${my_pn}-${my_pvr}" 420 REMOVE_PKG="${my_pn}-${my_pvr}"
428 421
429 if [ "${my_pn}" == "${PN}" ]; then 422 if [ "${my_pn}" == "${PN}" ]; then
430 if [ "${my_pvr}" != "${PVR}" ]; then 423 if [ "${my_pvr}" != "${PVR}" ]; then
431 einfo "This is an upgrade" 424 elog "This is an upgrade"
432 IS_UPGRADE=1 425 IS_UPGRADE=1
433 else 426 else
434 einfo "This is a re-installation" 427 elog "This is a re-installation"
435 IS_REPLACE=1 428 IS_REPLACE=1
436 fi 429 fi
437 else 430 else
438 einfo "${my_output} is installed there" 431 elog "${my_output} is installed there"
439 fi 432 fi
440 else 433 else
441 einfo "This is an installation" 434 elog "This is an installation"
442 fi 435 fi
443 fi 436 fi
444} 437}
445 438
446function webapp_src_preinst () 439function webapp_src_preinst ()
479 # if 'vhosts' is not set in your USE flags, we install a copy of 472 # if 'vhosts' is not set in your USE flags, we install a copy of
480 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you 473 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you
481 474
482 if ! use vhosts ; then 475 if ! use vhosts ; then
483 echo 476 echo
484 einfo "vhosts USE flag not set - auto-installing using webapp-config" 477 elog "vhosts USE flag not set - auto-installing using webapp-config"
485 478
486 webapp_getinstalltype 479 webapp_getinstalltype
487 480
488 G_HOSTNAME="localhost" 481 G_HOSTNAME="localhost"
489 local my_mode=-I 482 local my_mode=-I
490 webapp_read_config 483 webapp_read_config
491 484
492 if [ "${IS_REPLACE}" = "1" ]; then 485 if [ "${IS_REPLACE}" = "1" ]; then
493 einfo "${PN}-${PVR} is already installed - replacing" 486 elog "${PN}-${PVR} is already installed - replacing"
494 my_mode=-I 487 my_mode=-I
495 elif [ "${IS_UPGRADE}" = "1" ]; then 488 elif [ "${IS_UPGRADE}" = "1" ]; then
496 einfo "${REMOVE_PKG} is already installed - upgrading" 489 elog "${REMOVE_PKG} is already installed - upgrading"
497 my_mode=-U 490 my_mode=-U
498 else 491 else
499 einfo "${PN}-${PVR} is not installed - using install mode" 492 elog "${PN}-${PVR} is not installed - using install mode"
500 fi 493 fi
501 494
502 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" 495 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
503 einfo "Running ${my_cmd}" 496 elog "Running ${my_cmd}"
504 ${my_cmd} 497 ${my_cmd}
505 498
506 # remove the old version 499 # remove the old version
507 # 500 #
508 # why do we do this? well ... 501 # why do we do this? well ...
513 # 506 #
514 # if USE=-vhosts, then we want to remove the old version, because 507 # if USE=-vhosts, then we want to remove the old version, because
515 # the user is relying on portage to do the magical thing for it 508 # the user is relying on portage to do the magical thing for it
516 509
517 if [ "${IS_UPGRADE}" = "1" ] ; then 510 if [ "${IS_UPGRADE}" = "1" ] ; then
518 einfo "Removing old version ${REMOVE_PKG}" 511 elog "Removing old version ${REMOVE_PKG}"
519 512
520 emerge -C "${REMOVE_PKG}" 513 emerge -C "${REMOVE_PKG}"
521 fi 514 fi
522 else 515 else
523 # vhosts flag is on 516 # vhosts flag is on
524 # 517 #
525 # let's tell the administrator what to do next 518 # let's tell the administrator what to do next
526 519
527 einfo 520 elog
528 einfo "The 'vhosts' USE flag is switched ON" 521 elog "The 'vhosts' USE flag is switched ON"
529 einfo "This means that Portage will not automatically run webapp-config to" 522 elog "This means that Portage will not automatically run webapp-config to"
530 einfo "complete the installation." 523 elog "complete the installation."
531 einfo 524 elog
532 einfo "To install ${PN}-${PVR} into a virtual host, run the following command:" 525 elog "To install ${PN}-${PVR} into a virtual host, run the following command:"
533 einfo 526 elog
534 einfo " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" 527 elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
535 einfo 528 elog
536 einfo "For more details, see the webapp-config(8) man page" 529 elog "For more details, see the webapp-config(8) man page"
537 fi 530 fi
538 531
539 return 0 532 return 0
540} 533}
541 534

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20