aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorDonnie Berkholz <donnie@comet.(none)>2006-05-19 10:29:04 -0700
committerDonnie Berkholz <donnie@comet.(none)>2006-05-19 10:29:04 -0700
commitb4a00eb84e60c0e74d6536e7ed21562164b83f4a (patch)
tree87f191ba38ce7022cde282c4536fec17b610f278 /eclass
parentAdd autotooled, eselect-lapack compatible lapack-reference (diff)
downloaddberkholz-b4a00eb84e60c0e74d6536e7ed21562164b83f4a.tar.gz
dberkholz-b4a00eb84e60c0e74d6536e7ed21562164b83f4a.tar.bz2
dberkholz-b4a00eb84e60c0e74d6536e7ed21562164b83f4a.zip
Changes from ferdy:
- Branches are supported - Only updates from the branch you used - Clones a bare repository without a checkout - Uses git tar-tree instead of rsync to copy to $WORKDIR - Can prune and repack repository to save disk space and improve performance - "Bashifies" it -- tests with [[ ]] instead of [ ], better line wrapping, etc.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/git.eclass145
1 files changed, 99 insertions, 46 deletions
diff --git a/eclass/git.eclass b/eclass/git.eclass
index 57a6f7d..ca77f71 100644
--- a/eclass/git.eclass
+++ b/eclass/git.eclass
@@ -1,10 +1,11 @@
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: $
+# $Header: /var/cvs/overlay/eclass/git.eclass,v 1.4 2006/05/19 11:36:14 ferdy Exp $
## --------------------------------------------------------------------------- #
# subversion.eclass author: Akinori Hattori <hattya@gentoo.org>
# modified for git by Donnie Berkholz <spyderous@gentoo.org>
+# improved by Fernando J. Pereda <ferdy@gentoo.org>
#
# The git eclass is written to fetch the software sources from
# git repositories like the subversion eclass.
@@ -22,7 +23,7 @@ EGIT="git.eclass"
EXPORT_FUNCTIONS src_unpack
-HOMEPAGE="http://kernel.org/pub/software/scm/git/"
+HOMEPAGE="http://git.or.cz/"
DESCRIPTION="Based on the ${ECLASS} eclass"
@@ -36,20 +37,20 @@ DEPEND="dev-util/git"
EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src"
-## -- EGIT_FETCH_CMD: git fetch command
+## -- EGIT_FETCH_CMD: git clone command
#
-EGIT_FETCH_CMD="git-clone"
+EGIT_FETCH_CMD="git clone --bare"
-## -- EGIT_UPDATE_CMD: git update command
+## -- EGIT_UPDATE_CMD: git fetch command
#
-EGIT_UPDATE_CMD="git-pull"
+EGIT_UPDATE_CMD="git fetch -f -n -u"
## -- EGIT_OPTIONS:
#
# the options passed to checkout or update.
#
-[ -z "${EGIT_OPTIONS}" ] && EGIT_OPTIONS=
+: ${EGIT_OPTIONS:=}
## -- EGIT_REPO_URI: repository uri
@@ -64,7 +65,7 @@ EGIT_UPDATE_CMD="git-pull"
# rsync://
# ssh://
#
-[ -z "${EGIT_REPO_URI}" ] && EGIT_REPO_URI=""
+: ${EGIT_REPO_URI:=}
## -- EGIT_PROJECT: project name of your ebuild
@@ -81,19 +82,19 @@ EGIT_UPDATE_CMD="git-pull"
#
# default: ${PN/-git}.
#
-[ -z "${EGIT_PROJECT}" ] && EGIT_PROJECT="${PN/-git}"
+: ${EGIT_PROJECT:=${PN/-git}}
## -- EGIT_BOOTSTRAP:
#
# bootstrap script or command like autogen.sh or etc..
#
-[ -z "${EGIT_BOOTSTRAP}" ] && EGIT_BOOTSTRAP=""
+: ${EGIT_BOOTSTRAP:=}
## -- EGIT_PATCHES:
#
-# git eclass can apply pathces in git_bootstrap().
+# git eclass can apply patches in git_bootstrap().
# you can use regexp in this valiable like *.diff or *.patch or etc.
# NOTE: this patches will apply before eval EGIT_BOOTSTRAP.
#
@@ -102,17 +103,50 @@ EGIT_UPDATE_CMD="git-pull"
# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
# 3. die.
#
-[ -z "${EGIT_PATCHES}" ] && EGIT_PATCHES=""
+: ${EGIT_BOOTSTRAP:=}
+
+
+## -- EGIT_BRANCH:
+#
+# git eclass can fetch any branch in git_fetch().
+# Defaults to 'master'
+#
+: ${EGIT_BRANCH:=master}
+
+
+## -- EGIT_TREE:
+#
+# git eclass can checkout any tree.
+# Defaults to EGIT_BRANCH.
+#
+: ${EGIT_TREE:=${EGIT_BRANCH}}
+
+
+## - EGIT_REPACK:
+#
+# git eclass will repack objects to save disk space. However this can take a
+# long time with VERY big repositories. If this is your case set:
+# EGIT_REPACK=false
+#
+: ${EGIT_REPACK:=true}
+
+## - EGIT_PRUNE:
+#
+# git eclass can prune the local clone. This is useful if upstream rewinds and
+# rebases branches too often. If you don't want this to happen, set:
+# EGIT_PRUNE=false
+#
+: ${EGIT_PRUNE:=true}
## -- git_fetch() ------------------------------------------------- #
function git_fetch() {
- local EGIT_CO_DIR
+ local EGIT_CLONE_DIR
# EGIT_REPO_URI is empty.
- [ -z "${EGIT_REPO_URI}" ] && die "${EGIT}: EGIT_REPO_URI is empty."
+ [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty."
# check for the protocol.
case ${EGIT_REPO_URI%%:*} in
@@ -123,11 +157,14 @@ function git_fetch() {
;;
esac
- if [ ! -d "${EGIT_STORE_DIR}" ]; then
- debug-print "${FUNCNAME}: initial checkout. creating git directory"
+
+ if [[ ! -d ${EGIT_STORE_DIR} ]] ; then
+ debug-print "${FUNCNAME}: initial clone. creating git directory"
addwrite /
- mkdir -p "${EGIT_STORE_DIR}" || die "${EGIT}: can't mkdir ${EGIT_STORE_DIR}."
- chmod -f o+rw "${EGIT_STORE_DIR}" || die "${EGIT}: can't chmod ${EGIT_STORE_DIR}."
+ mkdir -p "${EGIT_STORE_DIR}" \
+ || die "${EGIT}: can't mkdir ${EGIT_STORE_DIR}."
+ chmod -f o+rw "${EGIT_STORE_DIR}" \
+ || die "${EGIT}: can't chmod ${EGIT_STORE_DIR}."
export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
fi
@@ -137,32 +174,51 @@ function git_fetch() {
# every time
addwrite "${EGIT_STORE_DIR}"
- [ -z "${EGIT_REPO_URI##*/}" ] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
- EGIT_CO_DIR="${EGIT_PROJECT}"
+ [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
+ EGIT_CLONE_DIR="${EGIT_PROJECT}"
debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\""
- if [ ! -d "${EGIT_CO_DIR}/.git" ]; then
- # first check out
- einfo "git check out start -->"
- einfo " repository: ${EGIT_REPO_URI}"
+ export GIT_DIR="${EGIT_CLONE_DIR}"
- ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}."
+ if [[ ! -d ${EGIT_CLONE_DIR} ]] ; then
+ # first clone
+ einfo "git clone start -->"
+ einfo " repository: ${EGIT_REPO_URI}"
+ ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${EGIT_REPO_URI}" ${EGIT_PROJECT} \
+ || die "${EGIT}: can't fetch from ${EGIT_REPO_URI}."
+
+ # We use --bare cloning, so git doesn't do this for us.
+ mkdir ${EGIT_PROJECT}/remotes
+ echo "URL: ${EGIT_REPO_URI}" > ${EGIT_PROJECT}/remotes/origin
else
- # update working copy
+ # fetch updates
einfo "git update start -->"
- einfo " repository: ${EGIT_REPO_URI}"
+ einfo " repository: ${EGIT_REPO_URI}"
+
+ ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH} \
+ || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
+ fi
- cd "${EGIT_CO_DIR}"
- ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
+ einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
+ if ${EGIT_REPACK} ; then
+ ebegin "Repacking objects"
+ # Strangely enough mv asks confirmation
+ yes y | git repack -a -d -f -q > /dev/null
+ eend $?
fi
- einfo " working copy: ${EGIT_STORE_DIR}/${EGIT_CO_DIR}"
+ if ${EGIT_PRUNE} ; then
+ ebegin "Removing unreachable objects"
+ git prune
+ eend $?
+ fi
# export to the ${WORKDIR}
- rsync -a --exclude=".git/" "${EGIT_STORE_DIR}/${EGIT_CO_DIR}/" "${S}" || die "${EGIT}: can't export to ${S}."
+ mkdir "${S}"
+ git tar-tree ${EGIT_TREE} | ( cd "${S}" ; tar xf - )
echo
}
@@ -176,21 +232,18 @@ function git_bootstrap() {
cd "${S}"
- if [ "${EGIT_PATCHES}" ]; then
+ if [[ -n ${EGIT_PATCHES} ]] ; then
einfo "apply patches -->"
- for patch in ${EGIT_PATCHES}; do
- if [ -f "${patch}" ]; then
+ for patch in ${EGIT_PATCHES} ; do
+ if [[ -f ${patch} ]] ; then
epatch ${patch}
-
else
- for lpatch in ${FILESDIR}/${patch}; do
- if [ -f "${lpatch}" ]; then
+ for lpatch in "${FILESDIR}"/${patch} ; do
+ if [[ -f ${lpatch} ]] ; then
epatch ${lpatch}
-
else
- die "${EGIT}; ${patch} is not found"
-
+ die "${EGIT}: ${patch} is not found"
fi
done
fi
@@ -198,17 +251,17 @@ function git_bootstrap() {
echo
fi
- if [ "${EGIT_BOOTSTRAP}" ]; then
+ if [[ -n ${EGIT_BOOTSTRAP} ]] ; then
einfo "begin bootstrap -->"
- if [ -f "${EGIT_BOOTSTRAP}" -a -x "${EGIT_BOOTSTRAP}" ]; then
+ if [[ -f ${EGIT_BOOTSTRAP} ]] && [[ -x ${EGIT_BOOTSTRAP} ]] ; then
einfo " bootstrap with a file: ${EGIT_BOOTSTRAP}"
- eval "./${EGIT_BOOTSTRAP}" || die "${EGIT}: can't execute EGIT_BOOTSTRAP."
-
+ eval "./${EGIT_BOOTSTRAP}" \
+ || die "${EGIT}: can't execute EGIT_BOOTSTRAP."
else
einfo " bootstrap with commands: ${EGIT_BOOTSTRAP}"
- eval "${EGIT_BOOTSTRAP}" || die "${EGIT}: can't eval EGIT_BOOTSTRAP."
-
+ eval "${EGIT_BOOTSTRAP}" \
+ || die "${EGIT}: can't eval EGIT_BOOTSTRAP."
fi
fi