/[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.24 Revision 1.28
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.24 2011/09/23 13:58:58 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.28 2012/01/19 16:53:39 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# Michał Górny <mgorny@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 9# @BLURB: Eclass for fetching and unpacking git repositories.
9# @DESCRIPTION: 10# @DESCRIPTION:
10# Eclass for easing maitenance of live ebuilds using git as remote repository. 11# Eclass for easing maitenance of live ebuilds using git as remote repository.
11# Eclass support working with git submodules and branching. 12# Eclass support working with git submodules and branching.
12 13
245 # initial clone, we have to create master git storage directory and play 246 # initial clone, we have to create master git storage directory and play
246 # nicely with sandbox 247 # nicely with sandbox
247 if [[ ! -d ${EGIT_STORE_DIR} ]]; then 248 if [[ ! -d ${EGIT_STORE_DIR} ]]; then
248 debug-print "${FUNCNAME}: Creating git main storage directory" 249 debug-print "${FUNCNAME}: Creating git main storage directory"
249 addwrite / 250 addwrite /
250 mkdir -p "${EGIT_STORE_DIR}" \ 251 mkdir -m 775 -p "${EGIT_STORE_DIR}" \
251 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" 252 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\""
252 fi 253 fi
253 254
254 # allow writing into EGIT_STORE_DIR 255 # allow writing into EGIT_STORE_DIR
255 addwrite "${EGIT_STORE_DIR}" 256 addwrite "${EGIT_STORE_DIR}"
257
258 # calculate git.eclass store dir for data
259 # We will try to clone the old repository,
260 # and we will remove it if we don't need it anymore.
261 EGIT_OLD_CLONE=
262 if [[ ${EGIT_STORE_DIR} == */egit-src ]]; then
263 local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
264 local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
265
266 if [[ -d ${old_location} ]]; then
267 EGIT_OLD_CLONE=${old_location}
268 # required to remove the old clone
269 addwrite "${old_store_dir}"
270 fi
271 fi
272
256 # calculate the proper store dir for data 273 # calculate the proper store dir for data
257 # If user didn't specify the EGIT_DIR, we check if he did specify 274 # If user didn't specify the EGIT_DIR, we check if he did specify
258 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI. 275 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
259 EGIT_REPO_URI=${EGIT_REPO_URI%/} 276 EGIT_REPO_URI=${EGIT_REPO_URI%/}
260 if [[ ! ${EGIT_DIR} ]]; then 277 if [[ ! ${EGIT_DIR} ]]; then
261 if [[ ${EGIT_PROJECT} ]]; then 278 if [[ ${EGIT_PROJECT} ]]; then
262 clone_dir=${EGIT_PROJECT} 279 clone_dir=${EGIT_PROJECT}
263 else 280 else
264 clone_dir=${EGIT_REPO_URI##*/} 281 local strippeduri=${EGIT_REPO_URI%/.git}
282 clone_dir=${strippeduri##*/}
265 fi 283 fi
266 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} 284 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
267 285
268 # Try to migrate from git.eclass git-src/ 286 if [[ ${EGIT_OLD_CLONE} && ! -d ${EGIT_DIR} ]]; then
269 if [[ ! -d ${EGIT_DIR} && ${EGIT_STORE_DIR} == */egit-src ]]; then
270 local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
271 local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
272
273 if [[ -d ${old_location} ]]; then
274 elog "${FUNCNAME}: ${CATEGORY}/${PF} will be cloned from old location." 287 elog "${FUNCNAME}: ${CATEGORY}/${PF} will be cloned from old location."
275 elog "It will be necessary to rebuild the package to fetch updates." 288 elog "It will be necessary to rebuild the package to fetch updates."
276 EGIT_REPO_URI="${old_location} ${EGIT_REPO_URI}" 289 EGIT_REPO_URI="${EGIT_OLD_CLONE} ${EGIT_REPO_URI}"
277 fi
278 fi 290 fi
279 fi 291 fi
280 export EGIT_DIR=${EGIT_DIR} 292 export EGIT_DIR=${EGIT_DIR}
281 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"." 293 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
282} 294}
412 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ 424 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
413 && echo " commit: ${EGIT_COMMIT}" 425 && echo " commit: ${EGIT_COMMIT}"
414 echo " branch: ${EGIT_BRANCH}" 426 echo " branch: ${EGIT_BRANCH}"
415 echo " storage directory: \"${EGIT_DIR}\"" 427 echo " storage directory: \"${EGIT_DIR}\""
416 echo " checkout type: ${repo_type}" 428 echo " checkout type: ${repo_type}"
429
430 # Cleanup after git.eclass
431 if [[ ${EGIT_OLD_CLONE} ]]; then
432 einfo "${FUNCNAME}: removing old clone in ${EGIT_OLD_CLONE}."
433 rm -rf "${EGIT_OLD_CLONE}"
434 fi
417} 435}
418 436
419# @FUNCTION: git_bootstrap 437# @FUNCTION: git_bootstrap
420# @INTERNAL 438# @INTERNAL
421# @DESCRIPTION: 439# @DESCRIPTION:

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20