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

Diff of /eclass/git.eclass

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

Revision 1.1 Revision 1.8
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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.1 2006/09/11 08:46:09 ferdy Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.8 2007/12/27 01:02:30 robbat2 Exp $
4 4
5## --------------------------------------------------------------------------- # 5## --------------------------------------------------------------------------- #
6# subversion.eclass author: Akinori Hattori <hattya@gentoo.org> 6# subversion.eclass author: Akinori Hattori <hattya@gentoo.org>
7# modified for git by Donnie Berkholz <spyderous@gentoo.org> 7# modified for git by Donnie Berkholz <spyderous@gentoo.org>
8# improved by Fernando J. Pereda <ferdy@gentoo.org> 8# improved by Fernando J. Pereda <ferdy@gentoo.org>
27DESCRIPTION="Based on the ${ECLASS} eclass" 27DESCRIPTION="Based on the ${ECLASS} eclass"
28 28
29 29
30## -- add git in DEPEND 30## -- add git in DEPEND
31# 31#
32DEPEND=">=dev-util/git-1.4.0" 32DEPEND=">=dev-util/git-1.5"
33 33
34 34
35## -- EGIT_STORE_DIR: git sources store directory 35## -- EGIT_STORE_DIR: git sources store directory
36# 36#
37EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src" 37EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src"
111 111
112 112
113## -- EGIT_BRANCH: 113## -- EGIT_BRANCH:
114# 114#
115# git eclass can fetch any branch in git_fetch(). 115# git eclass can fetch any branch in git_fetch().
116# If set, it must be before 'inherit git', otherwise both EGIT_BRANCH and
117# EGIT_TREE must be set after 'inherit git'.
116# Defaults to 'master' 118# Defaults to 'master'
117# 119#
118: ${EGIT_BRANCH:=master} 120: ${EGIT_BRANCH:=master}
119 121
120 122
150 local EGIT_CLONE_DIR 152 local EGIT_CLONE_DIR
151 153
152 # EGIT_REPO_URI is empty. 154 # EGIT_REPO_URI is empty.
153 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." 155 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty."
154 156
155 # check for the protocol. 157 # check for the protocol or pull from a local repo.
158 if [[ -z ${EGIT_REPO_URI%%:*} ]] ; then
156 case ${EGIT_REPO_URI%%:*} in 159 case ${EGIT_REPO_URI%%:*} in
157 git*|http|https|rsync|ssh) 160 git*|http|https|rsync|ssh)
158 ;; 161 ;;
159 *) 162 *)
160 die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented." 163 die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented."
161 ;; 164 ;;
162 esac 165 esac
166 fi
163 167
164 if [[ ! -d ${EGIT_STORE_DIR} ]] ; then 168 if [[ ! -d ${EGIT_STORE_DIR} ]] ; then
165 debug-print "${FUNCNAME}: initial clone. creating git directory" 169 debug-print "${FUNCNAME}: initial clone. creating git directory"
166 addwrite / 170 addwrite /
167 mkdir -p "${EGIT_STORE_DIR}" \ 171 mkdir -p "${EGIT_STORE_DIR}" \
191 195
192 ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} \ 196 ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} \
193 || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}." 197 || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}."
194 198
195 # We use --bare cloning, so git doesn't do this for us. 199 # We use --bare cloning, so git doesn't do this for us.
196 git repo-config remote.origin.url "${EGIT_REPO_URI}" 200 git config remote.origin.url "${EGIT_REPO_URI}"
197 else 201 else
202 # Git urls might change, so unconditionally set it here
203 git config remote.origin.url "${EGIT_REPO_URI}"
204
198 # fetch updates 205 # fetch updates
199 einfo "git update start -->" 206 einfo "git update start -->"
200 einfo " repository: ${EGIT_REPO_URI}" 207 einfo " repository: ${EGIT_REPO_URI}"
201 208
202 local oldsha1=$(git rev-parse ${EGIT_BRANCH}) 209 local oldsha1=$(git rev-parse ${EGIT_BRANCH})
203 210
204 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \ 211 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \
205 || die "${EGIT}: can't update from ${EGIT_REPO_URI}." 212 || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
206 213
214 # piping through cat is needed to avoid a stupid Git feature
207 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} 215 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} | cat
208 fi 216 fi
209 217
210 einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" 218 einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
211 219
212 if ${EGIT_REPACK} ; then 220 if ${EGIT_REPACK} || ${EGIT_PRUNE} ; then
213 ebegin "Repacking objects" 221 ebegin "Garbage collecting the repository"
214 # Strangely enough mv asks confirmation 222 git gc $(${EGIT_PRUNE} && echo '--prune')
215 yes y | git repack -a -d -f -q > /dev/null
216 eend $?
217 fi
218
219 if ${EGIT_PRUNE} ; then
220 ebegin "Removing unreachable objects"
221 git prune
222 eend $? 223 eend $?
223 fi 224 fi
224 225
225 einfo " committish: ${EGIT_TREE}" 226 einfo " committish: ${EGIT_TREE}"
226 227
227 # export to the ${WORKDIR} 228 # export to the ${WORKDIR}
228 mkdir -p "${S}" 229 mkdir -p "${S}"
229 git tar-tree ${EGIT_TREE} | ( cd "${S}" ; tar xf - ) 230 git archive --format=tar ${EGIT_TREE} | ( cd "${S}" ; tar xf - )
230 echo 231
232 echo ">>> Unpacked to ${S}"
231 233
232} 234}
233 235
234 236
235## -- git_bootstrap() ------------------------------------------------ # 237## -- git_bootstrap() ------------------------------------------------ #

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

  ViewVC Help
Powered by ViewVC 1.1.20