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

Diff of /eclass/subversion.eclass

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

Revision 1.78 Revision 1.79
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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/subversion.eclass,v 1.78 2012/06/10 11:05:46 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.79 2012/06/10 11:31:12 hattya Exp $
4 4
5# @ECLASS: subversion.eclass 5# @ECLASS: subversion.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Akinori Hattori <hattya@gentoo.org> 7# Akinori Hattori <hattya@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
404 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 404 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
405 fi 405 fi
406 fi 406 fi
407} 407}
408 408
409# @FUNCTION: subversion_wc_info
410# @USAGE: [repo_uri]
411# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
412# @DESCRIPTION:
413# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
414#
415# The working copy information on the specified repository URI are set to
416# ESVN_WC_* variables.
417subversion_wc_info() {
418 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
419 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
420
421 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
422 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
423
424 if [[ ! -d ${wc_path} ]]; then
425 return 1
426 fi
427
428 export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
429 export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
430 export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
431 export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
432 export ESVN_WC_PATH="${wc_path}"
433}
434
409# @FUNCTION: subversion_src_unpack 435# @FUNCTION: subversion_src_unpack
410# @DESCRIPTION: 436# @DESCRIPTION:
411# Default src_unpack. Fetch and, in older EAPIs, bootstrap. 437# Default src_unpack. Fetch and, in older EAPIs, bootstrap.
412subversion_src_unpack() { 438subversion_src_unpack() {
413 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." 439 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
419# @FUNCTION: subversion_src_prepare 445# @FUNCTION: subversion_src_prepare
420# @DESCRIPTION: 446# @DESCRIPTION:
421# Default src_prepare. Bootstrap. 447# Default src_prepare. Bootstrap.
422subversion_src_prepare() { 448subversion_src_prepare() {
423 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." 449 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
424}
425
426# @FUNCTION: subversion_wc_info
427# @USAGE: [repo_uri]
428# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
429# @DESCRIPTION:
430# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
431#
432# The working copy information on the specified repository URI are set to
433# ESVN_WC_* variables.
434subversion_wc_info() {
435 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
436 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
437
438 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
439 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
440
441 if [[ ! -d ${wc_path} ]]; then
442 return 1
443 fi
444
445 export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
446 export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
447 export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
448 export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
449 export ESVN_WC_PATH="${wc_path}"
450}
451
452## -- Private Functions
453
454## -- subversion__svn_info() ------------------------------------------------- #
455#
456# param $1 - a target.
457# param $2 - a key name.
458#
459subversion__svn_info() {
460 local target="${1}"
461 local key="${2}"
462
463 env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
464 | grep -i "^${key}" \
465 | cut -d" " -f2-
466}
467
468## -- subversion__get_repository_uri() --------------------------------------- #
469#
470# param $1 - a repository URI.
471subversion__get_repository_uri() {
472 local repo_uri="${1}"
473
474 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
475 if [[ -z ${repo_uri} ]]; then
476 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
477 fi
478 # delete trailing slash
479 if [[ -z ${repo_uri##*/} ]]; then
480 repo_uri="${repo_uri%/}"
481 fi
482 repo_uri="${repo_uri%@*}"
483
484 echo "${repo_uri}"
485}
486
487## -- subversion__get_wc_path() ---------------------------------------------- #
488#
489# param $1 - a repository URI.
490subversion__get_wc_path() {
491 local repo_uri="$(subversion__get_repository_uri "${1}")"
492
493 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
494
495 echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
496}
497
498## -- subversion__get_peg_revision() ----------------------------------------- #
499#
500# param $1 - a repository URI.
501subversion__get_peg_revision() {
502 local repo_uri="${1}"
503 local peg_rev=
504
505 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
506 # repo_uri has peg revision?
507 if [[ ${repo_uri} = *@* ]]; then
508 peg_rev="${repo_uri##*@}"
509 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
510 else
511 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
512 fi
513
514 echo "${peg_rev}"
515} 450}
516 451
517# @FUNCTION: subversion_pkg_preinst 452# @FUNCTION: subversion_pkg_preinst
518# @USAGE: [repo_uri] 453# @USAGE: [repo_uri]
519# @DESCRIPTION: 454# @DESCRIPTION:
534 else 469 else
535 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'" 470 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
536 fi 471 fi
537 fi 472 fi
538} 473}
474
475## -- Private Functions
476
477## -- subversion__svn_info() ------------------------------------------------- #
478#
479# param $1 - a target.
480# param $2 - a key name.
481#
482subversion__svn_info() {
483 local target="${1}"
484 local key="${2}"
485
486 env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
487 | grep -i "^${key}" \
488 | cut -d" " -f2-
489}
490
491## -- subversion__get_repository_uri() --------------------------------------- #
492#
493# param $1 - a repository URI.
494subversion__get_repository_uri() {
495 local repo_uri="${1}"
496
497 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
498 if [[ -z ${repo_uri} ]]; then
499 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
500 fi
501 # delete trailing slash
502 if [[ -z ${repo_uri##*/} ]]; then
503 repo_uri="${repo_uri%/}"
504 fi
505 repo_uri="${repo_uri%@*}"
506
507 echo "${repo_uri}"
508}
509
510## -- subversion__get_wc_path() ---------------------------------------------- #
511#
512# param $1 - a repository URI.
513subversion__get_wc_path() {
514 local repo_uri="$(subversion__get_repository_uri "${1}")"
515
516 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
517
518 echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
519}
520
521## -- subversion__get_peg_revision() ----------------------------------------- #
522#
523# param $1 - a repository URI.
524subversion__get_peg_revision() {
525 local repo_uri="${1}"
526 local peg_rev=
527
528 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
529 # repo_uri has peg revision?
530 if [[ ${repo_uri} = *@* ]]; then
531 peg_rev="${repo_uri##*@}"
532 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
533 else
534 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
535 fi
536
537 echo "${peg_rev}"
538}

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20