/[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.47
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.47 2010/07/26 03:24:19 reavertm 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>
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:
126 126
127# @ECLASS-VARIABLE: EGIT_BRANCH 127# @ECLASS-VARIABLE: EGIT_BRANCH
128# @DESCRIPTION: 128# @DESCRIPTION:
129# git eclass can fetch any branch in git_fetch(). 129# git eclass can fetch any branch in git_fetch().
130eval X="\$${PN//[-+]/_}_LIVE_BRANCH" 130eval X="\$${PN//[-+]/_}_LIVE_BRANCH"
131if [[ ${X} = "" ]]; then 131if [[ "${X}" = "" ]]; then
132 EGIT_BRANCH=${EGIT_BRANCH:=master} 132 : ${EGIT_BRANCH:=master}
133else 133else
134 EGIT_BRANCH="${X}" 134 EGIT_BRANCH="${X}"
135fi 135fi
136 136
137# @ECLASS-VARIABLE: EGIT_COMMIT 137# @ECLASS-VARIABLE: EGIT_COMMIT
138# @DESCRIPTION: 138# @DESCRIPTION:
139# git eclass can checkout any commit. 139# git eclass can checkout any commit.
140eval X="\$${PN//[-+]/_}_LIVE_COMMIT" 140eval X="\$${PN//[-+]/_}_LIVE_COMMIT"
141if [[ ${X} = "" ]]; then 141if [[ "${X}" = "" ]]; then
142 : ${EGIT_COMMIT:=${EGIT_BRANCH}} 142 : ${EGIT_COMMIT:=${EGIT_BRANCH}}
143else 143else
144 EGIT_COMMIT="${X}" 144 EGIT_COMMIT="${X}"
145fi 145fi
146 146
172# @DESCRIPTION: 172# @DESCRIPTION:
173# Internal function that changes branch for the repo based on EGIT_TREE and 173# Internal function that changes branch for the repo based on EGIT_TREE and
174# EGIT_BRANCH variables. 174# EGIT_BRANCH variables.
175git_branch() { 175git_branch() {
176 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} 176 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
177 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then 177 if [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]]; then
178 branchname=tree-${EGIT_COMMIT} 178 branchname=tree-${EGIT_COMMIT}
179 src=${EGIT_COMMIT} 179 src=${EGIT_COMMIT}
180 fi 180 fi
181 debug-print "git checkout -b ${branchname} ${src}" 181 debug-print "git checkout -b ${branchname} ${src}"
182 git checkout -b ${branchname} ${src} &> /dev/null 182 git checkout -b ${branchname} ${src} &> /dev/null
204 # which outputs into really smaller data transfers. 204 # which outputs into really smaller data transfers.
205 # Sadly we can do shallow copy for now because quite a few packages need .git 205 # Sadly we can do shallow copy for now because quite a few packages need .git
206 # folder. 206 # folder.
207 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \ 207 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \
208 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1" 208 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1"
209 if [[ ! -z ${EGIT_TREE} ]] ; then 209 if [[ -n ${EGIT_TREE} ]] ; then
210 EGIT_COMMIT=${EGIT_TREE} 210 EGIT_COMMIT=${EGIT_TREE}
211 ewarn "QA: Usage of deprecated EGIT_TREE variable detected." 211 ewarn "QA: Usage of deprecated EGIT_TREE variable detected."
212 ewarn "QA: Use EGIT_COMMIT variable instead." 212 ewarn "QA: Use EGIT_COMMIT variable instead."
213 fi 213 fi
214 214
250 if [[ -e "${GIT_DIR}/shallow" ]]; then 250 if [[ -e "${GIT_DIR}/shallow" ]]; then
251 rm -rf "${GIT_DIR}" 251 rm -rf "${GIT_DIR}"
252 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching." 252 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching."
253 fi 253 fi
254 # repack from bare copy to normal one 254 # repack from bare copy to normal one
255 if [[ -n ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && ! -d "${GIT_DIR}/.git/" ]]; then 255 if [[ -n ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && ! -d ${GIT_DIR}/.git ]]; then
256 rm -rf "${GIT_DIR}" 256 rm -rf "${GIT_DIR}"
257 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching." 257 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching."
258 fi 258 fi
259 if [[ -z ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then 259 if [[ -z ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then
260 rm -rf "${GIT_DIR}" 260 rm -rf "${GIT_DIR}"
318 318
319 git_submodules 319 git_submodules
320 cursha1=$(git rev-parse ${upstream_branch}) 320 cursha1=$(git rev-parse ${upstream_branch})
321 321
322 # write out message based on the revisions 322 # write out message based on the revisions
323 if [[ ${oldsha1} != ${cursha1} ]]; then 323 if [[ "${oldsha1}" != "${cursha1}" ]]; then
324 ${elogcmd} " updating from commit: ${oldsha1}" 324 ${elogcmd} " updating from commit: ${oldsha1}"
325 ${elogcmd} " to commit: ${cursha1}" 325 ${elogcmd} " to commit: ${cursha1}"
326 else 326 else
327 ${elogcmd} " at the commit: ${cursha1}" 327 ${elogcmd} " at the commit: ${cursha1}"
328 # @ECLASS_VARIABLE: LIVE_FAIL_FETCH_IF_REPO_NOT_UPDATED 328 # @ECLASS_VARIABLE: LIVE_FAIL_FETCH_IF_REPO_NOT_UPDATED
352 352
353 # export the git version 353 # export the git version
354 export EGIT_VERSION="${cursha1}" 354 export EGIT_VERSION="${cursha1}"
355 355
356 # log the repo state 356 # log the repo state
357 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}" 357 [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]] && ${elogcmd} " commit: ${EGIT_COMMIT}"
358 ${elogcmd} " branch: ${EGIT_BRANCH}" 358 ${elogcmd} " branch: ${EGIT_BRANCH}"
359 ${elogcmd} " storage directory: \"${GIT_DIR}\"" 359 ${elogcmd} " storage directory: \"${GIT_DIR}\""
360 360
361 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then 361 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
362 pushd "${GIT_DIR}" &> /dev/null 362 pushd "${GIT_DIR}" &> /dev/null
370 fi 370 fi
371 371
372 pushd "${S}" &> /dev/null 372 pushd "${S}" &> /dev/null
373 git_branch 373 git_branch
374 # submodules always reqire net (thanks to branches changing) 374 # submodules always reqire net (thanks to branches changing)
375 [[ -n ${EGIT_OFFLINE} ]] || git_submodules 375 [[ -z ${EGIT_OFFLINE} ]] && git_submodules
376 popd &> /dev/null 376 popd &> /dev/null
377 377
378 echo ">>> Unpacked to ${S}" 378 echo ">>> Unpacked to ${S}"
379} 379}
380 380
416} 416}
417 417
418# @FUNCTION: git_apply_patches 418# @FUNCTION: git_apply_patches
419# @DESCRIPTION: 419# @DESCRIPTION:
420# Apply patches from EGIT_PATCHES bash array. 420# Apply patches from EGIT_PATCHES bash array.
421# Preffered is using the variable as bash array but for now it allows to write 421# 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 422# it also as normal space separated string list. (This part of code should be
423# removed when all ebuilds get converted on bash array). 423# removed when all ebuilds get converted on bash array).
424git_apply_patches() { 424git_apply_patches() {
425 debug-print-function ${FUNCNAME} "$@" 425 debug-print-function ${FUNCNAME} "$@"
426 426
428 if [[ ${#EGIT_PATCHES[@]} -gt 1 ]] ; then 428 if [[ ${#EGIT_PATCHES[@]} -gt 1 ]] ; then
429 for i in "${EGIT_PATCHES[@]}"; do 429 for i in "${EGIT_PATCHES[@]}"; do
430 debug-print "$FUNCNAME: git_autopatch: patching from ${i}" 430 debug-print "$FUNCNAME: git_autopatch: patching from ${i}"
431 epatch "${i}" 431 epatch "${i}"
432 done 432 done
433 elif [[ ${EGIT_PATCHES} != "" ]]; then 433 elif [[ -n ${EGIT_PATCHES} ]]; then
434 # no need for loop if space separated string is passed. 434 # no need for loop if space separated string is passed.
435 debug-print "$FUNCNAME: git_autopatch: patching from ${EGIT_PATCHES}" 435 debug-print "$FUNCNAME: git_autopatch: patching from ${EGIT_PATCHES}"
436 epatch "${EGIT_PATCHES}" 436 epatch "${EGIT_PATCHES}"
437 fi 437 fi
438 438

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

  ViewVC Help
Powered by ViewVC 1.1.20