Gentoo Archives: gentoo-commits

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