/[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.1 Revision 1.12
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.1 2011/04/20 10:56:27 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.12 2011/07/16 13:11:54 mgorny Exp $
4 4
5# @ECLASS: git-2.eclass 5# @ECLASS: git-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Tomas Chvatal <scarabeus@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.
9# @DESCRIPTION: 9# @DESCRIPTION:
10# Eclass for easing maitenance of live ebuilds using git as remote repository. 10# Eclass for easing maitenance of live ebuilds using git as remote repository.
11# Eclass support working with git submodules and branching. 11# Eclass support working with git submodules and branching.
12 12
44# Variable for specifying master branch. 44# Variable for specifying master branch.
45# Usefull when upstream don't have master branch or name it differently. 45# Usefull when upstream don't have master branch or name it differently.
46# 46#
47# EGIT_MASTER="master" 47# EGIT_MASTER="master"
48 48
49# @ECLASS-VARIABLE: EGIT_PROJECT
50# @DESCRIPTION:
51# Variable specifying name for the folder where we check out the git
52# repository. Value of this variable should be unique in the
53# EGIT_STORE_DIR as otherwise you would override another repository.
54#
55# EGIT_PROJECT="${EGIT_REPO_URI##*/}"
56
49# @ECLASS-VARIABLE: EGIT_DIR 57# @ECLASS-VARIABLE: EGIT_DIR
50# @DESCRIPTION: 58# @DESCRIPTION:
51# Directory where we want to store the git data. 59# Directory where we want to store the git data.
52# This should not be overriden unless really required. 60# This should not be overriden unless really required.
53# 61#
54# EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_REPO_URI##*/}" 62# EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}"
55 63
56# @ECLASS-VARIABLE: EGIT_REPO_URI 64# @ECLASS-VARIABLE: EGIT_REPO_URI
57# @REQUIRED 65# @REQUIRED
58# @DEFAULT_UNSET 66# @DEFAULT_UNSET
59# @DESCRIPTION: 67# @DESCRIPTION:
81# @DESCRIPTION: 89# @DESCRIPTION:
82# Variable containing commit hash/tag we want to check out. 90# Variable containing commit hash/tag we want to check out.
83# It can be overriden via env using packagename_LIVE_COMMIT 91# It can be overriden via env using packagename_LIVE_COMMIT
84# variable. 92# variable.
85# 93#
86# EGIT_BRANCH="${EGIT_BRANCH}" 94# EGIT_COMMIT="${EGIT_BRANCH}"
87 95
88# @ECLASS-VARIABLE: EGIT_REPACK 96# @ECLASS-VARIABLE: EGIT_REPACK
89# @DEFAULT_UNSET 97# @DEFAULT_UNSET
90# @DESCRIPTION: 98# @DESCRIPTION:
91# If non-empty this variable specifies that repository will be repacked to 99# If non-empty this variable specifies that repository will be repacked to
228 addwrite / 236 addwrite /
229 mkdir -p "${EGIT_STORE_DIR}" \ 237 mkdir -p "${EGIT_STORE_DIR}" \
230 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" 238 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\""
231 fi 239 fi
232 240
233 cd -P "${EGIT_STORE_DIR}" \
234 || die "${FUNCNAME}: can't chdir to \"${EGIT_STORE_DIR}\""
235 # allow writing into EGIT_STORE_DIR 241 # allow writing into EGIT_STORE_DIR
236 addwrite "${EGIT_STORE_DIR}" 242 addwrite "${EGIT_STORE_DIR}"
237 # calculate the proper store dir for data 243 # calculate the proper store dir for data
244 # If user didn't specify the EGIT_DIR, we check if he did specify
245 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
238 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}" 246 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
239 if [[ -z ${EGIT_DIR} ]]; then 247 if [[ -z ${EGIT_DIR} ]]; then
248 if [[ -n ${EGIT_PROJECT} ]]; then
249 clone_dir=${EGIT_PROJECT}
250 else
240 clone_dir=${EGIT_REPO_URI##*/} 251 clone_dir=${EGIT_REPO_URI##*/}
252 fi
241 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} 253 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
242 fi 254 fi
243 export EGIT_DIR=${EGIT_DIR} 255 export EGIT_DIR=${EGIT_DIR}
244 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"." 256 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
245} 257}
304 EGIT_REPO_URI_SELECTED="" 316 EGIT_REPO_URI_SELECTED=""
305 for repo_uri in ${EGIT_REPO_URI}; do 317 for repo_uri in ${EGIT_REPO_URI}; do
306 # git urls might change, so reset it 318 # git urls might change, so reset it
307 git config remote.origin.url "${repo_uri}" 319 git config remote.origin.url "${repo_uri}"
308 320
309 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}" 321 debug-print "${EGIT_UPDATE_CMD}"
310 ${EGIT_UPDATE_CMD} > /dev/null 322 ${EGIT_UPDATE_CMD} > /dev/null
311 if [[ $? -eq 0 ]]; then 323 if [[ $? -eq 0 ]]; then
312 # global variable containing the repo_name we will be using 324 # global variable containing the repo_name we will be using
313 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" 325 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
314 EGIT_REPO_URI_SELECTED="${repo_uri}" 326 EGIT_REPO_URI_SELECTED="${repo_uri}"
356 368
357 # fetch updates 369 # fetch updates
358 echo "GIT update -->" 370 echo "GIT update -->"
359 echo " repository: ${EGIT_REPO_URI_SELECTED}" 371 echo " repository: ${EGIT_REPO_URI_SELECTED}"
360 # write out message based on the revisions 372 # write out message based on the revisions
361 if [[ "${oldsha1}" != "${cursha1}" ]]; then 373 if [[ "${oldsha}" != "${cursha}" ]]; then
362 echo " updating from commit: ${oldsha}" 374 echo " updating from commit: ${oldsha}"
363 echo " to commit: ${cursha}" 375 echo " to commit: ${cursha}"
364 else 376 else
365 echo " at the commit: ${cursha}" 377 echo " at the commit: ${cursha}"
366 fi 378 fi
368 # print nice statistic of what was changed 380 # print nice statistic of what was changed
369 git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH} 381 git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH}
370 popd > /dev/null 382 popd > /dev/null
371 fi 383 fi
372 # export the version the repository is at 384 # export the version the repository is at
373 export EGIT_VERSION="${cursha1}" 385 export EGIT_VERSION="${cursha}"
374 # log the repo state 386 # log the repo state
375 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ 387 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
376 && echo " commit: ${EGIT_COMMIT}" 388 && echo " commit: ${EGIT_COMMIT}"
377 echo " branch: ${EGIT_BRANCH}" 389 echo " branch: ${EGIT_BRANCH}"
378 echo " storage directory: \"${EGIT_DIR}\"" 390 echo " storage directory: \"${EGIT_DIR}\""
477 # set various options to work with both targets 489 # set various options to work with both targets
478 if [[ ${target} == bare ]]; then 490 if [[ ${target} == bare ]]; then
479 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" 491 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
480 EGIT_OPTIONS+=" --bare" 492 EGIT_OPTIONS+=" --bare"
481 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" 493 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
482 EGIT_UPDATE_CMD="git fetch -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}" 494 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
483 UPSTREAM_BRANCH="${EGIT_BRANCH}" 495 UPSTREAM_BRANCH="${EGIT_BRANCH}"
484 else 496 else
485 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\"" 497 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
486 MOVE_COMMAND="cp -pPR ." 498 MOVE_COMMAND="cp -pPR ."
487 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}" 499 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
490 fi 502 fi
491} 503}
492 504
493# @FUNCTION: git-2_src_unpack 505# @FUNCTION: git-2_src_unpack
494# @DESCRIPTION: 506# @DESCRIPTION:
495# Default git src_upack function. 507# Default git src_unpack function.
496git-2_src_unpack() { 508git-2_src_unpack() {
497 debug-print-function ${FUNCNAME} "$@" 509 debug-print-function ${FUNCNAME} "$@"
498 510
499 git-2_init_variables 511 git-2_init_variables
500 git-2_prepare_storedir 512 git-2_prepare_storedir
504 git-2_submodules 516 git-2_submodules
505 git-2_move_source 517 git-2_move_source
506 git-2_branch 518 git-2_branch
507 git-2_bootstrap 519 git-2_bootstrap
508 echo ">>> Unpacked to ${EGIT_SOURCEDIR}" 520 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
521
522 # Users can specify some SRC_URI and we should
523 # unpack the files too.
524 if has ${EAPI:-0} 0 1; then
525 [[ -n ${A} ]] && unpack ${A}
526 else
527 default_src_unpack
528 fi
509} 529}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20