/[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.49 Revision 1.51
1# Copyright 1999-2015 Gentoo Foundation 1# Copyright 1999-2015 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.49 2015/06/22 08:39:36 mrueg Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.51 2015/08/08 09:32:50 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.
183 case "${EGIT_MIN_CLONE_TYPE}" in 183 case "${EGIT_MIN_CLONE_TYPE}" in
184 shallow) 184 shallow)
185 ;; 185 ;;
186 single) 186 single)
187 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then 187 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then
188 einfo "git-r3: ebuild needs to be cloned in 'single' mode, adjusting" 188 einfo "git-r3: ebuild needs to be cloned in '\e[1msingle\e[22m' mode, adjusting"
189 EGIT_CLONE_TYPE=single 189 EGIT_CLONE_TYPE=single
190 fi 190 fi
191 ;; 191 ;;
192 single+tags) 192 single+tags)
193 if [[ ${EGIT_CLONE_TYPE} == shallow || ${EGIT_CLONE_TYPE} == single ]]; then 193 if [[ ${EGIT_CLONE_TYPE} == shallow || ${EGIT_CLONE_TYPE} == single ]]; then
194 einfo "git-r3: ebuild needs to be cloned in 'single+tags' mode, adjusting" 194 einfo "git-r3: ebuild needs to be cloned in '\e[1msingle+tags\e[22m' mode, adjusting"
195 EGIT_CLONE_TYPE=single+tags 195 EGIT_CLONE_TYPE=single+tags
196 fi 196 fi
197 ;; 197 ;;
198 mirror) 198 mirror)
199 if [[ ${EGIT_CLONE_TYPE} != mirror ]]; then 199 if [[ ${EGIT_CLONE_TYPE} != mirror ]]; then
200 einfo "git-r3: ebuild needs to be cloned in 'mirror' mode, adjusting" 200 einfo "git-r3: ebuild needs to be cloned in '\e[1mmirror\e[22m' mode, adjusting"
201 EGIT_CLONE_TYPE=mirror 201 EGIT_CLONE_TYPE=mirror
202 fi 202 fi
203 ;; 203 ;;
204 *) 204 *)
205 die "Invalid EGIT_MIN_CLONE_TYPE=${EGIT_MIN_CLONE_TYPE}" 205 die "Invalid EGIT_MIN_CLONE_TYPE=${EGIT_MIN_CLONE_TYPE}"
530 if [[ ${EVCS_UMASK} ]]; then 530 if [[ ${EVCS_UMASK} ]]; then
531 saved_umask=$(umask) 531 saved_umask=$(umask)
532 umask "${EVCS_UMASK}" || die "Bad options to umask: ${EVCS_UMASK}" 532 umask "${EVCS_UMASK}" || die "Bad options to umask: ${EVCS_UMASK}"
533 fi 533 fi
534 for r in "${repos[@]}"; do 534 for r in "${repos[@]}"; do
535 einfo "Fetching ${r} ..." 535 einfo "Fetching \e[1m${r}\e[22m ..."
536 536
537 local fetch_command=( git fetch "${r}" ) 537 local fetch_command=( git fetch "${r}" )
538 local clone_type=${EGIT_CLONE_TYPE} 538 local clone_type=${EGIT_CLONE_TYPE}
539 539
540 if [[ ${r} == https://* ]] && ! ROOT=/ has_version 'dev-vcs/git[curl]'; then 540 if [[ ${r} == https://* ]] && ! ROOT=/ has_version 'dev-vcs/git[curl]'; then
551 # 1) can't handle shallow clones at all, 551 # 1) can't handle shallow clones at all,
552 # 2) fetches duplicately when tags are pulled in with branch 552 # 2) fetches duplicately when tags are pulled in with branch
553 # so automatically switch to single+tags mode. 553 # so automatically switch to single+tags mode.
554 if [[ ${clone_type} == shallow ]]; then 554 if [[ ${clone_type} == shallow ]]; then
555 einfo " Google Code does not support shallow clones" 555 einfo " Google Code does not support shallow clones"
556 einfo " using EGIT_CLONE_TYPE=single+tags" 556 einfo " using \e[1mEGIT_CLONE_TYPE=single+tags\e[22m"
557 clone_type=single+tags 557 clone_type=single+tags
558 elif [[ ${clone_type} == single ]]; then 558 elif [[ ${clone_type} == single ]]; then
559 einfo " git-r3: Google Code does not send tags properly in 'single' mode" 559 einfo " git-r3: Google Code does not send tags properly in 'single' mode"
560 einfo " using EGIT_CLONE_TYPE=single+tags" 560 einfo " using \e[1mEGIT_CLONE_TYPE=single+tags\e[22m"
561 clone_type=single+tags 561 clone_type=single+tags
562 fi 562 fi
563 fi 563 fi
564 564
565 if [[ ${clone_type} == mirror ]]; then 565 if [[ ${clone_type} == mirror ]]; then
708 708
709 while [[ ${submodules[@]} ]]; do 709 while [[ ${submodules[@]} ]]; do
710 local subname=${submodules[0]} 710 local subname=${submodules[0]}
711 local url=${submodules[1]} 711 local url=${submodules[1]}
712 local path=${submodules[2]} 712 local path=${submodules[2]}
713
714 # use only submodules for which path does exist
715 # (this is in par with 'git submodule'), bug #551100
716 # note: git cat-file does not work for submodules
717 if [[ $(git ls-tree -d "${local_ref}" "${path}") ]]
718 then
713 local commit=$(git rev-parse "${local_ref}:${path}") 719 local commit=$(git rev-parse "${local_ref}:${path}" || die)
714 720
715 if [[ ! ${commit} ]]; then 721 if [[ ! ${commit} ]]; then
716 die "Unable to get commit id for submodule ${subname}" 722 die "Unable to get commit id for submodule ${subname}"
717 fi 723 fi
718 724
719 local subrepos 725 local subrepos
720 _git-r3_set_subrepos "${url}" "${repos[@]}" 726 _git-r3_set_subrepos "${url}" "${repos[@]}"
721 727
722 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}" 728 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}"
729 fi
723 730
724 submodules=( "${submodules[@]:3}" ) # shift 731 submodules=( "${submodules[@]:3}" ) # shift
725 done 732 done
726 fi 733 fi
727} 734}
762 local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}} 769 local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
763 770
764 local -x GIT_DIR 771 local -x GIT_DIR
765 _git-r3_set_gitdir "${repos[0]}" 772 _git-r3_set_gitdir "${repos[0]}"
766 773
767 einfo "Checking out ${repos[0]} to ${out_dir} ..." 774 einfo "Checking out \e[1m${repos[0]}\e[22m to \e[1m${out_dir}\[e22m ..."
768 775
769 if ! git cat-file -e refs/git-r3/"${local_id}"/__main__; then 776 if ! git cat-file -e refs/git-r3/"${local_id}"/__main__; then
770 if [[ ${EVCS_OFFLINE} ]]; then 777 if [[ ${EVCS_OFFLINE} ]]; then
771 die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE." 778 die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE."
772 else 779 else
847 854
848 while [[ ${submodules[@]} ]]; do 855 while [[ ${submodules[@]} ]]; do
849 local subname=${submodules[0]} 856 local subname=${submodules[0]}
850 local url=${submodules[1]} 857 local url=${submodules[1]}
851 local path=${submodules[2]} 858 local path=${submodules[2]}
859
860 # use only submodules for which path does exist
861 # (this is in par with 'git submodule'), bug #551100
862 if [[ -d ${out_dir}/${path} ]]; then
852 local subrepos 863 local subrepos
853 _git-r3_set_subrepos "${url}" "${repos[@]}" 864 _git-r3_set_subrepos "${url}" "${repos[@]}"
854 865
855 git-r3_checkout "${subrepos[*]}" "${out_dir}/${path}" \ 866 git-r3_checkout "${subrepos[*]}" "${out_dir}/${path}" \
856 "${local_id}/${subname}" 867 "${local_id}/${subname}"
868 fi
857 869
858 submodules=( "${submodules[@]:3}" ) # shift 870 submodules=( "${submodules[@]:3}" ) # shift
859 done 871 done
860 fi 872 fi
861 873
902 914
903 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset" 915 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
904 916
905 local r success 917 local r success
906 for r in "${repos[@]}"; do 918 for r in "${repos[@]}"; do
907 einfo "Peeking ${remote_ref} on ${r} ..." >&2 919 einfo "Peeking \e[1m${remote_ref}\e[22m on \e[1m${r}\e[22m ..." >&2
908 920
909 local is_branch lookup_ref 921 local is_branch lookup_ref
910 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]] 922 if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]]
911 then 923 then
912 is_branch=1 924 is_branch=1
952 git-r3_src_fetch 964 git-r3_src_fetch
953 git-r3_checkout 965 git-r3_checkout
954} 966}
955 967
956# https://bugs.gentoo.org/show_bug.cgi?id=482666 968# https://bugs.gentoo.org/show_bug.cgi?id=482666
957git-r3_pkg_outofdate() { 969git-r3_pkg_needrebuild() {
958 debug-print-function ${FUNCNAME} "$@" 970 debug-print-function ${FUNCNAME} "$@"
959 971
960 local new_commit_id=$(git-r3_peek_remote_ref) 972 local new_commit_id=$(git-r3_peek_remote_ref)
961 ewarn "old: ${EGIT_VERSION}" 973 [[ ${new_commit_id} && ${EGIT_VERSION} ]] || die "Lookup failed"
962 ewarn "new: ${new_commit_id}" 974
963 [[ ${new_commit_id} && ${old_commit_id} ]] || return 2 975 if [[ ${EGIT_VERSION} != ${new_commit_id} ]]; then
976 einfo "Update from \e[1m${EGIT_VERSION}\e[22m to \e[1m${new_commit_id}\e[22m"
977 else
978 einfo "Local and remote at \e[1m${EGIT_VERSION}\e[22m"
979 fi
964 980
965 [[ ${EGIT_VERSION} != ${new_commit_id} ]] 981 [[ ${EGIT_VERSION} != ${new_commit_id} ]]
966} 982}
983
984# 'export' locally until this gets into EAPI
985pkg_needrebuild() { git-r3_pkg_needrebuild; }
967 986
968_GIT_R3=1 987_GIT_R3=1
969fi 988fi

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.20