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

Diff of /eclass/subversion.eclass

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

Revision 1.50 Revision 1.63
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.50 2008/02/20 20:36:30 zlin Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.63 2009/04/26 02:18:09 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:
14# The subversion eclass provides functions to fetch, patch and bootstrap 15# The subversion eclass provides functions to fetch, patch and bootstrap
15# software sources from subversion repositories. 16# software sources from subversion repositories.
16#
17# You must define the ESVN_REPO_URI variable before inheriting this eclass.
18 17
19inherit eutils 18inherit eutils
20 19
21ESVN="${ECLASS}" 20ESVN="${ECLASS}"
22 21
76# to a specific revision 75# to a specific revision
77# 76#
78# Note: This should never be set in an ebuild! 77# Note: This should never be set in an ebuild!
79ESVN_REVISION="${ESVN_REVISION:-}" 78ESVN_REVISION="${ESVN_REVISION:-}"
80 79
80# @ECLASS-VARIABLE: ESVN_USER
81# @DESCRIPTION:
82# User name
83ESVN_USER="${ESVN_USER:-}"
84
85# @ECLASS-VARIABLE: ESVN_PASSWORD
86# @DESCRIPTION:
87# Password
88ESVN_PASSWORD="${ESVN_PASSWORD:-}"
89
81# @ECLASS-VARIABLE: ESVN_PROJECT 90# @ECLASS-VARIABLE: ESVN_PROJECT
82# @DESCRIPTION: 91# @DESCRIPTION:
83# project name of your ebuild (= name space) 92# project name of your ebuild (= name space)
84# 93#
85# subversion eclass will check out the subversion repository like: 94# subversion eclass will check out the subversion repository like:
128# @DESCRIPTION: 137# @DESCRIPTION:
129# Set this variable to a non-empty value to disable the automatic updating of 138# Set this variable to a non-empty value to disable the automatic updating of
130# an svn source tree. This is intended to be set outside the subversion source 139# an svn source tree. This is intended to be set outside the subversion source
131# tree by users. 140# tree by users.
132ESVN_OFFLINE="${ESVN_OFFLINE:-${ESCM_OFFLINE}}" 141ESVN_OFFLINE="${ESVN_OFFLINE:-${ESCM_OFFLINE}}"
142
143# @ECLASS-VARIABLE: ESVN_UP_FREQ
144# @DESCRIPTION:
145# Set the minimum number of hours between svn up'ing in any given svn module. This is particularly
146# useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same
147# revision. It should also be kept user overrideable.
148ESVN_UP_FREQ="${ESVN_UP_FREQ:=}"
133 149
134# @ECLASS-VARIABLE: ESCM_LOGDIR 150# @ECLASS-VARIABLE: ESCM_LOGDIR
135# @DESCRIPTION: 151# @DESCRIPTION:
136# User configuration variable. If set to a path such as e.g. /var/log/scm any 152# User configuration variable. If set to a path such as e.g. /var/log/scm any
137# package inheriting from subversion.eclass will record svn revision to 153# package inheriting from subversion.eclass will record svn revision to
151subversion_fetch() { 167subversion_fetch() {
152 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" 168 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
153 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" 169 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
154 local S_dest="${2}" 170 local S_dest="${2}"
155 171
172 if [[ -z ${repo_uri} ]]; then
173 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
174 fi
175
156 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}" 176 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
157 177
158 # check for the protocol 178 # check for the protocol
159 local protocol="${repo_uri%%:*}" 179 local protocol="${repo_uri%%:*}"
160 180
161 case "${protocol}" in 181 case "${protocol}" in
162 http|https) 182 http|https)
183 if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || \
163 if built_with_use dev-util/subversion nowebdav; then 184 built_with_use --missing false dev-util/subversion nowebdav; then
164 echo 185 echo
165 eerror "In order to emerge this package, you need to" 186 eerror "In order to emerge this package, you need to"
166 eerror "re-emerge subversion with USE=-nowebdav" 187 eerror "reinstall Subversion with support for WebDAV."
188 eerror "Subversion requires either Neon or Serf to support WebDAV."
167 echo 189 echo
168 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" 190 die "${ESVN}: reinstall Subversion with support for WebDAV."
169 fi 191 fi
170 ;; 192 ;;
171 svn|svn+ssh) 193 svn|svn+ssh)
172 ;; 194 ;;
173 *) 195 *)
193 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then 215 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
194 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please" 216 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
195 ewarn "see \${ESVN_REPO_URI}" 217 ewarn "see \${ESVN_REPO_URI}"
196 fi 218 fi
197 219
220 if has_version ">=dev-util/subversion-1.6.0"; then
221 options="${options} --config-option=config:auth:password-stores="
222 fi
223
198 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" 224 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
199 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 225 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
200 debug-print "${FUNCNAME}: options = \"${options}\"" 226 debug-print "${FUNCNAME}: options = \"${options}\""
201 227
202 if [[ ! -d ${wc_path}/.svn ]]; then 228 if [[ ! -d ${wc_path}/.svn ]]; then
229 if [[ -n ${ESVN_OFFLINE} ]]; then
230 ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
231 fi
203 # first check out 232 # first check out
204 einfo "subversion check out start -->" 233 einfo "subversion check out start -->"
205 einfo " repository: ${repo_uri}${revision:+@}${revision}" 234 einfo " repository: ${repo_uri}${revision:+@}${revision}"
206 235
207 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" 236 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
208 237
209 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 238 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
210 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 239 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
240 if [[ -n "${ESVN_USER}" ]]; then
241 ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
242 else
211 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 243 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
244 fi
212 245
213 elif [[ -n ${ESVN_OFFLINE} ]]; then 246 elif [[ -n ${ESVN_OFFLINE} ]]; then
247 svn cleanup "${wc_path}"
214 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 248 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
215 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then 249 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
216 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." 250 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
217 fi 251 fi
218 einfo "Fetching disabled: Using existing repository copy" 252 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
219 else 253 else
254 svn cleanup "${wc_path}"
220 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 255 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
221 256
257 local esvn_up_freq=
258 if [[ -n ${ESVN_UP_FREQ} ]]; then
259 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
260 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
261 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
262 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
263 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
264 esvn_up_freq=no_update
265 fi
266 fi
267
268 if [[ -z ${esvn_up_freq} ]]; then
222 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 269 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
223 einfo "suversion switch start -->" 270 einfo "subversion switch start -->"
224 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 271 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
225 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 272 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
226 273
227 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 274 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
228 275
229 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 276 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
277 if [[ -n "${ESVN_USER}" ]]; then
278 ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
279 else
230 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 280 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
281 fi
231 else 282 else
232 # update working copy 283 # update working copy
233 einfo "subversion update start -->" 284 einfo "subversion update start -->"
234 einfo " repository: ${repo_uri}${revision:+@}${revision}" 285 einfo " repository: ${repo_uri}${revision:+@}${revision}"
235 286
236 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 287 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
237 288
238 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 289 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
290 if [[ -n "${ESVN_USER}" ]]; then
291 ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
292 else
239 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 293 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
294 fi
240 fi 295 fi
241 296 fi
242 fi 297 fi
243 298
244 einfo " working copy: ${wc_path}" 299 einfo " working copy: ${wc_path}"
245 300
246 if ! has "export" ${ESVN_RESTRICT}; then 301 if ! has "export" ${ESVN_RESTRICT}; then
247 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 302 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
248 303
249 local S="${S}/${S_dest}" 304 local S="${S}/${S_dest}"
305 mkdir -p "${S}"
250 306
251 # export to the ${WORKDIR} 307 # export to the ${WORKDIR}
252 #* "svn export" has a bug. see http://bugs.gentoo.org/119236 308 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
253 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 309 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
254 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 310 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
323# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. 379# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
324# 380#
325# The working copy information on the specified repository URI are set to 381# The working copy information on the specified repository URI are set to
326# ESVN_WC_* variables. 382# ESVN_WC_* variables.
327subversion_wc_info() { 383subversion_wc_info() {
328 local repo_uri="$(subversion__get_repository_uri "${1}")" 384 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
329 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 385 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
330 386
331 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 387 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
332 debug-print "${FUNCNAME}: wc_path = ${wc_path}" 388 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
333 389
358 414
359## -- subversion__get_repository_uri() --------------------------------------- # 415## -- subversion__get_repository_uri() --------------------------------------- #
360# 416#
361# param $1 - a repository URI. 417# param $1 - a repository URI.
362subversion__get_repository_uri() { 418subversion__get_repository_uri() {
363 local repo_uri="${1}" 419 local repo_uri="${1}"
364 420
365 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 421 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
366 422
367 if [[ -z ${repo_uri} ]]; then 423 if [[ -z ${repo_uri} ]]; then
368 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." 424 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
409 465
410 echo "${peg_rev}" 466 echo "${peg_rev}"
411} 467}
412 468
413# @FUNCTION: subversion_pkg_preinst 469# @FUNCTION: subversion_pkg_preinst
470# @USAGE: [repo_uri]
414# @DESCRIPTION: 471# @DESCRIPTION:
415# Log the svn revision of source code. Doing this in pkg_preinst because we 472# Log the svn revision of source code. Doing this in pkg_preinst because we
416# want the logs to stick around if packages are uninstalled without messing with 473# want the logs to stick around if packages are uninstalled without messing with
417# config protection. 474# config protection.
418subversion_pkg_preinst() { 475subversion_pkg_preinst() {
419 local pkgdate=$(date "+%Y%m%d %H:%M:%S") 476 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
420 subversion_wc_info 477 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
421 if [[ -n ${ESCM_LOGDIR} ]]; then 478 if [[ -n ${ESCM_LOGDIR} ]]; then
422 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" 479 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
423 if [[ ! -d ${dir} ]]; then 480 if [[ ! -d ${dir} ]]; then
424 mkdir -p "${dir}" || \ 481 mkdir -p "${dir}" || \
425 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" 482 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.63

  ViewVC Help
Powered by ViewVC 1.1.20