| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 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.41 2007/04/01 14:48:37 hattya Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.44 2007/07/03 08:27:40 peper 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 |
| … | |
… | |
| 19 | |
19 | |
| 20 | ESVN="subversion.eclass" |
20 | ESVN="subversion.eclass" |
| 21 | |
21 | |
| 22 | EXPORT_FUNCTIONS src_unpack |
22 | EXPORT_FUNCTIONS src_unpack |
| 23 | |
23 | |
| 24 | HOMEPAGE="http://subversion.tigris.org/" |
|
|
| 25 | DESCRIPTION="Based on the ${ECLASS} eclass" |
24 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 26 | |
25 | |
| 27 | |
26 | |
| 28 | ## -- add subversion in DEPEND |
27 | ## -- add subversion in DEPEND |
| 29 | # |
28 | # |
| … | |
… | |
| 46 | |
45 | |
| 47 | ## -- ESVN_OPTIONS: |
46 | ## -- ESVN_OPTIONS: |
| 48 | # |
47 | # |
| 49 | # the options passed to checkout or update. |
48 | # the options passed to checkout or update. |
| 50 | # |
49 | # |
| 51 | : ESVN_OPTIONS=${ESVN_OPTIONS:=} |
50 | : ${ESVN_OPTIONS=} |
| 52 | |
51 | |
| 53 | |
52 | |
| 54 | ## -- ESVN_REPO_URI: repository uri |
53 | ## -- ESVN_REPO_URI: repository uri |
| 55 | # |
54 | # |
| 56 | # e.g. http://foo/trunk, svn://bar/trunk |
55 | # e.g. http://foo/trunk, svn://bar/trunk |
| … | |
… | |
| 59 | # http:// |
58 | # http:// |
| 60 | # https:// |
59 | # https:// |
| 61 | # svn:// |
60 | # svn:// |
| 62 | # svn+ssh:// |
61 | # svn+ssh:// |
| 63 | # |
62 | # |
| 64 | : ESVN_REPO_URI=${ESVN_REPO_URI:=} |
63 | : ${ESVN_REPO_URI=} |
| 65 | |
64 | |
| 66 | |
65 | |
| 67 | ## -- ESVN_PROJECT: project name of your ebuild (= name space) |
66 | ## -- ESVN_PROJECT: project name of your ebuild (= name space) |
| 68 | # |
67 | # |
| 69 | # subversion eclass will check out the subversion repository like: |
68 | # subversion eclass will check out the subversion repository like: |
| … | |
… | |
| 82 | # # jakarta commons-loggin |
81 | # # jakarta commons-loggin |
| 83 | # ESVN_PROJECT=commons/logging |
82 | # ESVN_PROJECT=commons/logging |
| 84 | # |
83 | # |
| 85 | # default: ${PN/-svn}. |
84 | # default: ${PN/-svn}. |
| 86 | # |
85 | # |
| 87 | : ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}} |
86 | : ${ESVN_PROJECT:=${PN/-svn}} |
| 88 | |
87 | |
| 89 | |
88 | |
| 90 | ## -- ESVN_BOOTSTRAP: |
89 | ## -- ESVN_BOOTSTRAP: |
| 91 | # |
90 | # |
| 92 | # bootstrap script or command like autogen.sh or etc.. |
91 | # bootstrap script or command like autogen.sh or etc.. |
| 93 | # |
92 | # |
| 94 | : ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=} |
93 | : ${ESVN_BOOTSTRAP=} |
| 95 | |
94 | |
| 96 | |
95 | |
| 97 | ## -- ESVN_PATCHES: |
96 | ## -- ESVN_PATCHES: |
| 98 | # |
97 | # |
| 99 | # subversion eclass can apply pathces in subversion_bootstrap(). |
98 | # subversion eclass can apply pathces in subversion_bootstrap(). |
| 100 | # you can use regexp in this valiable like *.diff or *.patch or etc. |
99 | # you can use regexp in this variable like *.diff or *.patch or etc. |
| 101 | # NOTE: this patches will apply before eval ESVN_BOOTSTRAP. |
100 | # NOTE: patches will be applied before ESVN_BOOTSTRAP is processed. |
| 102 | # |
101 | # |
| 103 | # the process of applying the patch is: |
102 | # Patches are searched both in / and ${FILESDIR}, if not found in both locations, |
| 104 | # 1. just epatch it, if the patch exists in the path. |
103 | # the installation dies. |
| 105 | # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR. |
|
|
| 106 | # 3. die. |
|
|
| 107 | # |
104 | # |
| 108 | : ESVN_PATCHES=${ESVN_PATCHES:=} |
105 | : ${ESVN_PATCHES=} |
| 109 | |
106 | |
| 110 | |
107 | |
| 111 | ## -- ESVN_RESTRICT: |
108 | ## -- ESVN_RESTRICT: |
| 112 | # |
109 | # |
| 113 | # this should be a space delimited list of subversion eclass features to |
110 | # this should be a space delimited list of subversion eclass features to |
| 114 | # restrict. |
111 | # restrict. |
| 115 | # export) |
112 | # export) |
| 116 | # don't export the working copy to S. |
113 | # don't export the working copy to S. |
| 117 | # |
114 | # |
| 118 | : ESVN_RESTRICT=${ESVN_RESTRICT:=} |
115 | : ${ESVN_RESTRICT=} |
| 119 | |
116 | |
| 120 | |
117 | |
| 121 | ## -- subversion_fetch() ----------------------------------------------------- # |
118 | ## -- subversion_fetch() ----------------------------------------------------- # |
| 122 | # |
119 | # |
| 123 | # @param $1 - a repository URI. default is the ESVN_REPO_URI. |
120 | # @param $1 - a repository URI. default is the ESVN_REPO_URI. |
| 124 | # @param $2 - a check out path in S. |
121 | # @param $2 - a check out path in S. |
| 125 | # |
122 | # |
| 126 | function subversion_fetch() { |
123 | function subversion_fetch() { |
| 127 | |
|
|
| 128 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
124 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
| 129 | local S_dest="${2}" |
125 | local S_dest="${2}" |
| 130 | |
126 | |
| 131 | # check for the protocol |
127 | # check for the protocol |
| 132 | local protocol="${repo_uri%%:*}" |
128 | local protocol="${repo_uri%%:*}" |
| … | |
… | |
| 146 | *) |
142 | *) |
| 147 | die "${ESVN}: fetch from "${protocol}" is not yet implemented." |
143 | die "${ESVN}: fetch from "${protocol}" is not yet implemented." |
| 148 | ;; |
144 | ;; |
| 149 | esac |
145 | esac |
| 150 | |
146 | |
| 151 | # every time |
|
|
| 152 | addread "/etc/subversion" |
147 | addread "/etc/subversion" |
| 153 | addwrite "${ESVN_STORE_DIR}" |
148 | addwrite "${ESVN_STORE_DIR}" |
| 154 | |
149 | |
| 155 | if [[ ! -d "${ESVN_STORE_DIR}" ]]; then |
150 | if [[ ! -d "${ESVN_STORE_DIR}" ]]; then |
| 156 | debug-print "${FUNCNAME}: initial checkout. creating subversion directory" |
151 | debug-print "${FUNCNAME}: initial checkout. creating subversion directory" |
| … | |
… | |
| 175 | |
170 | |
| 176 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
171 | mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." |
| 177 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
172 | cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}" |
| 178 | ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." |
173 | ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}." |
| 179 | |
174 | |
|
|
175 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
| 180 | else |
176 | else |
| 181 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
177 | subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy." |
| 182 | |
|
|
| 183 | if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then |
178 | if [ "${ESVN_WC_URL}" != "$(subversion__get_repository_uri "${repo_uri}" 1)" ]; then |
| 184 | die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched." |
179 | die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched." |
| 185 | fi |
180 | fi |
| 186 | |
181 | |
| 187 | # update working copy |
182 | # update working copy |
| … | |
… | |
| 190 | |
185 | |
| 191 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
186 | debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}" |
| 192 | |
187 | |
| 193 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
188 | cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}" |
| 194 | ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." |
189 | ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}." |
| 195 | |
|
|
| 196 | fi |
190 | fi |
| 197 | |
191 | |
| 198 | einfo " working copy: ${wc_path}" |
192 | einfo " working copy: ${wc_path}" |
| 199 | |
193 | |
| 200 | if ! has "export" ${ESVN_RESTRICT}; then |
194 | if ! has "export" ${ESVN_RESTRICT}; then |
| … | |
… | |
| 207 | #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." |
201 | #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." |
| 208 | rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." |
202 | rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}." |
| 209 | fi |
203 | fi |
| 210 | |
204 | |
| 211 | echo |
205 | echo |
| 212 | |
|
|
| 213 | } |
206 | } |
| 214 | |
207 | |
| 215 | |
208 | |
| 216 | ## -- subversion_bootstrap() ------------------------------------------------ # |
209 | ## -- subversion_bootstrap() ------------------------------------------------ # |
| 217 | # |
210 | # |
| 218 | function subversion_bootstrap() { |
211 | function subversion_bootstrap() { |
| 219 | |
|
|
| 220 | if has "export" ${ESVN_RESTRICT}; then |
212 | if has "export" ${ESVN_RESTRICT}; then |
| 221 | return |
213 | return |
| 222 | fi |
214 | fi |
| 223 | |
215 | |
| 224 | cd "${S}" |
216 | cd "${S}" |
| 225 | |
217 | |
| 226 | if [[ -n "${ESVN_PATCHES}" ]]; then |
218 | if [[ -n "${ESVN_PATCHES}" ]]; then |
| 227 | einfo "apply patches -->" |
219 | einfo "apply patches -->" |
| 228 | |
220 | |
| 229 | local p= |
221 | local patch fpatch |
| 230 | |
|
|
| 231 | for p in ${ESVN_PATCHES}; do |
222 | for patch in ${ESVN_PATCHES}; do |
| 232 | if [[ -f "${p}" ]]; then |
223 | if [[ -f "${patch}" ]]; then |
| 233 | epatch "${p}" |
224 | epatch "${patch}" |
| 234 | |
|
|
| 235 | else |
225 | else |
| 236 | local q= |
|
|
| 237 | |
|
|
| 238 | for q in ${FILESDIR}/${p}; do |
226 | for fpatch in ${FILESDIR}/${patch}; do |
| 239 | if [[ -f "${q}" ]]; then |
227 | if [[ -f "${fpatch}" ]]; then |
| 240 | epatch "${q}" |
228 | epatch "${fpatch}" |
| 241 | |
|
|
| 242 | else |
229 | else |
| 243 | die "${ESVN}; ${p} is not found" |
230 | die "${ESVN}: ${patch} not found" |
| 244 | |
|
|
| 245 | fi |
231 | fi |
| 246 | done |
232 | done |
| 247 | fi |
233 | fi |
| 248 | done |
234 | done |
| 249 | |
|
|
| 250 | echo |
235 | echo |
| 251 | |
|
|
| 252 | fi |
236 | fi |
| 253 | |
237 | |
| 254 | if [[ -n "${ESVN_BOOTSTRAP}" ]]; then |
238 | if [[ -n "${ESVN_BOOTSTRAP}" ]]; then |
| 255 | einfo "begin bootstrap -->" |
239 | einfo "begin bootstrap -->" |
| 256 | |
240 | |
| 257 | if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then |
241 | if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then |
| 258 | einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" |
242 | einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" |
| 259 | eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." |
243 | eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." |
| 260 | |
|
|
| 261 | else |
244 | else |
| 262 | einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}" |
245 | einfo " bootstrap with command: ${ESVN_BOOTSTRAP}" |
| 263 | eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." |
246 | eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." |
| 264 | |
|
|
| 265 | fi |
247 | fi |
| 266 | fi |
248 | fi |
| 267 | |
|
|
| 268 | } |
249 | } |
| 269 | |
|
|
| 270 | |
250 | |
| 271 | ## -- subversion_src_unpack() ------------------------------------------------ # |
251 | ## -- subversion_src_unpack() ------------------------------------------------ # |
| 272 | # |
252 | # |
| 273 | function subversion_src_unpack() { |
253 | function subversion_src_unpack() { |
| 274 | |
|
|
| 275 | subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." |
254 | subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch." |
| 276 | subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." |
255 | subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap." |
| 277 | |
|
|
| 278 | } |
256 | } |
| 279 | |
257 | |
| 280 | |
258 | |
| 281 | ## -- subversion_wc_info() --------------------------------------------------- # |
259 | ## -- subversion_wc_info() --------------------------------------------------- # |
| 282 | # |
260 | # |
| 283 | # @param $1 - repository URI. default is ESVN_REPO_URI. |
261 | # @param $1 - repository URI. default is ESVN_REPO_URI. |
| 284 | # |
262 | # |
| 285 | function subversion_wc_info() { |
263 | function subversion_wc_info() { |
| 286 | |
|
|
| 287 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
264 | local repo_uri="$(subversion__get_repository_uri "${1}")" |
| 288 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
265 | local wc_path="$(subversion__get_wc_path "${repo_uri}")" |
| 289 | |
266 | |
| 290 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
267 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 291 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
268 | debug-print "${FUNCNAME}: wc_path = ${wc_path}" |
| … | |
… | |
| 293 | if [[ ! -e "${wc_path}" ]]; then |
270 | if [[ ! -e "${wc_path}" ]]; then |
| 294 | return 1 |
271 | return 1 |
| 295 | fi |
272 | fi |
| 296 | |
273 | |
| 297 | local k |
274 | local k |
| 298 | |
|
|
| 299 | for k in url revision; do |
275 | for k in url revision; do |
| 300 | export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" |
276 | export ESVN_WC_$(subversion__to_upper_case "${k}")="$(subversion__svn_info "${wc_path}" "${k}")" |
| 301 | done |
277 | done |
| 302 | |
|
|
| 303 | } |
278 | } |
| 304 | |
|
|
| 305 | |
279 | |
| 306 | ## -- Private Functions |
280 | ## -- Private Functions |
| 307 | |
281 | |
| 308 | |
282 | |
| 309 | ## -- subversion__svn_info() ------------------------------------------------- # |
283 | ## -- subversion__svn_info() ------------------------------------------------- # |
| 310 | # |
284 | # |
| 311 | # @param $1 - a target. |
285 | # @param $1 - a target. |
| 312 | # @param $2 - a key name. |
286 | # @param $2 - a key name. |
| 313 | # |
287 | # |
| 314 | function subversion__svn_info() { |
288 | function subversion__svn_info() { |
| 315 | |
|
|
| 316 | local target="${1}" |
289 | local target="${1}" |
| 317 | local key="${2}" |
290 | local key="${2}" |
| 318 | |
291 | |
| 319 | env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- |
292 | env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2- |
| 320 | |
|
|
| 321 | } |
293 | } |
| 322 | |
294 | |
| 323 | |
295 | |
| 324 | ## -- subversion__get_repository_uri() --------------------------------------- # |
296 | ## -- subversion__get_repository_uri() --------------------------------------- # |
| 325 | # |
297 | # |
| 326 | # @param $1 - a repository URI. |
298 | # @param $1 - a repository URI. |
| 327 | # @param $2 - a peg revision is deleted from a return value if this is |
299 | # @param $2 - a peg revision is deleted from a return value if this is |
| 328 | # specified. |
300 | # specified. |
| 329 | # |
301 | # |
| 330 | function subversion__get_repository_uri() { |
302 | function subversion__get_repository_uri() { |
| 331 | |
|
|
| 332 | local repo_uri="${1:-${ESVN_REPO_URI}}" |
303 | local repo_uri="${1:-${ESVN_REPO_URI}}" |
| 333 | local remove_peg_revision="${2}" |
304 | local remove_peg_revision="${2}" |
| 334 | |
305 | |
| 335 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
306 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 336 | debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}" |
307 | debug-print "${FUNCNAME}: remove_peg_revision = ${remove_peg_revision}" |
| … | |
… | |
| 352 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
323 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 353 | fi |
324 | fi |
| 354 | fi |
325 | fi |
| 355 | |
326 | |
| 356 | echo "${repo_uri}" |
327 | echo "${repo_uri}" |
| 357 | |
|
|
| 358 | } |
328 | } |
| 359 | |
329 | |
| 360 | |
330 | |
| 361 | ## -- subversion__get_wc_path() ---------------------------------------------- # |
331 | ## -- subversion__get_wc_path() ---------------------------------------------- # |
| 362 | # |
332 | # |
| 363 | # @param $1 - a repository URI. |
333 | # @param $1 - a repository URI. |
| 364 | # |
334 | # |
| 365 | function subversion__get_wc_path() { |
335 | function subversion__get_wc_path() { |
| 366 | |
|
|
| 367 | local repo_uri="$(subversion__get_repository_uri "${1}" 1)" |
336 | local repo_uri="$(subversion__get_repository_uri "${1}" 1)" |
| 368 | |
337 | |
| 369 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
338 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 370 | |
339 | |
| 371 | echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" |
340 | echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}" |
| 372 | |
|
|
| 373 | } |
341 | } |
| 374 | |
342 | |
| 375 | |
343 | |
| 376 | ## -- subversion__has_peg_revision() ----------------------------------------- # |
344 | ## -- subversion__has_peg_revision() ----------------------------------------- # |
| 377 | # |
345 | # |
| 378 | # @param $1 - a repository URI. |
346 | # @param $1 - a repository URI. |
| 379 | # |
347 | # |
| 380 | function subversion__has_peg_revision() { |
348 | function subversion__has_peg_revision() { |
| 381 | |
|
|
| 382 | local repo_uri="${1}" |
349 | local repo_uri="${1}" |
| 383 | |
350 | |
| 384 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
351 | debug-print "${FUNCNAME}: repo_uri = ${repo_uri}" |
| 385 | |
352 | |
| 386 | # repo_uri has peg revision ? |
353 | # repo_uri has peg revision ? |
| … | |
… | |
| 407 | esac |
374 | esac |
| 408 | |
375 | |
| 409 | debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" |
376 | debug-print "${FUNCNAME}: peg_rev = ${peg_rev}" |
| 410 | |
377 | |
| 411 | return 0 |
378 | return 0 |
| 412 | |
|
|
| 413 | } |
379 | } |
| 414 | |
380 | |
| 415 | |
381 | |
| 416 | ## -- subversion__to_upper_case() ----------------------------------------- # |
382 | ## -- subversion__to_upper_case() ----------------------------------------- # |
| 417 | # |
383 | # |