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

Diff of /eclass/webapp.eclass

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

Revision 1.42 Revision 1.47
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.42 2006/06/15 07:01:01 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/webapp.eclass,v 1.47 2006/12/31 19:16:31 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
9# 9#
10# Author(s) Stuart Herbert <stuart@gentoo.org> 10# Author(s) Stuart Herbert
11# Renat Lumpau <rl03@gentoo.org> 11# Renat Lumpau <rl03@gentoo.org>
12# Gunnar Wrobel <wrobel@gentoo.org> 12# Gunnar Wrobel <wrobel@gentoo.org>
13# 13#
14# ------------------------------------------------------------------------ 14# ------------------------------------------------------------------------
15# 15#
22# 22#
23# ------------------------------------------------------------------------ 23# ------------------------------------------------------------------------
24 24
25SLOT="${PVR}" 25SLOT="${PVR}"
26IUSE="vhosts" 26IUSE="vhosts"
27DEPEND="app-admin/webapp-config" 27DEPEND=">=app-admin/webapp-config-1.50.15"
28RDEPEND="${DEPEND}" 28RDEPEND="${DEPEND}"
29 29
30EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm 30EXPORT_FUNCTIONS pkg_postinst pkg_setup src_install pkg_prerm
31 31
32INSTALL_DIR="/${PN}" 32INSTALL_DIR="/${PN}"
35 35
36INSTALL_CHECK_FILE="installed_by_webapp_eclass" 36INSTALL_CHECK_FILE="installed_by_webapp_eclass"
37 37
38ETC_CONFIG="${ROOT}/etc/vhosts/webapp-config" 38ETC_CONFIG="${ROOT}/etc/vhosts/webapp-config"
39WEBAPP_CONFIG="${ROOT}/usr/sbin/webapp-config" 39WEBAPP_CONFIG="${ROOT}/usr/sbin/webapp-config"
40WEBAPP_CLEANER="${ROOT}/usr/sbin/webapp-cleaner"
40 41
41# ------------------------------------------------------------------------ 42# ------------------------------------------------------------------------
42# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY 43# INTERNAL FUNCTION - USED BY THIS ECLASS ONLY
43# 44#
44# Load the config file /etc/vhosts/webapp-config 45# Load the config file /etc/vhosts/webapp-config
130 webapp_checkfileexists "${m}" "${D}" 131 webapp_checkfileexists "${m}" "${D}"
131 132
132 local MY_FILE="$(webapp_strip_appdir "${m}")" 133 local MY_FILE="$(webapp_strip_appdir "${m}")"
133 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 134 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
134 135
135 einfo "(config) ${MY_FILE}" 136 elog "(config) ${MY_FILE}"
136 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST} 137 echo "${MY_FILE}" >> ${D}/${WA_CONFIGLIST}
137 done 138 done
138} 139}
139 140
140# ------------------------------------------------------------------------ 141# ------------------------------------------------------------------------
148 149
149function webapp_hook_script () 150function webapp_hook_script ()
150{ 151{
151 webapp_checkfileexists "${1}" 152 webapp_checkfileexists "${1}"
152 153
153 einfo "(hook) ${1}" 154 elog "(hook) ${1}"
154 cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/" 155 cp "${1}" "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" || die "Unable to install ${1} into ${D}/${MY_HOOKSCRIPTSDIR}/"
155 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")" 156 chmod 555 "${D}/${MY_HOOKSCRIPTSDIR}/$(basename "${1}")"
156} 157}
157 158
158# ------------------------------------------------------------------------ 159# ------------------------------------------------------------------------
166 167
167function webapp_postinst_txt () 168function webapp_postinst_txt ()
168{ 169{
169 webapp_checkfileexists "${2}" 170 webapp_checkfileexists "${2}"
170 171
171 einfo "(info) ${2} (lang: ${1})" 172 elog "(info) ${2} (lang: ${1})"
172 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt" 173 cp "${2}" "${D}/${MY_APPDIR}/postinst-${1}.txt"
173} 174}
174 175
175# ------------------------------------------------------------------------ 176# ------------------------------------------------------------------------
176# EXPORTED FUNCTION - FOR USE IN EBUILDS 177# EXPORTED FUNCTION - FOR USE IN EBUILDS
183 184
184function webapp_postupgrade_txt () 185function webapp_postupgrade_txt ()
185{ 186{
186 webapp_checkfileexists "${2}" 187 webapp_checkfileexists "${2}"
187 188
188 einfo "(info) ${2} (lang: ${1})" 189 elog "(info) ${2} (lang: ${1})"
189 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt" 190 cp "${2}" "${D}/${MY_APPDIR}/postupgrade-${1}.txt"
190} 191}
191 192
192# ------------------------------------------------------------------------ 193# ------------------------------------------------------------------------
193# EXPORTED FUNCTION - FOR USE IN EBUILDS 194# EXPORTED FUNCTION - FOR USE IN EBUILDS
213 a=${a/${D}\/\///} 214 a=${a/${D}\/\///}
214 webapp_checkfileexists "${a}" "$D" 215 webapp_checkfileexists "${a}" "$D"
215 local MY_FILE="$(webapp_strip_appdir "${a}")" 216 local MY_FILE="$(webapp_strip_appdir "${a}")"
216 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 217 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
217 218
218 einfo "(server owned) ${MY_FILE}" 219 elog "(server owned) ${MY_FILE}"
219 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 220 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
220 done 221 done
221 done 222 done
222 else 223 else
223 for m in "$@" ; do 224 for m in "$@" ; do
224 webapp_checkfileexists "${m}" "$D" 225 webapp_checkfileexists "${m}" "$D"
225 local MY_FILE="$(webapp_strip_appdir "${m}")" 226 local MY_FILE="$(webapp_strip_appdir "${m}")"
226 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")" 227 MY_FILE="$(webapp_strip_cwd "${MY_FILE}")"
227 228
228 einfo "(server owned) ${MY_FILE}" 229 elog "(server owned) ${MY_FILE}"
229 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}" 230 echo "${MY_FILE}" >> "${D}/${WA_SOLIST}"
230 done 231 done
231 fi 232 fi
232} 233}
233 234
262 # warning: 263 # warning:
263 # 264 #
264 # do NOT change the naming convention used here without changing all 265 # do NOT change the naming convention used here without changing all
265 # the other scripts that also rely upon these names 266 # the other scripts that also rely upon these names
266 267
267 einfo "(${1}) config file '${my_file}'" 268 elog "(${1}) config file '${my_file}'"
268 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}" 269 cp "${2}" "${D}/${MY_SERVERCONFIGDIR}/${my_file}"
269} 270}
270 271
271# ------------------------------------------------------------------------ 272# ------------------------------------------------------------------------
272# EXPORTED FUNCTION - FOR USE IN EBUILDS 273# EXPORTED FUNCTION - FOR USE IN EBUILDS
299 # the other scripts that also rely upon these names 300 # the other scripts that also rely upon these names
300 301
301 # are we dealing with an 'upgrade'-type script? 302 # are we dealing with an 'upgrade'-type script?
302 if [ -n "${3}" ]; then 303 if [ -n "${3}" ]; then
303 # yes we are 304 # yes we are
304 einfo "(${1}) upgrade script from ${PN}-${PVR} to ${3}" 305 elog "(${1}) upgrade script from ${PN}-${PVR} to ${3}"
305 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" 306 cp "${2}" "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
306 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql" 307 chmod 600 "${D}${MY_SQLSCRIPTSDIR}/${1}/${3}_to_${PVR}.sql"
307 else 308 else
308 # no, we are not 309 # no, we are not
309 einfo "(${1}) create script for ${PN}-${PVR}" 310 elog "(${1}) create script for ${PN}-${PVR}"
310 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 311 cp "${2}" "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
311 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql" 312 chmod 600 "${D}/${MY_SQLSCRIPTSDIR}/${1}/${PVR}_create.sql"
312 fi 313 fi
313} 314}
314 315
350 351
351function webapp_pkg_setup () 352function webapp_pkg_setup ()
352{ 353{
353 # add sanity checks here 354 # add sanity checks here
354 355
355 if [ "${SLOT}+" != "${PVR}+" ]; then
356 # special case - some ebuilds *do* need to overwride the SLOT 356 # special case - some ebuilds *do* need to overwride the SLOT
357 if [ "${WEBAPP_MANUAL_SLOT}" != "yes" ]; then 357 if [[ "${SLOT}+" != "${PVR}+" && "${WEBAPP_MANUAL_SLOT}" != "yes" ]]; then
358 die "ebuild sets SLOT, overrides webapp.eclass" 358 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 359 fi
367 360
368 # pull in the shared configuration file 361 # pull in the shared configuration file
369 362
370 G_HOSTNAME="localhost" 363 G_HOSTNAME="localhost"
380 if [ -d "${my_dir}" ] ; then 373 if [ -d "${my_dir}" ] ; then
381 my_output="$(webapp_check_installedat)" 374 my_output="$(webapp_check_installedat)"
382 375
383 if [ "$?" != "0" ]; then 376 if [ "$?" != "0" ]; then
384 # okay, whatever is there, it isn't webapp-config-compatible 377 # okay, whatever is there, it isn't webapp-config-compatible
385 ewarn "You already have something installed in ${my_dir}" 378 ewarn "You already have something installed in ${my_dir}"
386 ewarn 379 ewarn
387 ewarn "Whatever is in ${my_dir}, it's not" 380 ewarn "Whatever is in ${my_dir}, it's not"
388 ewarn "compatible with webapp-config." 381 ewarn "compatible with webapp-config."
389 ewarn 382 ewarn
390 ewarn "This ebuild may be overwriting important files." 383 ewarn "This ebuild may be overwriting important files."
419 412
420 REMOVE_PKG="${my_pn}-${my_pvr}" 413 REMOVE_PKG="${my_pn}-${my_pvr}"
421 414
422 if [ "${my_pn}" == "${PN}" ]; then 415 if [ "${my_pn}" == "${PN}" ]; then
423 if [ "${my_pvr}" != "${PVR}" ]; then 416 if [ "${my_pvr}" != "${PVR}" ]; then
424 einfo "This is an upgrade" 417 elog "This is an upgrade"
425 IS_UPGRADE=1 418 IS_UPGRADE=1
426 else 419 else
427 einfo "This is a re-installation" 420 elog "This is a re-installation"
428 IS_REPLACE=1 421 IS_REPLACE=1
429 fi 422 fi
430 else 423 else
431 einfo "${my_output} is installed there" 424 elog "${my_output} is installed there"
432 fi 425 fi
433 else 426 else
434 einfo "This is an installation" 427 elog "This is an installation"
435 fi 428 fi
436 fi 429 fi
437} 430}
438 431
439function webapp_src_preinst () 432function webapp_src_preinst ()
472 # if 'vhosts' is not set in your USE flags, we install a copy of 465 # if 'vhosts' is not set in your USE flags, we install a copy of
473 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you 466 # this application in ${ROOT}/var/www/localhost/htdocs/${PN}/ for you
474 467
475 if ! use vhosts ; then 468 if ! use vhosts ; then
476 echo 469 echo
477 einfo "vhosts USE flag not set - auto-installing using webapp-config" 470 elog "vhosts USE flag not set - auto-installing using webapp-config"
478 471
479 webapp_getinstalltype 472 webapp_getinstalltype
480 473
481 G_HOSTNAME="localhost" 474 G_HOSTNAME="localhost"
482 local my_mode=-I 475 local my_mode=-I
483 webapp_read_config 476 webapp_read_config
484 477
485 if [ "${IS_REPLACE}" = "1" ]; then 478 if [ "${IS_REPLACE}" = "1" ]; then
486 einfo "${PN}-${PVR} is already installed - replacing" 479 elog "${PN}-${PVR} is already installed - replacing"
487 my_mode=-I 480 my_mode=-I
488 elif [ "${IS_UPGRADE}" = "1" ]; then 481 elif [ "${IS_UPGRADE}" = "1" ]; then
489 einfo "${REMOVE_PKG} is already installed - upgrading" 482 elog "${REMOVE_PKG} is already installed - upgrading"
490 my_mode=-U 483 my_mode=-U
491 else 484 else
492 einfo "${PN}-${PVR} is not installed - using install mode" 485 elog "${PN}-${PVR} is not installed - using install mode"
493 fi 486 fi
494 487
495 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}" 488 my_cmd="${WEBAPP_CONFIG} ${my_mode} -h localhost -u root -d ${INSTALL_DIR} ${PN} ${PVR}"
496 einfo "Running ${my_cmd}" 489 elog "Running ${my_cmd}"
497 ${my_cmd} 490 ${my_cmd}
498 491
499 # remove the old version 492 # run webapp-cleaner instead of emerge
500 # 493 echo
501 # why do we do this? well ... 494 local cleaner="${WEBAPP_CLEANER} -p -C ${PN}"
502 # 495 einfo "Running ${cleaner}"
503 # normally, emerge -u installs a new version and then removes the 496 ${cleaner}
504 # old version. however, if the new version goes into a different
505 # slot to the old version, then the old version gets left behind
506 #
507 # if USE=-vhosts, then we want to remove the old version, because
508 # the user is relying on portage to do the magical thing for it
509
510 if [ "${IS_UPGRADE}" = "1" ] ; then
511 einfo "Removing old version ${REMOVE_PKG}"
512
513 emerge -C "${REMOVE_PKG}"
514 fi
515 else 497 else
516 # vhosts flag is on 498 # vhosts flag is on
517 # 499 #
518 # let's tell the administrator what to do next 500 # let's tell the administrator what to do next
519 501
520 einfo 502 elog
521 einfo "The 'vhosts' USE flag is switched ON" 503 elog "The 'vhosts' USE flag is switched ON"
522 einfo "This means that Portage will not automatically run webapp-config to" 504 elog "This means that Portage will not automatically run webapp-config to"
523 einfo "complete the installation." 505 elog "complete the installation."
524 einfo 506 elog
525 einfo "To install ${PN}-${PVR} into a virtual host, run the following command:" 507 elog "To install ${PN}-${PVR} into a virtual host, run the following command:"
526 einfo 508 elog
527 einfo " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}" 509 elog " webapp-config -I -h <host> -d ${PN} ${PN} ${PVR}"
528 einfo 510 elog
529 einfo "For more details, see the webapp-config(8) man page" 511 elog "For more details, see the webapp-config(8) man page"
530 fi 512 fi
531 513
532 return 0 514 return 0
533} 515}
534 516

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.20