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

Diff of /eclass/subversion.eclass

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

Revision 1.44 Revision 1.45
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.45 2008/02/17 07:59:06 hattya Exp $
4 4
5## --------------------------------------------------------------------------- # 5## --------------------------------------------------------------------------- #
6# Author: Akinori Hattori <hattya@gentoo.org> 6# Author: Akinori Hattori <hattya@gentoo.org>
7# 7#
8# The subversion eclass is written to fetch the software sources from 8# The subversion eclass is written to fetch the software sources from
29DEPEND="dev-util/subversion" 29DEPEND="dev-util/subversion"
30 30
31 31
32## -- ESVN_STORE_DIR: subversion sources store directory 32## -- ESVN_STORE_DIR: subversion sources store directory
33# 33#
34ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src" 34[ -z "${ESVN_STORE_DIR}" ] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
35 35
36 36
37## -- ESVN_FETCH_CMD: subversion fetch command 37## -- ESVN_FETCH_CMD: subversion fetch command
38# 38#
39ESVN_FETCH_CMD="svn checkout" 39ESVN_FETCH_CMD="svn checkout"
45 45
46## -- ESVN_OPTIONS: 46## -- ESVN_OPTIONS:
47# 47#
48# the options passed to checkout or update. 48# the options passed to checkout or update.
49# 49#
50: ${ESVN_OPTIONS=} 50: ${ESVN_OPTIONS:=}
51 51
52 52
53## -- ESVN_REPO_URI: repository uri 53## -- ESVN_REPO_URI: repository uri
54# 54#
55# e.g. http://foo/trunk, svn://bar/trunk 55# e.g. http://foo/trunk, svn://bar/trunk
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: ${ESVN_REPO_URI:=}
64 64
65 65
66## -- ESVN_PROJECT: project name of your ebuild (= name space) 66## -- ESVN_PROJECT: project name of your ebuild (= name space)
67# 67#
68# subversion eclass will check out the subversion repository like: 68# subversion eclass will check out the subversion repository like:
88 88
89## -- ESVN_BOOTSTRAP: 89## -- ESVN_BOOTSTRAP:
90# 90#
91# bootstrap script or command like autogen.sh or etc.. 91# bootstrap script or command like autogen.sh or etc..
92# 92#
93: ${ESVN_BOOTSTRAP=} 93: ${ESVN_BOOTSTRAP:=}
94 94
95 95
96## -- ESVN_PATCHES: 96## -- ESVN_PATCHES:
97# 97#
98# subversion eclass can apply pathces in subversion_bootstrap(). 98# subversion eclass can apply pathces in subversion_bootstrap().
99# you can use regexp in this variable like *.diff or *.patch or etc. 99# you can use regexp in this variable like *.diff or *.patch or etc.
100# NOTE: patches will be applied before ESVN_BOOTSTRAP is processed. 100# NOTE: patches will be applied before ESVN_BOOTSTRAP is processed.
101# 101#
102# Patches are searched both in / and ${FILESDIR}, if not found in both locations, 102# the process of applying the patch is:
103# the installation dies. 103# 1. just epatch it, if the patch exists in the path.
104# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
105# 3. die.
104# 106#
105: ${ESVN_PATCHES=} 107: ${ESVN_PATCHES:=}
106 108
107 109
108## -- ESVN_RESTRICT: 110## -- ESVN_RESTRICT:
109# 111#
110# this should be a space delimited list of subversion eclass features to 112# this should be a space delimited list of subversion eclass features to
111# restrict. 113# restrict.
112# export) 114# export)
113# don't export the working copy to S. 115# don't export the working copy to S.
114# 116#
115: ${ESVN_RESTRICT=} 117: ${ESVN_RESTRICT:=}
116 118
117 119
118## -- subversion_fetch() ----------------------------------------------------- # 120## -- subversion_fetch() ----------------------------------------------------- #
119# 121#
120# @param $1 - a repository URI. default is the ESVN_REPO_URI. 122# @param $1 - a repository URI. default is the ESVN_REPO_URI.
121# @param $2 - a check out path in S. 123# @param $2 - a check out path in S.
122# 124#
123function subversion_fetch() { 125function subversion_fetch() {
126
124 local repo_uri="$(subversion__get_repository_uri "${1}")" 127 local repo_uri="$(subversion__get_repository_uri "${1}")"
125 local S_dest="${2}" 128 local S_dest="${2}"
126 129
127 # check for the protocol 130 # check for the protocol
128 local protocol="${repo_uri%%:*}" 131 local protocol="${repo_uri%%:*}"
142 *) 145 *)
143 die "${ESVN}: fetch from "${protocol}" is not yet implemented." 146 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
144 ;; 147 ;;
145 esac 148 esac
146 149
150 # every time
147 addread "/etc/subversion" 151 addread "/etc/subversion"
148 addwrite "${ESVN_STORE_DIR}" 152 addwrite "${ESVN_STORE_DIR}"
149 153
150 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then 154 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
151 debug-print "${FUNCNAME}: initial checkout. creating subversion directory" 155 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
170 174
171 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 175 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
172 cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" 176 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}." 177 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
174 178
175 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
176 else 179 else
177 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." 180 subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
181
178 if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then 182 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." 183 die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched."
180 fi 184 fi
181 185
182 # update working copy 186 # update working copy
185 189
186 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" 190 debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
187 191
188 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" 192 cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
189 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." 193 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}."
194
190 fi 195 fi
191 196
192 einfo " working copy: ${wc_path}" 197 einfo " working copy: ${wc_path}"
193 198
194 if ! has "export" ${ESVN_RESTRICT}; then 199 if ! has "export" ${ESVN_RESTRICT}; then
201 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." 206 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
202 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." 207 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
203 fi 208 fi
204 209
205 echo 210 echo
211
206} 212}
207 213
208 214
209## -- subversion_bootstrap() ------------------------------------------------ # 215## -- subversion_bootstrap() ------------------------------------------------ #
210# 216#
211function subversion_bootstrap() { 217function subversion_bootstrap() {
218
212 if has "export" ${ESVN_RESTRICT}; then 219 if has "export" ${ESVN_RESTRICT}; then
213 return 220 return
214 fi 221 fi
215 222
216 cd "${S}" 223 cd "${S}"
217 224
218 if [[ -n "${ESVN_PATCHES}" ]]; then 225 if [[ -n "${ESVN_PATCHES}" ]]; then
219 einfo "apply patches -->" 226 einfo "apply patches -->"
220 227
221 local patch fpatch 228 local patch fpatch
229
222 for patch in ${ESVN_PATCHES}; do 230 for patch in ${ESVN_PATCHES}; do
223 if [[ -f "${patch}" ]]; then 231 if [[ -f "${patch}" ]]; then
224 epatch "${patch}" 232 epatch "${patch}"
233
225 else 234 else
226 for fpatch in ${FILESDIR}/${patch}; do 235 for fpatch in ${FILESDIR}/${patch}; do
227 if [[ -f "${fpatch}" ]]; then 236 if [[ -f "${fpatch}" ]]; then
228 epatch "${fpatch}" 237 epatch "${fpatch}"
238
229 else 239 else
230 die "${ESVN}: ${patch} not found" 240 die "${ESVN}: ${patch} not found"
241
231 fi 242 fi
232 done 243 done
244
233 fi 245 fi
234 done 246 done
247
235 echo 248 echo
236 fi 249 fi
237 250
238 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then 251 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
239 einfo "begin bootstrap -->" 252 einfo "begin bootstrap -->"
240 253
241 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then 254 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
242 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" 255 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
243 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." 256 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
257
244 else 258 else
245 einfo " bootstrap with command: ${ESVN_BOOTSTRAP}" 259 einfo " bootstrap with command: ${ESVN_BOOTSTRAP}"
246 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 260 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
261
247 fi 262 fi
248 fi 263 fi
264
249} 265}
266
250 267
251## -- subversion_src_unpack() ------------------------------------------------ # 268## -- subversion_src_unpack() ------------------------------------------------ #
252# 269#
253function subversion_src_unpack() { 270function subversion_src_unpack() {
271
254 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." 272 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
255 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." 273 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
274
256} 275}
257 276
258 277
259## -- subversion_wc_info() --------------------------------------------------- # 278## -- subversion_wc_info() --------------------------------------------------- #
260# 279#
280# the working copy information on the specified repository URI are set to
281# ESVN_WC_* variables.
282#
283# the available variables:
284# ESVN_WC_URL
285# ESVN_WC_REVISION
286# ESVN_WC_PATH
287#
261# @param $1 - repository URI. default is ESVN_REPO_URI. 288# @param $1 - repository URI. default is ESVN_REPO_URI.
262# 289#
263function subversion_wc_info() { 290function subversion_wc_info() {
291
264 local repo_uri="$(subversion__get_repository_uri "${1}")" 292 local repo_uri="$(subversion__get_repository_uri "${1}")"
265 local wc_path="$(subversion__get_wc_path "${repo_uri}")" 293 local wc_path="$(subversion__get_wc_path "${repo_uri}")"
266 294
267 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 295 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
268 debug-print "${FUNCNAME}: wc_path = ${wc_path}" 296 debug-print "${FUNCNAME}: wc_path = ${wc_path}"
269 297
270 if [[ ! -e "${wc_path}" ]]; then 298 if [[ ! -d "${wc_path}" ]]; then
271 return 1 299 return 1
272 fi 300 fi
273 301
274 local k 302 local k
303
275 for k in url revision; do 304 for k in url revision; do
276 export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" 305 export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")"
277 done 306 done
307
308 export ESVN_WC_PATH="${wc_path}"
309
278} 310}
311
279 312
280## -- Private Functions 313## -- Private Functions
281 314
282 315
283## -- subversion__svn_info() ------------------------------------------------- # 316## -- subversion__svn_info() ------------------------------------------------- #
284# 317#
285# @param $1 - a target. 318# @param $1 - a target.
286# @param $2 - a key name. 319# @param $2 - a key name.
287# 320#
288function subversion__svn_info() { 321function subversion__svn_info() {
322
289 local target="${1}" 323 local target="${1}"
290 local key="${2}" 324 local key="${2}"
291 325
292 env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- 326 env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2-
327
293} 328}
294 329
295 330
296## -- subversion__get_repository_uri() --------------------------------------- # 331## -- subversion__get_repository_uri() --------------------------------------- #
297# 332#
298# @param $1 - a repository URI. 333# @param $1 - a repository URI.
299# @param $2 - a peg revision is deleted from a return value if this is 334# @param $2 - a peg revision is deleted from a return value if this is
300# specified. 335# specified.
301# 336#
302function subversion__get_repository_uri() { 337function subversion__get_repository_uri() {
338
303 local repo_uri="${1:-${ESVN_REPO_URI}}" 339 local repo_uri="${1:-${ESVN_REPO_URI}}"
304 local remove_peg_revision="${2}" 340 local remove_peg_revision="${2}"
305 341
306 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 342 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
307 debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}" 343 debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}"
323 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 359 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
324 fi 360 fi
325 fi 361 fi
326 362
327 echo "${repo_uri}" 363 echo "${repo_uri}"
364
328} 365}
329 366
330 367
331## -- subversion__get_wc_path() ---------------------------------------------- # 368## -- subversion__get_wc_path() ---------------------------------------------- #
332# 369#
333# @param $1 - a repository URI. 370# @param $1 - a repository URI.
334# 371#
335function subversion__get_wc_path() { 372function subversion__get_wc_path() {
373
336 local repo_uri="$(subversion__get_repository_uri "${1}" 1)" 374 local repo_uri="$(subversion__get_repository_uri "${1}" 1)"
337 375
338 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 376 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
339 377
340 echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" 378 echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
379
341} 380}
342 381
343 382
344## -- subversion__has_peg_revision() ----------------------------------------- # 383## -- subversion__has_peg_revision() ----------------------------------------- #
345# 384#
346# @param $1 - a repository URI. 385# @param $1 - a repository URI.
347# 386#
348function subversion__has_peg_revision() { 387function subversion__has_peg_revision() {
388
349 local repo_uri="${1}" 389 local repo_uri="${1}"
350 390
351 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" 391 debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
352 392
353 # repo_uri has peg revision ? 393 # repo_uri has peg revision ?
374 esac 414 esac
375 415
376 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" 416 debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
377 417
378 return 0 418 return 0
419
379} 420}
380 421
381 422
382## -- subversion__to_upper_case() ----------------------------------------- # 423## -- subversion__to_upper_case() ----------------------------------------- #
383# 424#
384# @param $@ - the strings to upper case. 425# @param $@ - the strings to upper case.
385# 426#
386function subversion__to_upper_case() { 427function subversion__to_upper_case() {
387 echo "${@}" | tr "[a-z]" "[A-Z]" 428
429 echo "${@}" | tr "[:lower:]" "[:upper:]"
430
388} 431}

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20