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

Contents of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (hide annotations) (download)
Fri Sep 23 13:58:22 2011 UTC (2 years, 11 months ago) by mgorny
Branch: MAIN
Changes since 1.21: +13 -1 lines
Mark internal functions @INTERNAL.

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

  ViewVC Help
Powered by ViewVC 1.1.20