/[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.12
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.12 2008/06/15 17:47:57 zlin 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"
93# 93#
94# bootstrap script or command like autogen.sh or etc.. 94# bootstrap script or command like autogen.sh or etc..
95# 95#
96: ${EGIT_BOOTSTRAP:=} 96: ${EGIT_BOOTSTRAP:=}
97 97
98# @ECLASS-VARIABLE: EGIT_OFFLINE
99# @DESCRIPTION:
100# Set this variable to a non-empty value to disable the automatic updating of
101# an GIT source tree. This is intended to be set outside the git source
102# tree by users.
103EGIT_OFFLINE="${EGIT_OFFLINE:-${ESCM_OFFLINE}}"
98 104
99## -- EGIT_PATCHES: 105## -- EGIT_PATCHES:
100# 106#
101# git eclass can apply pathces in git_bootstrap(). 107# git eclass can apply pathces in git_bootstrap().
102# you can use regexp in this valiable like *.diff or *.patch or etc. 108# you can use regexp in this valiable like *.diff or *.patch or etc.
111 117
112 118
113## -- EGIT_BRANCH: 119## -- EGIT_BRANCH:
114# 120#
115# git eclass can fetch any branch in git_fetch(). 121# git eclass can fetch any branch in git_fetch().
122# If set, it must be before 'inherit git', otherwise both EGIT_BRANCH and
123# EGIT_TREE must be set after 'inherit git'.
116# Defaults to 'master' 124# Defaults to 'master'
117# 125#
118: ${EGIT_BRANCH:=master} 126: ${EGIT_BRANCH:=master}
119 127
120 128
150 local EGIT_CLONE_DIR 158 local EGIT_CLONE_DIR
151 159
152 # EGIT_REPO_URI is empty. 160 # EGIT_REPO_URI is empty.
153 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." 161 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty."
154 162
155 # check for the protocol. 163 # check for the protocol or pull from a local repo.
164 if [[ -z ${EGIT_REPO_URI%%:*} ]] ; then
156 case ${EGIT_REPO_URI%%:*} in 165 case ${EGIT_REPO_URI%%:*} in
157 git*|http|https|rsync|ssh) 166 git*|http|https|rsync|ssh)
158 ;; 167 ;;
159 *) 168 *)
160 die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented." 169 die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented."
161 ;; 170 ;;
162 esac 171 esac
172 fi
163 173
164 if [[ ! -d ${EGIT_STORE_DIR} ]] ; then 174 if [[ ! -d ${EGIT_STORE_DIR} ]] ; then
165 debug-print "${FUNCNAME}: initial clone. creating git directory" 175 debug-print "${FUNCNAME}: initial clone. creating git directory"
166 addwrite / 176 addwrite /
167 mkdir -p "${EGIT_STORE_DIR}" \ 177 mkdir -p "${EGIT_STORE_DIR}" \
168 || die "${EGIT}: can't mkdir ${EGIT_STORE_DIR}." 178 || die "${EGIT}: can't mkdir ${EGIT_STORE_DIR}."
169 chmod -f o+rw "${EGIT_STORE_DIR}" \
170 || die "${EGIT}: can't chmod ${EGIT_STORE_DIR}."
171 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" 179 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
172 fi 180 fi
173 181
174 cd -P "${EGIT_STORE_DIR}" || die "${EGIT}: can't chdir to ${EGIT_STORE_DIR}" 182 cd -P "${EGIT_STORE_DIR}" || die "${EGIT}: can't chdir to ${EGIT_STORE_DIR}"
175 EGIT_STORE_DIR=${PWD} 183 EGIT_STORE_DIR=${PWD}
180 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}" 188 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
181 EGIT_CLONE_DIR="${EGIT_PROJECT}" 189 EGIT_CLONE_DIR="${EGIT_PROJECT}"
182 190
183 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\"" 191 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\""
184 192
185 export GIT_DIR="${EGIT_CLONE_DIR}" 193 export GIT_DIR="${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
186 194
187 if [[ ! -d ${EGIT_CLONE_DIR} ]] ; then 195 if [[ ! -d ${EGIT_CLONE_DIR} ]] ; then
188 # first clone 196 # first clone
189 einfo "git clone start -->" 197 einfo "git clone start -->"
190 einfo " repository: ${EGIT_REPO_URI}" 198 einfo " repository: ${EGIT_REPO_URI}"
191 199
192 ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} \ 200 ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} \
193 || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}." 201 || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}."
194 202
195 # We use --bare cloning, so git doesn't do this for us. 203 # We use --bare cloning, so git doesn't do this for us.
196 git repo-config remote.origin.url "${EGIT_REPO_URI}" 204 git config remote.origin.url "${EGIT_REPO_URI}"
205 elif [[ -n ${EGIT_OFFLINE} ]] ; then
206 local oldsha1=$(git rev-parse ${EGIT_BRANCH})
207 einfo "git update offline mode -->"
208 einfo " repository: ${EGIT_REPO_URI}"
209 einfo " commit: ${oldsha1}"
197 else 210 else
211 # Git urls might change, so unconditionally set it here
212 git config remote.origin.url "${EGIT_REPO_URI}"
213
198 # fetch updates 214 # fetch updates
199 einfo "git update start -->" 215 einfo "git update start -->"
200 einfo " repository: ${EGIT_REPO_URI}" 216 einfo " repository: ${EGIT_REPO_URI}"
201 217
202 local oldsha1=$(git rev-parse ${EGIT_BRANCH}) 218 local oldsha1=$(git rev-parse ${EGIT_BRANCH})
203 219
204 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \ 220 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \
205 || die "${EGIT}: can't update from ${EGIT_REPO_URI}." 221 || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
206 222
223 # piping through cat is needed to avoid a stupid Git feature
207 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} 224 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} | cat
208 fi 225 fi
209 226
210 einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" 227 einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
211 228
212 if ${EGIT_REPACK} ; then 229 if ${EGIT_REPACK} || ${EGIT_PRUNE} ; then
213 ebegin "Repacking objects" 230 ebegin "Garbage collecting the repository"
214 # Strangely enough mv asks confirmation 231 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 $? 232 eend $?
223 fi 233 fi
224 234
225 einfo " committish: ${EGIT_TREE}" 235 einfo " committish: ${EGIT_TREE}"
226 236
227 # export to the ${WORKDIR} 237 # export to the ${WORKDIR}
228 mkdir -p "${S}" 238 mkdir -p "${S}"
229 git tar-tree ${EGIT_TREE} | ( cd "${S}" ; tar xf - ) 239 git archive --format=tar ${EGIT_TREE} | ( cd "${S}" ; tar xf - )
230 echo 240
241 echo ">>> Unpacked to ${S}"
231 242
232} 243}
233 244
234 245
235## -- git_bootstrap() ------------------------------------------------ # 246## -- git_bootstrap() ------------------------------------------------ #

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

  ViewVC Help
Powered by ViewVC 1.1.20