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

Diff of /eclass/mercurial.eclass

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

Revision 1.7 Revision 1.12
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.7 2009/09/29 21:51:33 nelchael Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/mercurial.eclass,v 1.12 2010/04/02 18:29:39 nelchael 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}"
47 62
48# @ECLASS-VARIABLE: EHG_OFFLINE 63# @ECLASS-VARIABLE: EHG_OFFLINE
49# @DESCRIPTION: 64# @DESCRIPTION:
50# Set this variable to a non-empty value to disable the automatic updating of 65# 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 66# a mercurial source tree. This is intended to be set outside the ebuild by
63 debug-print-function ${FUNCNAME} ${*} 78 debug-print-function ${FUNCNAME} ${*}
64 79
65 EHG_REPO_URI=${1-${EHG_REPO_URI}} 80 EHG_REPO_URI=${1-${EHG_REPO_URI}}
66 [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty" 81 [[ -z "${EHG_REPO_URI}" ]] && die "EHG_REPO_URI is empty"
67 82
68 local hg_src_dir="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/hg-src"
69 local module="${2-$(basename "${EHG_REPO_URI}")}" 83 local module="${2-$(basename "${EHG_REPO_URI}")}"
70 84
71 # Should be set but blank to prevent using $HOME/.hgrc 85 # Should be set but blank to prevent using $HOME/.hgrc
72 export HGRCPATH= 86 export HGRCPATH=
73 87
74 # Check ${hg_src_dir} directory: 88 # Check ${EHG_STORE_DIR} directory:
75 addwrite "$(dirname "${hg_src_dir}")" || die "addwrite failed" 89 addwrite "$(dirname "${EHG_STORE_DIR}")" || die "addwrite failed"
76 if [[ ! -d "${hg_src_dir}" ]]; then 90 if [[ ! -d "${EHG_STORE_DIR}" ]]; then
77 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}"
78 chmod -f g+rw "${hg_src_dir}" || \ 92 chmod -f g+rw "${EHG_STORE_DIR}" || \
79 die "failed to chown ${hg_src_dir}" 93 die "failed to chown ${EHG_STORE_DIR}"
80 fi 94 fi
81 95
82 # Create project directory: 96 # Create project directory:
83 mkdir -p "${hg_src_dir}/${EHG_PROJECT}" || \ 97 mkdir -p "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
84 die "failed to create ${hg_src_dir}/${EHG_PROJECT}" 98 die "failed to create ${EHG_STORE_DIR}/${EHG_PROJECT}"
85 chmod -f g+rw "${hg_src_dir}/${EHG_PROJECT}" || \ 99 chmod -f g+rw "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
86 die "failed to chwon ${EHG_PROJECT}" 100 echo "Warning: failed to chmod g+rw ${EHG_PROJECT}"
87 cd "${hg_src_dir}/${EHG_PROJECT}" || \ 101 cd "${EHG_STORE_DIR}/${EHG_PROJECT}" || \
88 die "failed to cd to ${hg_src_dir}/${EHG_PROJECT}" 102 die "failed to cd to ${EHG_STORE_DIR}/${EHG_PROJECT}"
89 103
90 # Clone/update repository: 104 # Clone/update repository:
91 if [[ ! -d "${module}" ]]; then 105 if [[ ! -d "${module}" ]]; then
92 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}"
93 ${EHG_CLONE_CMD} "${EHG_REPO_URI}" "${module}" || { 107 ${EHG_CLONE_CMD} "${EHG_REPO_URI}" "${module}" || {
94 rm -rf "${module}" 108 rm -rf "${module}"
95 die "failed to clone ${EHG_REPO_URI}" 109 die "failed to clone ${EHG_REPO_URI}"
96 } 110 }
97 cd "${module}" 111 cd "${module}"
98 elif [[ -z "${EHG_OFFLINE}" ]]; then 112 elif [[ -z "${EHG_OFFLINE}" ]]; then
99 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}"
100 cd "${module}" || die "failed to cd to ${module}" 114 cd "${module}" || die "failed to cd to ${module}"
101 ${EHG_PULL_CMD} || die "update failed" 115 ${EHG_PULL_CMD} || die "update failed"
102 fi 116 fi
103 117
104 # Checkout working copy: 118 # Checkout working copy:
105 einfo "Creating working directory in ${WORKDIR}/${module} (revision: ${EHG_REVISION})" 119 einfo "Creating working directory in ${WORKDIR}/${module} (revision: ${EHG_REVISION})"
106 hg clone \ 120 hg clone \
107 --quiet \ 121 ${EHG_QUIET_CMD_OPT} \
108 --rev="${EHG_REVISION}" \ 122 --rev="${EHG_REVISION}" \
109 "${hg_src_dir}/${EHG_PROJECT}/${module}" \ 123 "${EHG_STORE_DIR}/${EHG_PROJECT}/${module}" \
110 "${WORKDIR}/${module}" || die "hg clone failed" 124 "${WORKDIR}/${module}" || die "hg clone failed"
111} 125}
112 126
113# @FUNCTION: mercurial_src_unpack 127# @FUNCTION: mercurial_src_unpack
114# @DESCRIPTION: 128# @DESCRIPTION:

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20