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

Diff of /eclass/subversion.eclass

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

Revision 1.77 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.77 2012/06/10 10:08:36 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}"
229 if [[ ! -d ${ESVN_STORE_DIR} ]]; then 213 if [[ ! -d ${ESVN_STORE_DIR} ]]; then
230 debug-print "${FUNCNAME}: initial checkout. creating subversion directory" 214 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
231 mkdir -m 775 -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." 215 mkdir -m 775 -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
232 fi 216 fi
233 217
234 pushd "${ESVN_STORE_DIR}" > /dev/null || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" 218 pushd "${ESVN_STORE_DIR}" >/dev/null || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
235 219
236 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 220 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
237 local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion" 221 local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
238 222
239 [[ -n "${revision}" ]] && options="${options} -r ${revision}" 223 [[ -n "${revision}" ]] && options="${options} -r ${revision}"
359 #* "svn export" has a bug. see http://bugs.gentoo.org/119236 343 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
360 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 344 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
361 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 345 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
362 fi 346 fi
363 347
364 popd > /dev/null 348 popd >/dev/null
365 echo 349 echo
366} 350}
367 351
368# @FUNCTION: subversion_bootstrap 352# @FUNCTION: subversion_bootstrap
369# @DESCRIPTION: 353# @DESCRIPTION:
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."
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} 434}
425 435
426# @FUNCTION: subversion_wc_info 436# @FUNCTION: subversion_pkg_preinst
427# @USAGE: [repo_uri] 437# @USAGE: [repo_uri]
428# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
429# @DESCRIPTION: 438# @DESCRIPTION:
430# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. 439# Log the svn revision of source code. Doing this in pkg_preinst because we
431# 440# want the logs to stick around if packages are uninstalled without messing with
432# The working copy information on the specified repository URI are set to 441# config protection.
433# ESVN_WC_* variables. 442subversion_pkg_preinst() {
443 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
434subversion_wc_info() { 444 subversion_wc_info "${1}"
435 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" 445 if [[ -n ${ESCM_LOGDIR} ]]; then
436 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 446 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
437
438 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
439 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
440
441 if [[ ! -d ${wc_path} ]]; then 447 if [[ ! -d ${dir} ]]; then
442 return 1 448 mkdir -p "${dir}" || eerror "Failed to create '${dir}' for logging svn revision"
443 fi 449 fi
444 450 local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
445 export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")" 451 if [[ -d ${dir} ]]; then
446 export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")" 452 echo "${logmessage}" >>"${dir}/${PN}.log"
447 export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")" 453 else
448 export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")" 454 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
449 export ESVN_WC_PATH="${wc_path}" 455 fi
456 fi
450} 457}
451 458
452## -- Private Functions 459## -- Private Functions
453 460
454## -- subversion__svn_info() ------------------------------------------------- # 461## -- subversion__svn_info() ------------------------------------------------- #
511 debug-print "${FUNCNAME}: repo_uri does not have a peg revision." 518 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
512 fi 519 fi
513 520
514 echo "${peg_rev}" 521 echo "${peg_rev}"
515} 522}
516
517# @FUNCTION: subversion_pkg_preinst
518# @USAGE: [repo_uri]
519# @DESCRIPTION:
520# Log the svn revision of source code. Doing this in pkg_preinst because we
521# want the logs to stick around if packages are uninstalled without messing with
522# config protection.
523subversion_pkg_preinst() {
524 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
525 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
526 if [[ -n ${ESCM_LOGDIR} ]]; then
527 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
528 if [[ ! -d ${dir} ]]; then
529 mkdir -p "${dir}" || \
530 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"
531 fi
532 local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
533 if [[ -d ${dir} ]]; then
534 echo "${logmessage}" >> "${dir}/${PN}.log"
535 else
536 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
537 fi
538 fi
539}

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

  ViewVC Help
Powered by ViewVC 1.1.20