/[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.61
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.61 2009/03/22 01:56:34 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:
167 # check for the protocol 168 # check for the protocol
168 local protocol="${repo_uri%%:*}" 169 local protocol="${repo_uri%%:*}"
169 170
170 case "${protocol}" in 171 case "${protocol}" in
171 http|https) 172 http|https)
173 if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || \
172 if built_with_use dev-util/subversion nowebdav; then 174 built_with_use --missing false dev-util/subversion nowebdav ; then
173 echo 175 echo
174 eerror "In order to emerge this package, you need to" 176 eerror "In order to emerge this package, you need to"
175 eerror "re-emerge subversion with USE=-nowebdav" 177 eerror "reinstall Subversion with support for WebDAV."
178 eerror "Subversion requires either Neon or Serf to support WebDAV."
176 echo 179 echo
177 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" 180 die "${ESVN}: reinstall Subversion with support for WebDAV."
178 fi 181 fi
179 ;; 182 ;;
180 svn|svn+ssh) 183 svn|svn+ssh)
181 ;; 184 ;;
182 *) 185 *)
202 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then 205 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
203 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please" 206 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
204 ewarn "see \${ESVN_REPO_URI}" 207 ewarn "see \${ESVN_REPO_URI}"
205 fi 208 fi
206 209
210 if has_version ">=dev-util/subversion-1.6.0"; then
211 options="${options} --config-option=config:auth:password-stores="
212 fi
213
207 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" 214 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
208 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 215 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
209 debug-print "${FUNCNAME}: options = \"${options}\"" 216 debug-print "${FUNCNAME}: options = \"${options}\""
210 217
211 if [[ ! -d ${wc_path}/.svn ]]; then 218 if [[ ! -d ${wc_path}/.svn ]]; then
219 if [[ -n ${ESVN_OFFLINE} ]]; then
220 ewarn "ESVN_OFFLINE cannot be used when the there is no existing checkout."
221 fi
212 # first check out 222 # first check out
213 einfo "subversion check out start -->" 223 einfo "subversion check out start -->"
214 einfo " repository: ${repo_uri}${revision:+@}${revision}" 224 einfo " repository: ${repo_uri}${revision:+@}${revision}"
215 225
216 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" 226 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
217 227
218 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 228 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
219 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 229 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
220 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 230 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
221 231
222 elif [[ -n ${ESVN_OFFLINE} ]]; then 232 elif [[ -n ${ESVN_OFFLINE} ]]; then
223 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 233 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 234 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." 235 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
226 fi 236 fi
227 einfo "Fetching disabled: Using existing repository copy" 237 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
228 else 238 else
229 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 239 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
230 240
231 local esvn_up_freq= 241 local esvn_up_freq=
232 if [[ -n ${ESVN_UP_FREQ} ]]; then 242 if [[ -n ${ESVN_UP_FREQ} ]]; then
233 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then 243 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." 244 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 245 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." 246 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
247 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
237 esvn_up_freq=no_update 248 esvn_up_freq=no_update
238 fi 249 fi
239 fi 250 fi
240 251
241 if [[ -z ${esvn_up_freq} ]]; then 252 if [[ -z ${esvn_up_freq} ]]; then
242 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 253 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
243 einfo "suversion switch start -->" 254 einfo "subversion switch start -->"
244 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 255 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
245 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 256 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
246 257
247 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 258 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
248 259
249 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 260 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
250 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 261 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}"
251 else 262 else
252 # update working copy 263 # update working copy
253 einfo "subversion update start -->" 264 einfo "subversion update start -->"
254 einfo " repository: ${repo_uri}${revision:+@}${revision}" 265 einfo " repository: ${repo_uri}${revision:+@}${revision}"
255 266
256 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 267 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
257 268
258 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 269 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
259 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 270 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
260 fi 271 fi
261 fi 272 fi
262 fi 273 fi
263 274
264 einfo " working copy: ${wc_path}" 275 einfo " working copy: ${wc_path}"
265 276
266 if ! has "export" ${ESVN_RESTRICT}; then 277 if ! has "export" ${ESVN_RESTRICT}; then
267 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 278 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
268 279
269 local S="${S}/${S_dest}" 280 local S="${S}/${S_dest}"
281 mkdir -p "${S}"
270 282
271 # export to the ${WORKDIR} 283 # export to the ${WORKDIR}
272 #* "svn export" has a bug. see http://bugs.gentoo.org/119236 284 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
273 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 285 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
274 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 286 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
343# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. 355# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
344# 356#
345# The working copy information on the specified repository URI are set to 357# The working copy information on the specified repository URI are set to
346# ESVN_WC_* variables. 358# ESVN_WC_* variables.
347subversion_wc_info() { 359subversion_wc_info() {
348 local repo_uri="$(subversion__get_repository_uri "${1}")" 360 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
349 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 361 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
350 362
351 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 363 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
352 debug-print "${FUNCNAME}: wc_path = ${wc_path}" 364 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
353 365
378 390
379## -- subversion__get_repository_uri() --------------------------------------- # 391## -- subversion__get_repository_uri() --------------------------------------- #
380# 392#
381# param $1 - a repository URI. 393# param $1 - a repository URI.
382subversion__get_repository_uri() { 394subversion__get_repository_uri() {
383 local repo_uri="${1}" 395 local repo_uri="${1}"
384 396
385 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 397 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
386 398
387 if [[ -z ${repo_uri} ]]; then 399 if [[ -z ${repo_uri} ]]; then
388 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." 400 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
429 441
430 echo "${peg_rev}" 442 echo "${peg_rev}"
431} 443}
432 444
433# @FUNCTION: subversion_pkg_preinst 445# @FUNCTION: subversion_pkg_preinst
446# @USAGE: [repo_uri]
434# @DESCRIPTION: 447# @DESCRIPTION:
435# Log the svn revision of source code. Doing this in pkg_preinst because we 448# 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 449# want the logs to stick around if packages are uninstalled without messing with
437# config protection. 450# config protection.
438subversion_pkg_preinst() { 451subversion_pkg_preinst() {
439 local pkgdate=$(date "+%Y%m%d %H:%M:%S") 452 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
440 subversion_wc_info 453 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
441 if [[ -n ${ESCM_LOGDIR} ]]; then 454 if [[ -n ${ESCM_LOGDIR} ]]; then
442 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" 455 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
443 if [[ ! -d ${dir} ]]; then 456 if [[ ! -d ${dir} ]]; then
444 mkdir -p "${dir}" || \ 457 mkdir -p "${dir}" || \
445 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" 458 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"

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

  ViewVC Help
Powered by ViewVC 1.1.20