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

Diff of /eclass/mercurial.eclass

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

Revision 1.5 Revision 1.13
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.5 2009/03/09 20:09:24 nelchael Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.13 2010/08/24 16:49:18 robbat2 Exp $
4 4
5# @ECLASS: mercurial.eclass 5# @ECLASS: mercurial.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# nelchael@gentoo.org 7# Krzysztof Pawlik <nelchael@gentoo.org>
8# Dirkjan Ochtman <djc@gentoo.org>
8# @BLURB: This eclass provides generic mercurial fetching functions 9# @BLURB: This eclass provides generic mercurial fetching functions
9# @DESCRIPTION: 10# @DESCRIPTION:
10# This eclass provides generic mercurial fetching functions. To fetch sources 11# 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# 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# you need to share single repository between several ebuilds set EHG_PROJECT to
14 15
15inherit eutils 16inherit eutils
16 17
17EXPORT_FUNCTIONS src_unpack 18EXPORT_FUNCTIONS src_unpack
18 19
19DEPEND="dev-util/mercurial" 20DEPEND="dev-vcs/mercurial"
20 21
21# @ECLASS-VARIABLE: EHG_REPO_URI 22# @ECLASS-VARIABLE: EHG_REPO_URI
22# @DESCRIPTION: 23# @DESCRIPTION:
23# Mercurial repository URI. 24# Mercurial repository URI.
24 25
25# @ECLASS-VARIABLE: EHG_REVISION 26# @ECLASS-VARIABLE: EHG_REVISION
26# @DESCRIPTION: 27# @DESCRIPTION:
27# Create working directory for specified revision, defaults to tip. 28# Create working directory for specified revision, defaults to tip.
29#
30# EHG_REVISION is passed as a value for --rev parameter, so it can be more than
31# just a revision, please consult `hg help revisions' for more details.
28[[ -z "${EHG_REVISION}" ]] && EHG_REVISION="tip" 32[[ -z "${EHG_REVISION}" ]] && EHG_REVISION="tip"
33
34# @ECLASS-VARIABLE: EHG_STORE_DIR
35# @DESCRIPTION:
36# Mercurial sources store directory. Users may override this in /etc/make.conf
37[[ -z "${EHG_STORE_DIR}" ]] && EHG_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/hg-src"
29 38
30# @ECLASS-VARIABLE: EHG_PROJECT 39# @ECLASS-VARIABLE: EHG_PROJECT
31# @DESCRIPTION: 40# @DESCRIPTION:
32# Project name. 41# Project name.
33# 42#
34# This variable default to $PN, but can be changed to allow repository sharing 43# This variable default to $PN, but can be changed to allow repository sharing
35# between several ebuilds. 44# between several ebuilds.
36[[ -z "${EHG_PROJECT}" ]] && EHG_PROJECT="${PN}" 45[[ -z "${EHG_PROJECT}" ]] && EHG_PROJECT="${PN}"
37 46
47# @ECLASS-VARIABLE: EHG_QUIET
48# @DESCRIPTION:
49# Suppress some extra noise from mercurial, set it to 'OFF' to be louder.
50: ${EHG_QUIET:="ON"}
51[[ "${EHG_QUIET}" == "ON" ]] && EHG_QUIET_CMD_OPT="--quiet"
52
38# @ECLASS-VARIABLE: EHG_CLONE_CMD 53# @ECLASS-VARIABLE: EHG_CLONE_CMD
39# @DESCRIPTION: 54# @DESCRIPTION:
40# Command used to perform initial repository clone. 55# Command used to perform initial repository clone.
41[[ -z "${EHG_CLONE_CMD}" ]] && EHG_CLONE_CMD="hg clone --quiet --pull --noupdate" 56[[ -z "${EHG_CLONE_CMD}" ]] && EHG_CLONE_CMD="hg clone ${EHG_QUIET_CMD_OPT} --pull --noupdate"
42 57
43# @ECLASS-VARIABLE: EHG_PULL_CMD 58# @ECLASS-VARIABLE: EHG_PULL_CMD
44# @DESCRIPTION: 59# @DESCRIPTION:
45# Command used to update repository. 60# Command used to update repository.
46[[ -z "${EHG_PULL_CMD}" ]] && EHG_PULL_CMD="hg pull --quiet" 61[[ -z "${EHG_PULL_CMD}" ]] && EHG_PULL_CMD="hg pull ${EHG_QUIET_CMD_OPT}"
62
63# @ECLASS-VARIABLE: EHG_OFFLINE
64# @DESCRIPTION:
65# Set this variable to a non-empty value to disable the automatic updating of
66# a mercurial source tree. This is intended to be set outside the ebuild by
67# users.
68EHG_OFFLINE="${EHG_OFFLINE:-${ESCM_OFFLINE}}"
47 69
48# @FUNCTION: mercurial_fetch 70# @FUNCTION: mercurial_fetch
49# @USAGE: [repository_uri] [module] 71# @USAGE: [repository_uri] [module]
50# @DESCRIPTION: 72# @DESCRIPTION:
51# Clone or update repository. 73# Clone or update repository.
56 debug-print-function ${FUNCNAME} ${*} 78 debug-print-function ${FUNCNAME} ${*}
57 79
58 EHG_REPO_URI=${1-${EHG_REPO_URI}} 80 EHG_REPO_URI=${1-${EHG_REPO_URI}}
59 [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty" 81 [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty"
60 82
61 local hg_src_dir="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src"
62 local module="${2-$(basename "${EHG_REPO_URI}")}" 83 local module="${2-$(basename "${EHG_REPO_URI}")}"
63 84
64 # Should be set but blank to prevent using $HOME/.hgrc 85 # Should be set but blank to prevent using $HOME/.hgrc
65 export HGRCPATH= 86 export HGRCPATH=
66 87
67 # Check ${hg_src_dir} directory: 88 # Check ${EHG_STORE_DIR} directory:
68 addwrite "$(dirname "${hg_src_dir}")" || die "addwrite failed" 89 addwrite "$(dirname "${EHG_STORE_DIR}")" || die "addwrite failed"
69 if [[ ! -d "${hg_src_dir}" ]]; then 90 if [[ ! -d "${EHG_STORE_DIR}" ]]; then
70 mkdir -p "${hg_src_dir}" || die "failed to create ${hg_src_dir}" 91 mkdir -p "${EHG_STORE_DIR}" || die "failed to create ${EHG_STORE_DIR}"
71 chmod -f g+rw "${hg_src_dir}" || \ 92 chmod -f g+rw "${EHG_STORE_DIR}" || \
72 die "failed to chown ${hg_src_dir}" 93 die "failed to chown ${EHG_STORE_DIR}"
73 fi 94 fi
74 95
75 # Create project directory: 96 # Create project directory:
76 mkdir -p "${hg_src_dir}/${EHG_PROJECT}" || \ 97 mkdir -p "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
77 die "failed to create ${hg_src_dir}/${EHG_PROJECT}" 98 die "failed to create ${EHG_STORE_DIR}/${EHG_PROJECT}"
78 chmod -f g+rw "${hg_src_dir}/${EHG_PROJECT}" || \ 99 chmod -f g+rw "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
79 die "failed to chwon ${EHG_PROJECT}" 100 echo "Warning: failed to chmod g+rw ${EHG_PROJECT}"
80 cd "${hg_src_dir}/${EHG_PROJECT}" || \ 101 cd "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
81 die "failed to cd to ${hg_src_dir}/${EHG_PROJECT}" 102 die "failed to cd to ${EHG_STORE_DIR}/${EHG_PROJECT}"
82 103
83 # Clone/update repository: 104 # Clone/update repository:
84 if [[ ! -d "${module}" ]]; then 105 if [[ ! -d "${module}" ]]; then
85 einfo "Cloning ${EHG_REPO_URI} to ${hg_src_dir}/${EHG_PROJECT}/${module}" 106 einfo "Cloning ${EHG_REPO_URI} to ${EHG_STORE_DIR}/${EHG_PROJECT}/${module}"
86 ${EHG_CLONE_CMD} "${EHG_REPO_URI}" "${module}" || { 107 ${EHG_CLONE_CMD} "${EHG_REPO_URI}" "${module}" || {
87 rm -rf "${module}" 108 rm -rf "${module}"
88 die "failed to clone ${EHG_REPO_URI}" 109 die "failed to clone ${EHG_REPO_URI}"
89 } 110 }
90 cd "${module}" 111 cd "${module}"
91 else 112 elif [[ -z "${EHG_OFFLINE}" ]]; then
92 einfo "Updating ${hg_src_dir}/${EHG_PROJECT}/${module} from ${EHG_REPO_URI}" 113 einfo "Updating ${EHG_STORE_DIR}/${EHG_PROJECT}/${module} from ${EHG_REPO_URI}"
93 cd "${module}" || die "failed to cd to ${module}" 114 cd "${module}" || die "failed to cd to ${module}"
94 ${EHG_PULL_CMD} || die "update failed" 115 ${EHG_PULL_CMD} || die "update failed"
95 fi 116 fi
96 117
97 # Checkout working copy: 118 # Checkout working copy:
98 einfo "Creating working directory in ${WORKDIR}/${module} (revision: ${EHG_REVISION})" 119 einfo "Creating working directory in ${WORKDIR}/${module} (target revision: ${EHG_REVISION})"
99 hg clone \ 120 hg clone \
100 --quiet \ 121 ${EHG_QUIET_CMD_OPT} \
101 --rev="${EHG_REVISION}" \ 122 --rev="${EHG_REVISION}" \
102 "${hg_src_dir}/${EHG_PROJECT}/${module}" \ 123 "${EHG_STORE_DIR}/${EHG_PROJECT}/${module}" \
103 "${WORKDIR}/${module}" || die "hg archive failed" 124 "${WORKDIR}/${module}" || die "hg clone failed"
125 # An exact revision helps a lot for testing purposes, so have some output...
126 # id num branch
127 # fd6e32d61721 6276 default
128 local HG_REVDATA=($(hg identify -b -i "${WORKDIR}/${module}"))
129 local HG_REV_ID=${HG_REVDATA[0]}
130 local HG_REV_BRANCH=${HG_REVDATA[1]}
131 einfo "Work directory: ${WORKDIR}/${module} global id: ${HG_REV_ID} branch: ${HG_REV_BRANCH}"
104} 132}
105 133
106# @FUNCTION: mercurial_src_unpack 134# @FUNCTION: mercurial_src_unpack
107# @DESCRIPTION: 135# @DESCRIPTION:
108# The mercurial src_unpack function, which will be exported. 136# The mercurial src_unpack function, which will be exported.

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20