/[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.83
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.83 2012/07/29 05:54:17 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:
17ESVN="${ECLASS}" 17ESVN="${ECLASS}"
18 18
19case "${EAPI:-0}" in 19case "${EAPI:-0}" in
20 0|1) 20 0|1)
21 EXPORT_FUNCTIONS src_unpack pkg_preinst 21 EXPORT_FUNCTIONS src_unpack pkg_preinst
22 DEPEND="dev-vcs/subversion"
22 ;; 23 ;;
23 *) 24 *)
24 EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst 25 EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst
26 DEPEND="|| ( dev-vcs/subversion[webdav-neon] dev-vcs/subversion[webdav-serf] )"
25 ;; 27 ;;
26esac 28esac
27 29
28DESCRIPTION="Based on the ${ECLASS} eclass" 30DEPEND+=" net-misc/rsync"
29
30SUBVERSION_DEPEND="dev-vcs/subversion
31 net-misc/rsync"
32
33if [[ -z "${ESVN_DISABLE_DEPENDENCIES}" ]]; then
34 DEPEND="${SUBVERSION_DEPEND}"
35fi
36 31
37# @ECLASS-VARIABLE: ESVN_STORE_DIR 32# @ECLASS-VARIABLE: ESVN_STORE_DIR
38# @DESCRIPTION: 33# @DESCRIPTION:
39# subversion sources store directory. Users may override this in /etc/make.conf 34# subversion sources store directory. Users may override this in /etc/make.conf
40[[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src" 35[[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
64# @DESCRIPTION: 59# @DESCRIPTION:
65# repository uri 60# repository uri
66# 61#
67# e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234 62# e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234
68# 63#
69# supported protocols: 64# supported URI schemes:
70# http:// 65# http://
71# https:// 66# https://
72# svn:// 67# svn://
73# svn+ssh:// 68# svn+ssh://
69# file://
74# 70#
75# to peg to a specific revision, append @REV to the repo's uri 71# to peg to a specific revision, append @REV to the repo's uri
76ESVN_REPO_URI="${ESVN_REPO_URI:-}" 72ESVN_REPO_URI="${ESVN_REPO_URI:-}"
77 73
78# @ECLASS-VARIABLE: ESVN_REVISION 74# @ECLASS-VARIABLE: ESVN_REVISION
138# this should be a space delimited list of subversion eclass features to 134# this should be a space delimited list of subversion eclass features to
139# restrict. 135# restrict.
140# export) 136# export)
141# don't export the working copy to S. 137# don't export the working copy to S.
142ESVN_RESTRICT="${ESVN_RESTRICT:-}" 138ESVN_RESTRICT="${ESVN_RESTRICT:-}"
143
144# @ECLASS-VARIABLE: ESVN_DISABLE_DEPENDENCIES
145# @DESCRIPTION:
146# Set this variable to a non-empty value to disable the automatic inclusion of
147# Subversion in dependencies.
148ESVN_DISABLE_DEPENDENCIES="${ESVN_DISABLE_DEPENDENCIES:-}"
149 139
150# @ECLASS-VARIABLE: ESVN_OFFLINE 140# @ECLASS-VARIABLE: ESVN_OFFLINE
151# @DESCRIPTION: 141# @DESCRIPTION:
152# Set this variable to a non-empty value to disable the automatic updating of 142# Set this variable to a non-empty value to disable the automatic updating of
153# an svn source tree. This is intended to be set outside the subversion source 143# an svn source tree. This is intended to be set outside the subversion source
197 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." 187 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
198 fi 188 fi
199 189
200 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}" 190 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
201 191
202 # check for the protocol 192 # check for the scheme
203 local protocol="${repo_uri%%:*}" 193 local scheme="${repo_uri%%:*}"
204 case "${protocol}" in 194 case "${scheme}" in
205 http|https) 195 http|https)
206 if ! built_with_use -o dev-vcs/subversion webdav-neon webdav-serf; then
207 echo
208 eerror "In order to emerge this package, you need to"
209 eerror "reinstall Subversion with support for WebDAV."
210 eerror "Subversion requires either Neon or Serf to support WebDAV."
211 echo
212 die "${ESVN}: reinstall Subversion with support for WebDAV."
213 fi
214 ;; 196 ;;
215 svn|svn+ssh) 197 svn|svn+ssh)
216 ;; 198 ;;
199 file)
200 ;;
217 *) 201 *)
218 die "${ESVN}: fetch from '${protocol}' is not yet implemented." 202 die "${ESVN}: fetch from '${scheme}' is not yet implemented."
219 ;; 203 ;;
220 esac 204 esac
221 205
222 addread "/etc/subversion" 206 addread "/etc/subversion"
223 addwrite "${ESVN_STORE_DIR}" 207 addwrite "${ESVN_STORE_DIR}"
404 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 388 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
405 fi 389 fi
406 fi 390 fi
407} 391}
408 392
393# @FUNCTION: subversion_wc_info
394# @USAGE: [repo_uri]
395# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
396# @DESCRIPTION:
397# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
398#
399# The working copy information on the specified repository URI are set to
400# ESVN_WC_* variables.
401subversion_wc_info() {
402 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
403 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
404
405 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
406 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
407
408 if [[ ! -d ${wc_path} ]]; then
409 return 1
410 fi
411
412 export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
413 export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
414 export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
415 export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
416 export ESVN_WC_PATH="${wc_path}"
417}
418
409# @FUNCTION: subversion_src_unpack 419# @FUNCTION: subversion_src_unpack
410# @DESCRIPTION: 420# @DESCRIPTION:
411# Default src_unpack. Fetch and, in older EAPIs, bootstrap. 421# Default src_unpack. Fetch and, in older EAPIs, bootstrap.
412subversion_src_unpack() { 422subversion_src_unpack() {
413 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." 423 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
419# @FUNCTION: subversion_src_prepare 429# @FUNCTION: subversion_src_prepare
420# @DESCRIPTION: 430# @DESCRIPTION:
421# Default src_prepare. Bootstrap. 431# Default src_prepare. Bootstrap.
422subversion_src_prepare() { 432subversion_src_prepare() {
423 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." 433 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} 434}
516 435
517# @FUNCTION: subversion_pkg_preinst 436# @FUNCTION: subversion_pkg_preinst
518# @USAGE: [repo_uri] 437# @USAGE: [repo_uri]
519# @DESCRIPTION: 438# @DESCRIPTION:
534 else 453 else
535 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'" 454 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
536 fi 455 fi
537 fi 456 fi
538} 457}
458
459## -- Private Functions
460
461## -- subversion__svn_info() ------------------------------------------------- #
462#
463# param $1 - a target.
464# param $2 - a key name.
465#
466subversion__svn_info() {
467 local target="${1}"
468 local key="${2}"
469
470 env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
471 | grep -i "^${key}" \
472 | cut -d" " -f2-
473}
474
475## -- subversion__get_repository_uri() --------------------------------------- #
476#
477# param $1 - a repository URI.
478subversion__get_repository_uri() {
479 local repo_uri="${1}"
480
481 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
482 if [[ -z ${repo_uri} ]]; then
483 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
484 fi
485 # delete trailing slash
486 if [[ -z ${repo_uri##*/} ]]; then
487 repo_uri="${repo_uri%/}"
488 fi
489 repo_uri="${repo_uri%@*}"
490
491 echo "${repo_uri}"
492}
493
494## -- subversion__get_wc_path() ---------------------------------------------- #
495#
496# param $1 - a repository URI.
497subversion__get_wc_path() {
498 local repo_uri="$(subversion__get_repository_uri "${1}")"
499
500 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
501
502 echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
503}
504
505## -- subversion__get_peg_revision() ----------------------------------------- #
506#
507# param $1 - a repository URI.
508subversion__get_peg_revision() {
509 local repo_uri="${1}"
510 local peg_rev=
511
512 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
513 # repo_uri has peg revision?
514 if [[ ${repo_uri} = *@* ]]; then
515 peg_rev="${repo_uri##*@}"
516 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
517 else
518 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
519 fi
520
521 echo "${peg_rev}"
522}

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

  ViewVC Help
Powered by ViewVC 1.1.20