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