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

Contents of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (hide annotations) (download)
Fri Sep 23 13:58:58 2011 UTC (3 years, 2 months ago) by mgorny
Branch: MAIN
Changes since 1.23: +13 -1 lines
Try to migrate git.eclass checkouts to the new eclass.

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=383761

1 scarabeus 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.24 # $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.23 2011/09/23 13:58:35 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 mgorny 1.24
268     # Try to migrate from git.eclass git-src/
269     if [[ ! -d ${EGIT_DIR} && ${EGIT_STORE_DIR} == */egit-src ]]; then
270     local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
271     local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
272    
273     if [[ -d ${old_location} ]]; then
274     elog "${FUNCNAME}: ${CATEGORY}/${PF} will be cloned from old location."
275     elog "It will be necessary to rebuild the package to fetch updates."
276     EGIT_REPO_URI="${old_location} ${EGIT_REPO_URI}"
277     fi
278     fi
279 scarabeus 1.1 fi
280     export EGIT_DIR=${EGIT_DIR}
281     debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
282     }
283    
284     # @FUNCTION: git-2_move_source
285 mgorny 1.22 # @INTERNAL
286 scarabeus 1.1 # @DESCRIPTION:
287     # Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
288     git-2_move_source() {
289     debug-print-function ${FUNCNAME} "$@"
290    
291     debug-print "${FUNCNAME}: ${MOVE_COMMAND} \"${EGIT_DIR}\" \"${EGIT_SOURCEDIR}\""
292     pushd "${EGIT_DIR}" > /dev/null
293     mkdir -p "${EGIT_SOURCEDIR}" \
294     || die "${FUNCNAME}: failed to create ${EGIT_SOURCEDIR}"
295     ${MOVE_COMMAND} "${EGIT_SOURCEDIR}" \
296     || die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed"
297     popd > /dev/null
298     }
299    
300     # @FUNCTION: git-2_initial_clone
301 mgorny 1.22 # @INTERNAL
302 scarabeus 1.1 # @DESCRIPTION:
303     # Internal function running initial clone on specified repo_uri.
304     git-2_initial_clone() {
305     debug-print-function ${FUNCNAME} "$@"
306    
307     local repo_uri
308    
309     EGIT_REPO_URI_SELECTED=""
310     for repo_uri in ${EGIT_REPO_URI}; do
311 scarabeus 1.13 debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
312 mgorny 1.18 if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
313 scarabeus 1.1 # global variable containing the repo_name we will be using
314     debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
315     EGIT_REPO_URI_SELECTED="${repo_uri}"
316     break
317     fi
318     done
319    
320 mgorny 1.17 [[ ${EGIT_REPO_URI_SELECTED} ]] \
321     || die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
322 scarabeus 1.1 }
323    
324     # @FUNCTION: git-2_update_repo
325 mgorny 1.22 # @INTERNAL
326 scarabeus 1.1 # @DESCRIPTION:
327     # Internal function running update command on specified repo_uri.
328     git-2_update_repo() {
329     debug-print-function ${FUNCNAME} "$@"
330    
331     local repo_uri
332    
333 mgorny 1.17 if [[ ${EGIT_LOCAL_NONBARE} ]]; then
334 scarabeus 1.1 # checkout master branch and drop all other local branches
335     git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
336     for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
337     debug-print "${FUNCNAME}: git branch -D ${x}"
338     git branch -D ${x} > /dev/null
339     done
340     fi
341    
342     EGIT_REPO_URI_SELECTED=""
343     for repo_uri in ${EGIT_REPO_URI}; do
344     # git urls might change, so reset it
345     git config remote.origin.url "${repo_uri}"
346    
347 scarabeus 1.3 debug-print "${EGIT_UPDATE_CMD}"
348 mgorny 1.18 if ${EGIT_UPDATE_CMD} > /dev/null; then
349 scarabeus 1.1 # global variable containing the repo_name we will be using
350     debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
351     EGIT_REPO_URI_SELECTED="${repo_uri}"
352     break
353     fi
354     done
355    
356 mgorny 1.17 [[ ${EGIT_REPO_URI_SELECTED} ]] \
357     || die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
358 scarabeus 1.1 }
359    
360     # @FUNCTION: git-2_fetch
361 mgorny 1.22 # @INTERNAL
362 scarabeus 1.1 # @DESCRIPTION:
363     # Internal function fetching repository from EGIT_REPO_URI and storing it in
364     # specified EGIT_STORE_DIR.
365     git-2_fetch() {
366     debug-print-function ${FUNCNAME} "$@"
367    
368     local oldsha cursha repo_type
369    
370 mgorny 1.17 [[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
371 scarabeus 1.1
372     if [[ ! -d ${EGIT_DIR} ]]; then
373     git-2_initial_clone
374     pushd "${EGIT_DIR}" > /dev/null
375     cursha=$(git rev-parse ${UPSTREAM_BRANCH})
376     echo "GIT NEW clone -->"
377     echo " repository: ${EGIT_REPO_URI_SELECTED}"
378     echo " at the commit: ${cursha}"
379    
380     popd > /dev/null
381 mgorny 1.17 elif [[ ${EVCS_OFFLINE} ]]; then
382 scarabeus 1.1 pushd "${EGIT_DIR}" > /dev/null
383     cursha=$(git rev-parse ${UPSTREAM_BRANCH})
384     echo "GIT offline update -->"
385     echo " repository: $(git config remote.origin.url)"
386     echo " at the commit: ${cursha}"
387     popd > /dev/null
388     else
389     pushd "${EGIT_DIR}" > /dev/null
390     oldsha=$(git rev-parse ${UPSTREAM_BRANCH})
391     git-2_update_repo
392     cursha=$(git rev-parse ${UPSTREAM_BRANCH})
393    
394     # fetch updates
395     echo "GIT update -->"
396     echo " repository: ${EGIT_REPO_URI_SELECTED}"
397     # write out message based on the revisions
398 mgorny 1.5 if [[ "${oldsha}" != "${cursha}" ]]; then
399 scarabeus 1.1 echo " updating from commit: ${oldsha}"
400     echo " to commit: ${cursha}"
401     else
402     echo " at the commit: ${cursha}"
403     fi
404    
405     # print nice statistic of what was changed
406     git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH}
407     popd > /dev/null
408     fi
409     # export the version the repository is at
410 mgorny 1.5 export EGIT_VERSION="${cursha}"
411 scarabeus 1.1 # log the repo state
412     [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
413     && echo " commit: ${EGIT_COMMIT}"
414     echo " branch: ${EGIT_BRANCH}"
415     echo " storage directory: \"${EGIT_DIR}\""
416     echo " checkout type: ${repo_type}"
417     }
418    
419     # @FUNCTION: git_bootstrap
420 mgorny 1.22 # @INTERNAL
421 scarabeus 1.1 # @DESCRIPTION:
422     # Internal function that runs bootstrap command on unpacked source.
423     git-2_bootstrap() {
424     debug-print-function ${FUNCNAME} "$@"
425    
426 vapier 1.14 # @ECLASS-VARIABLE: EGIT_BOOTSTRAP
427 scarabeus 1.1 # @DESCRIPTION:
428     # Command to be executed after checkout and clone of the specified
429     # repository.
430     # enviroment the package will fail if there is no update, thus in
431     # combination with --keep-going it would lead in not-updating
432     # pakcages that are up-to-date.
433 mgorny 1.17 if [[ ${EGIT_BOOTSTRAP} ]]; then
434 scarabeus 1.1 pushd "${EGIT_SOURCEDIR}" > /dev/null
435     einfo "Starting bootstrap"
436    
437     if [[ -f ${EGIT_BOOTSTRAP} ]]; then
438     # we have file in the repo which we should execute
439     debug-print "${FUNCNAME}: bootstraping with file \"${EGIT_BOOTSTRAP}\""
440    
441     if [[ -x ${EGIT_BOOTSTRAP} ]]; then
442     eval "./${EGIT_BOOTSTRAP}" \
443     || die "${FUNCNAME}: bootstrap script failed"
444     else
445     eerror "\"${EGIT_BOOTSTRAP}\" is not executable."
446     eerror "Report upstream, or bug ebuild maintainer to remove bootstrap command."
447     die "\"${EGIT_BOOTSTRAP}\" is not executable"
448     fi
449     else
450     # we execute some system command
451     debug-print "${FUNCNAME}: bootstraping with commands \"${EGIT_BOOTSTRAP}\""
452    
453     eval "${EGIT_BOOTSTRAP}" \
454     || die "${FUNCNAME}: bootstrap commands failed"
455     fi
456    
457     einfo "Bootstrap finished"
458     popd > /dev/null
459     fi
460     }
461    
462     # @FUNCTION: git-2_migrate_repository
463 mgorny 1.22 # @INTERNAL
464 scarabeus 1.1 # @DESCRIPTION:
465     # Internal function migrating between bare and normal checkout repository.
466     # This is based on usage of EGIT_SUBMODULES, at least until they
467     # start to work with bare checkouts sanely.
468 scarabeus 1.13 # This function also set some global variables that differ between
469     # bare and non-bare checkout.
470 scarabeus 1.1 git-2_migrate_repository() {
471     debug-print-function ${FUNCNAME} "$@"
472    
473 mgorny 1.20 local bare returnstate
474 scarabeus 1.1
475     # first find out if we have submodules
476 mgorny 1.20 # or user explicitly wants us to use non-bare clones
477     if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
478     bare=1
479 scarabeus 1.13 fi
480 scarabeus 1.1
481     # test if we already have some repo and if so find out if we have
482     # to migrate the data
483     if [[ -d ${EGIT_DIR} ]]; then
484 mgorny 1.20 if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
485 scarabeus 1.1 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
486    
487     ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
488     mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
489     export GIT_DIR="${EGIT_DIR}.bare"
490     git config core.bare true > /dev/null
491     returnstate=$?
492     unset GIT_DIR
493     rm -rf "${EGIT_DIR}"
494     mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
495     eend ${returnstate}
496 mgorny 1.20 elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
497 scarabeus 1.1 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
498    
499     ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
500     git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
501     returnstate=$?
502     rm -rf "${EGIT_DIR}"
503     mv "${EGIT_DIR}.nonbare" "${EGIT_DIR}"
504     eend ${returnstate}
505     fi
506     fi
507     if [[ ${returnstate} -ne 0 ]]; then
508     debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" failed, removing to start from scratch"
509    
510     # migration failed, remove the EGIT_DIR to play it safe
511     einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
512     rm -rf "${EGIT_DIR}"
513     fi
514    
515     # set various options to work with both targets
516 mgorny 1.20 if [[ ${bare} ]]; then
517 scarabeus 1.1 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
518 scarabeus 1.13 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
519 scarabeus 1.1 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
520 scarabeus 1.2 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
521 scarabeus 1.1 UPSTREAM_BRANCH="${EGIT_BRANCH}"
522 mgorny 1.23 EGIT_LOCAL_NONBARE=
523 scarabeus 1.1 else
524     debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
525     MOVE_COMMAND="cp -pPR ."
526 scarabeus 1.13 EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
527 scarabeus 1.1 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
528     UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
529 scarabeus 1.13 EGIT_LOCAL_NONBARE="true"
530 scarabeus 1.1 fi
531     }
532    
533 scarabeus 1.13 # @FUNCTION: git-2_cleanup
534 mgorny 1.22 # @INTERNAL
535 scarabeus 1.13 # @DESCRIPTION:
536     # Internal function cleaning up all the global variables
537     # that are not required after the unpack has been done.
538     git-2_cleanup() {
539     debug-print-function ${FUNCNAME} "$@"
540    
541     # Here we can unset only variables that are GLOBAL
542     # defined by the eclass, BUT NOT subject to change
543     # by user (like EGIT_PROJECT).
544     # If ebuild writer polutes his environment it is
545     # his problem only.
546     unset EGIT_DIR
547     unset MOVE_COMMAND
548     unset EGIT_LOCAL_OPTIONS
549     unset EGIT_UPDATE_CMD
550     unset UPSTREAM_BRANCH
551     unset EGIT_LOCAL_NONBARE
552     }
553    
554 scarabeus 1.1 # @FUNCTION: git-2_src_unpack
555     # @DESCRIPTION:
556 scarabeus 1.7 # Default git src_unpack function.
557 scarabeus 1.1 git-2_src_unpack() {
558     debug-print-function ${FUNCNAME} "$@"
559    
560     git-2_init_variables
561     git-2_prepare_storedir
562     git-2_migrate_repository
563     git-2_fetch "$@"
564     git-2_gc
565     git-2_submodules
566     git-2_move_source
567     git-2_branch
568     git-2_bootstrap
569 scarabeus 1.13 git-2_cleanup
570 scarabeus 1.1 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
571 scarabeus 1.9
572     # Users can specify some SRC_URI and we should
573     # unpack the files too.
574 mgorny 1.17 if [[ ! ${EGIT_NOUNPACK} ]]; then
575 scarabeus 1.13 if has ${EAPI:-0} 0 1; then
576 mgorny 1.17 [[ ${A} ]] && unpack ${A}
577 scarabeus 1.13 else
578     default_src_unpack
579     fi
580 mgorny 1.12 fi
581 scarabeus 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20