/[gentoo-x86]/eclass/git-2.eclass
Gentoo

Contents of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.33 - (show annotations) (download)
Tue Oct 8 11:19:48 2013 UTC (9 months, 2 weeks ago) by mgorny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.32: +2 -1 lines
Fix git-r3 -> git-2 dependency leak, as noted in bug #487026.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.32 2013/09/08 22:54:24 mgorny Exp $
4
5 # @ECLASS: git-2.eclass
6 # @MAINTAINER:
7 # Michał Górny <mgorny@gentoo.org>
8 # Donnie Berkholz <dberkholz@gentoo.org>
9 # @BLURB: Eclass for fetching and unpacking git repositories.
10 # @DESCRIPTION:
11 # Eclass for easing maitenance of live ebuilds using git as remote repository.
12 # Eclass support working with git submodules and branching.
13
14 # @ECLASS-VARIABLE: EGIT_USE_GIT_R3
15 # @DEFAULT_UNSET
16 # @DESCRIPTION:
17 # Use git-r3 backend instead of classic git-2 behavior. This is intended
18 # for early testing of git-r3 and is to be set in make.conf.
19
20 # (since we override src_unpack this doesn't hurt)
21 _INHERITED_BY_GIT_2=1 \
22 inherit git-r3
23
24 # This eclass support all EAPIs
25 EXPORT_FUNCTIONS src_unpack
26
27 DEPEND="dev-vcs/git"
28
29 # @ECLASS-VARIABLE: EGIT_SOURCEDIR
30 # @DESCRIPTION:
31 # This variable specifies destination where the cloned
32 # data are copied to.
33 #
34 # EGIT_SOURCEDIR="${S}"
35
36 # @ECLASS-VARIABLE: EGIT_STORE_DIR
37 # @DESCRIPTION:
38 # Storage directory for git sources.
39 #
40 # EGIT_STORE_DIR="${DISTDIR}/egit-src"
41
42 # @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
43 # @DEFAULT_UNSET
44 # @DESCRIPTION:
45 # If non-empty this variable enables support for git submodules in our
46 # checkout. Also this makes the checkout to be non-bare for now.
47
48 # @ECLASS-VARIABLE: EGIT_OPTIONS
49 # @DEFAULT_UNSET
50 # @DESCRIPTION:
51 # Variable specifying additional options for fetch command.
52
53 # @ECLASS-VARIABLE: EGIT_MASTER
54 # @DESCRIPTION:
55 # Variable for specifying master branch.
56 # Usefull when upstream don't have master branch or name it differently.
57 #
58 # EGIT_MASTER="master"
59
60 # @ECLASS-VARIABLE: EGIT_PROJECT
61 # @DESCRIPTION:
62 # Variable specifying name for the folder where we check out the git
63 # repository. Value of this variable should be unique in the
64 # EGIT_STORE_DIR as otherwise you would override another repository.
65 #
66 # EGIT_PROJECT="${EGIT_REPO_URI##*/}"
67
68 # @ECLASS-VARIABLE: EGIT_DIR
69 # @DESCRIPTION:
70 # Directory where we want to store the git data.
71 # This variable should not be overriden.
72 #
73 # EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}"
74
75 # @ECLASS-VARIABLE: EGIT_REPO_URI
76 # @REQUIRED
77 # @DEFAULT_UNSET
78 # @DESCRIPTION:
79 # URI for the repository
80 # e.g. http://foo, git://bar
81 #
82 # It can be overriden via env using packagename_LIVE_REPO
83 # variable.
84 #
85 # Support multiple values:
86 # EGIT_REPO_URI="git://a/b.git http://c/d.git"
87
88 # @ECLASS-VARIABLE: EVCS_OFFLINE
89 # @DEFAULT_UNSET
90 # @DESCRIPTION:
91 # If non-empty this variable prevents performance of any online
92 # operations.
93
94 # @ECLASS-VARIABLE: EGIT_BRANCH
95 # @DESCRIPTION:
96 # Variable containing branch name we want to check out.
97 # It can be overriden via env using packagename_LIVE_BRANCH
98 # variable.
99 #
100 # EGIT_BRANCH="${EGIT_MASTER}"
101
102 # @ECLASS-VARIABLE: EGIT_COMMIT
103 # @DESCRIPTION:
104 # Variable containing commit hash/tag we want to check out.
105 # It can be overriden via env using packagename_LIVE_COMMIT
106 # variable.
107 #
108 # EGIT_COMMIT="${EGIT_BRANCH}"
109
110 # @ECLASS-VARIABLE: EGIT_REPACK
111 # @DEFAULT_UNSET
112 # @DESCRIPTION:
113 # If non-empty this variable specifies that repository will be repacked to
114 # save space. However this can take a REALLY LONG time with VERY big
115 # repositories.
116
117 # @ECLASS-VARIABLE: EGIT_PRUNE
118 # @DEFAULT_UNSET
119 # @DESCRIPTION:
120 # If non-empty this variable enables pruning all loose objects on each fetch.
121 # This is useful if upstream rewinds and rebases branches often.
122
123 # @ECLASS-VARIABLE: EGIT_NONBARE
124 # @DEFAULT_UNSET
125 # @DESCRIPTION:
126 # If non-empty this variable specifies that all checkouts will be done using
127 # non bare repositories. This is useful if you can't operate with bare
128 # checkouts for some reason.
129
130 # @ECLASS-VARIABLE: EGIT_NOUNPACK
131 # @DEFAULT_UNSET
132 # @DESCRIPTION:
133 # If non-empty this variable bans unpacking of ${A} content into the srcdir.
134 # Default behaviour is to unpack ${A} content.
135
136 # @FUNCTION: git-2_init_variables
137 # @INTERNAL
138 # @DESCRIPTION:
139 # Internal function initializing all git variables.
140 # We define it in function scope so user can define
141 # all the variables before and after inherit.
142 git-2_init_variables() {
143 debug-print-function ${FUNCNAME} "$@"
144
145 local esc_pn liverepo livebranch livecommit
146 esc_pn=${PN//[-+]/_}
147
148 : ${EGIT_SOURCEDIR="${S}"}
149
150 : ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/egit-src"}
151
152 : ${EGIT_HAS_SUBMODULES:=}
153
154 : ${EGIT_OPTIONS:=}
155
156 : ${EGIT_MASTER:=master}
157
158 liverepo=${esc_pn}_LIVE_REPO
159 EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
160 [[ ${EGIT_REPO_URI} ]] || die "EGIT_REPO_URI must have some value"
161
162 : ${EVCS_OFFLINE:=}
163
164 livebranch=${esc_pn}_LIVE_BRANCH
165 [[ ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
166 EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
167
168 livecommit=${esc_pn}_LIVE_COMMIT
169 [[ ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
170 EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
171
172 : ${EGIT_REPACK:=}
173
174 : ${EGIT_PRUNE:=}
175 }
176
177 # @FUNCTION: git-2_submodules
178 # @INTERNAL
179 # @DESCRIPTION:
180 # Internal function wrapping the submodule initialisation and update.
181 git-2_submodules() {
182 debug-print-function ${FUNCNAME} "$@"
183 if [[ ${EGIT_HAS_SUBMODULES} ]]; then
184 if [[ ${EVCS_OFFLINE} ]]; then
185 # for submodules operations we need to be online
186 debug-print "${FUNCNAME}: not updating submodules in offline mode"
187 return 1
188 fi
189
190 debug-print "${FUNCNAME}: working in \"${1}\""
191 pushd "${EGIT_DIR}" > /dev/null
192
193 debug-print "${FUNCNAME}: git submodule init"
194 git submodule init || die
195 debug-print "${FUNCNAME}: git submodule sync"
196 git submodule sync || die
197 debug-print "${FUNCNAME}: git submodule update"
198 git submodule update || die
199
200 popd > /dev/null
201 fi
202 }
203
204 # @FUNCTION: git-2_branch
205 # @INTERNAL
206 # @DESCRIPTION:
207 # Internal function that changes branch for the repo based on EGIT_COMMIT and
208 # EGIT_BRANCH variables.
209 git-2_branch() {
210 debug-print-function ${FUNCNAME} "$@"
211
212 local branchname src
213
214 debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\""
215 pushd "${EGIT_SOURCEDIR}" > /dev/null
216
217 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
218 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then
219 branchname=tree-${EGIT_COMMIT}
220 src=${EGIT_COMMIT}
221 fi
222 debug-print "${FUNCNAME}: git checkout -b ${branchname} ${src}"
223 git checkout -b ${branchname} ${src} \
224 || die "${FUNCNAME}: changing the branch failed"
225
226 popd > /dev/null
227 }
228
229 # @FUNCTION: git-2_gc
230 # @INTERNAL
231 # @DESCRIPTION:
232 # Internal function running garbage collector on checked out tree.
233 git-2_gc() {
234 debug-print-function ${FUNCNAME} "$@"
235
236 local args
237
238 if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
239 pushd "${EGIT_DIR}" > /dev/null
240 ebegin "Garbage collecting the repository"
241 [[ ${EGIT_PRUNE} ]] && args='--prune'
242 debug-print "${FUNCNAME}: git gc ${args}"
243 git gc ${args}
244 eend $?
245 popd > /dev/null
246 fi
247 }
248
249 # @FUNCTION: git-2_prepare_storedir
250 # @INTERNAL
251 # @DESCRIPTION:
252 # Internal function preparing directory where we are going to store SCM
253 # repository.
254 git-2_prepare_storedir() {
255 debug-print-function ${FUNCNAME} "$@"
256
257 local clone_dir
258
259 # initial clone, we have to create master git storage directory and play
260 # nicely with sandbox
261 if [[ ! -d ${EGIT_STORE_DIR} ]]; then
262 debug-print "${FUNCNAME}: Creating git main storage directory"
263 addwrite /
264 mkdir -m 775 -p "${EGIT_STORE_DIR}" \
265 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\""
266 fi
267
268 # allow writing into EGIT_STORE_DIR
269 addwrite "${EGIT_STORE_DIR}"
270
271 # calculate git.eclass store dir for data
272 # We will try to clone the old repository,
273 # and we will remove it if we don't need it anymore.
274 EGIT_OLD_CLONE=
275 if [[ ${EGIT_STORE_DIR} == */egit-src ]]; then
276 local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
277 local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
278
279 if [[ -d ${old_location} ]]; then
280 EGIT_OLD_CLONE=${old_location}
281 # required to remove the old clone
282 addwrite "${old_store_dir}"
283 fi
284 fi
285
286 # calculate the proper store dir for data
287 # If user didn't specify the EGIT_DIR, we check if he did specify
288 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
289 EGIT_REPO_URI=${EGIT_REPO_URI%/}
290 if [[ ! ${EGIT_DIR} ]]; then
291 if [[ ${EGIT_PROJECT} ]]; then
292 clone_dir=${EGIT_PROJECT}
293 else
294 local strippeduri=${EGIT_REPO_URI%/.git}
295 clone_dir=${strippeduri##*/}
296 fi
297 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
298
299 if [[ ${EGIT_OLD_CLONE} && ! -d ${EGIT_DIR} ]]; then
300 elog "${FUNCNAME}: ${CATEGORY}/${PF} will be cloned from old location."
301 elog "It will be necessary to rebuild the package to fetch updates."
302 EGIT_REPO_URI="${EGIT_OLD_CLONE} ${EGIT_REPO_URI}"
303 fi
304 fi
305 export EGIT_DIR=${EGIT_DIR}
306 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
307 }
308
309 # @FUNCTION: git-2_move_source
310 # @INTERNAL
311 # @DESCRIPTION:
312 # Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
313 git-2_move_source() {
314 debug-print-function ${FUNCNAME} "$@"
315
316 debug-print "${FUNCNAME}: ${MOVE_COMMAND} \"${EGIT_DIR}\" \"${EGIT_SOURCEDIR}\""
317 pushd "${EGIT_DIR}" > /dev/null
318 mkdir -p "${EGIT_SOURCEDIR}" \
319 || die "${FUNCNAME}: failed to create ${EGIT_SOURCEDIR}"
320 ${MOVE_COMMAND} "${EGIT_SOURCEDIR}" \
321 || die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed"
322 popd > /dev/null
323 }
324
325 # @FUNCTION: git-2_initial_clone
326 # @INTERNAL
327 # @DESCRIPTION:
328 # Internal function running initial clone on specified repo_uri.
329 git-2_initial_clone() {
330 debug-print-function ${FUNCNAME} "$@"
331
332 local repo_uri
333
334 EGIT_REPO_URI_SELECTED=""
335 for repo_uri in ${EGIT_REPO_URI}; do
336 debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
337 if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
338 # global variable containing the repo_name we will be using
339 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
340 EGIT_REPO_URI_SELECTED="${repo_uri}"
341 break
342 fi
343 done
344
345 [[ ${EGIT_REPO_URI_SELECTED} ]] \
346 || die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
347 }
348
349 # @FUNCTION: git-2_update_repo
350 # @INTERNAL
351 # @DESCRIPTION:
352 # Internal function running update command on specified repo_uri.
353 git-2_update_repo() {
354 debug-print-function ${FUNCNAME} "$@"
355
356 local repo_uri
357
358 if [[ ${EGIT_LOCAL_NONBARE} ]]; then
359 # checkout master branch and drop all other local branches
360 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
361 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
362 debug-print "${FUNCNAME}: git branch -D ${x}"
363 git branch -D ${x} > /dev/null
364 done
365 fi
366
367 EGIT_REPO_URI_SELECTED=""
368 for repo_uri in ${EGIT_REPO_URI}; do
369 # git urls might change, so reset it
370 git config remote.origin.url "${repo_uri}"
371
372 debug-print "${EGIT_UPDATE_CMD}"
373 if ${EGIT_UPDATE_CMD} > /dev/null; then
374 # global variable containing the repo_name we will be using
375 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
376 EGIT_REPO_URI_SELECTED="${repo_uri}"
377 break
378 fi
379 done
380
381 [[ ${EGIT_REPO_URI_SELECTED} ]] \
382 || die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
383 }
384
385 # @FUNCTION: git-2_fetch
386 # @INTERNAL
387 # @DESCRIPTION:
388 # Internal function fetching repository from EGIT_REPO_URI and storing it in
389 # specified EGIT_STORE_DIR.
390 git-2_fetch() {
391 debug-print-function ${FUNCNAME} "$@"
392
393 local oldsha cursha repo_type
394
395 [[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
396
397 if [[ ! -d ${EGIT_DIR} ]]; then
398 git-2_initial_clone
399 pushd "${EGIT_DIR}" > /dev/null
400 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
401 echo "GIT NEW clone -->"
402 echo " repository: ${EGIT_REPO_URI_SELECTED}"
403 echo " at the commit: ${cursha}"
404
405 popd > /dev/null
406 elif [[ ${EVCS_OFFLINE} ]]; then
407 pushd "${EGIT_DIR}" > /dev/null
408 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
409 echo "GIT offline update -->"
410 echo " repository: $(git config remote.origin.url)"
411 echo " at the commit: ${cursha}"
412 popd > /dev/null
413 else
414 pushd "${EGIT_DIR}" > /dev/null
415 oldsha=$(git rev-parse ${UPSTREAM_BRANCH})
416 git-2_update_repo
417 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
418
419 # fetch updates
420 echo "GIT update -->"
421 echo " repository: ${EGIT_REPO_URI_SELECTED}"
422 # write out message based on the revisions
423 if [[ "${oldsha}" != "${cursha}" ]]; then
424 echo " updating from commit: ${oldsha}"
425 echo " to commit: ${cursha}"
426 else
427 echo " at the commit: ${cursha}"
428 fi
429
430 # print nice statistic of what was changed
431 git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH}
432 popd > /dev/null
433 fi
434 # export the version the repository is at
435 export EGIT_VERSION="${cursha}"
436 # log the repo state
437 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
438 && echo " commit: ${EGIT_COMMIT}"
439 echo " branch: ${EGIT_BRANCH}"
440 echo " storage directory: \"${EGIT_DIR}\""
441 echo " checkout type: ${repo_type}"
442
443 # Cleanup after git.eclass
444 if [[ ${EGIT_OLD_CLONE} ]]; then
445 einfo "${FUNCNAME}: removing old clone in ${EGIT_OLD_CLONE}."
446 rm -rf "${EGIT_OLD_CLONE}"
447 fi
448 }
449
450 # @FUNCTION: git_bootstrap
451 # @INTERNAL
452 # @DESCRIPTION:
453 # Internal function that runs bootstrap command on unpacked source.
454 git-2_bootstrap() {
455 debug-print-function ${FUNCNAME} "$@"
456
457 # @ECLASS-VARIABLE: EGIT_BOOTSTRAP
458 # @DESCRIPTION:
459 # Command to be executed after checkout and clone of the specified
460 # repository.
461 # enviroment the package will fail if there is no update, thus in
462 # combination with --keep-going it would lead in not-updating
463 # pakcages that are up-to-date.
464 if [[ ${EGIT_BOOTSTRAP} ]]; then
465 pushd "${EGIT_SOURCEDIR}" > /dev/null
466 einfo "Starting bootstrap"
467
468 if [[ -f ${EGIT_BOOTSTRAP} ]]; then
469 # we have file in the repo which we should execute
470 debug-print "${FUNCNAME}: bootstraping with file \"${EGIT_BOOTSTRAP}\""
471
472 if [[ -x ${EGIT_BOOTSTRAP} ]]; then
473 eval "./${EGIT_BOOTSTRAP}" \
474 || die "${FUNCNAME}: bootstrap script failed"
475 else
476 eerror "\"${EGIT_BOOTSTRAP}\" is not executable."
477 eerror "Report upstream, or bug ebuild maintainer to remove bootstrap command."
478 die "\"${EGIT_BOOTSTRAP}\" is not executable"
479 fi
480 else
481 # we execute some system command
482 debug-print "${FUNCNAME}: bootstraping with commands \"${EGIT_BOOTSTRAP}\""
483
484 eval "${EGIT_BOOTSTRAP}" \
485 || die "${FUNCNAME}: bootstrap commands failed"
486 fi
487
488 einfo "Bootstrap finished"
489 popd > /dev/null
490 fi
491 }
492
493 # @FUNCTION: git-2_migrate_repository
494 # @INTERNAL
495 # @DESCRIPTION:
496 # Internal function migrating between bare and normal checkout repository.
497 # This is based on usage of EGIT_SUBMODULES, at least until they
498 # start to work with bare checkouts sanely.
499 # This function also set some global variables that differ between
500 # bare and non-bare checkout.
501 git-2_migrate_repository() {
502 debug-print-function ${FUNCNAME} "$@"
503
504 local bare returnstate
505
506 # first find out if we have submodules
507 # or user explicitly wants us to use non-bare clones
508 if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
509 bare=1
510 fi
511
512 # test if we already have some repo and if so find out if we have
513 # to migrate the data
514 if [[ -d ${EGIT_DIR} ]]; then
515 if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
516 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
517
518 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
519 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
520 export GIT_DIR="${EGIT_DIR}.bare"
521 git config core.bare true > /dev/null
522 returnstate=$?
523 unset GIT_DIR
524 rm -rf "${EGIT_DIR}"
525 mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
526 eend ${returnstate}
527 elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
528 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
529
530 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
531 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
532 returnstate=$?
533 rm -rf "${EGIT_DIR}"
534 mv "${EGIT_DIR}.nonbare" "${EGIT_DIR}"
535 eend ${returnstate}
536 fi
537 fi
538 if [[ ${returnstate} -ne 0 ]]; then
539 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" failed, removing to start from scratch"
540
541 # migration failed, remove the EGIT_DIR to play it safe
542 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
543 rm -rf "${EGIT_DIR}"
544 fi
545
546 # set various options to work with both targets
547 if [[ ${bare} ]]; then
548 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
549 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
550 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
551 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
552 UPSTREAM_BRANCH="${EGIT_BRANCH}"
553 EGIT_LOCAL_NONBARE=
554 else
555 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
556 MOVE_COMMAND="cp -pPR ."
557 EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
558 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
559 UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
560 EGIT_LOCAL_NONBARE="true"
561 fi
562 }
563
564 # @FUNCTION: git-2_cleanup
565 # @INTERNAL
566 # @DESCRIPTION:
567 # Internal function cleaning up all the global variables
568 # that are not required after the unpack has been done.
569 git-2_cleanup() {
570 debug-print-function ${FUNCNAME} "$@"
571
572 # Here we can unset only variables that are GLOBAL
573 # defined by the eclass, BUT NOT subject to change
574 # by user (like EGIT_PROJECT).
575 # If ebuild writer polutes his environment it is
576 # his problem only.
577 unset EGIT_DIR
578 unset MOVE_COMMAND
579 unset EGIT_LOCAL_OPTIONS
580 unset EGIT_UPDATE_CMD
581 unset UPSTREAM_BRANCH
582 unset EGIT_LOCAL_NONBARE
583 }
584
585 git-2_r3_wrapper() {
586 ewarn "Using git-r3 backend in git-2. Not everything is supported."
587 ewarn "Expect random failures and have fun testing."
588
589 if [[ ${EGIT_SOURCEDIR} ]]; then
590 EGIT_CHECKOUT_DIR=${EGIT_SOURCEDIR}
591 unset EGIT_SOURCEDIR
592 fi
593
594 if [[ ${EGIT_MASTER} ]]; then
595 : ${EGIT_BRANCH:=${EGIT_MASTER}}
596 unset EGIT_MASTER
597 fi
598
599 if [[ ${EGIT_HAS_SUBMODULES} ]]; then
600 unset EGIT_HAS_SUBMODULES
601 fi
602
603 if [[ ${EGIT_PROJECT} ]]; then
604 unset EGIT_PROJECT
605 fi
606
607 local boots unp
608 if [[ ${EGIT_NOUNPACK} ]]; then
609 unp=1
610 unset EGIT_NOUNPACK
611 fi
612
613 if [[ ${EGIT_BOOTSTRAP} ]]; then
614 boots=1
615 unset EGIT_BOOTSTRAP
616 fi
617
618 git-r3_src_unpack
619
620 [[ ${boots} ]] && EGIT_BOOTSTRAP=${boots} git-2_bootstrap
621 [[ ${unp} ]] && EGIT_NOUNPACK=1
622 }
623
624 # @FUNCTION: git-2_src_unpack
625 # @DESCRIPTION:
626 # Default git src_unpack function.
627 git-2_src_unpack() {
628 debug-print-function ${FUNCNAME} "$@"
629
630 if [[ ${EGIT_USE_GIT_R3} ]]; then
631 git-2_r3_wrapper
632 else
633 git-2_init_variables
634 git-2_prepare_storedir
635 git-2_migrate_repository
636 git-2_fetch "$@"
637 git-2_gc
638 git-2_submodules
639 git-2_move_source
640 git-2_branch
641 git-2_bootstrap
642 git-2_cleanup
643 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
644 fi
645
646 # Users can specify some SRC_URI and we should
647 # unpack the files too.
648 if [[ ! ${EGIT_NOUNPACK} ]]; then
649 if has ${EAPI:-0} 0 1; then
650 [[ ${A} ]] && unpack ${A}
651 else
652 default_src_unpack
653 fi
654 fi
655 }

  ViewVC Help
Powered by ViewVC 1.1.20