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

Diff of /eclass/git.eclass

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

Revision 1.35 Revision 1.38
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.35 2010/01/13 20:04:19 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.38 2010/01/23 15:46:50 scarabeus 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>
61 61
62# @ECLASS-VARIABLE: EGIT_OPTIONS 62# @ECLASS-VARIABLE: EGIT_OPTIONS
63# @DESCRIPTION: 63# @DESCRIPTION:
64# This variable value is passed to clone and fetch. 64# This variable value is passed to clone and fetch.
65: ${EGIT_OPTIONS:=} 65: ${EGIT_OPTIONS:=}
66
67# @ECLASS-VARIABLE: EGIT_MASTER
68# @DESCRIPTION:
69# Variable for specifying master branch.
70# Usefull when upstream don't have master branch.
71: ${EGIT_MASTER:=master}
66 72
67# @ECLASS-VARIABLE: EGIT_REPO_URI 73# @ECLASS-VARIABLE: EGIT_REPO_URI
68# @DESCRIPTION: 74# @DESCRIPTION:
69# URI for the repository 75# URI for the repository
70# e.g. http://foo, git://bar 76# e.g. http://foo, git://bar
143: ${EGIT_PRUNE:=false} 149: ${EGIT_PRUNE:=false}
144 150
145# @FUNCTION: git_submodules 151# @FUNCTION: git_submodules
146# @DESCRIPTION: 152# @DESCRIPTION:
147# Internal function wrapping the submodule initialisation and update 153# Internal function wrapping the submodule initialisation and update
148git_sumbodules() { 154git_submodules() {
149 debug-print "git submodule init" 155 debug-print "git submodule init"
150 git submodule init 156 git submodule init
151 debug-print "git submodule update" 157 debug-print "git submodule update"
152 git submodule update 158 git submodule update
159}
160
161# @FUNCTION: git_branch
162# @DESCRIPTION:
163# Internal function that changes branch for the repo based on EGIT_TREE and
164# EGIT_BRANCH variables.
165git_branch() {
166 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
167 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then
168 branchname=tree-${EGIT_COMMIT}
169 src=${EGIT_COMMIT}
170 fi
171 debug-print "git checkout -b ${branchname} ${src}"
172 git checkout -b ${branchname} ${src} &> /dev/null
173
174 unset branchname src
153} 175}
154 176
155# @FUNCTION: git_fetch 177# @FUNCTION: git_fetch
156# @DESCRIPTION: 178# @DESCRIPTION:
157# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR 179# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR
173 # folder. 195 # folder.
174 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \ 196 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \
175 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1" 197 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1"
176 if [[ ! -z ${EGIT_TREE} ]] ; then 198 if [[ ! -z ${EGIT_TREE} ]] ; then
177 EGIT_COMMIT=${EGIT_TREE} 199 EGIT_COMMIT=${EGIT_TREE}
178 eqawarn "Usage of deprecated EGIT_TREE variable detected." 200 ewarn "QA: Usage of deprecated EGIT_TREE variable detected."
179 eqawarn "Use EGIT_COMMIT variable instead." 201 ewarn "QA: Use EGIT_COMMIT variable instead."
180 fi 202 fi
181 203
182 # EGIT_REPO_URI is empty. 204 # EGIT_REPO_URI is empty.
183 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." 205 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty."
184 206
210 EGIT_CLONE_DIR="${EGIT_PROJECT}" 232 EGIT_CLONE_DIR="${EGIT_PROJECT}"
211 233
212 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\"" 234 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\""
213 235
214 GIT_DIR="${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" 236 GIT_DIR="${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
215 pushd ${EGIT_STORE_DIR} &> /dev/null
216 # we also have to remove all shallow copied repositories 237 # we also have to remove all shallow copied repositories
217 # and fetch them again 238 # and fetch them again
218 if [[ -e "${GIT_DIR}/shallow" ]]; then 239 if [[ -e "${GIT_DIR}/shallow" ]]; then
219 rm -rf "${GIT_DIR}" 240 rm -rf "${GIT_DIR}"
220 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching." 241 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching."
236 257
237 pushd "${GIT_DIR}" &> /dev/null 258 pushd "${GIT_DIR}" &> /dev/null
238 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 259 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
239 ${elogcmd} " at the commit: ${cursha1}" 260 ${elogcmd} " at the commit: ${cursha1}"
240 261
241 git_sumbodules 262 git_submodules
242 popd &> /dev/null 263 popd &> /dev/null
243 elif [[ -n ${EGIT_OFFLINE} ]] ; then 264 elif [[ -n ${EGIT_OFFLINE} ]] ; then
244 pushd "${GIT_DIR}" &> /dev/null 265 pushd "${GIT_DIR}" &> /dev/null
245 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 266 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
246 ${elogcmd} "GIT offline update -->" 267 ${elogcmd} "GIT offline update -->"
257 ${elogcmd} " repository: ${EGIT_REPO_URI}" 278 ${elogcmd} " repository: ${EGIT_REPO_URI}"
258 279
259 oldsha1=$(git rev-parse origin/${EGIT_BRANCH}) 280 oldsha1=$(git rev-parse origin/${EGIT_BRANCH})
260 281
261 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}" 282 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}"
283 # fix branching
284 git checkout ${EGIT_MASTER}
285 for x in $(git branch |grep -v "* master" |tr '\n' ' '); do
286 git branch -D ${x}
287 done
262 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} \ 288 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} \
263 || die "${EGIT}: can't update from ${EGIT_REPO_URI}." 289 || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
264 290
265 git_sumbodules 291 git_submodules
266 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 292 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
267 293
268 # write out message based on the revisions 294 # write out message based on the revisions
269 if [[ ${oldsha1} != ${cursha1} ]]; then 295 if [[ ${oldsha1} != ${cursha1} ]]; then
270 ${elogcmd} " updating from commit: ${oldsha1}" 296 ${elogcmd} " updating from commit: ${oldsha1}"
295 popd &> /dev/null 321 popd &> /dev/null
296 322
297 # export the git version 323 # export the git version
298 export EGIT_VERSION="${cursha1}" 324 export EGIT_VERSION="${cursha1}"
299 325
326 # log the repo state
300 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}" 327 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}"
301 ${elogcmd} " branch: ${EGIT_BRANCH}" 328 ${elogcmd} " branch: ${EGIT_BRANCH}"
302 ${elogcmd} " storage directory: \"${GIT_DIR}\"" 329 ${elogcmd} " storage directory: \"${GIT_DIR}\""
303 330
304 # unpack to the ${S} 331 pushd "${GIT_DIR}" &> /dev/null
332 debug-print "rsync -rlpgo . \"${S}\""
333 time rsync -rlpgo . "${S}"
305 popd &> /dev/null 334 popd &> /dev/null
306 debug-print "git clone -l \"${GIT_DIR}\" \"${S}\""
307 git clone -l "${GIT_DIR}" "${S}"
308 335
309 # set correct branch and the tree ebuild specified
310 pushd "${S}" > /dev/null 336 pushd "${S}" &> /dev/null
311 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} 337 git_branch
312 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then 338 # submodules always reqire net (thanks to branches changing)
313 branchname=tree-${EGIT_COMMIT} 339 [[ -n ${EGIT_OFFLINE} ]] || git_submodules
314 src=${EGIT_COMMIT}
315 fi
316 debug-print "git checkout -b ${branchname} ${src}"
317 git checkout -b ${branchname} ${src} 2>&1 > /dev/null
318 git_sumbodules
319 popd > /dev/null 340 popd &> /dev/null
320
321 unset branchname src
322 341
323 echo ">>> Unpacked to ${S}" 342 echo ">>> Unpacked to ${S}"
324} 343}
325 344
326# @FUNCTION: git_bootstrap 345# @FUNCTION: git_bootstrap

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20