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

Diff of /eclass/git.eclass

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

Revision 1.46 Revision 1.51
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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/Attic/git.eclass,v 1.46 2010/07/26 02:51:33 reavertm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.51 2011/02/02 19:26:53 ulm Exp $
4 4
5# @ECLASS: git.eclass 5# @ECLASS: git.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Tomas Chvatal <scarabeus@gentoo.org> 7# Tomas Chvatal <scarabeus@gentoo.org>
8# Donnie Berkholz <dberkholz@gentoo.org> 8# Donnie Berkholz <dberkholz@gentoo.org>
21# We DEPEND on at least a bit recent git version 21# We DEPEND on at least a bit recent git version
22DEPEND=">=dev-vcs/git-1.6" 22DEPEND=">=dev-vcs/git-1.6"
23 23
24EXPORTED_FUNCTIONS="src_unpack" 24EXPORTED_FUNCTIONS="src_unpack"
25case "${EAPI:-0}" in 25case "${EAPI:-0}" in
26 3|2) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare" ;; 26 4|3|2) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare" ;;
27 1|0) ;; 27 1|0) ;;
28 :) DEPEND="EAPI-UNSUPPORTED" ;; 28 *) DEPEND="EAPI-UNSUPPORTED" ;;
29esac 29esac
30EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS} 30EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
31 31
32# define some nice defaults but only if nothing is set already 32# define some nice defaults but only if nothing is set already
33: ${HOMEPAGE:=http://git-scm.com/} 33: ${HOMEPAGE:=http://git-scm.com/}
39 39
40# @ECLASS-VARIABLE: EGIT_STORE_DIR 40# @ECLASS-VARIABLE: EGIT_STORE_DIR
41# @DESCRIPTION: 41# @DESCRIPTION:
42# Storage directory for git sources. 42# Storage directory for git sources.
43# Can be redefined. 43# Can be redefined.
44[[ -z ${EGIT_STORE_DIR} ]] && EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src" 44: ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src"}
45 45
46# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES 46# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
47# @DESCRIPTION: 47# @DESCRIPTION:
48# Set this to non-empty value to enable submodule support (slower). 48# Set this to non-empty value to enable submodule support (slower).
49: ${EGIT_HAS_SUBMODULES:=} 49: ${EGIT_HAS_SUBMODULES:=}
89# git+ssh:// 89# git+ssh://
90# rsync:// 90# rsync://
91# ssh:// 91# ssh://
92eval X="\$${PN//[-+]/_}_LIVE_REPO" 92eval X="\$${PN//[-+]/_}_LIVE_REPO"
93if [[ ${X} = "" ]]; then 93if [[ ${X} = "" ]]; then
94 EGIT_REPO_URI=${EGIT_REPO_URI:=} 94 : ${EGIT_REPO_URI:=}
95else 95else
96 EGIT_REPO_URI="${X}" 96 EGIT_REPO_URI="${X}"
97fi 97fi
98# @ECLASS-VARIABLE: EGIT_PROJECT 98# @ECLASS-VARIABLE: EGIT_PROJECT
99# @DESCRIPTION: 99# @DESCRIPTION:
100# Project name of your ebuild. 100# Project name, it must be unique across EGIT_STORE_DIR.
101# Git eclass will check out the git repository like: 101# Git eclass will check out the git repository into ${EGIT_STORE_DIR}/${EGIT_PROJECT}/${EGIT_REPO_URI##*/}
102# ${EGIT_STORE_DIR}/${EGIT_PROJECT}/${EGIT_REPO_URI##*/} 102# Default is ${PN}.
103# so if you define EGIT_REPO_URI as http://git.collab.net/repo/git or
104# http://git.collab.net/repo/git. and PN is subversion-git.
105# it will check out like:
106# ${EGIT_STORE_DIR}/subversion
107: ${EGIT_PROJECT:=${PN/-git}} 103: ${EGIT_PROJECT:=${PN}}
108 104
109# @ECLASS-VARIABLE: EGIT_BOOTSTRAP 105# @ECLASS-VARIABLE: EGIT_BOOTSTRAP
110# @DESCRIPTION: 106# @DESCRIPTION:
111# bootstrap script or command like autogen.sh or etc... 107# bootstrap script or command like autogen.sh or etc...
112: ${EGIT_BOOTSTRAP:=} 108: ${EGIT_BOOTSTRAP:=}
126 122
127# @ECLASS-VARIABLE: EGIT_BRANCH 123# @ECLASS-VARIABLE: EGIT_BRANCH
128# @DESCRIPTION: 124# @DESCRIPTION:
129# git eclass can fetch any branch in git_fetch(). 125# git eclass can fetch any branch in git_fetch().
130eval X="\$${PN//[-+]/_}_LIVE_BRANCH" 126eval X="\$${PN//[-+]/_}_LIVE_BRANCH"
131if [[ ${X} = "" ]]; then 127if [[ "${X}" = "" ]]; then
132 EGIT_BRANCH=${EGIT_BRANCH:=master} 128 : ${EGIT_BRANCH:=master}
133else 129else
134 EGIT_BRANCH="${X}" 130 EGIT_BRANCH="${X}"
135fi 131fi
136 132
137# @ECLASS-VARIABLE: EGIT_COMMIT 133# @ECLASS-VARIABLE: EGIT_COMMIT
138# @DESCRIPTION: 134# @DESCRIPTION:
139# git eclass can checkout any commit. 135# git eclass can checkout any commit.
140eval X="\$${PN//[-+]/_}_LIVE_COMMIT" 136eval X="\$${PN//[-+]/_}_LIVE_COMMIT"
141if [[ ${X} = "" ]]; then 137if [[ "${X}" = "" ]]; then
142 : ${EGIT_COMMIT:=${EGIT_BRANCH}} 138 : ${EGIT_COMMIT:=${EGIT_BRANCH}}
143else 139else
144 EGIT_COMMIT="${X}" 140 EGIT_COMMIT="${X}"
145fi 141fi
146 142
161# Internal function wrapping the submodule initialisation and update 157# Internal function wrapping the submodule initialisation and update
162git_submodules() { 158git_submodules() {
163 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then 159 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
164 debug-print "git submodule init" 160 debug-print "git submodule init"
165 git submodule init 161 git submodule init
162 debug-print "git submodule sync"
163 git submodule sync
166 debug-print "git submodule update" 164 debug-print "git submodule update"
167 git submodule update 165 git submodule update
168 fi 166 fi
169} 167}
170 168
172# @DESCRIPTION: 170# @DESCRIPTION:
173# Internal function that changes branch for the repo based on EGIT_TREE and 171# Internal function that changes branch for the repo based on EGIT_TREE and
174# EGIT_BRANCH variables. 172# EGIT_BRANCH variables.
175git_branch() { 173git_branch() {
176 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} 174 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
177 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then 175 if [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]]; then
178 branchname=tree-${EGIT_COMMIT} 176 branchname=tree-${EGIT_COMMIT}
179 src=${EGIT_COMMIT} 177 src=${EGIT_COMMIT}
180 fi 178 fi
181 debug-print "git checkout -b ${branchname} ${src}" 179 debug-print "git checkout -b ${branchname} ${src}"
182 git checkout -b ${branchname} ${src} &> /dev/null 180 git checkout -b ${branchname} ${src} &> /dev/null
204 # which outputs into really smaller data transfers. 202 # which outputs into really smaller data transfers.
205 # Sadly we can do shallow copy for now because quite a few packages need .git 203 # Sadly we can do shallow copy for now because quite a few packages need .git
206 # folder. 204 # folder.
207 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \ 205 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \
208 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1" 206 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1"
209 if [[ ! -z ${EGIT_TREE} ]] ; then 207 if [[ -n ${EGIT_TREE} ]] ; then
210 EGIT_COMMIT=${EGIT_TREE} 208 EGIT_COMMIT=${EGIT_TREE}
211 ewarn "QA: Usage of deprecated EGIT_TREE variable detected." 209 ewarn "QA: Usage of deprecated EGIT_TREE variable detected."
212 ewarn "QA: Use EGIT_COMMIT variable instead." 210 ewarn "QA: Use EGIT_COMMIT variable instead."
213 fi 211 fi
214 212
250 if [[ -e "${GIT_DIR}/shallow" ]]; then 248 if [[ -e "${GIT_DIR}/shallow" ]]; then
251 rm -rf "${GIT_DIR}" 249 rm -rf "${GIT_DIR}"
252 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching." 250 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching."
253 fi 251 fi
254 # repack from bare copy to normal one 252 # repack from bare copy to normal one
255 if [[ -n ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && ! -d "${GIT_DIR}/.git/" ]]; then 253 if [[ -n ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && ! -d ${GIT_DIR}/.git ]]; then
256 rm -rf "${GIT_DIR}" 254 rm -rf "${GIT_DIR}"
257 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching." 255 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching."
258 fi 256 fi
259 if [[ -z ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then 257 if [[ -z ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then
260 rm -rf "${GIT_DIR}" 258 rm -rf "${GIT_DIR}"
318 316
319 git_submodules 317 git_submodules
320 cursha1=$(git rev-parse ${upstream_branch}) 318 cursha1=$(git rev-parse ${upstream_branch})
321 319
322 # write out message based on the revisions 320 # write out message based on the revisions
323 if [[ ${oldsha1} != ${cursha1} ]]; then 321 if [[ "${oldsha1}" != "${cursha1}" ]]; then
324 ${elogcmd} " updating from commit: ${oldsha1}" 322 ${elogcmd} " updating from commit: ${oldsha1}"
325 ${elogcmd} " to commit: ${cursha1}" 323 ${elogcmd} " to commit: ${cursha1}"
326 else 324 else
327 ${elogcmd} " at the commit: ${cursha1}" 325 ${elogcmd} " at the commit: ${cursha1}"
328 # @ECLASS_VARIABLE: LIVE_FAIL_FETCH_IF_REPO_NOT_UPDATED 326 # @ECLASS_VARIABLE: LIVE_FAIL_FETCH_IF_REPO_NOT_UPDATED
352 350
353 # export the git version 351 # export the git version
354 export EGIT_VERSION="${cursha1}" 352 export EGIT_VERSION="${cursha1}"
355 353
356 # log the repo state 354 # log the repo state
357 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}" 355 [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]] && ${elogcmd} " commit: ${EGIT_COMMIT}"
358 ${elogcmd} " branch: ${EGIT_BRANCH}" 356 ${elogcmd} " branch: ${EGIT_BRANCH}"
359 ${elogcmd} " storage directory: \"${GIT_DIR}\"" 357 ${elogcmd} " storage directory: \"${GIT_DIR}\""
360 358
361 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then 359 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
362 pushd "${GIT_DIR}" &> /dev/null 360 pushd "${GIT_DIR}" &> /dev/null
363 debug-print "rsync -rlpgo . \"${S}\"" 361 debug-print "rsync -rlpgo . \"${S}\""
364 time rsync -rlpgo . "${S}" 362 rsync -rlpgo . "${S}"
365 popd &> /dev/null 363 popd &> /dev/null
366 else 364 else
367 unset GIT_DIR 365 unset GIT_DIR
368 debug-print "git clone -l -s -n \"${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}\" \"${S}\"" 366 debug-print "git clone -l -s -n \"${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}\" \"${S}\""
369 git clone -l -s -n "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" "${S}" 367 git clone -l -s -n "${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" "${S}"
370 fi 368 fi
371 369
372 pushd "${S}" &> /dev/null 370 pushd "${S}" &> /dev/null
373 git_branch 371 git_branch
374 # submodules always reqire net (thanks to branches changing) 372 # submodules always reqire net (thanks to branches changing)
375 [[ -n ${EGIT_OFFLINE} ]] || git_submodules 373 [[ -z ${EGIT_OFFLINE} ]] && git_submodules
376 popd &> /dev/null 374 popd &> /dev/null
377 375
378 echo ">>> Unpacked to ${S}" 376 echo ">>> Unpacked to ${S}"
379} 377}
380 378
416} 414}
417 415
418# @FUNCTION: git_apply_patches 416# @FUNCTION: git_apply_patches
419# @DESCRIPTION: 417# @DESCRIPTION:
420# Apply patches from EGIT_PATCHES bash array. 418# Apply patches from EGIT_PATCHES bash array.
421# Preffered is using the variable as bash array but for now it allows to write 419# Preferred is using the variable as bash array but for now it allows to write
422# it also as normal space separated string list. (This part of code should be 420# it also as normal space separated string list. (This part of code should be
423# removed when all ebuilds get converted on bash array). 421# removed when all ebuilds get converted on bash array).
424git_apply_patches() { 422git_apply_patches() {
425 debug-print-function ${FUNCNAME} "$@" 423 debug-print-function ${FUNCNAME} "$@"
426 424
428 if [[ ${#EGIT_PATCHES[@]} -gt 1 ]] ; then 426 if [[ ${#EGIT_PATCHES[@]} -gt 1 ]] ; then
429 for i in "${EGIT_PATCHES[@]}"; do 427 for i in "${EGIT_PATCHES[@]}"; do
430 debug-print "$FUNCNAME: git_autopatch: patching from ${i}" 428 debug-print "$FUNCNAME: git_autopatch: patching from ${i}"
431 epatch "${i}" 429 epatch "${i}"
432 done 430 done
433 elif [[ ${EGIT_PATCHES} != "" ]]; then 431 elif [[ -n ${EGIT_PATCHES} ]]; then
434 # no need for loop if space separated string is passed. 432 # no need for loop if space separated string is passed.
435 debug-print "$FUNCNAME: git_autopatch: patching from ${EGIT_PATCHES}" 433 debug-print "$FUNCNAME: git_autopatch: patching from ${EGIT_PATCHES}"
436 epatch "${EGIT_PATCHES}" 434 epatch "${EGIT_PATCHES}"
437 fi 435 fi
438 436

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

  ViewVC Help
Powered by ViewVC 1.1.20