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

Contents of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.32 - (show annotations) (download)
Sun Sep 8 22:54:24 2013 UTC (11 months, 2 weeks ago) by mgorny
Branch: MAIN
Changes since 1.31: +3 -4 lines
Inherit git-r3 unconditionally to avoid metadata variancy. The eclass is properly namespaced, does not touch variables in global scope and exports only src_unpack() that git-2 overrides anyway.

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

  ViewVC Help
Powered by ViewVC 1.1.20