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

Diff of /eclass/bzr.eclass

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

Revision 1.15 Revision 1.19
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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/bzr.eclass,v 1.15 2011/07/26 23:22:35 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.19 2012/09/18 06:41:45 ulm Exp $
4# 4#
5# @ECLASS: bzr.eclass 5# @ECLASS: bzr.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Emacs team <emacs@gentoo.org>
8# Bazaar team <bazaar@gentoo.org>
9# @AUTHOR:
7# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>, 10# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
8# Ulrich Müller <ulm@gentoo.org>,
9# Christian Faulhammer <fauli@gentoo.org>,
10# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>, 11# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>
11# and anyone who wants to help 12# Ulrich Müller <ulm@gentoo.org>
13# Christian Faulhammer <fauli@gentoo.org>
12# @BLURB: generic fetching functions for the Bazaar VCS 14# @BLURB: generic fetching functions for the Bazaar VCS
13# @DESCRIPTION: 15# @DESCRIPTION:
14# The bzr.eclass provides functions to fetch, unpack, patch, and 16# The bzr.eclass provides functions to fetch, unpack, patch, and
15# bootstrap sources from repositories of the Bazaar distributed version 17# bootstrap sources from repositories of the Bazaar distributed version
16# control system. The eclass was originally derived from git.eclass. 18# control system. The eclass was originally derived from git.eclass.
24 26
25case "${EAPI:-0}" in 27case "${EAPI:-0}" in
26 0|1) EXPORT_FUNCTIONS src_unpack ;; 28 0|1) EXPORT_FUNCTIONS src_unpack ;;
27 *) EXPORT_FUNCTIONS src_unpack src_prepare ;; 29 *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
28esac 30esac
29
30HOMEPAGE="http://bazaar-vcs.org/"
31DESCRIPTION="Based on the ${EBZR} eclass"
32 31
33DEPEND=">=dev-vcs/bzr-2.0.1" 32DEPEND=">=dev-vcs/bzr-2.0.1"
34case "${EAPI:-0}" in 33case "${EAPI:-0}" in
35 0|1) ;; 34 0|1) ;;
36 *) [[ ${EBZR_REPO_URI%%:*} = sftp ]] \ 35 *) [[ ${EBZR_REPO_URI%%:*} = sftp ]] \
60# @ECLASS-VARIABLE: EBZR_EXPORT_CMD 59# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
61# @DESCRIPTION: 60# @DESCRIPTION:
62# The Bazaar command to export a branch. 61# The Bazaar command to export a branch.
63: ${EBZR_EXPORT_CMD:="bzr export"} 62: ${EBZR_EXPORT_CMD:="bzr export"}
64 63
64# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
65# @DESCRIPTION:
66# The Bazaar command to checkout a branch.
67: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
68
65# @ECLASS-VARIABLE: EBZR_REVNO_CMD 69# @ECLASS-VARIABLE: EBZR_REVNO_CMD
66# @DESCRIPTION: 70# @DESCRIPTION:
67# The Bazaar command to list a revision number of the branch. 71# The Bazaar command to list a revision number of the branch.
68: ${EBZR_REVNO_CMD:="bzr revno"} 72: ${EBZR_REVNO_CMD:="bzr revno"}
69 73
143# @DESCRIPTION: 147# @DESCRIPTION:
144# Set this variable to a non-empty value to disable automatic updating 148# Set this variable to a non-empty value to disable automatic updating
145# of a bzr source tree. This is intended to be set outside the ebuild 149# of a bzr source tree. This is intended to be set outside the ebuild
146# by users. 150# by users.
147: ${EBZR_OFFLINE=${EVCS_OFFLINE}} 151: ${EBZR_OFFLINE=${EVCS_OFFLINE}}
152
153# @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT
154# @DEFAULT_UNSET
155# @DESCRIPTION:
156# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will
157# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR.
148 158
149# @FUNCTION: bzr_initial_fetch 159# @FUNCTION: bzr_initial_fetch
150# @USAGE: <repository URI> <branch directory> 160# @USAGE: <repository URI> <branch directory>
151# @DESCRIPTION: 161# @DESCRIPTION:
152# Internal function, retrieves the source code from a repository for the 162# Internal function, retrieves the source code from a repository for the
195# Wrapper function to fetch sources from a Bazaar repository with 205# Wrapper function to fetch sources from a Bazaar repository with
196# bzr branch or bzr pull, depending on whether there is an existing 206# bzr branch or bzr pull, depending on whether there is an existing
197# working copy. 207# working copy.
198bzr_fetch() { 208bzr_fetch() {
199 local repo_dir branch_dir 209 local repo_dir branch_dir
210 local save_sandbox_write=${SANDBOX_WRITE}
200 211
201 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty" 212 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
202 213
203 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then 214 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
204 local save_sandbox_write=${SANDBOX_WRITE}
205 addwrite / 215 addwrite /
206 mkdir -p "${EBZR_STORE_DIR}" \ 216 mkdir -p "${EBZR_STORE_DIR}" \
207 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}" 217 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
208 SANDBOX_WRITE=${save_sandbox_write} 218 SANDBOX_WRITE=${save_sandbox_write}
209 fi 219 fi
214 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT} 224 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
215 branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}} 225 branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
216 226
217 addwrite "${EBZR_STORE_DIR}" 227 addwrite "${EBZR_STORE_DIR}"
218 228
219 # Clean up if the existing local copy is a checkout (as was the case
220 # with an older version of bzr.eclass).
221 # This test can be removed after 1 Mar 2012.
222 if [[ ${EBZR_FETCH_CMD} != *checkout* && -d ${repo_dir}/.bzr/checkout ]]
223 then
224 local tmpname=$(mktemp -u "${repo_dir}._old_.XXXXXX")
225 ewarn "checkout from old version of ${EBZR} found, moving it to:"
226 ewarn "${tmpname}"
227 ewarn "you may manually remove it"
228 mv "${repo_dir}" "${tmpname}" \
229 || die "${EBZR}: can't move old checkout out of the way"
230 fi
231
232 if [[ ! -d ${branch_dir}/.bzr ]]; then 229 if [[ ! -d ${branch_dir}/.bzr ]]; then
233 if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then 230 if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
234 einfo "creating shared bzr repository" 231 einfo "creating shared bzr repository: ${repo_dir}"
235 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \ 232 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
236 || die "${EBZR}: can't create shared repository" 233 || die "${EBZR}: can't create shared repository"
237 fi 234 fi
238 235
239 if [[ -z ${EBZR_INITIAL_URI} ]]; then 236 if [[ -z ${EBZR_INITIAL_URI} ]]; then
251 fi 248 fi
252 else 249 else
253 bzr_update "${EBZR_REPO_URI}" "${branch_dir}" 250 bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
254 fi 251 fi
255 252
253 # Restore sandbox environment
254 SANDBOX_WRITE=${save_sandbox_write}
255
256 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}" 256 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
257 257
258 # Save revision number in environment. #311101 258 # Save revision number in environment. #311101
259 export EBZR_REVNO=$(${EBZR_REVNO_CMD}) 259 export EBZR_REVNO=$(${EBZR_REVNO_CMD})
260 260
261 if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
262 einfo "checking out ..."
263 ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
264 . "${WORKDIR}/${P}" || die "${EBZR}: checkout failed"
265 else
261 einfo "exporting ..." 266 einfo "exporting ..."
262 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ 267 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
263 "${WORKDIR}/${P}" . || die "${EBZR}: export failed" 268 "${WORKDIR}/${P}" . || die "${EBZR}: export failed"
269 fi
264 einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}" 270 einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}"
265 271
266 popd > /dev/null 272 popd > /dev/null
267} 273}
268 274

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.20