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

Diff of /eclass/bzr.eclass

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

Revision 1.18 Revision 1.19
1# Copyright 1999-2012 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.18 2012/07/18 15:12:54 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> 7# Emacs team <emacs@gentoo.org>
8# Bazaar team <bazaar@gentoo.org> 8# Bazaar team <bazaar@gentoo.org>
59# @ECLASS-VARIABLE: EBZR_EXPORT_CMD 59# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
60# @DESCRIPTION: 60# @DESCRIPTION:
61# The Bazaar command to export a branch. 61# The Bazaar command to export a branch.
62: ${EBZR_EXPORT_CMD:="bzr export"} 62: ${EBZR_EXPORT_CMD:="bzr export"}
63 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
64# @ECLASS-VARIABLE: EBZR_REVNO_CMD 69# @ECLASS-VARIABLE: EBZR_REVNO_CMD
65# @DESCRIPTION: 70# @DESCRIPTION:
66# The Bazaar command to list a revision number of the branch. 71# The Bazaar command to list a revision number of the branch.
67: ${EBZR_REVNO_CMD:="bzr revno"} 72: ${EBZR_REVNO_CMD:="bzr revno"}
68 73
142# @DESCRIPTION: 147# @DESCRIPTION:
143# 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
144# 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
145# by users. 150# by users.
146: ${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.
147 158
148# @FUNCTION: bzr_initial_fetch 159# @FUNCTION: bzr_initial_fetch
149# @USAGE: <repository URI> <branch directory> 160# @USAGE: <repository URI> <branch directory>
150# @DESCRIPTION: 161# @DESCRIPTION:
151# Internal function, retrieves the source code from a repository for the 162# Internal function, retrieves the source code from a repository for the
194# Wrapper function to fetch sources from a Bazaar repository with 205# Wrapper function to fetch sources from a Bazaar repository with
195# 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
196# working copy. 207# working copy.
197bzr_fetch() { 208bzr_fetch() {
198 local repo_dir branch_dir 209 local repo_dir branch_dir
210 local save_sandbox_write=${SANDBOX_WRITE}
199 211
200 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty" 212 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
201 213
202 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then 214 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
203 local save_sandbox_write=${SANDBOX_WRITE}
204 addwrite / 215 addwrite /
205 mkdir -p "${EBZR_STORE_DIR}" \ 216 mkdir -p "${EBZR_STORE_DIR}" \
206 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}" 217 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
207 SANDBOX_WRITE=${save_sandbox_write} 218 SANDBOX_WRITE=${save_sandbox_write}
208 fi 219 fi
212 223
213 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT} 224 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
214 branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}} 225 branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
215 226
216 addwrite "${EBZR_STORE_DIR}" 227 addwrite "${EBZR_STORE_DIR}"
217
218 # Clean up if the existing local copy is a checkout (as was the case
219 # with an older version of bzr.eclass).
220 # This test can be removed after 1 Mar 2012.
221 if [[ ${EBZR_FETCH_CMD} != *checkout* && -d ${repo_dir}/.bzr/checkout ]]
222 then
223 local tmpname=$(mktemp -u "${repo_dir}._old_.XXXXXX")
224 ewarn "checkout from old version of ${EBZR} found, moving it to:"
225 ewarn "${tmpname}"
226 ewarn "you may manually remove it"
227 mv "${repo_dir}" "${tmpname}" \
228 || die "${EBZR}: can't move old checkout out of the way"
229 fi
230 228
231 if [[ ! -d ${branch_dir}/.bzr ]]; then 229 if [[ ! -d ${branch_dir}/.bzr ]]; then
232 if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then 230 if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
233 einfo "creating shared bzr repository: ${repo_dir}" 231 einfo "creating shared bzr repository: ${repo_dir}"
234 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \ 232 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
250 fi 248 fi
251 else 249 else
252 bzr_update "${EBZR_REPO_URI}" "${branch_dir}" 250 bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
253 fi 251 fi
254 252
253 # Restore sandbox environment
254 SANDBOX_WRITE=${save_sandbox_write}
255
255 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}" 256 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
256 257
257 # Save revision number in environment. #311101 258 # Save revision number in environment. #311101
258 export EBZR_REVNO=$(${EBZR_REVNO_CMD}) 259 export EBZR_REVNO=$(${EBZR_REVNO_CMD})
259 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
260 einfo "exporting ..." 266 einfo "exporting ..."
261 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ 267 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
262 "${WORKDIR}/${P}" . || die "${EBZR}: export failed" 268 "${WORKDIR}/${P}" . || die "${EBZR}: export failed"
269 fi
263 einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}" 270 einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}"
264 271
265 popd > /dev/null 272 popd > /dev/null
266} 273}
267 274

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

  ViewVC Help
Powered by ViewVC 1.1.20