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

Contents of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.35 - (hide annotations) (download)
Thu Nov 20 15:32:09 2014 UTC (2 years, 4 months ago) by mgorny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.34: +3 -1 lines
Deprecate the few eclasses.

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

  ViewVC Help
Powered by ViewVC 1.1.20