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

Diff of /eclass/subversion.eclass

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

Revision 1.49 Revision 1.59
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 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.49 2008/02/20 20:32:00 zlin Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.59 2008/05/15 13:27:40 zlin 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>
11# 11#
12# @BLURB: The subversion eclass is written to fetch software sources from subversion repositories 12# @BLURB: The subversion eclass is written to fetch software sources from subversion repositories
13# @DESCRIPTION: 13# @DESCRIPTION:
14# The subversion eclass provides functions to fetch, patch and bootstrap 14# The subversion eclass provides functions to fetch, patch and bootstrap
15# software sources from subversion repositories. 15# software sources from subversion repositories.
16#
17# You must define the ESVN_REPO_URI variable before inheriting this eclass.
18 16
19inherit eutils 17inherit eutils
20 18
21ESVN="${ECLASS}" 19ESVN="${ECLASS}"
22 20
23EXPORT_FUNCTIONS src_unpack 21EXPORT_FUNCTIONS src_unpack pkg_preinst
24 22
25DESCRIPTION="Based on the ${ECLASS} eclass" 23DESCRIPTION="Based on the ${ECLASS} eclass"
26 24
27DEPEND="dev-util/subversion 25DEPEND="dev-util/subversion
28 net-misc/rsync" 26 net-misc/rsync"
128# @DESCRIPTION: 126# @DESCRIPTION:
129# Set this variable to a non-empty value to disable the automatic updating of 127# 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 128# an svn source tree. This is intended to be set outside the subversion source
131# tree by users. 129# tree by users.
132ESVN_OFFLINE="${ESVN_OFFLINE:-${ESCM_OFFLINE}}" 130ESVN_OFFLINE="${ESVN_OFFLINE:-${ESCM_OFFLINE}}"
131
132# @ECLASS-VARIABLE: ESVN_UP_FREQ
133# @DESCRIPTION:
134# Set the minimum number of hours between svn up'ing in any given svn module. This is particularly
135# useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same
136# revision. It should also be kept user overrideable.
137ESVN_UP_FREQ="${ESVN_UP_FREQ:=}"
138
139# @ECLASS-VARIABLE: ESCM_LOGDIR
140# @DESCRIPTION:
141# User configuration variable. If set to a path such as e.g. /var/log/scm any
142# package inheriting from subversion.eclass will record svn revision to
143# ${CATEGORY}/${PN}.log in that path in pkg_preinst. This is not supposed to be
144# set by ebuilds/eclasses. It defaults to empty so users need to opt in.
145ESCM_LOGDIR="${ESCM_LOGDIR:=}"
133 146
134# @FUNCTION: subversion_fetch 147# @FUNCTION: subversion_fetch
135# @USAGE: [repo_uri] [destination] 148# @USAGE: [repo_uri] [destination]
136# @DESCRIPTION: 149# @DESCRIPTION:
137# Wrapper function to fetch sources from subversion via svn checkout or svn update, 150# Wrapper function to fetch sources from subversion via svn checkout or svn update,
143subversion_fetch() { 156subversion_fetch() {
144 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" 157 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
145 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" 158 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
146 local S_dest="${2}" 159 local S_dest="${2}"
147 160
161 if [[ -z ${repo_uri} ]]; then
162 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
163 fi
164
148 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}" 165 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
149 166
150 # check for the protocol 167 # check for the protocol
151 local protocol="${repo_uri%%:*}" 168 local protocol="${repo_uri%%:*}"
152 169
153 case "${protocol}" in 170 case "${protocol}" in
154 http|https) 171 http|https)
172 if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || \
155 if built_with_use dev-util/subversion nowebdav; then 173 built_with_use --missing false dev-util/subversion nowebdav ; then
156 echo 174 echo
157 eerror "In order to emerge this package, you need to" 175 eerror "In order to emerge this package, you need to"
158 eerror "re-emerge subversion with USE=-nowebdav" 176 eerror "reinstall Subversion with support for WebDAV."
177 eerror "Subversion requires either Neon or Serf to support WebDAV."
159 echo 178 echo
160 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" 179 die "${ESVN}: reinstall Subversion with support for WebDAV."
161 fi 180 fi
162 ;; 181 ;;
163 svn|svn+ssh) 182 svn|svn+ssh)
164 ;; 183 ;;
165 *) 184 *)
190 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" 209 debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
191 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 210 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
192 debug-print "${FUNCNAME}: options = \"${options}\"" 211 debug-print "${FUNCNAME}: options = \"${options}\""
193 212
194 if [[ ! -d ${wc_path}/.svn ]]; then 213 if [[ ! -d ${wc_path}/.svn ]]; then
214 if [[ -n ${ESVN_OFFLINE} ]]; then
215 ewarn "ESVN_OFFLINE cannot be used when the there is no existing checkout."
216 fi
195 # first check out 217 # first check out
196 einfo "subversion check out start -->" 218 einfo "subversion check out start -->"
197 einfo " repository: ${repo_uri}${revision:+@}${revision}" 219 einfo " repository: ${repo_uri}${revision:+@}${revision}"
198 220
199 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" 221 debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
200 222
201 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 223 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
202 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 224 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
203 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 225 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
204 226
205 elif [[ -n ${ESVN_OFFLINE} ]]; then 227 elif [[ -n ${ESVN_OFFLINE} ]]; then
206 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 228 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
207 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then 229 if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
208 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." 230 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
209 fi 231 fi
210 einfo "Fetching disabled: Using existing repository copy" 232 einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
211 else 233 else
212 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 234 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
213 235
236 local esvn_up_freq=
237 if [[ -n ${ESVN_UP_FREQ} ]]; then
238 if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
239 die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
240 elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
241 einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
242 einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
243 esvn_up_freq=no_update
244 fi
245 fi
246
247 if [[ -z ${esvn_up_freq} ]]; then
214 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 248 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
215 einfo "suversion switch start -->" 249 einfo "subversion switch start -->"
216 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 250 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
217 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 251 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
218 252
219 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 253 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
220 254
221 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 255 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
222 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 256 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}"
223 else 257 else
224 # update working copy 258 # update working copy
225 einfo "subversion update start -->" 259 einfo "subversion update start -->"
226 einfo " repository: ${repo_uri}${revision:+@}${revision}" 260 einfo " repository: ${repo_uri}${revision:+@}${revision}"
227 261
228 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 262 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
229 263
230 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 264 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
231 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 265 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
232 fi 266 fi
233 267 fi
234 fi 268 fi
235 269
236 einfo " working copy: ${wc_path}" 270 einfo " working copy: ${wc_path}"
237 271
238 if ! has "export" ${ESVN_RESTRICT}; then 272 if ! has "export" ${ESVN_RESTRICT}; then
315# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. 349# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
316# 350#
317# The working copy information on the specified repository URI are set to 351# The working copy information on the specified repository URI are set to
318# ESVN_WC_* variables. 352# ESVN_WC_* variables.
319subversion_wc_info() { 353subversion_wc_info() {
320 local repo_uri="$(subversion__get_repository_uri "${1}")" 354 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
321 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 355 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
322 356
323 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 357 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
324 debug-print "${FUNCNAME}: wc_path = ${wc_path}" 358 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
325 359
350 384
351## -- subversion__get_repository_uri() --------------------------------------- # 385## -- subversion__get_repository_uri() --------------------------------------- #
352# 386#
353# param $1 - a repository URI. 387# param $1 - a repository URI.
354subversion__get_repository_uri() { 388subversion__get_repository_uri() {
355 local repo_uri="${1}" 389 local repo_uri="${1}"
356 390
357 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 391 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
358 392
359 if [[ -z ${repo_uri} ]]; then 393 if [[ -z ${repo_uri} ]]; then
360 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." 394 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
399 433
400 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" 434 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
401 435
402 echo "${peg_rev}" 436 echo "${peg_rev}"
403} 437}
438
439# @FUNCTION: subversion_pkg_preinst
440# @USAGE: [repo_uri]
441# @DESCRIPTION:
442# Log the svn revision of source code. Doing this in pkg_preinst because we
443# want the logs to stick around if packages are uninstalled without messing with
444# config protection.
445subversion_pkg_preinst() {
446 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
447 subversion_wc_info "${1:-${ESVN_REPO_URI}}"
448 if [[ -n ${ESCM_LOGDIR} ]]; then
449 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
450 if [[ ! -d ${dir} ]]; then
451 mkdir -p "${dir}" || \
452 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"
453 fi
454 local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
455 if [[ -d ${dir} ]]; then
456 echo "${logmessage}" >> "${dir}/${PN}.log"
457 else
458 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
459 fi
460 fi
461}

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.59

  ViewVC Help
Powered by ViewVC 1.1.20