diff options
author | Aron Griffis <agriffis@gentoo.org> | 2006-05-20 02:43:01 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2006-05-20 02:43:01 +0000 |
commit | bef714c9b0cbdda6d2e572869ec7023e2b138954 (patch) | |
tree | 1a337311930b89bea8bbd16d38b22f2a95c38ce2 /eclass/mercurial.eclass | |
parent | added to ~mips for testing (diff) | |
download | gentoo-2-bef714c9b0cbdda6d2e572869ec7023e2b138954.tar.gz gentoo-2-bef714c9b0cbdda6d2e572869ec7023e2b138954.tar.bz2 gentoo-2-bef714c9b0cbdda6d2e572869ec7023e2b138954.zip |
add mercurial.eclass, similar to cvs.eclass etc
Diffstat (limited to 'eclass/mercurial.eclass')
-rw-r--r-- | eclass/mercurial.eclass | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/eclass/mercurial.eclass b/eclass/mercurial.eclass new file mode 100644 index 000000000000..941b6e21b112 --- /dev/null +++ b/eclass/mercurial.eclass @@ -0,0 +1,69 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.1 2006/05/20 02:43:01 agriffis Exp $ + +# mercurial: Fetch sources from mercurial repositories, similar to cvs.eclass. +# To use this from an ebuild, set EHG_REPO_URI in your ebuild. Then either +# leave the default src_unpack or call mercurial_src_unpack. + +inherit eutils + +EXPORT_FUNCTIONS src_unpack + +DEPEND="dev-util/mercurial net-misc/rsync" +EHG_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src" + +# This must be set by the ebuild +: ${EHG_REPO_URI:=} # repository uri + +# These can be set by the ebuild but are usually fine as-is +: ${EHG_CLONE_CMD:=hg clone} # clone cmd +: ${EHG_PULL_CMD:=hg pull -u} # pull cmd + +# should be set but blank to prevent using $HOME/.hgrc +export HGRCPATH= + +function mercurial_fetch { + declare repo=${1:-$EHG_REPO_URI} proj=${2:-${PN/-hg}} + repo=${repo%/} # remove trailing slash + [[ -n $repo ]] || die "EHG_REPO_URI is empty" + + if [[ ! -d ${EHG_STORE_DIR} ]]; then + ebegin "create ${EHG_STORE_DIR}" + addwrite / && + mkdir -p "${EHG_STORE_DIR}" && + chmod -f o+rw "${EHG_STORE_DIR}" && + export SANDBOX_WRITE="${SANDBOX_WRITE%:/}" + eend $? || die + fi + + cd "${EHG_STORE_DIR}" || die "can't chdir to ${EHG_STORE_DIR}" + addwrite "$(pwd -P)" + + if [[ ! -d ${proj}/${repo##*/} ]]; then + # first check out + ebegin "${EHG_CLONE_CMD} ${repo}" + mkdir -p "${proj}" && + chmod -f o+rw "${proj}" && + cd "${proj}" && + ${EHG_CLONE_CMD} "${repo}" && + cd "${repo##*/}" + eend $? || die + else + # update working copy + ebegin "${EHG_PULL_CMD} ${repo}" + cd "${proj}/${repo##*/}" && + ${EHG_PULL_CMD} + eend $? || die + fi + + # use rsync instead of cp for --exclude + ebegin "rsync to ${S}" + mkdir -p "${S}" && + rsync -av --delete --exclude=.hg/ . "${S}" + eend $? || die +} + +function mercurial_src_unpack { + mercurial_fetch +} |