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

Diff of /eclass/mercurial.eclass

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

Revision 1.1 Revision 1.3
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/mercurial.eclass,v 1.1 2006/05/20 02:43:01 agriffis Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.3 2006/10/13 23:45:03 agriffis Exp $
4 4
5# mercurial: Fetch sources from mercurial repositories, similar to cvs.eclass. 5# mercurial: Fetch sources from mercurial repositories, similar to cvs.eclass.
6# To use this from an ebuild, set EHG_REPO_URI in your ebuild. Then either 6# To use this from an ebuild, set EHG_REPO_URI in your ebuild. Then either
7# leave the default src_unpack or call mercurial_src_unpack. 7# leave the default src_unpack or call mercurial_src_unpack.
8 8
12 12
13DEPEND="dev-util/mercurial net-misc/rsync" 13DEPEND="dev-util/mercurial net-misc/rsync"
14EHG_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src" 14EHG_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src"
15 15
16# This must be set by the ebuild 16# This must be set by the ebuild
17: ${EHG_REPO_URI:=} # repository uri 17: ${EHG_REPO_URI:=} # repository uri
18 18
19# These can be set by the ebuild but are usually fine as-is 19# These can be set by the ebuild but are usually fine as-is
20: ${EHG_PROJECT:=$PN} # dir under EHG_STORE_DIR
20: ${EHG_CLONE_CMD:=hg clone} # clone cmd 21: ${EHG_CLONE_CMD:=hg clone} # clone cmd
21: ${EHG_PULL_CMD:=hg pull -u} # pull cmd 22: ${EHG_PULL_CMD:=hg pull -u} # pull cmd
22 23
23# should be set but blank to prevent using $HOME/.hgrc 24# should be set but blank to prevent using $HOME/.hgrc
24export HGRCPATH= 25export HGRCPATH=
25 26
26function mercurial_fetch { 27function mercurial_fetch {
27 declare repo=${1:-$EHG_REPO_URI} proj=${2:-${PN/-hg}} 28 declare repo=${1:-$EHG_REPO_URI}
28 repo=${repo%/} # remove trailing slash 29 repo=${repo%/} # remove trailing slash
29 [[ -n $repo ]] || die "EHG_REPO_URI is empty" 30 [[ -n $repo ]] || die "EHG_REPO_URI is empty"
31 declare module=${2:-${repo##*/}}
30 32
31 if [[ ! -d ${EHG_STORE_DIR} ]]; then 33 if [[ ! -d ${EHG_STORE_DIR} ]]; then
32 ebegin "create ${EHG_STORE_DIR}" 34 ebegin "create ${EHG_STORE_DIR}"
33 addwrite / && 35 addwrite / &&
34 mkdir -p "${EHG_STORE_DIR}" && 36 mkdir -p "${EHG_STORE_DIR}" &&
35 chmod -f o+rw "${EHG_STORE_DIR}" && 37 chmod -f g+rw "${EHG_STORE_DIR}" &&
36 export SANDBOX_WRITE="${SANDBOX_WRITE%:/}" 38 export SANDBOX_WRITE="${SANDBOX_WRITE%:/}"
37 eend $? || die 39 eend $? || die
38 fi 40 fi
39 41
40 cd "${EHG_STORE_DIR}" || die "can't chdir to ${EHG_STORE_DIR}" 42 pushd "${EHG_STORE_DIR}" >/dev/null \
43 || die "can't chdir to ${EHG_STORE_DIR}"
41 addwrite "$(pwd -P)" 44 addwrite "$(pwd -P)"
42 45
43 if [[ ! -d ${proj}/${repo##*/} ]]; then 46 if [[ ! -d ${EHG_PROJECT}/${module} ]]; then
44 # first check out 47 # first check out
45 ebegin "${EHG_CLONE_CMD} ${repo}" 48 ebegin "${EHG_CLONE_CMD} ${repo}"
46 mkdir -p "${proj}" && 49 mkdir -p "${EHG_PROJECT}" &&
47 chmod -f o+rw "${proj}" && 50 chmod -f g+rw "${EHG_PROJECT}" &&
48 cd "${proj}" && 51 cd "${EHG_PROJECT}" &&
49 ${EHG_CLONE_CMD} "${repo}" && 52 ${EHG_CLONE_CMD} "${repo}" "${module}" &&
50 cd "${repo##*/}" 53 cd "${module}"
51 eend $? || die 54 eend $? || die
52 else 55 else
53 # update working copy 56 # update working copy
54 ebegin "${EHG_PULL_CMD} ${repo}" 57 ebegin "${EHG_PULL_CMD} ${repo}"
55 cd "${proj}/${repo##*/}" && 58 cd "${EHG_PROJECT}/${module}" &&
56 ${EHG_PULL_CMD} 59 ${EHG_PULL_CMD}
60 case $? in
61 # hg pull returns status 1 when there were no changes to pull
62 1) eend 0 ;;
57 eend $? || die 63 *) eend $? || die ;;
64 esac
58 fi 65 fi
59 66
60 # use rsync instead of cp for --exclude 67 # use rsync instead of cp for --exclude
61 ebegin "rsync to ${S}" 68 ebegin "rsync to ${WORKDIR}/${module}"
62 mkdir -p "${S}" && 69 mkdir -p "${WORKDIR}/${module}" &&
63 rsync -av --delete --exclude=.hg/ . "${S}" 70 rsync -a --delete --exclude=.hg/ . "${WORKDIR}/${module}"
64 eend $? || die 71 eend $? || die
72
73 popd >/dev/null
65} 74}
66 75
67function mercurial_src_unpack { 76function mercurial_src_unpack {
68 mercurial_fetch 77 mercurial_fetch
69} 78}

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

  ViewVC Help
Powered by ViewVC 1.1.20