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