Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/lisp:master commit in: eclass/
Date: Thu, 08 Aug 2019 21:24:09
Message-Id: 1565299112.e9e354f4f1185174f954786937f9093f27c53015.ulm@gentoo
1 commit: e9e354f4f1185174f954786937f9093f27c53015
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Thu Aug 8 21:18:32 2019 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Thu Aug 8 21:18:32 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/lisp.git/commit/?id=e9e354f4
7
8 subversion.eclass: Copied from Gentoo repository.
9
10 Bug: https://bugs.gentoo.org/690646
11 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
12
13 eclass/subversion.eclass | 542 +++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 542 insertions(+)
15
16 diff --git a/eclass/subversion.eclass b/eclass/subversion.eclass
17 new file mode 100644
18 index 00000000..6d26820b
19 --- /dev/null
20 +++ b/eclass/subversion.eclass
21 @@ -0,0 +1,542 @@
22 +# Copyright 1999-2019 Gentoo Authors
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +# @ECLASS: subversion.eclass
26 +# @MAINTAINER:
27 +# Akinori Hattori <hattya@g.o>
28 +# @AUTHOR:
29 +# Original Author: Akinori Hattori <hattya@g.o>
30 +# @SUPPORTED_EAPIS: 4 5 6 7
31 +# @BLURB: Fetch software sources from subversion repositories
32 +# @DESCRIPTION:
33 +# The subversion eclass provides functions to fetch, patch and bootstrap
34 +# software sources from subversion repositories.
35 +
36 +ESVN="${ECLASS}"
37 +
38 +case ${EAPI:-0} in
39 + 4|5)
40 + inherit eutils
41 + EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst
42 + ;;
43 + 6|7)
44 + inherit estack
45 + EXPORT_FUNCTIONS src_unpack pkg_preinst
46 + ;;
47 + *)
48 + die "${ESVN}: EAPI ${EAPI:-0} is not supported"
49 + ;;
50 +esac
51 +
52 +PROPERTIES+=" live"
53 +
54 +DEPEND="|| (
55 + dev-vcs/subversion[http]
56 + dev-vcs/subversion[webdav-neon]
57 + dev-vcs/subversion[webdav-serf]
58 + )
59 + net-misc/rsync"
60 +
61 +case ${EAPI} in
62 + 4|5|6) ;;
63 + *) BDEPEND="${DEPEND}"; DEPEND="" ;;
64 +esac
65 +
66 +# @ECLASS-VARIABLE: ESVN_STORE_DIR
67 +# @DESCRIPTION:
68 +# subversion sources store directory. Users may override this in /etc/portage/make.conf
69 +[[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
70 +
71 +# @ECLASS-VARIABLE: ESVN_FETCH_CMD
72 +# @DESCRIPTION:
73 +# subversion checkout command
74 +ESVN_FETCH_CMD="svn checkout"
75 +
76 +# @ECLASS-VARIABLE: ESVN_UPDATE_CMD
77 +# @DESCRIPTION:
78 +# subversion update command
79 +ESVN_UPDATE_CMD="svn update"
80 +
81 +# @ECLASS-VARIABLE: ESVN_SWITCH_CMD
82 +# @DESCRIPTION:
83 +# subversion switch command
84 +ESVN_SWITCH_CMD="svn switch"
85 +
86 +# @ECLASS-VARIABLE: ESVN_OPTIONS
87 +# @DESCRIPTION:
88 +# the options passed to checkout or update. If you want a specific revision see
89 +# ESVN_REPO_URI instead of using -rREV.
90 +ESVN_OPTIONS="${ESVN_OPTIONS:-}"
91 +
92 +# @ECLASS-VARIABLE: ESVN_REPO_URI
93 +# @DESCRIPTION:
94 +# repository uri
95 +#
96 +# e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234
97 +#
98 +# supported URI schemes:
99 +# http://
100 +# https://
101 +# svn://
102 +# svn+ssh://
103 +# file://
104 +#
105 +# to peg to a specific revision, append @REV to the repo's uri
106 +ESVN_REPO_URI="${ESVN_REPO_URI:-}"
107 +
108 +# @ECLASS-VARIABLE: ESVN_REVISION
109 +# @DESCRIPTION:
110 +# User configurable revision checkout or update to from the repository
111 +#
112 +# Useful for live svn or trunk svn ebuilds allowing the user to peg
113 +# to a specific revision
114 +#
115 +# Note: This should never be set in an ebuild!
116 +ESVN_REVISION="${ESVN_REVISION:-}"
117 +
118 +# @ECLASS-VARIABLE: ESVN_USER
119 +# @DESCRIPTION:
120 +# User name
121 +ESVN_USER="${ESVN_USER:-}"
122 +
123 +# @ECLASS-VARIABLE: ESVN_PASSWORD
124 +# @DESCRIPTION:
125 +# Password
126 +ESVN_PASSWORD="${ESVN_PASSWORD:-}"
127 +
128 +# @ECLASS-VARIABLE: ESVN_PROJECT
129 +# @DESCRIPTION:
130 +# project name of your ebuild (= name space)
131 +#
132 +# subversion eclass will check out the subversion repository like:
133 +#
134 +# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
135 +#
136 +# so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
137 +# http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
138 +# it will check out like:
139 +#
140 +# ${ESVN_STORE_DIR}/subversion/trunk
141 +#
142 +# this is not used in order to declare the name of the upstream project.
143 +# so that you can declare this like:
144 +#
145 +# # jakarta commons-loggin
146 +# ESVN_PROJECT=commons/logging
147 +#
148 +# default: ${PN/-svn}.
149 +ESVN_PROJECT="${ESVN_PROJECT:-${PN/-svn}}"
150 +
151 +# @ECLASS-VARIABLE: ESVN_BOOTSTRAP
152 +# @DESCRIPTION:
153 +# Bootstrap script or command like autogen.sh or etc..
154 +# Removed in EAPI 6 and later.
155 +ESVN_BOOTSTRAP="${ESVN_BOOTSTRAP:-}"
156 +
157 +# @ECLASS-VARIABLE: ESVN_PATCHES
158 +# @DESCRIPTION:
159 +# subversion eclass can apply patches in subversion_bootstrap().
160 +# you can use regexp in this variable like *.diff or *.patch or etc.
161 +# NOTE: patches will be applied before ESVN_BOOTSTRAP is processed.
162 +#
163 +# Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
164 +# location, the installation dies.
165 +#
166 +# Removed in EAPI 6 and later, use PATCHES instead.
167 +ESVN_PATCHES="${ESVN_PATCHES:-}"
168 +
169 +# @ECLASS-VARIABLE: ESVN_RESTRICT
170 +# @DESCRIPTION:
171 +# this should be a space delimited list of subversion eclass features to
172 +# restrict.
173 +# export)
174 +# don't export the working copy to S.
175 +ESVN_RESTRICT="${ESVN_RESTRICT:-}"
176 +
177 +# @ECLASS-VARIABLE: ESVN_OFFLINE
178 +# @DESCRIPTION:
179 +# Set this variable to a non-empty value to disable the automatic updating of
180 +# an svn source tree. This is intended to be set outside the subversion source
181 +# tree by users.
182 +ESVN_OFFLINE="${ESVN_OFFLINE:-${EVCS_OFFLINE}}"
183 +
184 +# @ECLASS-VARIABLE: ESVN_UMASK
185 +# @DESCRIPTION:
186 +# Set this variable to a custom umask. This is intended to be set by users.
187 +# By setting this to something like 002, it can make life easier for people
188 +# who do development as non-root (but are in the portage group), and then
189 +# switch over to building with FEATURES=userpriv. Or vice-versa. Shouldn't
190 +# be a security issue here as anyone who has portage group write access
191 +# already can screw the system over in more creative ways.
192 +ESVN_UMASK="${ESVN_UMASK:-${EVCS_UMASK}}"
193 +
194 +# @ECLASS-VARIABLE: ESVN_UP_FREQ
195 +# @DESCRIPTION:
196 +# Set the minimum number of hours between svn up'ing in any given svn module. This is particularly
197 +# useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same
198 +# revision. It should also be kept user overrideable.
199 +ESVN_UP_FREQ="${ESVN_UP_FREQ:=}"
200 +
201 +# @ECLASS-VARIABLE: ESCM_LOGDIR
202 +# @DESCRIPTION:
203 +# User configuration variable. If set to a path such as e.g. /var/log/scm any
204 +# package inheriting from subversion.eclass will record svn revision to
205 +# ${CATEGORY}/${PN}.log in that path in pkg_preinst. This is not supposed to be
206 +# set by ebuilds/eclasses. It defaults to empty so users need to opt in.
207 +ESCM_LOGDIR="${ESCM_LOGDIR:=}"
208 +
209 +# @FUNCTION: subversion_fetch
210 +# @USAGE: [repo_uri] [destination]
211 +# @DESCRIPTION:
212 +# Wrapper function to fetch sources from subversion via svn checkout or svn update,
213 +# depending on whether there is an existing working copy in ${ESVN_STORE_DIR}.
214 +#
215 +# Can take two optional parameters:
216 +# repo_uri - a repository URI. default is ESVN_REPO_URI.
217 +# destination - a check out path in S.
218 +subversion_fetch() {
219 + local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
220 + local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
221 + local S_dest="${2}"
222 +
223 + if [[ -z ${repo_uri} ]]; then
224 + die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
225 + fi
226 +
227 + [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
228 +
229 + # check for the scheme
230 + local scheme="${repo_uri%%:*}"
231 + case "${scheme}" in
232 + http|https)
233 + ;;
234 + svn|svn+ssh)
235 + ;;
236 + file)
237 + ;;
238 + *)
239 + die "${ESVN}: fetch from '${scheme}' is not yet implemented."
240 + ;;
241 + esac
242 +
243 + addread "/etc/subversion"
244 + addwrite "${ESVN_STORE_DIR}"
245 +
246 + if [[ -n "${ESVN_UMASK}" ]]; then
247 + eumask_push "${ESVN_UMASK}"
248 + fi
249 +
250 + if [[ ! -d ${ESVN_STORE_DIR} ]]; then
251 + debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
252 + mkdir -m 775 -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
253 + fi
254 +
255 + pushd "${ESVN_STORE_DIR}" >/dev/null || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
256 +
257 + local wc_path="$(subversion__get_wc_path "${repo_uri}")"
258 + local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
259 +
260 + [[ -n "${revision}" ]] && options="${options} -r ${revision}"
261 +
262 + if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
263 + ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
264 + ewarn "see \${ESVN_REPO_URI}"
265 + fi
266 +
267 + if has_version ">=dev-vcs/subversion-1.6.0"; then
268 + options="${options} --config-option=config:auth:password-stores="
269 + fi
270 +
271 + debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
272 + debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
273 + debug-print "${FUNCNAME}: options = \"${options}\""
274 +
275 + if [[ ! -d ${wc_path}/.svn ]]; then
276 + if [[ -n ${ESVN_OFFLINE} ]]; then
277 + ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
278 + fi
279 + # first check out
280 + einfo "subversion check out start -->"
281 + einfo " repository: ${repo_uri}${revision:+@}${revision}"
282 +
283 + debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
284 +
285 + mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
286 + cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
287 + if [[ -n "${ESVN_USER}" ]]; then
288 + ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
289 + else
290 + ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
291 + fi
292 +
293 + elif [[ -n ${ESVN_OFFLINE} ]]; then
294 + svn upgrade "${wc_path}" &>/dev/null
295 + svn cleanup "${wc_path}" &>/dev/null
296 + subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
297 +
298 + if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
299 + die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
300 + fi
301 + einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
302 + else
303 + svn upgrade "${wc_path}" &>/dev/null
304 + svn cleanup "${wc_path}" &>/dev/null
305 + subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
306 +
307 + local esvn_up_freq=
308 + if [[ -n ${ESVN_UP_FREQ} ]]; then
309 + if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
310 + die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
311 + elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
312 + einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
313 + einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
314 + esvn_up_freq=no_update
315 + fi
316 + fi
317 +
318 + if [[ -z ${esvn_up_freq} ]]; then
319 + if [[ ${ESVN_WC_UUID} != $(subversion__svn_info "${repo_uri}" "Repository UUID") ]]; then
320 + # UUID mismatch. Delete working copy and check out it again.
321 + einfo "subversion recheck out start -->"
322 + einfo " old UUID: ${ESVN_WC_UUID}"
323 + einfo " new UUID: $(subversion__svn_info "${repo_uri}" "Repository UUID")"
324 + einfo " repository: ${repo_uri}${revision:+@}${revision}"
325 +
326 + rm -fr "${ESVN_PROJECT}" || die
327 +
328 + debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
329 +
330 + mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
331 + cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
332 + if [[ -n "${ESVN_USER}" ]]; then
333 + ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
334 + else
335 + ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
336 + fi
337 + elif [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
338 + einfo "subversion switch start -->"
339 + einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
340 + einfo " new repository: ${repo_uri}${revision:+@}${revision}"
341 +
342 + debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
343 +
344 + cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
345 + if [[ -n "${ESVN_USER}" ]]; then
346 + ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
347 + else
348 + ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
349 + fi
350 + else
351 + # update working copy
352 + einfo "subversion update start -->"
353 + einfo " repository: ${repo_uri}${revision:+@}${revision}"
354 +
355 + debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
356 +
357 + cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
358 + if [[ -n "${ESVN_USER}" ]]; then
359 + ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
360 + else
361 + ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
362 + fi
363 + fi
364 +
365 + # export updated information for the working copy
366 + subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
367 + fi
368 + fi
369 +
370 + if [[ -n "${ESVN_UMASK}" ]]; then
371 + eumask_pop
372 + fi
373 +
374 + einfo " working copy: ${wc_path}"
375 +
376 + if ! has "export" ${ESVN_RESTRICT}; then
377 + cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
378 +
379 + local S="${S}/${S_dest}"
380 + mkdir -p "${S}"
381 +
382 + # export to the ${WORKDIR}
383 + #* "svn export" has a bug. see https://bugs.gentoo.org/119236
384 + #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
385 + rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
386 + fi
387 +
388 + popd >/dev/null
389 + echo
390 +}
391 +
392 +# @FUNCTION: subversion_bootstrap
393 +# @DESCRIPTION:
394 +# Apply patches in ${ESVN_PATCHES} and run ${ESVN_BOOTSTRAP} if specified.
395 +# Removed in EAPI 6 and later.
396 +subversion_bootstrap() {
397 + [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is removed from subversion.eclass in EAPI 6 and later"
398 +
399 + if has "export" ${ESVN_RESTRICT}; then
400 + return
401 + fi
402 +
403 + cd "${S}"
404 +
405 + if [[ -n ${ESVN_PATCHES} ]]; then
406 + local patch fpatch
407 + einfo "apply patches -->"
408 + for patch in ${ESVN_PATCHES}; do
409 + if [[ -f ${patch} ]]; then
410 + epatch "${patch}"
411 + else
412 + for fpatch in ${FILESDIR}/${patch}; do
413 + if [[ -f ${fpatch} ]]; then
414 + epatch "${fpatch}"
415 + else
416 + die "${ESVN}: ${patch} not found"
417 + fi
418 + done
419 + fi
420 + done
421 + echo
422 + fi
423 +
424 + if [[ -n ${ESVN_BOOTSTRAP} ]]; then
425 + einfo "begin bootstrap -->"
426 + if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then
427 + einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
428 + eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
429 + else
430 + einfo " bootstrap with command: ${ESVN_BOOTSTRAP}"
431 + eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
432 + fi
433 + fi
434 +}
435 +
436 +# @FUNCTION: subversion_wc_info
437 +# @USAGE: [repo_uri]
438 +# @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
439 +# @DESCRIPTION:
440 +# Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
441 +#
442 +# The working copy information on the specified repository URI are set to
443 +# ESVN_WC_* variables.
444 +subversion_wc_info() {
445 + local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
446 + local wc_path="$(subversion__get_wc_path "${repo_uri}")"
447 +
448 + debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
449 + debug-print "${FUNCNAME}: wc_path = ${wc_path}"
450 +
451 + if [[ ! -d ${wc_path} ]]; then
452 + return 1
453 + fi
454 +
455 + export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
456 + export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
457 + export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
458 + export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
459 + export ESVN_WC_PATH="${wc_path}"
460 +}
461 +
462 +# @FUNCTION: subversion_src_unpack
463 +# @DESCRIPTION:
464 +# Default src_unpack. Fetch.
465 +subversion_src_unpack() {
466 + subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
467 +}
468 +
469 +# @FUNCTION: subversion_src_prepare
470 +# @DESCRIPTION:
471 +# Default src_prepare. Bootstrap.
472 +# Removed in EAPI 6 and later.
473 +subversion_src_prepare() {
474 + [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is removed from subversion.eclass in EAPI 6 and later"
475 + subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
476 +}
477 +
478 +# @FUNCTION: subversion_pkg_preinst
479 +# @USAGE: [repo_uri]
480 +# @DESCRIPTION:
481 +# Log the svn revision of source code. Doing this in pkg_preinst because we
482 +# want the logs to stick around if packages are uninstalled without messing with
483 +# config protection.
484 +subversion_pkg_preinst() {
485 + local pkgdate=$(date "+%Y%m%d %H:%M:%S")
486 + if [[ -n ${ESCM_LOGDIR} ]]; then
487 + local dir="${EROOT%/}${ESCM_LOGDIR}/${CATEGORY}"
488 + if [[ ! -d ${dir} ]]; then
489 + mkdir -p "${dir}" || eerror "Failed to create '${dir}' for logging svn revision"
490 + fi
491 + local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
492 + if [[ -d ${dir} ]]; then
493 + echo "${logmessage}" >>"${dir}/${PN}.log"
494 + else
495 + eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
496 + fi
497 + fi
498 +}
499 +
500 +## -- Private Functions
501 +
502 +## -- subversion__svn_info() ------------------------------------------------- #
503 +#
504 +# param $1 - a target.
505 +# param $2 - a key name.
506 +#
507 +subversion__svn_info() {
508 + local target="${1}"
509 + local key="${2}"
510 +
511 + env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
512 + | grep -i "^${key}" \
513 + | cut -d" " -f2-
514 +}
515 +
516 +## -- subversion__get_repository_uri() --------------------------------------- #
517 +#
518 +# param $1 - a repository URI.
519 +subversion__get_repository_uri() {
520 + local repo_uri="${1}"
521 +
522 + debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
523 + if [[ -z ${repo_uri} ]]; then
524 + die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
525 + fi
526 + # delete trailing slash
527 + if [[ -z ${repo_uri##*/} ]]; then
528 + repo_uri="${repo_uri%/}"
529 + fi
530 + repo_uri="${repo_uri%@*}"
531 +
532 + echo "${repo_uri}"
533 +}
534 +
535 +## -- subversion__get_wc_path() ---------------------------------------------- #
536 +#
537 +# param $1 - a repository URI.
538 +subversion__get_wc_path() {
539 + local repo_uri="$(subversion__get_repository_uri "${1}")"
540 +
541 + debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
542 +
543 + echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
544 +}
545 +
546 +## -- subversion__get_peg_revision() ----------------------------------------- #
547 +#
548 +# param $1 - a repository URI.
549 +subversion__get_peg_revision() {
550 + local repo_uri="${1}"
551 + local peg_rev=
552 +
553 + debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
554 + # repo_uri has peg revision?
555 + if [[ ${repo_uri} = *@* ]]; then
556 + peg_rev="${repo_uri##*@}"
557 + debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
558 + else
559 + debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
560 + fi
561 +
562 + echo "${peg_rev}"
563 +}