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

Contents of /eclass/mercurial.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Sun Feb 22 13:01:17 2009 UTC (5 years, 5 months ago) by nelchael
Branch: MAIN
Changes since 1.3: +5 -5 lines
Use clone --pull to fix bug #238314.

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

  ViewVC Help
Powered by ViewVC 1.1.20