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

Contents of /eclass/mercurial.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Tue Sep 29 21:51:33 2009 UTC (4 years, 10 months ago) by nelchael
Branch: MAIN
Changes since 1.6: +9 -2 lines
Add support for ESCM_OFFLINE, see bug 280214.

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

  ViewVC Help
Powered by ViewVC 1.1.20