/[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.44
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.44 2006/07/11 02:36:23 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
350 350
351function webapp_pkg_setup () 351function webapp_pkg_setup ()
352{ 352{
353 # add sanity checks here 353 # add sanity checks here
354 354
355 if [ "${SLOT}+" != "${PVR}+" ]; then
356 # special case - some ebuilds *do* need to overwride the SLOT 355 # special case - some ebuilds *do* need to overwride the SLOT
357 if [ "${WEBAPP_MANUAL_SLOT}" != "yes" ]; then 356 if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then
358 die "ebuild sets SLOT, overrides webapp.eclass" 357 die "Set WEBAPP_MANUAL_SLOT=\"yes\" if you need to SLOT manually"
359 else
360 ewarn
361 ewarn "This ebuild overrides the default SLOT behaviour for webapps"
362 ewarn "If this package installs files into the htdocs dir, this is"
363 ewarn "probably a bug in the ebuild."
364 ewarn
365 fi
366 fi 358 fi
367 359
368 # pull in the shared configuration file 360 # pull in the shared configuration file
369 361
370 G_HOSTNAME="localhost" 362 G_HOSTNAME="localhost"
376 if ! use vhosts ; then 368 if ! use vhosts ; then
377 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}" 369 local my_dir="${ROOT}${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}"
378 local my_output 370 local my_output
379 371
380 if [ -d "${my_dir}" ] ; then 372 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)" 373 my_output="$(webapp_check_installedat)"
385 374
386 if [ "$?" != "0" ]; then 375 if [ "$?" != "0" ]; then
387
388 # okay, whatever is there, it isn't webapp-config-compatible 376 # okay, whatever is there, it isn't webapp-config-compatible
377 ewarn "You already have something installed in ${my_dir}"
389 ewarn 378 ewarn
390 ewarn "Whatever is in ${my_dir}, it's not" 379 ewarn "Whatever is in ${my_dir}, it's not"
391 ewarn "compatible with webapp-config." 380 ewarn "compatible with webapp-config."
392 ewarn 381 ewarn
393 ewarn "This ebuild may be overwriting important files." 382 ewarn "This ebuild may be overwriting important files."
394 ewarn 383 ewarn
395 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then 384 elif [ "$(echo ${my_output} | awk '{ print $1 }')" != "${PN}" ]; then
396 eerror "${my_dir} contains ${my_output}" 385 eerror "${my_dir} contains ${my_output}"
397 eerror "I cannot upgrade that" 386 eerror "I cannot upgrade that"
398 die "Cannot upgrade contents of ${my_dir}" 387 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 388 fi
404 fi 389 fi
405 fi 390 fi
406} 391}
407 392
426 411
427 REMOVE_PKG="${my_pn}-${my_pvr}" 412 REMOVE_PKG="${my_pn}-${my_pvr}"
428 413
429 if [ "${my_pn}" == "${PN}" ]; then 414 if [ "${my_pn}" == "${PN}" ]; then
430 if [ "${my_pvr}" != "${PVR}" ]; then 415 if [ "${my_pvr}" != "${PVR}" ]; then
431 einfo "This is an upgrade" 416 elog "This is an upgrade"
432 IS_UPGRADE=1 417 IS_UPGRADE=1
433 else 418 else
434 einfo "This is a re-installation" 419 elog "This is a re-installation"
435 IS_REPLACE=1 420 IS_REPLACE=1
436 fi 421 fi
437 else 422 else
438 einfo "${my_output} is installed there" 423 elog "${my_output} is installed there"
439 fi 424 fi
440 else 425 else
441 einfo "This is an installation" 426 elog "This is an installation"
442 fi 427 fi
443 fi 428 fi
444} 429}
445 430
446function webapp_src_preinst () 431function webapp_src_preinst ()
479 # if 'vhosts' is not set in your USE flags, we install a copy of 464 # 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 465 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you
481 466
482 if ! use vhosts ; then 467 if ! use vhosts ; then
483 echo 468 echo
484 einfo "vhosts USE flag not set - auto-installing using webapp-config" 469 elog "vhosts USE flag not set - auto-installing using webapp-config"
485 470
486 webapp_getinstalltype 471 webapp_getinstalltype
487 472
488 G_HOSTNAME="localhost" 473 G_HOSTNAME="localhost"
489 local my_mode=-I 474 local my_mode=-I
490 webapp_read_config 475 webapp_read_config
491 476
492 if [ "${IS_REPLACE}" = "1" ]; then 477 if [ "${IS_REPLACE}" = "1" ]; then
493 einfo "${PN}-${PVR} is already installed - replacing" 478 elog "${PN}-${PVR} is already installed - replacing"
494 my_mode=-I 479 my_mode=-I
495 elif [ "${IS_UPGRADE}" = "1" ]; then 480 elif [ "${IS_UPGRADE}" = "1" ]; then
496 einfo "${REMOVE_PKG} is already installed - upgrading" 481 elog "${REMOVE_PKG} is already installed - upgrading"
497 my_mode=-U 482 my_mode=-U
498 else 483 else
499 einfo "${PN}-${PVR} is not installed - using install mode" 484 elog "${PN}-${PVR} is not installed - using install mode"
500 fi 485 fi
501 486
502 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" 487 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
503 einfo "Running ${my_cmd}" 488 elog "Running ${my_cmd}"
504 ${my_cmd} 489 ${my_cmd}
505 490
506 # remove the old version 491 # remove the old version
507 # 492 #
508 # why do we do this? well ... 493 # why do we do this? well ...
513 # 498 #
514 # if USE=-vhosts, then we want to remove the old version, because 499 # 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 500 # the user is relying on portage to do the magical thing for it
516 501
517 if [ "${IS_UPGRADE}" = "1" ] ; then 502 if [ "${IS_UPGRADE}" = "1" ] ; then
518 einfo "Removing old version ${REMOVE_PKG}" 503 elog "Removing old version ${REMOVE_PKG}"
519 504
520 emerge -C "${REMOVE_PKG}" 505 emerge -C "${REMOVE_PKG}"
521 fi 506 fi
522 else 507 else
523 # vhosts flag is on 508 # vhosts flag is on
524 # 509 #
525 # let's tell the administrator what to do next 510 # let's tell the administrator what to do next
526 511
527 einfo 512 elog
528 einfo "The 'vhosts' USE flag is switched ON" 513 elog "The 'vhosts' USE flag is switched ON"
529 einfo "This means that Portage will not automatically run webapp-config to" 514 elog "This means that Portage will not automatically run webapp-config to"
530 einfo "complete the installation." 515 elog "complete the installation."
531 einfo 516 elog
532 einfo "To install ${PN}-${PVR} into a virtual host, run the following command:" 517 elog "To install ${PN}-${PVR} into a virtual host, run the following command:"
533 einfo 518 elog
534 einfo " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" 519 elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
535 einfo 520 elog
536 einfo "For more details, see the webapp-config(8) man page" 521 elog "For more details, see the webapp-config(8) man page"
537 fi 522 fi
538 523
539 return 0 524 return 0
540} 525}
541 526

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

  ViewVC Help
Powered by ViewVC 1.1.20