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

Diff of /eclass/subversion.eclass

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

Revision 1.54 Revision 1.65
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.54 2008/02/21 16:01:53 zlin Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.65 2009/04/29 22:26:31 scarabeus 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
21EXPORT_FUNCTIONS src_unpack pkg_preinst 22EXPORTED_FUNCTIONS="src_unpack pkg_preinst"
23case "${EAPI:-0}" in
24 2) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare" ;;
25 1|0) ;;
26 *) die "Unknown EAPI, Bug eclass maintainers." ;;
27esac
28EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
22 29
23DESCRIPTION="Based on the ${ECLASS} eclass" 30DESCRIPTION="Based on the ${ECLASS} eclass"
24 31
25DEPEND="dev-util/subversion 32DEPEND="dev-util/subversion
26 net-misc/rsync" 33 net-misc/rsync"
73# Useful for live svn or trunk svn ebuilds allowing the user to peg 80# Useful for live svn or trunk svn ebuilds allowing the user to peg
74# to a specific revision 81# to a specific revision
75# 82#
76# Note: This should never be set in an ebuild! 83# Note: This should never be set in an ebuild!
77ESVN_REVISION="${ESVN_REVISION:-}" 84ESVN_REVISION="${ESVN_REVISION:-}"
85
86# @ECLASS-VARIABLE: ESVN_USER
87# @DESCRIPTION:
88# User name
89ESVN_USER="${ESVN_USER:-}"
90
91# @ECLASS-VARIABLE: ESVN_PASSWORD
92# @DESCRIPTION:
93# Password
94ESVN_PASSWORD="${ESVN_PASSWORD:-}"
78 95
79# @ECLASS-VARIABLE: ESVN_PROJECT 96# @ECLASS-VARIABLE: ESVN_PROJECT
80# @DESCRIPTION: 97# @DESCRIPTION:
81# project name of your ebuild (= name space) 98# project name of your ebuild (= name space)
82# 99#
167 # check for the protocol 184 # check for the protocol
168 local protocol="${repo_uri%%:*}" 185 local protocol="${repo_uri%%:*}"
169 186
170 case "${protocol}" in 187 case "${protocol}" in
171 http|https) 188 http|https)
189 if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || \
172 if built_with_use dev-util/subversion nowebdav; then 190 built_with_use --missing false dev-util/subversion nowebdav; then
173 echo 191 echo
174 eerror "In order to emerge this package, you need to" 192 eerror "In order to emerge this package, you need to"
175 eerror "re-emerge subversion with USE=-nowebdav" 193 eerror "reinstall Subversion with support for WebDAV."
194 eerror "Subversion requires either Neon or Serf to support WebDAV."
176 echo 195 echo
177 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" 196 die "${ESVN}: reinstall Subversion with support for WebDAV."
178 fi 197 fi
179 ;; 198 ;;
180 svn|svn+ssh) 199 svn|svn+ssh)
181 ;; 200 ;;
182 *) 201 *)
202 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then 221 if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
203 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please" 222 ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
204 ewarn "see \${ESVN_REPO_URI}" 223 ewarn "see \${ESVN_REPO_URI}"
205 fi 224 fi
206 225
226 if has_version ">=dev-util/subversion-1.6.0"; then
227 options="${options} --config-option=config:auth:password-stores="
228 fi
229
207 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" 230 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
208 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 231 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
209 debug-print "${FUNCNAME}: options = \"${options}\"" 232 debug-print "${FUNCNAME}: options = \"${options}\""
210 233
211 if [[ ! -d ${wc_path}/.svn ]]; then 234 if [[ ! -d ${wc_path}/.svn ]]; then
212 if [[ -n ${ESVN_OFFLINE} ]]; then 235 if [[ -n ${ESVN_OFFLINE} ]]; then
213 ewarn "ESVN_OFFLINE cannot be used when the there is no existing checkout." 236 ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
214 fi 237 fi
215 # first check out 238 # first check out
216 einfo "subversion check out start -->" 239 einfo "subversion check out start -->"
217 einfo " repository: ${repo_uri}${revision:+@}${revision}" 240 einfo " repository: ${repo_uri}${revision:+@}${revision}"
218 241
219 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" 242 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
220 243
221 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 244 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
222 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 245 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
246 if [[ -n "${ESVN_USER}" ]]; then
247 ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
248 else
223 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 249 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
250 fi
224 251
225 elif [[ -n ${ESVN_OFFLINE} ]]; then 252 elif [[ -n ${ESVN_OFFLINE} ]]; then
253 svn cleanup "${wc_path}"
226 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 254 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
227 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then 255 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
228 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." 256 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
229 fi 257 fi
230 einfo "Fetching disabled: Using existing repository copy" 258 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
231 else 259 else
260 svn cleanup "${wc_path}"
232 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 261 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
233 262
234 local esvn_up_freq= 263 local esvn_up_freq=
235 if [[ -n ${ESVN_UP_FREQ} ]]; then 264 if [[ -n ${ESVN_UP_FREQ} ]]; then
236 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then 265 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
237 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up." 266 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
238 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then 267 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
239 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours hasn't passed since last update." 268 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
269 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
240 esvn_up_freq=no_update 270 esvn_up_freq=no_update
241 fi 271 fi
242 fi 272 fi
243 273
244 if [[ -z ${esvn_up_freq} ]]; then 274 if [[ -z ${esvn_up_freq} ]]; then
245 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 275 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
246 einfo "suversion switch start -->" 276 einfo "subversion switch start -->"
247 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 277 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
248 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 278 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
249 279
250 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 280 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
251 281
252 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 282 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
283 if [[ -n "${ESVN_USER}" ]]; then
284 ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
285 else
253 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 286 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
287 fi
254 else 288 else
255 # update working copy 289 # update working copy
256 einfo "subversion update start -->" 290 einfo "subversion update start -->"
257 einfo " repository: ${repo_uri}${revision:+@}${revision}" 291 einfo " repository: ${repo_uri}${revision:+@}${revision}"
258 292
259 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 293 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
260 294
261 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 295 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
296 if [[ -n "${ESVN_USER}" ]]; then
297 ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
298 else
262 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 299 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
300 fi
263 fi 301 fi
264 fi 302 fi
265 fi 303 fi
266 304
267 einfo " working copy: ${wc_path}" 305 einfo " working copy: ${wc_path}"
268 306
269 if ! has "export" ${ESVN_RESTRICT}; then 307 if ! has "export" ${ESVN_RESTRICT}; then
270 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 308 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
271 309
272 local S="${S}/${S_dest}" 310 local S="${S}/${S_dest}"
311 mkdir -p "${S}"
273 312
274 # export to the ${WORKDIR} 313 # export to the ${WORKDIR}
275 #* "svn export" has a bug. see http://bugs.gentoo.org/119236 314 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
276 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 315 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
277 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 316 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
331 fi 370 fi
332} 371}
333 372
334# @FUNCTION: subversion_src_unpack 373# @FUNCTION: subversion_src_unpack
335# @DESCRIPTION: 374# @DESCRIPTION:
336# default src_unpack. fetch and bootstrap. 375# Default src_unpack. Fetch and, in older EAPIs, bootstrap.
337subversion_src_unpack() { 376subversion_src_unpack() {
338 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." 377 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
378 has src_prepare ${EXPORTED_FUNCTIONS} || git_src_prepare
379}
380
381# @FUNCTION: subversion_src_prepare
382# @DESCRIPTION:
383# Default src_prepare. Bootstrap.
384subversion_src_prepare() {
339 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." 385 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
340} 386}
341 387
342# @FUNCTION: subversion_wc_info 388# @FUNCTION: subversion_wc_info
343# @USAGE: [repo_uri] 389# @USAGE: [repo_uri]
432 478
433 echo "${peg_rev}" 479 echo "${peg_rev}"
434} 480}
435 481
436# @FUNCTION: subversion_pkg_preinst 482# @FUNCTION: subversion_pkg_preinst
483# @USAGE: [repo_uri]
437# @DESCRIPTION: 484# @DESCRIPTION:
438# Log the svn revision of source code. Doing this in pkg_preinst because we 485# Log the svn revision of source code. Doing this in pkg_preinst because we
439# want the logs to stick around if packages are uninstalled without messing with 486# want the logs to stick around if packages are uninstalled without messing with
440# config protection. 487# config protection.
441subversion_pkg_preinst() { 488subversion_pkg_preinst() {
442 local pkgdate=$(date "+%Y%m%d %H:%M:%S") 489 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
443 subversion_wc_info 490 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
444 if [[ -n ${ESCM_LOGDIR} ]]; then 491 if [[ -n ${ESCM_LOGDIR} ]]; then
445 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" 492 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
446 if [[ ! -d ${dir} ]]; then 493 if [[ ! -d ${dir} ]]; then
447 mkdir -p "${dir}" || \ 494 mkdir -p "${dir}" || \
448 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" 495 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.65

  ViewVC Help
Powered by ViewVC 1.1.20