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

Contents of /eclass/mercurial.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Sun Jan 17 11:21:12 2010 UTC (4 years, 7 months ago) by nelchael
Branch: MAIN
Changes since 1.8: +4 -1 lines
Mention hg help revisions in description of EHG_REVISION, see bug #300969.

1 agriffis 1.1 # Copyright 1999-2006 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 nelchael 1.9 # $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.8 2009/12/11 21:02:29 robbat2 Exp $
4 agriffis 1.1
5 nelchael 1.5 # @ECLASS: mercurial.eclass
6     # @MAINTAINER:
7     # nelchael@gentoo.org
8     # @BLURB: This eclass provides generic mercurial fetching functions
9     # @DESCRIPTION:
10     # This eclass provides generic mercurial fetching functions. To fetch sources
11     # from mercurial repository just set EHG_REPO_URI to correct repository URI. If
12     # you need to share single repository between several ebuilds set EHG_PROJECT to
13     # project name in all of them.
14 agriffis 1.1
15     inherit eutils
16    
17     EXPORT_FUNCTIONS src_unpack
18    
19 nelchael 1.5 DEPEND="dev-util/mercurial"
20 agriffis 1.1
21 nelchael 1.5 # @ECLASS-VARIABLE: EHG_REPO_URI
22     # @DESCRIPTION:
23     # Mercurial repository URI.
24    
25     # @ECLASS-VARIABLE: EHG_REVISION
26     # @DESCRIPTION:
27     # Create working directory for specified revision, defaults to tip.
28 nelchael 1.9 #
29     # EHG_REVISION is passed as a value for --rev parameter, so it can be more than
30     # just a revision, please consult `hg help revisions' for more details.
31 nelchael 1.5 [[ -z "${EHG_REVISION}" ]] && EHG_REVISION="tip"
32    
33     # @ECLASS-VARIABLE: EHG_PROJECT
34     # @DESCRIPTION:
35     # Project name.
36     #
37     # This variable default to $PN, but can be changed to allow repository sharing
38     # between several ebuilds.
39     [[ -z "${EHG_PROJECT}" ]] && EHG_PROJECT="${PN}"
40    
41 robbat2 1.8 # @ECLASS-VARIABLE: EHG_QUIET
42     # @DESCRIPTION:
43     # Suppress some extra noise from mercurial, set it to 'OFF' to be louder.
44     : ${EHG_QUIET:="ON"}
45     [[ "${EHG_QUIET}" == "ON" ]] && EHG_QUIET_CMD_OPT="--quiet"
46    
47 nelchael 1.5 # @ECLASS-VARIABLE: EHG_CLONE_CMD
48     # @DESCRIPTION:
49     # Command used to perform initial repository clone.
50 robbat2 1.8 [[ -z "${EHG_CLONE_CMD}" ]] && EHG_CLONE_CMD="hg clone ${EHG_QUIET_CMD_OPT} --pull --noupdate"
51 nelchael 1.5
52     # @ECLASS-VARIABLE: EHG_PULL_CMD
53     # @DESCRIPTION:
54     # Command used to update repository.
55 robbat2 1.8 [[ -z "${EHG_PULL_CMD}" ]] && EHG_PULL_CMD="hg pull ${EHG_QUIET_CMD_OPT}"
56 nelchael 1.5
57 nelchael 1.7 # @ECLASS-VARIABLE: EHG_OFFLINE
58     # @DESCRIPTION:
59     # Set this variable to a non-empty value to disable the automatic updating of
60     # a mercurial source tree. This is intended to be set outside the ebuild by
61     # users.
62     EHG_OFFLINE="${EHG_OFFLINE:-${ESCM_OFFLINE}}"
63    
64 nelchael 1.5 # @FUNCTION: mercurial_fetch
65     # @USAGE: [repository_uri] [module]
66     # @DESCRIPTION:
67     # Clone or update repository.
68     #
69     # If not repository URI is passed it defaults to EHG_REPO_URI, if module is
70     # empty it defaults to basename of EHG_REPO_URI.
71     function mercurial_fetch {
72     debug-print-function ${FUNCNAME} ${*}
73 agriffis 1.1
74 nelchael 1.5 EHG_REPO_URI=${1-${EHG_REPO_URI}}
75     [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty"
76 agriffis 1.1
77 nelchael 1.5 local hg_src_dir="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src"
78     local module="${2-$(basename "${EHG_REPO_URI}")}"
79 agriffis 1.1
80 nelchael 1.5 # Should be set but blank to prevent using $HOME/.hgrc
81     export HGRCPATH=
82    
83     # Check ${hg_src_dir} directory:
84     addwrite "$(dirname "${hg_src_dir}")" || die "addwrite failed"
85     if [[ ! -d "${hg_src_dir}" ]]; then
86     mkdir -p "${hg_src_dir}" || die "failed to create ${hg_src_dir}"
87     chmod -f g+rw "${hg_src_dir}" || \
88     die "failed to chown ${hg_src_dir}"
89 agriffis 1.1 fi
90    
91 nelchael 1.5 # Create project directory:
92     mkdir -p "${hg_src_dir}/${EHG_PROJECT}" || \
93     die "failed to create ${hg_src_dir}/${EHG_PROJECT}"
94     chmod -f g+rw "${hg_src_dir}/${EHG_PROJECT}" || \
95     die "failed to chwon ${EHG_PROJECT}"
96     cd "${hg_src_dir}/${EHG_PROJECT}" || \
97     die "failed to cd to ${hg_src_dir}/${EHG_PROJECT}"
98    
99     # Clone/update repository:
100     if [[ ! -d "${module}" ]]; then
101     einfo "Cloning ${EHG_REPO_URI} to ${hg_src_dir}/${EHG_PROJECT}/${module}"
102     ${EHG_CLONE_CMD} "${EHG_REPO_URI}" "${module}" || {
103     rm -rf "${module}"
104     die "failed to clone ${EHG_REPO_URI}"
105     }
106     cd "${module}"
107 nelchael 1.7 elif [[ -z "${EHG_OFFLINE}" ]]; then
108 nelchael 1.5 einfo "Updating ${hg_src_dir}/${EHG_PROJECT}/${module} from ${EHG_REPO_URI}"
109     cd "${module}" || die "failed to cd to ${module}"
110     ${EHG_PULL_CMD} || die "update failed"
111 agriffis 1.1 fi
112    
113 nelchael 1.5 # Checkout working copy:
114     einfo "Creating working directory in ${WORKDIR}/${module} (revision: ${EHG_REVISION})"
115     hg clone \
116 robbat2 1.8 ${EHG_QUIET_CMD_OPT} \
117 nelchael 1.5 --rev="${EHG_REVISION}" \
118     "${hg_src_dir}/${EHG_PROJECT}/${module}" \
119 nelchael 1.6 "${WORKDIR}/${module}" || die "hg clone failed"
120 agriffis 1.1 }
121    
122 nelchael 1.5 # @FUNCTION: mercurial_src_unpack
123     # @DESCRIPTION:
124     # The mercurial src_unpack function, which will be exported.
125 agriffis 1.1 function mercurial_src_unpack {
126     mercurial_fetch
127     }

  ViewVC Help
Powered by ViewVC 1.1.20