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

Contents of /eclass/mercurial.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Fri Dec 11 21:02:29 2009 UTC (4 years, 11 months ago) by robbat2
Branch: MAIN
Changes since 1.7: +10 -4 lines
Implement EHG_QUIET similar to EGIT_QUIET if you need more Mercurial output to see why a clone or pull is doing or failing.

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

  ViewVC Help
Powered by ViewVC 1.1.20