summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorAkinori Hattori <hattya@gentoo.org>2007-01-19 10:39:51 +0000
committerAkinori Hattori <hattya@gentoo.org>2007-01-19 10:39:51 +0000
commit5eea39dbf262b565eef852cab7bc9dca9321a403 (patch)
tree995e6a09f918801a769e2f16458dc68ffa80c5b7 /eclass
parentstable on x86. (diff)
downloadhistorical-5eea39dbf262b565eef852cab7bc9dca9321a403.tar.gz
historical-5eea39dbf262b565eef852cab7bc9dca9321a403.tar.bz2
historical-5eea39dbf262b565eef852cab7bc9dca9321a403.zip
fixes bug #153227, bug #156712 and bug #161584.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/subversion.eclass170
1 files changed, 135 insertions, 35 deletions
diff --git a/eclass/subversion.eclass b/eclass/subversion.eclass
index dbdef559910c..1c7882e51c75 100644
--- a/eclass/subversion.eclass
+++ b/eclass/subversion.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.38 2006/09/27 16:20:20 hattya Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.39 2007/01/19 10:39:51 hattya Exp $
## --------------------------------------------------------------------------- #
# Author: Akinori Hattori <hattya@gentoo.org>
@@ -110,7 +110,8 @@ ESVN_UPDATE_CMD="svn update"
## -- ESVN_RESTRICT:
#
-# this should be a space delimited list of subversion eclass features to restrict.
+# this should be a space delimited list of subversion eclass features to
+# restrict.
# export)
# don't export the working copy to S.
#
@@ -118,22 +119,16 @@ ESVN_UPDATE_CMD="svn update"
## -- subversion_fetch() ----------------------------------------------------- #
-
+#
+# @param $1 - a repository URI. default is the ESVN_REPO_URI.
+#
function subversion_fetch() {
- local repo_uri=${1:-${ESVN_REPO_URI}}
-
- if [[ -z "${repo_uri}" ]]; then
- die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
- fi
-
- # delete trailing slash
- if [[ -z "${repo_uri##*/}" ]]; then
- repo_uri=${repo_uri%/}
- fi
+ local repo_uri="$(subversion__get_repository_uri "${1}")"
+ local S_dest="${2}"
# check for the protocol
- local protocol=${repo_uri%%:*}
+ local protocol="${repo_uri%%:*}"
case "${protocol}" in
http|https)
@@ -158,16 +153,15 @@ function subversion_fetch() {
if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
-
mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
fi
cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
-
- local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
+ local wc_path="$(subversion__get_wc_path "${repo_uri}")"
local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
+ debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
debug-print "${FUNCNAME}: options = \"${options}\""
@@ -176,14 +170,16 @@ function subversion_fetch() {
einfo "subversion check out start -->"
einfo " repository: ${repo_uri}"
- mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
- cd "${ESVN_PROJECT}"
+ debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
+
+ mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
+ cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
else
- subversion_wc_info || die "${ESVN}: unknown problem occurred while accessing working copy."
+ subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
- if [[ "${ESVN_WC_URL}" != "${repo_uri}" ]]; then
+ if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then
die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched."
fi
@@ -191,15 +187,19 @@ function subversion_fetch() {
einfo "subversion update start -->"
einfo " repository: ${repo_uri}"
- cd "${wc_path}"
+ debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
+
+ cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}."
fi
- einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
+ einfo " working copy: ${wc_path}"
if ! has "export" ${ESVN_RESTRICT}; then
- cd "${ESVN_STORE_DIR}/${wc_path}"
+ cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
+
+ local S="${S}/${S_dest}"
# export to the ${WORKDIR}
#* "svn export" has a bug. see http://bugs.gentoo.org/119236
@@ -213,7 +213,7 @@ function subversion_fetch() {
## -- subversion_bootstrap() ------------------------------------------------ #
-
+#
function subversion_bootstrap() {
if has "export" ${ESVN_RESTRICT}; then
@@ -268,7 +268,7 @@ function subversion_bootstrap() {
## -- subversion_src_unpack() ------------------------------------------------ #
-
+#
function subversion_src_unpack() {
subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
@@ -278,26 +278,126 @@ function subversion_src_unpack() {
## -- subversion_wc_info() --------------------------------------------------- #
-
+#
+# @param $1 - repository URI. default is ESVN_REPO_URI.
+#
function subversion_wc_info() {
- local repo_uri=${ESVN_REPO_URI}
+ local repo_uri="$(subversion__get_repository_uri "${1}")"
+ local wc_path="$(subversion__get_wc_path "${repo_uri}")"
+
+ debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
+ debug-print "${FUNCNAME}: wc_path = ${wc_path}"
+
+ if [[ ! -e "${wc_path}" ]]; then
+ return 1
+ fi
+
+ local k
+
+ for k in url revision; do
+ export ESVN_WC_$(echo "${k}" | tr "[a-z]" "[A-Z]")="$(subversion__svn_info "${wc_path}" "${k}")"
+ done
+
+}
+
+
+## -- Private Functions
+
+
+## -- subversion__svn_info() ------------------------------------------------- #
+#
+# @param $1 - a target.
+# @param $2 - a key name.
+#
+function subversion__svn_info() {
+
+ local target="${1}"
+ local key="${2}"
+
+ env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2-
+
+}
+
+
+## -- subversion__get_repository_uri() --------------------------------------- #
+#
+# @param $1 - a repository URI.
+# @param $2 - a peg revision is deleted from a return value if this is
+# specified.
+#
+function subversion__get_repository_uri() {
+
+ local repo_uri="${1:-${ESVN_REPO_URI}}"
+ local remove_peg_revision="${2}"
+
+ debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
+ debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}"
+
+ if [[ -z "${repo_uri}" ]]; then
+ die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
+ fi
# delete trailing slash
if [[ -z "${repo_uri##*/}" ]]; then
repo_uri="${repo_uri%/}"
fi
- local wc_path=${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}
+ if [[ -n "${remove_peg_revision}" ]]; then
+ if subversion__has_peg_revision "${repo_uri}"; then
+ repo_uri="${repo_uri%@*}"
- if [[ ! -e "${wc_path}" ]]; then
+ debug-print "${FUNCNAME}: repo_uri has a peg revision"
+ debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
+ fi
+ fi
+
+ echo "${repo_uri}"
+
+}
+
+
+## -- subversion__get_wc_path() ---------------------------------------------- #
+#
+# @param $1 - a repository URI.
+#
+function subversion__get_wc_path() {
+
+ local repo_uri="$(subversion__get_repository_uri "${1}" 1)"
+
+ debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
+
+ echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
+
+}
+
+
+## -- subversion__has_peg_revision() ----------------------------------------- #
+#
+# @param $1 - a repository URI.
+#
+function subversion__has_peg_revision() {
+
+ local repo_uri="${1}"
+
+ debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
+
+ # repo_uri has peg revision ?
+ if [[ "${repo_uri}" != *@* ]]; then
+ debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
return 1
fi
- local k=
+ local peg_rev="${repo_uri##*@}"
+ local rev=$(subversion__svn_info "${repo_uri}" "revision")
- for k in url revision; do
- export ESVN_WC_$(echo "${k}" | tr [a-z] [A-Z])=$(env LC_ALL=C svn info "${wc_path}" | grep -i "^${k}" | cut -d" " -f2)
- done
+ debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
+ debug-print "${FUNCNAME}: rev = ${rev} "
+
+ if [[ "${peg_rev}" -eq "${rev}" ]]; then
+ return 0
+ fi
+
+ return 1
}