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

Diff of /eclass/git-2.eclass

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

Revision 1.16 Revision 1.17
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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-2.eclass,v 1.16 2011/09/23 13:56:29 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.17 2011/09/23 13:57:15 mgorny Exp $
4 4
5# @ECLASS: git-2.eclass 5# @ECLASS: git-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Donnie Berkholz <dberkholz@gentoo.org> 7# Donnie Berkholz <dberkholz@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 8# @BLURB: Eclass for fetching and unpacking git repositories.
140 140
141 : ${EGIT_MASTER:=master} 141 : ${EGIT_MASTER:=master}
142 142
143 liverepo=${esc_pn}_LIVE_REPO 143 liverepo=${esc_pn}_LIVE_REPO
144 EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}} 144 EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
145 [[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value" 145 [[ ${EGIT_REPO_URI} ]] || die "EGIT_REPO_URI must have some value"
146 146
147 : ${EVCS_OFFLINE:=} 147 : ${EVCS_OFFLINE:=}
148 148
149 livebranch=${esc_pn}_LIVE_BRANCH 149 livebranch=${esc_pn}_LIVE_BRANCH
150 [[ -n ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support" 150 [[ ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
151 EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}} 151 EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
152 152
153 livecommit=${esc_pn}_LIVE_COMMIT 153 livecommit=${esc_pn}_LIVE_COMMIT
154 [[ -n ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support" 154 [[ ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
155 EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}} 155 EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
156 156
157 : ${EGIT_REPACK:=} 157 : ${EGIT_REPACK:=}
158 158
159 : ${EGIT_PRUNE:=} 159 : ${EGIT_PRUNE:=}
162# @FUNCTION: git-2_submodules 162# @FUNCTION: git-2_submodules
163# @DESCRIPTION: 163# @DESCRIPTION:
164# Internal function wrapping the submodule initialisation and update. 164# Internal function wrapping the submodule initialisation and update.
165git-2_submodules() { 165git-2_submodules() {
166 debug-print-function ${FUNCNAME} "$@" 166 debug-print-function ${FUNCNAME} "$@"
167 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then 167 if [[ ${EGIT_HAS_SUBMODULES} ]]; then
168 if [[ -n ${EVCS_OFFLINE} ]]; then 168 if [[ ${EVCS_OFFLINE} ]]; then
169 # for submodules operations we need to be online 169 # for submodules operations we need to be online
170 debug-print "${FUNCNAME}: not updating submodules in offline mode" 170 debug-print "${FUNCNAME}: not updating submodules in offline mode"
171 return 1 171 return 1
172 fi 172 fi
173 173
216 debug-print-function ${FUNCNAME} "$@" 216 debug-print-function ${FUNCNAME} "$@"
217 217
218 local args 218 local args
219 219
220 pushd "${EGIT_DIR}" > /dev/null 220 pushd "${EGIT_DIR}" > /dev/null
221 if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then 221 if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
222 ebegin "Garbage collecting the repository" 222 ebegin "Garbage collecting the repository"
223 [[ -n ${EGIT_PRUNE} ]] && args='--prune' 223 [[ ${EGIT_PRUNE} ]] && args='--prune'
224 debug-print "${FUNCNAME}: git gc ${args}" 224 debug-print "${FUNCNAME}: git gc ${args}"
225 git gc ${args} 225 git gc ${args}
226 eend $? 226 eend $?
227 fi 227 fi
228 popd > /dev/null 228 popd > /dev/null
250 addwrite "${EGIT_STORE_DIR}" 250 addwrite "${EGIT_STORE_DIR}"
251 # calculate the proper store dir for data 251 # calculate the proper store dir for data
252 # If user didn't specify the EGIT_DIR, we check if he did specify 252 # If user didn't specify the EGIT_DIR, we check if he did specify
253 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI. 253 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
254 EGIT_REPO_URI=${EGIT_REPO_URI%/} 254 EGIT_REPO_URI=${EGIT_REPO_URI%/}
255 if [[ -z ${EGIT_DIR} ]]; then 255 if [[ ! ${EGIT_DIR} ]]; then
256 if [[ -n ${EGIT_PROJECT} ]]; then 256 if [[ ${EGIT_PROJECT} ]]; then
257 clone_dir=${EGIT_PROJECT} 257 clone_dir=${EGIT_PROJECT}
258 else 258 else
259 clone_dir=${EGIT_REPO_URI##*/} 259 clone_dir=${EGIT_REPO_URI##*/}
260 fi 260 fi
261 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} 261 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
297 EGIT_REPO_URI_SELECTED="${repo_uri}" 297 EGIT_REPO_URI_SELECTED="${repo_uri}"
298 break 298 break
299 fi 299 fi
300 done 300 done
301 301
302 if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then 302 [[ ${EGIT_REPO_URI_SELECTED} ]] \
303 die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}" 303 || die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
304 fi
305} 304}
306 305
307# @FUNCTION: git-2_update_repo 306# @FUNCTION: git-2_update_repo
308# @DESCRIPTION: 307# @DESCRIPTION:
309# Internal function running update command on specified repo_uri. 308# Internal function running update command on specified repo_uri.
310git-2_update_repo() { 309git-2_update_repo() {
311 debug-print-function ${FUNCNAME} "$@" 310 debug-print-function ${FUNCNAME} "$@"
312 311
313 local repo_uri 312 local repo_uri
314 313
315 if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then 314 if [[ ${EGIT_LOCAL_NONBARE} ]]; then
316 # checkout master branch and drop all other local branches 315 # checkout master branch and drop all other local branches
317 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}" 316 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
318 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do 317 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
319 debug-print "${FUNCNAME}: git branch -D ${x}" 318 debug-print "${FUNCNAME}: git branch -D ${x}"
320 git branch -D ${x} > /dev/null 319 git branch -D ${x} > /dev/null
334 EGIT_REPO_URI_SELECTED="${repo_uri}" 333 EGIT_REPO_URI_SELECTED="${repo_uri}"
335 break 334 break
336 fi 335 fi
337 done 336 done
338 337
339 if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then 338 [[ ${EGIT_REPO_URI_SELECTED} ]] \
340 die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}" 339 || die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
341 fi
342} 340}
343 341
344# @FUNCTION: git-2_fetch 342# @FUNCTION: git-2_fetch
345# @DESCRIPTION: 343# @DESCRIPTION:
346# Internal function fetching repository from EGIT_REPO_URI and storing it in 344# Internal function fetching repository from EGIT_REPO_URI and storing it in
348git-2_fetch() { 346git-2_fetch() {
349 debug-print-function ${FUNCNAME} "$@" 347 debug-print-function ${FUNCNAME} "$@"
350 348
351 local oldsha cursha repo_type 349 local oldsha cursha repo_type
352 350
353 [[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository" 351 [[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
354 352
355 if [[ ! -d ${EGIT_DIR} ]]; then 353 if [[ ! -d ${EGIT_DIR} ]]; then
356 git-2_initial_clone 354 git-2_initial_clone
357 pushd "${EGIT_DIR}" > /dev/null 355 pushd "${EGIT_DIR}" > /dev/null
358 cursha=$(git rev-parse ${UPSTREAM_BRANCH}) 356 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
359 echo "GIT NEW clone -->" 357 echo "GIT NEW clone -->"
360 echo " repository: ${EGIT_REPO_URI_SELECTED}" 358 echo " repository: ${EGIT_REPO_URI_SELECTED}"
361 echo " at the commit: ${cursha}" 359 echo " at the commit: ${cursha}"
362 360
363 popd > /dev/null 361 popd > /dev/null
364 elif [[ -n ${EVCS_OFFLINE} ]]; then 362 elif [[ ${EVCS_OFFLINE} ]]; then
365 pushd "${EGIT_DIR}" > /dev/null 363 pushd "${EGIT_DIR}" > /dev/null
366 cursha=$(git rev-parse ${UPSTREAM_BRANCH}) 364 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
367 echo "GIT offline update -->" 365 echo "GIT offline update -->"
368 echo " repository: $(git config remote.origin.url)" 366 echo " repository: $(git config remote.origin.url)"
369 echo " at the commit: ${cursha}" 367 echo " at the commit: ${cursha}"
410 # Command to be executed after checkout and clone of the specified 408 # Command to be executed after checkout and clone of the specified
411 # repository. 409 # repository.
412 # enviroment the package will fail if there is no update, thus in 410 # enviroment the package will fail if there is no update, thus in
413 # combination with --keep-going it would lead in not-updating 411 # combination with --keep-going it would lead in not-updating
414 # pakcages that are up-to-date. 412 # pakcages that are up-to-date.
415 if [[ -n ${EGIT_BOOTSTRAP} ]]; then 413 if [[ ${EGIT_BOOTSTRAP} ]]; then
416 pushd "${EGIT_SOURCEDIR}" > /dev/null 414 pushd "${EGIT_SOURCEDIR}" > /dev/null
417 einfo "Starting bootstrap" 415 einfo "Starting bootstrap"
418 416
419 if [[ -f ${EGIT_BOOTSTRAP} ]]; then 417 if [[ -f ${EGIT_BOOTSTRAP} ]]; then
420 # we have file in the repo which we should execute 418 # we have file in the repo which we should execute
452 debug-print-function ${FUNCNAME} "$@" 450 debug-print-function ${FUNCNAME} "$@"
453 451
454 local target returnstate 452 local target returnstate
455 453
456 # first find out if we have submodules 454 # first find out if we have submodules
457 if [[ -z ${EGIT_HAS_SUBMODULES} ]]; then 455 if [[ ! ${EGIT_HAS_SUBMODULES} ]]; then
458 target="bare" 456 target="bare"
459 else 457 else
460 target="full" 458 target="full"
461 fi 459 fi
462 # check if user didn't specify that we want non-bare repo 460 # check if user didn't specify that we want non-bare repo
463 if [[ -n ${EGIT_NONBARE} ]]; then 461 if [[ ${EGIT_NONBARE} ]]; then
464 target="full" 462 target="full"
465 EGIT_LOCAL_NONBARE="true" 463 EGIT_LOCAL_NONBARE="true"
466 fi 464 fi
467 465
468 # test if we already have some repo and if so find out if we have 466 # test if we already have some repo and if so find out if we have
555 git-2_cleanup 553 git-2_cleanup
556 echo ">>> Unpacked to ${EGIT_SOURCEDIR}" 554 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
557 555
558 # Users can specify some SRC_URI and we should 556 # Users can specify some SRC_URI and we should
559 # unpack the files too. 557 # unpack the files too.
560 if [[ -z ${EGIT_NOUNPACK} ]]; then 558 if [[ ! ${EGIT_NOUNPACK} ]]; then
561 if has ${EAPI:-0} 0 1; then 559 if has ${EAPI:-0} 0 1; then
562 [[ -n ${A} ]] && unpack ${A} 560 [[ ${A} ]] && unpack ${A}
563 else 561 else
564 default_src_unpack 562 default_src_unpack
565 fi 563 fi
566 fi 564 fi
567} 565}

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20