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