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

Diff of /eclass/subversion.eclass

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

Revision 1.48 Revision 1.52
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.48 2008/02/20 19:18:53 cardoe Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.52 2008/02/20 22:35: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"
121# this should be a space delimited list of subversion eclass features to 119# this should be a space delimited list of subversion eclass features to
122# restrict. 120# restrict.
123# export) 121# export)
124# don't export the working copy to S. 122# don't export the working copy to S.
125ESVN_RESTRICT="${ESVN_RESTRICT:-}" 123ESVN_RESTRICT="${ESVN_RESTRICT:-}"
124
125# @ECLASS-VARIABLE: ESVN_OFFLINE
126# @DESCRIPTION:
127# 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
129# tree by users.
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:=}"
126 146
127# @FUNCTION: subversion_fetch 147# @FUNCTION: subversion_fetch
128# @USAGE: [repo_uri] [destination] 148# @USAGE: [repo_uri] [destination]
129# @DESCRIPTION: 149# @DESCRIPTION:
130# 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,
135# destination - a check out path in S. 155# destination - a check out path in S.
136subversion_fetch() { 156subversion_fetch() {
137 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" 157 local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
138 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" 158 local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
139 local S_dest="${2}" 159 local S_dest="${2}"
160
161 if [[ -z ${repo_uri} ]]; then
162 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
163 fi
140 164
141 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}" 165 [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
142 166
143 # check for the protocol 167 # check for the protocol
144 local protocol="${repo_uri%%:*}" 168 local protocol="${repo_uri%%:*}"
193 217
194 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 218 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
195 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 219 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
196 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." 220 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
197 221
222 elif [[ -n ${ESVN_OFFLINE} ]]; then
223 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
225 die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
226 fi
227 einfo "Fetching disabled: Using existing repository copy"
198 else 228 else
199 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 229 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
200 230
231 local esvn_up_freq=
232 if [[ -n ${ESVN_UP_FREQ} ]]; then
233 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."
235 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."
237 esvn_up_freq=no_update
238 fi
239 fi
240
241 if [[ -z ${esvn_up_freq} ]]; then
201 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then 242 if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
202 einfo "suversion switch start -->" 243 einfo "suversion switch start -->"
203 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" 244 einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
204 einfo " new repository: ${repo_uri}${revision:+@}${revision}" 245 einfo " new repository: ${repo_uri}${revision:+@}${revision}"
205 246
206 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" 247 debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
207 248
208 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 249 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
209 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}" 250 ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update from ${repo_uri}"
210 else 251 else
211 # update working copy 252 # update working copy
212 einfo "subversion update start -->" 253 einfo "subversion update start -->"
213 einfo " repository: ${repo_uri}${revision:+@}${revision}" 254 einfo " repository: ${repo_uri}${revision:+@}${revision}"
214 255
215 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 256 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
216 257
217 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 258 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
218 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 259 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}."
219 fi 260 fi
220 261 fi
221 fi 262 fi
222 263
223 einfo " working copy: ${wc_path}" 264 einfo " working copy: ${wc_path}"
224 265
225 if ! has "export" ${ESVN_RESTRICT}; then 266 if ! has "export" ${ESVN_RESTRICT}; then
378 419
379 # repo_uri has peg revision ? 420 # repo_uri has peg revision ?
380 if [[ ${repo_uri} != *@* ]]; then 421 if [[ ${repo_uri} != *@* ]]; then
381 debug-print "${FUNCNAME}: repo_uri does not have a peg revision." 422 debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
382 fi 423 fi
383 424
384 local peg_rev= 425 local peg_rev=
385 [[ ${repo_uri} = *@* ]] && peg_rev="${repo_uri##*@}" 426 [[ ${repo_uri} = *@* ]] && peg_rev="${repo_uri##*@}"
386 427
387 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" 428 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
388 429
389 echo "${peg_rev}" 430 echo "${peg_rev}"
390} 431}
432
433# @FUNCTION: subversion_pkg_preinst
434# @DESCRIPTION:
435# 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
437# config protection.
438subversion_pkg_preinst() {
439 local pkgdate=$(date "+%Y%m%d %H:%M:%S")
440 subversion_wc_info
441 if [[ -n ${ESCM_LOGDIR} ]]; then
442 local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}"
443 if [[ ! -d ${dir} ]]; then
444 mkdir -p "${dir}" || \
445 eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'"
446 fi
447 local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
448 if [[ -d ${dir} ]]; then
449 echo "${logmessage}" >> "${dir}/${PN}.log"
450 else
451 eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
452 fi
453 fi
454}

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

  ViewVC Help
Powered by ViewVC 1.1.20