| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.1 2011/04/20 10:56:27 scarabeus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.14 2011/08/22 04:46:31 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: git-2.eclass |
5 | # @ECLASS: git-2.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Tomas Chvatal <scarabeus@gentoo.org> |
7 | # Donnie Berkholz <dberkholz@gentoo.org> |
| 8 | # @BLURB: Eclass for fetching and unpacking git repositories. |
8 | # @BLURB: Eclass for fetching and unpacking git repositories. |
| 9 | # @DESCRIPTION: |
9 | # @DESCRIPTION: |
| 10 | # Eclass for easing maitenance of live ebuilds using git as remote repository. |
10 | # Eclass for easing maitenance of live ebuilds using git as remote repository. |
| 11 | # Eclass support working with git submodules and branching. |
11 | # Eclass support working with git submodules and branching. |
| 12 | |
12 | |
| … | |
… | |
| 44 | # Variable for specifying master branch. |
44 | # Variable for specifying master branch. |
| 45 | # Usefull when upstream don't have master branch or name it differently. |
45 | # Usefull when upstream don't have master branch or name it differently. |
| 46 | # |
46 | # |
| 47 | # EGIT_MASTER="master" |
47 | # EGIT_MASTER="master" |
| 48 | |
48 | |
|
|
49 | # @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 | |
| 49 | # @ECLASS-VARIABLE: EGIT_DIR |
57 | # @ECLASS-VARIABLE: EGIT_DIR |
| 50 | # @DESCRIPTION: |
58 | # @DESCRIPTION: |
| 51 | # Directory where we want to store the git data. |
59 | # Directory where we want to store the git data. |
| 52 | # This should not be overriden unless really required. |
60 | # This variable should not be overriden. |
| 53 | # |
61 | # |
| 54 | # EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_REPO_URI##*/}" |
62 | # EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}" |
| 55 | |
63 | |
| 56 | # @ECLASS-VARIABLE: EGIT_REPO_URI |
64 | # @ECLASS-VARIABLE: EGIT_REPO_URI |
| 57 | # @REQUIRED |
65 | # @REQUIRED |
| 58 | # @DEFAULT_UNSET |
66 | # @DEFAULT_UNSET |
| 59 | # @DESCRIPTION: |
67 | # @DESCRIPTION: |
| … | |
… | |
| 81 | # @DESCRIPTION: |
89 | # @DESCRIPTION: |
| 82 | # Variable containing commit hash/tag we want to check out. |
90 | # Variable containing commit hash/tag we want to check out. |
| 83 | # It can be overriden via env using packagename_LIVE_COMMIT |
91 | # It can be overriden via env using packagename_LIVE_COMMIT |
| 84 | # variable. |
92 | # variable. |
| 85 | # |
93 | # |
| 86 | # EGIT_BRANCH="${EGIT_BRANCH}" |
94 | # EGIT_COMMIT="${EGIT_BRANCH}" |
| 87 | |
95 | |
| 88 | # @ECLASS-VARIABLE: EGIT_REPACK |
96 | # @ECLASS-VARIABLE: EGIT_REPACK |
| 89 | # @DEFAULT_UNSET |
97 | # @DEFAULT_UNSET |
| 90 | # @DESCRIPTION: |
98 | # @DESCRIPTION: |
| 91 | # If non-empty this variable specifies that repository will be repacked to |
99 | # If non-empty this variable specifies that repository will be repacked to |
| … | |
… | |
| 102 | # @DEFAULT_UNSET |
110 | # @DEFAULT_UNSET |
| 103 | # @DESCRIPTION: |
111 | # @DESCRIPTION: |
| 104 | # If non-empty this variable specifies that all checkouts will be done using |
112 | # If non-empty this variable specifies that all checkouts will be done using |
| 105 | # non bare repositories. This is useful if you can't operate with bare |
113 | # non bare repositories. This is useful if you can't operate with bare |
| 106 | # checkouts for some reason. |
114 | # checkouts for some reason. |
|
|
115 | |
|
|
116 | # @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. |
| 107 | |
121 | |
| 108 | # @FUNCTION: git-2_init_variables |
122 | # @FUNCTION: git-2_init_variables |
| 109 | # @DESCRIPTION: |
123 | # @DESCRIPTION: |
| 110 | # Internal function initializing all git variables. |
124 | # Internal function initializing all git variables. |
| 111 | # We define it in function scope so user can define |
125 | # We define it in function scope so user can define |
| … | |
… | |
| 175 | # Internal function that changes branch for the repo based on EGIT_COMMIT and |
189 | # Internal function that changes branch for the repo based on EGIT_COMMIT and |
| 176 | # EGIT_BRANCH variables. |
190 | # EGIT_BRANCH variables. |
| 177 | git-2_branch() { |
191 | git-2_branch() { |
| 178 | debug-print-function ${FUNCNAME} "$@" |
192 | debug-print-function ${FUNCNAME} "$@" |
| 179 | |
193 | |
|
|
194 | local branchname src |
|
|
195 | |
| 180 | debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\"" |
196 | debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\"" |
| 181 | pushd "${EGIT_SOURCEDIR}" > /dev/null |
197 | pushd "${EGIT_SOURCEDIR}" > /dev/null |
| 182 | |
198 | |
| 183 | local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} |
199 | local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} |
| 184 | if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then |
200 | if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then |
| … | |
… | |
| 188 | debug-print "${FUNCNAME}: git checkout -b ${branchname} ${src}" |
204 | debug-print "${FUNCNAME}: git checkout -b ${branchname} ${src}" |
| 189 | git checkout -b ${branchname} ${src} \ |
205 | git checkout -b ${branchname} ${src} \ |
| 190 | || die "${FUNCNAME}: changing the branch failed" |
206 | || die "${FUNCNAME}: changing the branch failed" |
| 191 | |
207 | |
| 192 | popd > /dev/null |
208 | popd > /dev/null |
| 193 | |
|
|
| 194 | unset branchname src |
|
|
| 195 | } |
209 | } |
| 196 | |
210 | |
| 197 | # @FUNCTION: git-2_gc |
211 | # @FUNCTION: git-2_gc |
| 198 | # @DESCRIPTION: |
212 | # @DESCRIPTION: |
| 199 | # Internal function running garbage collector on checked out tree. |
213 | # Internal function running garbage collector on checked out tree. |
| 200 | git-2_gc() { |
214 | git-2_gc() { |
| 201 | debug-print-function ${FUNCNAME} "$@" |
215 | debug-print-function ${FUNCNAME} "$@" |
|
|
216 | |
|
|
217 | local args |
| 202 | |
218 | |
| 203 | pushd "${EGIT_DIR}" > /dev/null |
219 | pushd "${EGIT_DIR}" > /dev/null |
| 204 | if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then |
220 | if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then |
| 205 | ebegin "Garbage collecting the repository" |
221 | ebegin "Garbage collecting the repository" |
| 206 | local args |
|
|
| 207 | [[ -n ${EGIT_PRUNE} ]] && args='--prune' |
222 | [[ -n ${EGIT_PRUNE} ]] && args='--prune' |
| 208 | debug-print "${FUNCNAME}: git gc ${args}" |
223 | debug-print "${FUNCNAME}: git gc ${args}" |
| 209 | git gc ${args} |
224 | git gc ${args} |
| 210 | eend $? |
225 | eend $? |
| 211 | fi |
226 | fi |
| … | |
… | |
| 228 | addwrite / |
243 | addwrite / |
| 229 | mkdir -p "${EGIT_STORE_DIR}" \ |
244 | mkdir -p "${EGIT_STORE_DIR}" \ |
| 230 | || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" |
245 | || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" |
| 231 | fi |
246 | fi |
| 232 | |
247 | |
| 233 | cd -P "${EGIT_STORE_DIR}" \ |
|
|
| 234 | || die "${FUNCNAME}: can't chdir to \"${EGIT_STORE_DIR}\"" |
|
|
| 235 | # allow writing into EGIT_STORE_DIR |
248 | # allow writing into EGIT_STORE_DIR |
| 236 | addwrite "${EGIT_STORE_DIR}" |
249 | addwrite "${EGIT_STORE_DIR}" |
| 237 | # calculate the proper store dir for data |
250 | # calculate the proper store dir for data |
|
|
251 | # If user didn't specify the EGIT_DIR, we check if he did specify |
|
|
252 | # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI. |
| 238 | [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}" |
253 | [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}" |
| 239 | if [[ -z ${EGIT_DIR} ]]; then |
254 | if [[ -z ${EGIT_DIR} ]]; then |
|
|
255 | if [[ -n ${EGIT_PROJECT} ]]; then |
|
|
256 | clone_dir=${EGIT_PROJECT} |
|
|
257 | else |
| 240 | clone_dir=${EGIT_REPO_URI##*/} |
258 | clone_dir=${EGIT_REPO_URI##*/} |
|
|
259 | fi |
| 241 | EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} |
260 | EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} |
| 242 | fi |
261 | fi |
| 243 | export EGIT_DIR=${EGIT_DIR} |
262 | export EGIT_DIR=${EGIT_DIR} |
| 244 | debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"." |
263 | debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"." |
| 245 | } |
264 | } |
| … | |
… | |
| 267 | |
286 | |
| 268 | local repo_uri |
287 | local repo_uri |
| 269 | |
288 | |
| 270 | EGIT_REPO_URI_SELECTED="" |
289 | EGIT_REPO_URI_SELECTED="" |
| 271 | for repo_uri in ${EGIT_REPO_URI}; do |
290 | for repo_uri in ${EGIT_REPO_URI}; do |
| 272 | debug-print "${FUNCNAME}: git clone ${EGIT_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\"" |
291 | debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\"" |
| 273 | git clone ${EGIT_OPTIONS} "${repo_uri}" "${EGIT_DIR}" |
292 | git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}" |
| 274 | if [[ $? -eq 0 ]]; then |
293 | if [[ $? -eq 0 ]]; then |
| 275 | # global variable containing the repo_name we will be using |
294 | # global variable containing the repo_name we will be using |
| 276 | debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" |
295 | debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" |
| 277 | EGIT_REPO_URI_SELECTED="${repo_uri}" |
296 | EGIT_REPO_URI_SELECTED="${repo_uri}" |
| 278 | break |
297 | break |
| … | |
… | |
| 290 | git-2_update_repo() { |
309 | git-2_update_repo() { |
| 291 | debug-print-function ${FUNCNAME} "$@" |
310 | debug-print-function ${FUNCNAME} "$@" |
| 292 | |
311 | |
| 293 | local repo_uri |
312 | local repo_uri |
| 294 | |
313 | |
| 295 | if [[ -n ${EGIT_NONBARE} ]]; then |
314 | if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then |
| 296 | # checkout master branch and drop all other local branches |
315 | # checkout master branch and drop all other local branches |
| 297 | git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}" |
316 | git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}" |
| 298 | for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do |
317 | for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do |
| 299 | debug-print "${FUNCNAME}: git branch -D ${x}" |
318 | debug-print "${FUNCNAME}: git branch -D ${x}" |
| 300 | git branch -D ${x} > /dev/null |
319 | git branch -D ${x} > /dev/null |
| … | |
… | |
| 304 | EGIT_REPO_URI_SELECTED="" |
323 | EGIT_REPO_URI_SELECTED="" |
| 305 | for repo_uri in ${EGIT_REPO_URI}; do |
324 | for repo_uri in ${EGIT_REPO_URI}; do |
| 306 | # git urls might change, so reset it |
325 | # git urls might change, so reset it |
| 307 | git config remote.origin.url "${repo_uri}" |
326 | git config remote.origin.url "${repo_uri}" |
| 308 | |
327 | |
| 309 | debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}" |
328 | debug-print "${EGIT_UPDATE_CMD}" |
| 310 | ${EGIT_UPDATE_CMD} > /dev/null |
329 | ${EGIT_UPDATE_CMD} > /dev/null |
| 311 | if [[ $? -eq 0 ]]; then |
330 | if [[ $? -eq 0 ]]; then |
| 312 | # global variable containing the repo_name we will be using |
331 | # global variable containing the repo_name we will be using |
| 313 | debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" |
332 | debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" |
| 314 | EGIT_REPO_URI_SELECTED="${repo_uri}" |
333 | EGIT_REPO_URI_SELECTED="${repo_uri}" |
| … | |
… | |
| 328 | git-2_fetch() { |
347 | git-2_fetch() { |
| 329 | debug-print-function ${FUNCNAME} "$@" |
348 | debug-print-function ${FUNCNAME} "$@" |
| 330 | |
349 | |
| 331 | local oldsha cursha repo_type |
350 | local oldsha cursha repo_type |
| 332 | |
351 | |
| 333 | [[ -n ${EGIT_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository" |
352 | [[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository" |
| 334 | |
353 | |
| 335 | if [[ ! -d ${EGIT_DIR} ]]; then |
354 | if [[ ! -d ${EGIT_DIR} ]]; then |
| 336 | git-2_initial_clone |
355 | git-2_initial_clone |
| 337 | pushd "${EGIT_DIR}" > /dev/null |
356 | pushd "${EGIT_DIR}" > /dev/null |
| 338 | cursha=$(git rev-parse ${UPSTREAM_BRANCH}) |
357 | cursha=$(git rev-parse ${UPSTREAM_BRANCH}) |
| … | |
… | |
| 356 | |
375 | |
| 357 | # fetch updates |
376 | # fetch updates |
| 358 | echo "GIT update -->" |
377 | echo "GIT update -->" |
| 359 | echo " repository: ${EGIT_REPO_URI_SELECTED}" |
378 | echo " repository: ${EGIT_REPO_URI_SELECTED}" |
| 360 | # write out message based on the revisions |
379 | # write out message based on the revisions |
| 361 | if [[ "${oldsha1}" != "${cursha1}" ]]; then |
380 | if [[ "${oldsha}" != "${cursha}" ]]; then |
| 362 | echo " updating from commit: ${oldsha}" |
381 | echo " updating from commit: ${oldsha}" |
| 363 | echo " to commit: ${cursha}" |
382 | echo " to commit: ${cursha}" |
| 364 | else |
383 | else |
| 365 | echo " at the commit: ${cursha}" |
384 | echo " at the commit: ${cursha}" |
| 366 | fi |
385 | fi |
| … | |
… | |
| 368 | # print nice statistic of what was changed |
387 | # print nice statistic of what was changed |
| 369 | git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH} |
388 | git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH} |
| 370 | popd > /dev/null |
389 | popd > /dev/null |
| 371 | fi |
390 | fi |
| 372 | # export the version the repository is at |
391 | # export the version the repository is at |
| 373 | export EGIT_VERSION="${cursha1}" |
392 | export EGIT_VERSION="${cursha}" |
| 374 | # log the repo state |
393 | # log the repo state |
| 375 | [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ |
394 | [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ |
| 376 | && echo " commit: ${EGIT_COMMIT}" |
395 | && echo " commit: ${EGIT_COMMIT}" |
| 377 | echo " branch: ${EGIT_BRANCH}" |
396 | echo " branch: ${EGIT_BRANCH}" |
| 378 | echo " storage directory: \"${EGIT_DIR}\"" |
397 | echo " storage directory: \"${EGIT_DIR}\"" |
| … | |
… | |
| 383 | # @DESCRIPTION: |
402 | # @DESCRIPTION: |
| 384 | # Internal function that runs bootstrap command on unpacked source. |
403 | # Internal function that runs bootstrap command on unpacked source. |
| 385 | git-2_bootstrap() { |
404 | git-2_bootstrap() { |
| 386 | debug-print-function ${FUNCNAME} "$@" |
405 | debug-print-function ${FUNCNAME} "$@" |
| 387 | |
406 | |
| 388 | # @ECLASS_VARIABLE: EGIT_BOOTSTRAP |
407 | # @ECLASS-VARIABLE: EGIT_BOOTSTRAP |
| 389 | # @DESCRIPTION: |
408 | # @DESCRIPTION: |
| 390 | # Command to be executed after checkout and clone of the specified |
409 | # Command to be executed after checkout and clone of the specified |
| 391 | # repository. |
410 | # repository. |
| 392 | # enviroment the package will fail if there is no update, thus in |
411 | # enviroment the package will fail if there is no update, thus in |
| 393 | # combination with --keep-going it would lead in not-updating |
412 | # combination with --keep-going it would lead in not-updating |
| … | |
… | |
| 424 | # @FUNCTION: git-2_migrate_repository |
443 | # @FUNCTION: git-2_migrate_repository |
| 425 | # @DESCRIPTION: |
444 | # @DESCRIPTION: |
| 426 | # Internal function migrating between bare and normal checkout repository. |
445 | # Internal function migrating between bare and normal checkout repository. |
| 427 | # This is based on usage of EGIT_SUBMODULES, at least until they |
446 | # This is based on usage of EGIT_SUBMODULES, at least until they |
| 428 | # start to work with bare checkouts sanely. |
447 | # start to work with bare checkouts sanely. |
|
|
448 | # This function also set some global variables that differ between |
|
|
449 | # bare and non-bare checkout. |
| 429 | git-2_migrate_repository() { |
450 | git-2_migrate_repository() { |
| 430 | debug-print-function ${FUNCNAME} "$@" |
451 | debug-print-function ${FUNCNAME} "$@" |
| 431 | |
452 | |
| 432 | local target returnstate |
453 | local target returnstate |
| 433 | |
454 | |
| … | |
… | |
| 435 | if [[ -z ${EGIT_HAS_SUBMODULES} ]]; then |
456 | if [[ -z ${EGIT_HAS_SUBMODULES} ]]; then |
| 436 | target="bare" |
457 | target="bare" |
| 437 | else |
458 | else |
| 438 | target="full" |
459 | target="full" |
| 439 | fi |
460 | fi |
| 440 | [[ -n ${EGIT_NONBARE} ]] && target="full" |
461 | # check if user didn't specify that we want non-bare repo |
|
|
462 | if [[ -n ${EGIT_NONBARE} ]]; then |
|
|
463 | target="full" |
|
|
464 | EGIT_LOCAL_NONBARE="true" |
|
|
465 | fi |
| 441 | |
466 | |
| 442 | # test if we already have some repo and if so find out if we have |
467 | # test if we already have some repo and if so find out if we have |
| 443 | # to migrate the data |
468 | # to migrate the data |
| 444 | if [[ -d ${EGIT_DIR} ]]; then |
469 | if [[ -d ${EGIT_DIR} ]]; then |
| 445 | if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then |
470 | if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then |
| … | |
… | |
| 475 | fi |
500 | fi |
| 476 | |
501 | |
| 477 | # set various options to work with both targets |
502 | # set various options to work with both targets |
| 478 | if [[ ${target} == bare ]]; then |
503 | if [[ ${target} == bare ]]; then |
| 479 | debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" |
504 | debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" |
| 480 | EGIT_OPTIONS+=" --bare" |
505 | EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare" |
| 481 | MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" |
506 | MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" |
| 482 | EGIT_UPDATE_CMD="git fetch -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}" |
507 | EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}" |
| 483 | UPSTREAM_BRANCH="${EGIT_BRANCH}" |
508 | UPSTREAM_BRANCH="${EGIT_BRANCH}" |
| 484 | else |
509 | else |
| 485 | debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\"" |
510 | debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\"" |
| 486 | MOVE_COMMAND="cp -pPR ." |
511 | MOVE_COMMAND="cp -pPR ." |
|
|
512 | EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}" |
| 487 | EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}" |
513 | EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}" |
| 488 | UPSTREAM_BRANCH="origin/${EGIT_BRANCH}" |
514 | UPSTREAM_BRANCH="origin/${EGIT_BRANCH}" |
| 489 | EGIT_NONBARE="true" |
515 | EGIT_LOCAL_NONBARE="true" |
| 490 | fi |
516 | fi |
|
|
517 | } |
|
|
518 | |
|
|
519 | # @FUNCTION: git-2_cleanup |
|
|
520 | # @DESCRIPTION: |
|
|
521 | # Internal function cleaning up all the global variables |
|
|
522 | # that are not required after the unpack has been done. |
|
|
523 | git-2_cleanup() { |
|
|
524 | debug-print-function ${FUNCNAME} "$@" |
|
|
525 | |
|
|
526 | # Here we can unset only variables that are GLOBAL |
|
|
527 | # defined by the eclass, BUT NOT subject to change |
|
|
528 | # by user (like EGIT_PROJECT). |
|
|
529 | # If ebuild writer polutes his environment it is |
|
|
530 | # his problem only. |
|
|
531 | unset EGIT_DIR |
|
|
532 | unset MOVE_COMMAND |
|
|
533 | unset EGIT_LOCAL_OPTIONS |
|
|
534 | unset EGIT_UPDATE_CMD |
|
|
535 | unset UPSTREAM_BRANCH |
|
|
536 | unset EGIT_LOCAL_NONBARE |
| 491 | } |
537 | } |
| 492 | |
538 | |
| 493 | # @FUNCTION: git-2_src_unpack |
539 | # @FUNCTION: git-2_src_unpack |
| 494 | # @DESCRIPTION: |
540 | # @DESCRIPTION: |
| 495 | # Default git src_upack function. |
541 | # Default git src_unpack function. |
| 496 | git-2_src_unpack() { |
542 | git-2_src_unpack() { |
| 497 | debug-print-function ${FUNCNAME} "$@" |
543 | debug-print-function ${FUNCNAME} "$@" |
| 498 | |
544 | |
| 499 | git-2_init_variables |
545 | git-2_init_variables |
| 500 | git-2_prepare_storedir |
546 | git-2_prepare_storedir |
| … | |
… | |
| 503 | git-2_gc |
549 | git-2_gc |
| 504 | git-2_submodules |
550 | git-2_submodules |
| 505 | git-2_move_source |
551 | git-2_move_source |
| 506 | git-2_branch |
552 | git-2_branch |
| 507 | git-2_bootstrap |
553 | git-2_bootstrap |
|
|
554 | git-2_cleanup |
| 508 | echo ">>> Unpacked to ${EGIT_SOURCEDIR}" |
555 | echo ">>> Unpacked to ${EGIT_SOURCEDIR}" |
|
|
556 | |
|
|
557 | # Users can specify some SRC_URI and we should |
|
|
558 | # unpack the files too. |
|
|
559 | if [[ -z ${EGIT_NOUNPACK} ]]; then |
|
|
560 | if has ${EAPI:-0} 0 1; then |
|
|
561 | [[ -n ${A} ]] && unpack ${A} |
|
|
562 | else |
|
|
563 | default_src_unpack |
|
|
564 | fi |
|
|
565 | fi |
| 509 | } |
566 | } |