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

Diff of /eclass/subversion.eclass

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

Revision 1.52 Revision 1.67
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2009 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.52 2008/02/20 22:35:40 zlin Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.67 2009/05/10 20:33:38 arfrever 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# Bo ├śrsted Andresen <zlin@gentoo.org> 8# Bo ├śrsted Andresen <zlin@gentoo.org>
9# Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
9# 10#
10# Original Author: Akinori Hattori <hattya@gentoo.org> 11# Original Author: Akinori Hattori <hattya@gentoo.org>
11# 12#
12# @BLURB: The subversion eclass is written to fetch software sources from subversion repositories 13# @BLURB: The subversion eclass is written to fetch software sources from subversion repositories
13# @DESCRIPTION: 14# @DESCRIPTION:
16 17
17inherit eutils 18inherit eutils
18 19
19ESVN="${ECLASS}" 20ESVN="${ECLASS}"
20 21
22case "${EAPI:-0}" in
23 0|1)
21EXPORT_FUNCTIONS src_unpack pkg_preinst 24 EXPORT_FUNCTIONS src_unpack pkg_preinst
25 ;;
26 *)
27 EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst
28 ;;
29esac
22 30
23DESCRIPTION="Based on the ${ECLASS} eclass" 31DESCRIPTION="Based on the ${ECLASS} eclass"
24 32
25DEPEND="dev-util/subversion 33SUBVERSION_DEPEND="dev-util/subversion
26 net-misc/rsync" 34 net-misc/rsync"
35
36if [[ -z "${ESVN_DISABLE_DEPENDENCIES}" ]]; then
37 DEPEND="${SUBVERSION_DEPEND}"
38fi
27 39
28# @ECLASS-VARIABLE: ESVN_STORE_DIR 40# @ECLASS-VARIABLE: ESVN_STORE_DIR
29# @DESCRIPTION: 41# @DESCRIPTION:
30# subversion sources store directory. Users may override this in /etc/make.conf 42# subversion sources store directory. Users may override this in /etc/make.conf
31[[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src" 43[[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
74# to a specific revision 86# to a specific revision
75# 87#
76# Note: This should never be set in an ebuild! 88# Note: This should never be set in an ebuild!
77ESVN_REVISION="${ESVN_REVISION:-}" 89ESVN_REVISION="${ESVN_REVISION:-}"
78 90
91# @ECLASS-VARIABLE: ESVN_USER
92# @DESCRIPTION:
93# User name
94ESVN_USER="${ESVN_USER:-}"
95
96# @ECLASS-VARIABLE: ESVN_PASSWORD
97# @DESCRIPTION:
98# Password
99ESVN_PASSWORD="${ESVN_PASSWORD:-}"
100
79# @ECLASS-VARIABLE: ESVN_PROJECT 101# @ECLASS-VARIABLE: ESVN_PROJECT
80# @DESCRIPTION: 102# @DESCRIPTION:
81# project name of your ebuild (= name space) 103# project name of your ebuild (= name space)
82# 104#
83# subversion eclass will check out the subversion repository like: 105# subversion eclass will check out the subversion repository like:
119# this should be a space delimited list of subversion eclass features to 141# this should be a space delimited list of subversion eclass features to
120# restrict. 142# restrict.
121# export) 143# export)
122# don't export the working copy to S. 144# don't export the working copy to S.
123ESVN_RESTRICT="${ESVN_RESTRICT:-}" 145ESVN_RESTRICT="${ESVN_RESTRICT:-}"
146
147# @ECLASS-VARIABLE: ESVN_DISABLE_DEPENDENCIES
148# @DESCRIPTION:
149# Set this variable to a non-empty value to disable the automatic inclusion of
150# Subversion in dependencies.
151ESVN_DISABLE_DEPENDENCIES="${ESVN_DISABLE_DEPENDENCIES:-}"
124 152
125# @ECLASS-VARIABLE: ESVN_OFFLINE 153# @ECLASS-VARIABLE: ESVN_OFFLINE
126# @DESCRIPTION: 154# @DESCRIPTION:
127# Set this variable to a non-empty value to disable the automatic updating of 155# Set this variable to a non-empty value to disable the automatic updating of
128# an svn source tree. This is intended to be set outside the subversion source 156# an svn source tree. This is intended to be set outside the subversion source
167 # check for the protocol 195 # check for the protocol
168 local protocol="${repo_uri%%:*}" 196 local protocol="${repo_uri%%:*}"
169 197
170 case "${protocol}" in 198 case "${protocol}" in
171 http|https) 199 http|https)
172 if built_with_use dev-util/subversion nowebdav; then 200 if ! built_with_use -o dev-util/subversion webdav-neon webdav-serf; then
173 echo 201 echo
174 eerror "In order to emerge this package, you need to" 202 eerror "In order to emerge this package, you need to"
175 eerror "re-emerge subversion with USE=-nowebdav" 203 eerror "reinstall Subversion with support for WebDAV."
204 eerror "Subversion requires either Neon or Serf to support WebDAV."
176 echo 205 echo
177 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" 206 die "${ESVN}: reinstall Subversion with support for WebDAV."
178 fi 207 fi
179 ;; 208 ;;
180 svn|svn+ssh) 209 svn|svn+ssh)
181 ;; 210 ;;
182 *) 211 *)
202 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then 231 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
203 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please" 232 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
204 ewarn "see \${ESVN_REPO_URI}" 233 ewarn "see \${ESVN_REPO_URI}"
205 fi 234 fi
206 235
236 if has_version ">=dev-util/subversion-1.6.0"; then
237 options="${options} --config-option=config:auth:password-stores="
238 fi
239
207 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" 240 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
208 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 241 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
209 debug-print "${FUNCNAME}: options = \"${options}\"" 242 debug-print "${FUNCNAME}: options = \"${options}\""
210 243
211 if [[ ! -d ${wc_path}/.svn ]]; then 244 if [[ ! -d ${wc_path}/.svn ]]; then
245 if [[ -n ${ESVN_OFFLINE} ]]; then
246 ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
247 fi
212 # first check out 248 # first check out
213 einfo "subversion check out start -->" 249 einfo "subversion check out start -->"
214 einfo " repository: ${repo_uri}${revision:+@}${revision}" 250 einfo " repository: ${repo_uri}${revision:+@}${revision}"
215 251
216 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" 252 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
217 253
218 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 254 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
219 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 255 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
256 if [[ -n "${ESVN_USER}" ]]; then
257 ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
258 else
220 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 259 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
260 fi
221 261
222 elif [[ -n ${ESVN_OFFLINE} ]]; then 262 elif [[ -n ${ESVN_OFFLINE} ]]; then
263 svn upgrade "${wc_path}" &>/dev/null
264 svn cleanup "${wc_path}" &>/dev/null
223 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 265 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
224 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then 266 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
225 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." 267 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
226 fi 268 fi
227 einfo "Fetching disabled: Using existing repository copy" 269 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
228 else 270 else
271 svn upgrade "${wc_path}" &>/dev/null
272 svn cleanup "${wc_path}" &>/dev/null
229 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 273 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
230 274
231 local esvn_up_freq= 275 local esvn_up_freq=
232 if [[ -n ${ESVN_UP_FREQ} ]]; then 276 if [[ -n ${ESVN_UP_FREQ} ]]; then
233 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then 277 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
234 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up." 278 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
235 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then 279 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
236 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours hasn't passed since last update." 280 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
281 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
237 esvn_up_freq=no_update 282 esvn_up_freq=no_update
238 fi 283 fi
239 fi 284 fi
240 285
241 if [[ -z ${esvn_up_freq} ]]; then 286 if [[ -z ${esvn_up_freq} ]]; then
242 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 287 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
243 einfo "suversion switch start -->" 288 einfo "subversion switch start -->"
244 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 289 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
245 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 290 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
246 291
247 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 292 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
248 293
249 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 294 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
295 if [[ -n "${ESVN_USER}" ]]; then
296 ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
297 else
250 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 298 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
299 fi
251 else 300 else
252 # update working copy 301 # update working copy
253 einfo "subversion update start -->" 302 einfo "subversion update start -->"
254 einfo " repository: ${repo_uri}${revision:+@}${revision}" 303 einfo " repository: ${repo_uri}${revision:+@}${revision}"
255 304
256 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 305 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
257 306
258 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 307 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
308 if [[ -n "${ESVN_USER}" ]]; then
309 ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
310 else
259 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 311 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
312 fi
260 fi 313 fi
261 fi 314 fi
262 fi 315 fi
263 316
264 einfo " working copy: ${wc_path}" 317 einfo " working copy: ${wc_path}"
265 318
266 if ! has "export" ${ESVN_RESTRICT}; then 319 if ! has "export" ${ESVN_RESTRICT}; then
267 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 320 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
268 321
269 local S="${S}/${S_dest}" 322 local S="${S}/${S_dest}"
323 mkdir -p "${S}"
270 324
271 # export to the ${WORKDIR} 325 # export to the ${WORKDIR}
272 #* "svn export" has a bug. see http://bugs.gentoo.org/119236 326 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
273 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 327 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
274 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 328 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
328 fi 382 fi
329} 383}
330 384
331# @FUNCTION: subversion_src_unpack 385# @FUNCTION: subversion_src_unpack
332# @DESCRIPTION: 386# @DESCRIPTION:
333# default src_unpack. fetch and bootstrap. 387# Default src_unpack. Fetch and, in older EAPIs, bootstrap.
334subversion_src_unpack() { 388subversion_src_unpack() {
335 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." 389 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
390 if has "${EAPI:-0}" 0 1; then
391 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
392 fi
393}
394
395# @FUNCTION: subversion_src_prepare
396# @DESCRIPTION:
397# Default src_prepare. Bootstrap.
398subversion_src_prepare() {
336 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." 399 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
337} 400}
338 401
339# @FUNCTION: subversion_wc_info 402# @FUNCTION: subversion_wc_info
340# @USAGE: [repo_uri] 403# @USAGE: [repo_uri]
343# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. 406# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
344# 407#
345# The working copy information on the specified repository URI are set to 408# The working copy information on the specified repository URI are set to
346# ESVN_WC_* variables. 409# ESVN_WC_* variables.
347subversion_wc_info() { 410subversion_wc_info() {
348 local repo_uri="$(subversion__get_repository_uri "${1}")" 411 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
349 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 412 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
350 413
351 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 414 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
352 debug-print "${FUNCNAME}: wc_path = ${wc_path}" 415 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
353 416
378 441
379## -- subversion__get_repository_uri() --------------------------------------- # 442## -- subversion__get_repository_uri() --------------------------------------- #
380# 443#
381# param $1 - a repository URI. 444# param $1 - a repository URI.
382subversion__get_repository_uri() { 445subversion__get_repository_uri() {
383 local repo_uri="${1}" 446 local repo_uri="${1}"
384 447
385 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 448 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
386 449
387 if [[ -z ${repo_uri} ]]; then 450 if [[ -z ${repo_uri} ]]; then
388 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." 451 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
429 492
430 echo "${peg_rev}" 493 echo "${peg_rev}"
431} 494}
432 495
433# @FUNCTION: subversion_pkg_preinst 496# @FUNCTION: subversion_pkg_preinst
497# @USAGE: [repo_uri]
434# @DESCRIPTION: 498# @DESCRIPTION:
435# Log the svn revision of source code. Doing this in pkg_preinst because we 499# Log the svn revision of source code. Doing this in pkg_preinst because we
436# want the logs to stick around if packages are uninstalled without messing with 500# want the logs to stick around if packages are uninstalled without messing with
437# config protection. 501# config protection.
438subversion_pkg_preinst() { 502subversion_pkg_preinst() {
439 local pkgdate=$(date "+%Y%m%d %H:%M:%S") 503 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
440 subversion_wc_info 504 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
441 if [[ -n ${ESCM_LOGDIR} ]]; then 505 if [[ -n ${ESCM_LOGDIR} ]]; then
442 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" 506 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
443 if [[ ! -d ${dir} ]]; then 507 if [[ ! -d ${dir} ]]; then
444 mkdir -p "${dir}" || \ 508 mkdir -p "${dir}" || \
445 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" 509 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.67

  ViewVC Help
Powered by ViewVC 1.1.20