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

Diff of /eclass/git-r3.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 Revision 1.9
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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-r3.eclass,v 1.8 2013/09/25 10:49:11 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.9 2013/09/25 11:19:09 mgorny Exp $
4 4
5# @ECLASS: git-r3.eclass 5# @ECLASS: git-r3.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Michał Górny <mgorny@gentoo.org> 7# Michał Górny <mgorny@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 8# @BLURB: Eclass for fetching and unpacking git repositories.
41# URIs to the repository, e.g. git://foo, https://foo. If multiple URIs 41# URIs to the repository, e.g. git://foo, https://foo. If multiple URIs
42# are provided, the eclass will consider them as fallback URIs to try 42# are provided, the eclass will consider them as fallback URIs to try
43# if the first URI does not work. 43# if the first URI does not work.
44# 44#
45# It can be overriden via env using ${PN}_LIVE_REPO variable. 45# It can be overriden via env using ${PN}_LIVE_REPO variable.
46#
47# Can be a whitespace-separated list or an array.
46# 48#
47# Example: 49# Example:
48# @CODE 50# @CODE
49# EGIT_REPO_URI="git://a/b.git https://c/d.git" 51# EGIT_REPO_URI="git://a/b.git https://c/d.git"
50# @CODE 52# @CODE
370# If the repository contains submodules, they will be fetched 372# If the repository contains submodules, they will be fetched
371# recursively. 373# recursively.
372git-r3_fetch() { 374git-r3_fetch() {
373 debug-print-function ${FUNCNAME} "$@" 375 debug-print-function ${FUNCNAME} "$@"
374 376
377 if [[ $(declare -p EGIT_REPO_URI) != "declare -a"* ]]; then
378 local EGIT_REPO_URI=( ${EGIT_REPO_URI} )
379 fi
380
375 local repos=( ${1:-${EGIT_REPO_URI}} ) 381 local repos=( "${1:-${EGIT_REPO_URI[@]}}" )
376 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}} 382 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
377 local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}} 383 local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
378 local local_id=${3:-${CATEGORY}/${PN}/${SLOT}} 384 local local_id=${3:-${CATEGORY}/${PN}/${SLOT}}
379 local local_ref=refs/heads/${local_id}/__main__ 385 local local_ref=refs/heads/${local_id}/__main__
380 386
381 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset" 387 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
382 388
383 local -x GIT_DIR 389 local -x GIT_DIR
384 _git-r3_set_gitdir ${repos[0]} 390 _git-r3_set_gitdir "${repos[0]}"
385 391
386 # try to fetch from the remote 392 # try to fetch from the remote
387 local r success 393 local r success
388 for r in ${repos[@]}; do 394 for r in "${repos[@]}"; do
389 einfo "Fetching ${remote_ref} from ${r} ..." 395 einfo "Fetching ${remote_ref} from ${r} ..."
390 396
391 local is_branch lookup_ref 397 local is_branch lookup_ref
392 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]] 398 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]]
393 then 399 then
519# the repository state into the environment. If the repository contains 525# the repository state into the environment. If the repository contains
520# submodules, they will be checked out recursively. 526# submodules, they will be checked out recursively.
521git-r3_checkout() { 527git-r3_checkout() {
522 debug-print-function ${FUNCNAME} "$@" 528 debug-print-function ${FUNCNAME} "$@"
523 529
530 if [[ $(declare -p EGIT_REPO_URI) != "declare -a"* ]]; then
531 local EGIT_REPO_URI=( ${EGIT_REPO_URI} )
532 fi
533
524 local repos=( ${1:-${EGIT_REPO_URI}} ) 534 local repos=( "${1:-${EGIT_REPO_URI[@]}}" )
525 local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}} 535 local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}}
526 local local_id=${3:-${CATEGORY}/${PN}/${SLOT}} 536 local local_id=${3:-${CATEGORY}/${PN}/${SLOT}}
527 537
528 local -x GIT_DIR GIT_WORK_TREE 538 local -x GIT_DIR GIT_WORK_TREE
529 _git-r3_set_gitdir ${repos[0]} 539 _git-r3_set_gitdir "${repos[0]}"
530 GIT_WORK_TREE=${out_dir} 540 GIT_WORK_TREE=${out_dir}
531 mkdir -p "${GIT_WORK_TREE}" 541 mkdir -p "${GIT_WORK_TREE}"
532 542
533 einfo "Checking out ${repos[0]} to ${out_dir} ..." 543 einfo "Checking out ${repos[0]} to ${out_dir} ..."
534 544
616# On success, the function returns 0 and writes hexadecimal commit SHA1 626# On success, the function returns 0 and writes hexadecimal commit SHA1
617# to stdout. On failure, the function returns 1. 627# to stdout. On failure, the function returns 1.
618git-r3_peek_remote_ref() { 628git-r3_peek_remote_ref() {
619 debug-print-function ${FUNCNAME} "$@" 629 debug-print-function ${FUNCNAME} "$@"
620 630
631 if [[ $(declare -p EGIT_REPO_URI) != "declare -a"* ]]; then
632 local EGIT_REPO_URI=( ${EGIT_REPO_URI} )
633 fi
634
621 local repos=( ${1:-${EGIT_REPO_URI}} ) 635 local repos=( "${1:-${EGIT_REPO_URI[@]}}" )
622 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}} 636 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
623 local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}} 637 local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
624 638
625 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset" 639 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
626 640
627 local r success 641 local r success
628 for r in ${repos[@]}; do 642 for r in "${repos[@]}"; do
629 einfo "Peeking ${remote_ref} on ${r} ..." >&2 643 einfo "Peeking ${remote_ref} on ${r} ..." >&2
630 644
631 local is_branch lookup_ref 645 local is_branch lookup_ref
632 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]] 646 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]]
633 then 647 then

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20