| 1 | # Copyright 1999-2007 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.44 2007/07/03 08:27:40 peper Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.46 2008/02/20 17:11:34 zlin Exp $ |
| 4 | |
4 | |
| 5 | ## --------------------------------------------------------------------------- # |
5 | # @ECLASS: subversion.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # Akinori Hattori <hattya@gentoo.org> |
|
|
8 | # Bo Ørsted Andresen <zlin@gentoo.org> |
|
|
9 | # |
| 6 | # Author: Akinori Hattori <hattya@gentoo.org> |
10 | # Original Author: Akinori Hattori <hattya@gentoo.org> |
| 7 | # |
11 | # |
| 8 | # The subversion eclass is written to fetch the software sources from |
12 | # @BLURB: The subversion eclass is written to fetch software sources from subversion repositories |
| 9 | # subversion repositories like the cvs eclass. |
13 | # @DESCRIPTION: |
|
|
14 | # The subversion eclass provides functions to fetch, patch and bootstrap |
|
|
15 | # software sources from subversion repositories. |
| 10 | # |
16 | # |
| 11 | # |
17 | # You must define the ESVN_REPO_URI variable before inheriting this eclass. |
| 12 | # Description: |
|
|
| 13 | # If you use this eclass, the ${S} is ${WORKDIR}/${P}. |
|
|
| 14 | # It is necessary to define the ESVN_REPO_URI variable at least. |
|
|
| 15 | # |
|
|
| 16 | ## --------------------------------------------------------------------------- # |
|
|
| 17 | |
18 | |
| 18 | inherit eutils |
19 | inherit eutils |
| 19 | |
20 | |
| 20 | ESVN="subversion.eclass" |
21 | ESVN="${ECLASS}" |
| 21 | |
22 | |
| 22 | EXPORT_FUNCTIONS src_unpack |
23 | EXPORT_FUNCTIONS src_unpack |
| 23 | |
24 | |
| 24 | DESCRIPTION="Based on the ${ECLASS} eclass" |
25 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 25 | |
26 | |
| 26 | |
|
|
| 27 | ## -- add subversion in DEPEND |
|
|
| 28 | # |
|
|
| 29 | DEPEND="dev-util/subversion" |
27 | DEPEND="dev-util/subversion |
|
|
28 | net-misc/rsync" |
| 30 | |
29 | |
| 31 | |
30 | # @ECLASS-VARIABLE: ESVN_STORE_DIR |
| 32 | ## -- ESVN_STORE_DIR: subversion sources store directory |
31 | # @DESCRIPTION: |
| 33 | # |
32 | # subversion sources store directory. Users may override this in /etc/make.conf |
| 34 | ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src" |
33 | [[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src" |
| 35 | |
34 | |
| 36 | |
35 | # @ECLASS-VARIABLE: ESVN_FETCH_CMD |
| 37 | ## -- ESVN_FETCH_CMD: subversion fetch command |
36 | # @DESCRIPTION: |
| 38 | # |
37 | # subversion checkout command |
| 39 | ESVN_FETCH_CMD="svn checkout" |
38 | ESVN_FETCH_CMD="svn checkout" |
| 40 | |
39 | |
| 41 | ## -- ESVN_UPDATE_CMD: subversion update command |
40 | # @ECLASS-VARIABLE: ESVN_UPDATE_CMD |
| 42 | # |
41 | # @DESCRIPTION: |
|
|
42 | # subversion update command |
| 43 | ESVN_UPDATE_CMD="svn update" |
43 | ESVN_UPDATE_CMD="svn update" |
| 44 | |
44 | |
|
|
45 | # @ECLASS-VARIABLE: ESVN_OPTIONS |
|
|
46 | # @DESCRIPTION: |
|
|
47 | # the options passed to checkout or update. If you want a specific revision see |
|
|
48 | # ESVN_REPO_URI instead of using -rREV. |
|
|
49 | ESVN_OPTIONS="${ESVN_OPTIONS:-}" |
| 45 | |
50 | |
| 46 | ## -- ESVN_OPTIONS: |
51 | # @ECLASS-VARIABLE: ESVN_REPO_URI |
|
|
52 | # @DESCRIPTION: |
|
|
53 | # repository uri |
| 47 | # |
54 | # |
| 48 | # the options passed to checkout or update. |
55 | # e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234 |
| 49 | # |
|
|
| 50 | : ${ESVN_OPTIONS=} |
|
|
| 51 | |
|
|
| 52 | |
|
|
| 53 | ## -- ESVN_REPO_URI: repository uri |
|
|
| 54 | # |
|
|
| 55 | # e.g. http://foo/trunk, svn://bar/trunk |
|
|
| 56 | # |
56 | # |
| 57 | # supported protocols: |
57 | # supported protocols: |
| 58 | # http:// |
58 | # http:// |
| 59 | # https:// |
59 | # https:// |
| 60 | # svn:// |
60 | # svn:// |
| 61 | # svn+ssh:// |
61 | # svn+ssh:// |
| 62 | # |
62 | # |
| 63 | : ${ESVN_REPO_URI=} |
63 | # to peg to a specific revision, append @REV to the repo's uri |
|
|
64 | ESVN_REPO_URI="${ESVN_REPO_URI:-}" |
| 64 | |
65 | |
| 65 | |
66 | # @ECLASS-VARIABLE: ESVN_PROJECT |
|
|
67 | # @DESCRIPTION: |
| 66 | ## -- ESVN_PROJECT: project name of your ebuild (= name space) |
68 | # project name of your ebuild (= name space) |
| 67 | # |
69 | # |
| 68 | # subversion eclass will check out the subversion repository like: |
70 | # subversion eclass will check out the subversion repository like: |
| 69 | # |
71 | # |
| 70 | # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} |
72 | # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} |
| 71 | # |
73 | # |
| … | |
… | |
| 80 | # |
82 | # |
| 81 | # # jakarta commons-loggin |
83 | # # jakarta commons-loggin |
| 82 | # ESVN_PROJECT=commons/logging |
84 | # ESVN_PROJECT=commons/logging |
| 83 | # |
85 | # |
| 84 | # default: ${PN/-svn}. |
86 | # default: ${PN/-svn}. |
| 85 | # |
87 | ESVN_PROJECT="${ESVN_PROJECT:-${PN/-svn}}" |
| 86 | : ${ESVN_PROJECT:=${PN/-svn}} |
|
|
| 87 | |
88 | |
| 88 | |
89 | # @ECLASS-VARIABLE: ESVN_BOOTSTRAP |
| 89 | ## -- ESVN_BOOTSTRAP: |
90 | # @DESCRIPTION: |
| 90 | # |
|
|
| 91 | # bootstrap script or command like autogen.sh or etc.. |
91 | # bootstrap script or command like autogen.sh or etc.. |
| 92 | # |
92 | ESVN_BOOTSTRAP="${ESVN_BOOTSTRAP:-}" |
| 93 | : ${ESVN_BOOTSTRAP=} |
|
|
| 94 | |
93 | |
| 95 | |
94 | # @ECLASS-VARIABLE: ESVN_PATCHES |
| 96 | ## -- ESVN_PATCHES: |
95 | # @DESCRIPTION: |
| 97 | # |
|
|
| 98 | # subversion eclass can apply pathces in subversion_bootstrap(). |
96 | # subversion eclass can apply patches in subversion_bootstrap(). |
| 99 | # you can use regexp in this variable like *.diff or *.patch or etc. |
97 | # you can use regexp in this variable like *.diff or *.patch or etc. |
| 100 | # NOTE: patches will be applied before ESVN_BOOTSTRAP is processed. |
98 | # NOTE: patches will be applied before ESVN_BOOTSTRAP is processed. |
| 101 | # |
99 | # |
| 102 | # Patches are searched both in / and ${FILESDIR}, if not found in both locations, |
100 | # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either |
| 103 | # the installation dies. |
101 | # location, the installation dies. |
| 104 | # |
102 | ESVN_PATCHES="${ESVN_PATCHES:-}" |
| 105 | : ${ESVN_PATCHES=} |
|
|
| 106 | |
103 | |
| 107 | |
104 | # @ECLASS-VARIABLE: ESVN_RESTRICT |
| 108 | ## -- ESVN_RESTRICT: |
105 | # @DESCRIPTION: |
| 109 | # |
|
|
| 110 | # this should be a space delimited list of subversion eclass features to |
106 | # this should be a space delimited list of subversion eclass features to |
| 111 | # restrict. |
107 | # restrict. |
| 112 | # export) |
108 | # export) |
| 113 | # don't export the working copy to S. |
109 | # don't export the working copy to S. |
| 114 | # |
110 | ESVN_RESTRICT="${ESVN_RESTRICT:-}" |
| 115 | : ${ESVN_RESTRICT=} |
|
|
| 116 | |
111 | |
| 117 | |
112 | # @FUNCTION: subversion_fetch |
| 118 | ## -- subversion_fetch() ----------------------------------------------------- # |
113 | # @USAGE: [repo_uri] [destination] |
|
|
114 | # @DESCRIPTION: |
|
|
115 | # Wrapper function to fetch sources from subversion via svn checkout or svn update, |
|
|
116 | # depending on whether there is an existing working copy in ${ESVN_STORE_DIR}. |
| 119 | # |
117 | # |
|
|
118 | # Can take two optional parameters: |
| 120 | # @param $1 - a repository URI. default is the ESVN_REPO_URI. |
119 | # repo_uri - a repository URI. default is ESVN_REPO_URI. |
| 121 | # @param $2 - a check out path in S. |
120 | # destination - a check out path in S. |
| 122 | # |
|
|
| 123 | function subversion_fetch() { |
121 | subversion_fetch() { |
| 124 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
122 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
| 125 | local S_dest="${2}" |
123 | local S_dest="${2}" |
| 126 | |
124 | |
| 127 | # check for the protocol |
125 | # check for the protocol |
| 128 | local protocol="${repo_uri%%:*}" |
126 | local protocol="${repo_uri%%:*}" |
| … | |
… | |
| 138 | fi |
136 | fi |
| 139 | ;; |
137 | ;; |
| 140 | svn|svn+ssh) |
138 | svn|svn+ssh) |
| 141 | ;; |
139 | ;; |
| 142 | *) |
140 | *) |
| 143 | die "${ESVN}: fetch from "${protocol}" is not yet implemented." |
141 | die "${ESVN}: fetch from '${protocol}' is not yet implemented." |
| 144 | ;; |
142 | ;; |
| 145 | esac |
143 | esac |
| 146 | |
144 | |
| 147 | addread "/etc/subversion" |
145 | addread "/etc/subversion" |
| 148 | addwrite "${ESVN_STORE_DIR}" |
146 | addwrite "${ESVN_STORE_DIR}" |
| 149 | |
147 | |
| 150 | if [[ ! -d "${ESVN_STORE_DIR}" ]]; then |
148 | if [[ ! -d ${ESVN_STORE_DIR} ]]; then |
| 151 | debug-print "${FUNCNAME}: initial checkout. creating subversion directory" |
149 | debug-print "${FUNCNAME}: initial checkout. creating subversion directory" |
| 152 | mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." |
150 | mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." |
| 153 | fi |
151 | fi |
| 154 | |
152 | |
| 155 | cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" |
153 | cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" |
| … | |
… | |
| 159 | |
157 | |
| 160 | debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" |
158 | debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"" |
| 161 | debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" |
159 | debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" |
| 162 | debug-print "${FUNCNAME}: options = \"${options}\"" |
160 | debug-print "${FUNCNAME}: options = \"${options}\"" |
| 163 | |
161 | |
| 164 | if [[ ! -d "${wc_path}/.svn" ]]; then |
162 | if [[ ! -d ${wc_path}/.svn ]]; then |
| 165 | # first check out |
163 | # first check out |
| 166 | einfo "subversion check out start -->" |
164 | einfo "subversion check out start -->" |
| 167 | einfo " repository: ${repo_uri}" |
165 | einfo " repository: ${repo_uri}" |
| 168 | |
166 | |
| 169 | debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" |
167 | debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}" |
| 170 | |
168 | |
| 171 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
169 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
| 172 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
170 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
| 173 | ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." |
171 | ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." |
| 174 | |
172 | |
| 175 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
|
|
| 176 | else |
173 | else |
| 177 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
174 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
|
|
175 | |
| 178 | if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then |
176 | if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}" 1) ]]; then |
| 179 | die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched." |
177 | die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched." |
| 180 | fi |
178 | fi |
| 181 | |
179 | |
| 182 | # update working copy |
180 | # update working copy |
| 183 | einfo "subversion update start -->" |
181 | einfo "subversion update start -->" |
| … | |
… | |
| 185 | |
183 | |
| 186 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
184 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
| 187 | |
185 | |
| 188 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
186 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
| 189 | ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." |
187 | ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." |
|
|
188 | |
| 190 | fi |
189 | fi |
| 191 | |
190 | |
| 192 | einfo " working copy: ${wc_path}" |
191 | einfo " working copy: ${wc_path}" |
| 193 | |
192 | |
| 194 | if ! has "export" ${ESVN_RESTRICT}; then |
193 | if ! has "export" ${ESVN_RESTRICT}; then |
| … | |
… | |
| 203 | fi |
202 | fi |
| 204 | |
203 | |
| 205 | echo |
204 | echo |
| 206 | } |
205 | } |
| 207 | |
206 | |
| 208 | |
207 | # @FUNCTION: subversion_bootstrap |
| 209 | ## -- subversion_bootstrap() ------------------------------------------------ # |
208 | # @DESCRIPTION: |
| 210 | # |
209 | # Apply patches in ${ESVN_PATCHES} and run ${ESVN_BOOTSTRAP} if specified. |
| 211 | function subversion_bootstrap() { |
210 | subversion_bootstrap() { |
| 212 | if has "export" ${ESVN_RESTRICT}; then |
211 | if has "export" ${ESVN_RESTRICT}; then |
| 213 | return |
212 | return |
| 214 | fi |
213 | fi |
| 215 | |
214 | |
| 216 | cd "${S}" |
215 | cd "${S}" |
| 217 | |
216 | |
| 218 | if [[ -n "${ESVN_PATCHES}" ]]; then |
217 | if [[ -n ${ESVN_PATCHES} ]]; then |
| 219 | einfo "apply patches -->" |
218 | einfo "apply patches -->" |
| 220 | |
219 | |
| 221 | local patch fpatch |
220 | local patch fpatch |
|
|
221 | |
| 222 | for patch in ${ESVN_PATCHES}; do |
222 | for patch in ${ESVN_PATCHES}; do |
| 223 | if [[ -f "${patch}" ]]; then |
223 | if [[ -f ${patch} ]]; then |
| 224 | epatch "${patch}" |
224 | epatch "${patch}" |
|
|
225 | |
| 225 | else |
226 | else |
| 226 | for fpatch in ${FILESDIR}/${patch}; do |
227 | for fpatch in ${FILESDIR}/${patch}; do |
| 227 | if [[ -f "${fpatch}" ]]; then |
228 | if [[ -f ${fpatch} ]]; then |
| 228 | epatch "${fpatch}" |
229 | epatch "${fpatch}" |
|
|
230 | |
| 229 | else |
231 | else |
| 230 | die "${ESVN}: ${patch} not found" |
232 | die "${ESVN}: ${patch} not found" |
|
|
233 | |
| 231 | fi |
234 | fi |
| 232 | done |
235 | done |
|
|
236 | |
| 233 | fi |
237 | fi |
| 234 | done |
238 | done |
|
|
239 | |
| 235 | echo |
240 | echo |
| 236 | fi |
241 | fi |
| 237 | |
242 | |
| 238 | if [[ -n "${ESVN_BOOTSTRAP}" ]]; then |
243 | if [[ -n ${ESVN_BOOTSTRAP} ]]; then |
| 239 | einfo "begin bootstrap -->" |
244 | einfo "begin bootstrap -->" |
| 240 | |
245 | |
| 241 | if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then |
246 | if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then |
| 242 | einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" |
247 | einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" |
| 243 | eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." |
248 | eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." |
|
|
249 | |
| 244 | else |
250 | else |
| 245 | einfo " bootstrap with command: ${ESVN_BOOTSTRAP}" |
251 | einfo " bootstrap with command: ${ESVN_BOOTSTRAP}" |
| 246 | eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." |
252 | eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." |
|
|
253 | |
| 247 | fi |
254 | fi |
| 248 | fi |
255 | fi |
| 249 | } |
256 | } |
| 250 | |
257 | |
| 251 | ## -- subversion_src_unpack() ------------------------------------------------ # |
258 | # @FUNCTION: subversion_src_unpack |
| 252 | # |
259 | # @DESCRIPTION: |
|
|
260 | # default src_unpack. fetch and bootstrap. |
| 253 | function subversion_src_unpack() { |
261 | subversion_src_unpack() { |
| 254 | subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." |
262 | subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." |
| 255 | subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." |
263 | subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." |
| 256 | } |
264 | } |
| 257 | |
265 | |
| 258 | |
266 | # @FUNCTION: subversion_wc_info |
| 259 | ## -- subversion_wc_info() --------------------------------------------------- # |
267 | # @USAGE: [repo_uri] |
|
|
268 | # @RETURN: ESVN_WC_URL, ESVN_WC_REVISION and ESVN_WC_PATH |
|
|
269 | # @DESCRIPTION: |
|
|
270 | # Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI. |
| 260 | # |
271 | # |
| 261 | # @param $1 - repository URI. default is ESVN_REPO_URI. |
272 | # The working copy information on the specified repository URI are set to |
| 262 | # |
273 | # ESVN_WC_* variables. |
| 263 | function subversion_wc_info() { |
274 | subversion_wc_info() { |
| 264 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
275 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
| 265 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
276 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
| 266 | |
277 | |
| 267 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
278 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 268 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
279 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
| 269 | |
280 | |
| 270 | if [[ ! -e "${wc_path}" ]]; then |
281 | if [[ ! -d ${wc_path} ]]; then |
| 271 | return 1 |
282 | return 1 |
| 272 | fi |
283 | fi |
| 273 | |
284 | |
| 274 | local k |
285 | local k |
|
|
286 | |
| 275 | for k in url revision; do |
287 | for k in url revision; do |
| 276 | export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" |
288 | export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" |
| 277 | done |
289 | done |
|
|
290 | |
|
|
291 | export ESVN_WC_PATH="${wc_path}" |
| 278 | } |
292 | } |
| 279 | |
293 | |
| 280 | ## -- Private Functions |
294 | ## -- Private Functions |
| 281 | |
295 | |
| 282 | |
|
|
| 283 | ## -- subversion__svn_info() ------------------------------------------------- # |
296 | ## -- subversion__svn_info() ------------------------------------------------- # |
| 284 | # |
297 | # |
| 285 | # @param $1 - a target. |
298 | # param $1 - a target. |
| 286 | # @param $2 - a key name. |
299 | # param $2 - a key name. |
| 287 | # |
300 | # |
| 288 | function subversion__svn_info() { |
301 | subversion__svn_info() { |
| 289 | local target="${1}" |
302 | local target="${1}" |
| 290 | local key="${2}" |
303 | local key="${2}" |
| 291 | |
304 | |
| 292 | env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- |
305 | env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- |
| 293 | } |
306 | } |
| 294 | |
307 | |
| 295 | |
|
|
| 296 | ## -- subversion__get_repository_uri() --------------------------------------- # |
308 | ## -- subversion__get_repository_uri() --------------------------------------- # |
| 297 | # |
309 | # |
| 298 | # @param $1 - a repository URI. |
310 | # param $1 - a repository URI. |
| 299 | # @param $2 - a peg revision is deleted from a return value if this is |
311 | # param $2 - a peg revision is deleted from a return value if this is |
| 300 | # specified. |
312 | # specified. |
| 301 | # |
|
|
| 302 | function subversion__get_repository_uri() { |
313 | subversion__get_repository_uri() { |
| 303 | local repo_uri="${1:-${ESVN_REPO_URI}}" |
314 | local repo_uri="${1:-${ESVN_REPO_URI}}" |
| 304 | local remove_peg_revision="${2}" |
315 | local remove_peg_revision="${2}" |
| 305 | |
316 | |
| 306 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
317 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 307 | debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}" |
318 | debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}" |
| 308 | |
319 | |
| 309 | if [[ -z "${repo_uri}" ]]; then |
320 | if [[ -z ${repo_uri} ]]; then |
| 310 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
321 | die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty." |
| 311 | fi |
322 | fi |
| 312 | |
323 | |
| 313 | # delete trailing slash |
324 | # delete trailing slash |
| 314 | if [[ -z "${repo_uri##*/}" ]]; then |
325 | if [[ -z ${repo_uri##*/} ]]; then |
| 315 | repo_uri="${repo_uri%/}" |
326 | repo_uri="${repo_uri%/}" |
| 316 | fi |
327 | fi |
| 317 | |
328 | |
| 318 | if [[ -n "${remove_peg_revision}" ]]; then |
329 | if [[ -n ${remove_peg_revision} ]]; then |
| 319 | if subversion__has_peg_revision "${repo_uri}"; then |
330 | if subversion__has_peg_revision "${repo_uri}"; then |
| 320 | repo_uri="${repo_uri%@*}" |
331 | repo_uri="${repo_uri%@*}" |
| 321 | |
332 | |
| 322 | debug-print "${FUNCNAME}: repo_uri has a peg revision" |
333 | debug-print "${FUNCNAME}: repo_uri has a peg revision" |
| 323 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
334 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| … | |
… | |
| 325 | fi |
336 | fi |
| 326 | |
337 | |
| 327 | echo "${repo_uri}" |
338 | echo "${repo_uri}" |
| 328 | } |
339 | } |
| 329 | |
340 | |
| 330 | |
|
|
| 331 | ## -- subversion__get_wc_path() ---------------------------------------------- # |
341 | ## -- subversion__get_wc_path() ---------------------------------------------- # |
| 332 | # |
342 | # |
| 333 | # @param $1 - a repository URI. |
343 | # param $1 - a repository URI. |
| 334 | # |
|
|
| 335 | function subversion__get_wc_path() { |
344 | subversion__get_wc_path() { |
| 336 | local repo_uri="$(subversion__get_repository_uri "${1}" 1)" |
345 | local repo_uri="$(subversion__get_repository_uri "${1}" 1)" |
| 337 | |
346 | |
| 338 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
347 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 339 | |
348 | |
| 340 | echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" |
349 | echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" |
| 341 | } |
350 | } |
| 342 | |
351 | |
| 343 | |
|
|
| 344 | ## -- subversion__has_peg_revision() ----------------------------------------- # |
352 | ## -- subversion__has_peg_revision() ----------------------------------------- # |
| 345 | # |
353 | # |
| 346 | # @param $1 - a repository URI. |
354 | # param $1 - a repository URI. |
| 347 | # |
|
|
| 348 | function subversion__has_peg_revision() { |
355 | subversion__has_peg_revision() { |
| 349 | local repo_uri="${1}" |
356 | local repo_uri="${1}" |
| 350 | |
357 | |
| 351 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
358 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 352 | |
359 | |
| 353 | # repo_uri has peg revision ? |
360 | # repo_uri has peg revision ? |
| 354 | if [[ "${repo_uri}" != *@* ]]; then |
361 | if [[ ${repo_uri} != *@* ]]; then |
| 355 | debug-print "${FUNCNAME}: repo_uri does not have a peg revision." |
362 | debug-print "${FUNCNAME}: repo_uri does not have a peg revision." |
| 356 | return 1 |
363 | return 1 |
| 357 | fi |
364 | fi |
| 358 | |
365 | |
| 359 | local peg_rev="${repo_uri##*@}" |
366 | local peg_rev="${repo_uri##*@}" |
| … | |
… | |
| 376 | debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" |
383 | debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" |
| 377 | |
384 | |
| 378 | return 0 |
385 | return 0 |
| 379 | } |
386 | } |
| 380 | |
387 | |
| 381 | |
|
|
| 382 | ## -- subversion__to_upper_case() ----------------------------------------- # |
388 | ## -- subversion__to_upper_case() ----------------------------------------- # |
| 383 | # |
389 | # |
| 384 | # @param $@ - the strings to upper case. |
390 | # param $@ - the strings to upper case. |
| 385 | # |
|
|
| 386 | function subversion__to_upper_case() { |
391 | subversion__to_upper_case() { |
| 387 | echo "${@}" | tr "[a-z]" "[A-Z]" |
392 | echo "${@}" | tr "[:lower:]" "[:upper:]" |
| 388 | } |
393 | } |