| 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.53 2008/02/21 13:38:36 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> |
| … | |
… | |
| 152 | # |
152 | # |
| 153 | # Can take two optional parameters: |
153 | # Can take two optional parameters: |
| 154 | # repo_uri - a repository URI. default is ESVN_REPO_URI. |
154 | # repo_uri - a repository URI. default is ESVN_REPO_URI. |
| 155 | # destination - a check out path in S. |
155 | # destination - a check out path in S. |
| 156 | subversion_fetch() { |
156 | subversion_fetch() { |
| 157 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
157 | local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" |
| 158 | local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" |
158 | local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")" |
| 159 | local S_dest="${2}" |
159 | local S_dest="${2}" |
| 160 | |
160 | |
| 161 | if [[ -z ${repo_uri} ]]; then |
161 | if [[ -z ${repo_uri} ]]; then |
| 162 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
162 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
| … | |
… | |
| 167 | # check for the protocol |
167 | # check for the protocol |
| 168 | local protocol="${repo_uri%%:*}" |
168 | local protocol="${repo_uri%%:*}" |
| 169 | |
169 | |
| 170 | case "${protocol}" in |
170 | case "${protocol}" in |
| 171 | http|https) |
171 | http|https) |
|
|
172 | if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || \ |
| 172 | if built_with_use dev-util/subversion nowebdav; then |
173 | built_with_use --missing false dev-util/subversion nowebdav ; then |
| 173 | echo |
174 | echo |
| 174 | eerror "In order to emerge this package, you need to" |
175 | eerror "In order to emerge this package, you need to" |
| 175 | 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." |
| 176 | echo |
178 | echo |
| 177 | die "${ESVN}: please run 'USE=-nowebdav emerge subversion'" |
179 | die "${ESVN}: reinstall Subversion with support for WebDAV." |
| 178 | fi |
180 | fi |
| 179 | ;; |
181 | ;; |
| 180 | svn|svn+ssh) |
182 | svn|svn+ssh) |
| 181 | ;; |
183 | ;; |
| 182 | *) |
184 | *) |
| … | |
… | |
| 218 | |
220 | |
| 219 | debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" |
221 | debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" |
| 220 | |
222 | |
| 221 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
223 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
| 222 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
224 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
| 223 | ${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}." |
| 224 | |
226 | |
| 225 | elif [[ -n ${ESVN_OFFLINE} ]]; then |
227 | elif [[ -n ${ESVN_OFFLINE} ]]; then |
| 226 | 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." |
| 227 | if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then |
229 | 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." |
230 | die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally." |
| 229 | fi |
231 | fi |
| 230 | einfo "Fetching disabled: Using existing repository copy" |
232 | einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}." |
| 231 | else |
233 | else |
| 232 | 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." |
| 233 | |
235 | |
| 234 | local esvn_up_freq= |
236 | local esvn_up_freq= |
| 235 | if [[ -n ${ESVN_UP_FREQ} ]]; then |
237 | if [[ -n ${ESVN_UP_FREQ} ]]; then |
| 236 | if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then |
238 | 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." |
239 | 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 |
240 | 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." |
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}." |
| 240 | esvn_up_freq=no_update |
243 | esvn_up_freq=no_update |
| 241 | fi |
244 | fi |
| 242 | fi |
245 | fi |
| 243 | |
246 | |
| 244 | if [[ -z ${esvn_up_freq} ]]; then |
247 | if [[ -z ${esvn_up_freq} ]]; then |
| 245 | if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then |
248 | if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then |
| 246 | einfo "suversion switch start -->" |
249 | einfo "subversion switch start -->" |
| 247 | einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" |
250 | einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}" |
| 248 | einfo " new repository: ${repo_uri}${revision:+@}${revision}" |
251 | einfo " new repository: ${repo_uri}${revision:+@}${revision}" |
| 249 | |
252 | |
| 250 | debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" |
253 | debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}" |
| 251 | |
254 | |
| 252 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
255 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
| 253 | ${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}" |
| 254 | else |
257 | else |
| 255 | # update working copy |
258 | # update working copy |
| 256 | einfo "subversion update start -->" |
259 | einfo "subversion update start -->" |
| 257 | einfo " repository: ${repo_uri}${revision:+@}${revision}" |
260 | einfo " repository: ${repo_uri}${revision:+@}${revision}" |
| 258 | |
261 | |
| 259 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
262 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
| 260 | |
263 | |
| 261 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
264 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
| 262 | ${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}." |
| 263 | fi |
266 | fi |
| 264 | fi |
267 | fi |
| 265 | fi |
268 | fi |
| 266 | |
269 | |
| 267 | einfo " working copy: ${wc_path}" |
270 | einfo " working copy: ${wc_path}" |
| … | |
… | |
| 346 | # 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. |
| 347 | # |
350 | # |
| 348 | # 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 |
| 349 | # ESVN_WC_* variables. |
352 | # ESVN_WC_* variables. |
| 350 | subversion_wc_info() { |
353 | subversion_wc_info() { |
| 351 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
354 | local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")" |
| 352 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
355 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
| 353 | |
356 | |
| 354 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
357 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 355 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
358 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
| 356 | |
359 | |
| … | |
… | |
| 381 | |
384 | |
| 382 | ## -- subversion__get_repository_uri() --------------------------------------- # |
385 | ## -- subversion__get_repository_uri() --------------------------------------- # |
| 383 | # |
386 | # |
| 384 | # param $1 - a repository URI. |
387 | # param $1 - a repository URI. |
| 385 | subversion__get_repository_uri() { |
388 | subversion__get_repository_uri() { |
| 386 | local repo_uri="${1:-${ESVN_REPO_URI}}" |
389 | local repo_uri="${1}" |
| 387 | |
390 | |
| 388 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
391 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 389 | |
392 | |
| 390 | if [[ -z ${repo_uri} ]]; then |
393 | if [[ -z ${repo_uri} ]]; then |
| 391 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
394 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
| … | |
… | |
| 432 | |
435 | |
| 433 | echo "${peg_rev}" |
436 | echo "${peg_rev}" |
| 434 | } |
437 | } |
| 435 | |
438 | |
| 436 | # @FUNCTION: subversion_pkg_preinst |
439 | # @FUNCTION: subversion_pkg_preinst |
|
|
440 | # @USAGE: [repo_uri] |
| 437 | # @DESCRIPTION: |
441 | # @DESCRIPTION: |
| 438 | # Log the svn revision of source code. Doing this in pkg_preinst because we |
442 | # 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 |
443 | # want the logs to stick around if packages are uninstalled without messing with |
| 440 | # config protection. |
444 | # config protection. |
| 441 | subversion_pkg_preinst() { |
445 | subversion_pkg_preinst() { |
| 442 | local pkgdate=$(date "+%Y%m%d %H:%M:%S") |
446 | local pkgdate=$(date "+%Y%m%d %H:%M:%S") |
| 443 | subversion_wc_info |
447 | subversion_wc_info "${1:-${ESVN_REPO_URI}}" |
| 444 | if [[ -n ${ESCM_LOGDIR} ]]; then |
448 | if [[ -n ${ESCM_LOGDIR} ]]; then |
| 445 | local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" |
449 | local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}" |
| 446 | if [[ ! -d ${dir} ]]; then |
450 | if [[ ! -d ${dir} ]]; then |
| 447 | mkdir -p "${dir}" || \ |
451 | mkdir -p "${dir}" || \ |
| 448 | eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" |
452 | eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'" |