summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2011-02-10 20:08:59 +0000
committerUlrich Müller <ulm@gentoo.org>2011-02-10 20:08:59 +0000
commitb93fea644288f5bdc2d0d4d8dcce9399e6a391a0 (patch)
tree7eacee95817d9a673c14664ffd0551e8660a1834 /eclass
parentStable on amd64 wrt bug #354183 (diff)
downloadgentoo-2-b93fea644288f5bdc2d0d4d8dcce9399e6a391a0.tar.gz
gentoo-2-b93fea644288f5bdc2d0d4d8dcce9399e6a391a0.tar.bz2
gentoo-2-b93fea644288f5bdc2d0d4d8dcce9399e6a391a0.zip
Use branches instead of lightweight checkouts:
1) initial branch with "bzr branch --no-tree", 2) subsequent updates with "bzr pull", 3) export to ${WORKDIR} with "bzr export". Reintroduce EBZR_BRANCH variable, to allow for shared repositories. Export EBZR_REVNO and EBZR_WC_PATH variables, bug 311101.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/bzr.eclass293
1 files changed, 157 insertions, 136 deletions
diff --git a/eclass/bzr.eclass b/eclass/bzr.eclass
index 68871a599f35..e82bcd4c17ce 100644
--- a/eclass/bzr.eclass
+++ b/eclass/bzr.eclass
@@ -1,22 +1,22 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.10 2010/11/07 22:44:35 fauli Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.11 2011/02/10 20:08:59 ulm Exp $
#
# @ECLASS: bzr.eclass
# @MAINTAINER:
# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
-# Ulrich Mueller <ulm@gentoo.org>,
+# Ulrich Müller <ulm@gentoo.org>,
# Christian Faulhammer <fauli@gentoo.org>,
# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>,
# and anyone who wants to help
-# @BLURB: This eclass provides support to use the Bazaar VCS
+# @BLURB: generic fetching functions for the Bazaar VCS
# @DESCRIPTION:
-# The bzr.eclass provides support for apps using the Bazaar VCS
-# (distributed version control system).
-# The eclass was originally derived from the git eclass.
+# The bzr.eclass provides functions to fetch, unpack, patch, and
+# bootstrap sources from repositories of the Bazaar distributed version
+# control system. The eclass was originally derived from git.eclass.
#
-# Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack()
-# of this eclass will put an export of the branch in ${WORKDIR}/${PN}.
+# Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack()
+# of this eclass will export the branch to ${WORKDIR}/${P}.
inherit eutils
@@ -30,209 +30,236 @@ esac
HOMEPAGE="http://bazaar-vcs.org/"
DESCRIPTION="Based on the ${EBZR} eclass"
-DEPEND=">=dev-vcs/bzr-1.5"
+DEPEND=">=dev-vcs/bzr-2.0.1"
+case "${EAPI:-0}" in
+ 0|1) ;;
+ *) [[ ${EBZR_REPO_URI%%:*} = sftp ]] \
+ && DEPEND=">=dev-vcs/bzr-2.0.1[sftp]" ;;
+esac
# @ECLASS-VARIABLE: EBZR_STORE_DIR
# @DESCRIPTION:
# The directory to store all fetched Bazaar live sources.
-: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src}
+: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
+
+# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
+# @DESCRIPTION:
+# The Bazaar command to initialise a shared repository.
+: ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
# @ECLASS-VARIABLE: EBZR_FETCH_CMD
# @DESCRIPTION:
# The Bazaar command to fetch the sources.
-EBZR_FETCH_CMD="bzr checkout --lightweight"
+: ${EBZR_FETCH_CMD="bzr branch --no-tree"}
# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
# @DESCRIPTION:
# The Bazaar command to update the sources.
-EBZR_UPDATE_CMD="bzr update"
-
-# @ECLASS-VARIABLE: EBZR_DIFF_CMD
-# @DESCRIPTION:
-# The Bazaar command to get the diff output.
-EBZR_DIFF_CMD="bzr diff"
+: ${EBZR_UPDATE_CMD:="bzr pull"}
# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
# @DESCRIPTION:
# The Bazaar command to export a branch.
-EBZR_EXPORT_CMD="bzr export"
+: ${EBZR_EXPORT_CMD:="bzr export"}
# @ECLASS-VARIABLE: EBZR_REVNO_CMD
# @DESCRIPTION:
# The Bazaar command to list a revision number of the branch.
-EBZR_REVNO_CMD="bzr revno"
+: ${EBZR_REVNO_CMD:="bzr revno"}
# @ECLASS-VARIABLE: EBZR_OPTIONS
+# @DEFAULT_UNSET
# @DESCRIPTION:
# The options passed to the fetch and update commands.
-EBZR_OPTIONS="${EBZR_OPTIONS:-}"
# @ECLASS-VARIABLE: EBZR_REPO_URI
+# @DEFAULT_UNSET
+# @REQUIRED
# @DESCRIPTION:
# The repository URI for the source package.
#
-# @CODE
-# Supported protocols:
-# - http://
-# - https://
-# - sftp://
-# - rsync://
-# - lp:
-# @CODE
+# Note: If the ebuild uses an sftp:// URI, then in EAPI 0 or 1 it must
+# make sure that dev-vcs/bzr was built with USE="sftp". In EAPI 2 or
+# later, the eclass will depend on dev-vcs/bzr[sftp].
+
+# @ECLASS-VARIABLE: EBZR_MIRROR_URI
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The URI of a fast mirror of the source repository. If this variable
+# is set, the initial branch will be cloned from the mirror, followed
+# by a pull from the original repository. This is intended for special
+# cases, where download from the original repository is slow, but a fast
+# mirror exists but may be out of date.
#
-# Note: lp: seems to be an alias for https://launchpad.net
-EBZR_REPO_URI="${EBZR_REPO_URI:-}"
+# Normally, this variable needs not be set.
# @ECLASS-VARIABLE: EBZR_BOOTSTRAP
+# @DEFAULT_UNSET
# @DESCRIPTION:
# Bootstrap script or command like autogen.sh or etc.
-EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}"
# @ECLASS-VARIABLE: EBZR_PATCHES
+# @DEFAULT_UNSET
# @DESCRIPTION:
-# bzr eclass can apply patches in bzr_bootstrap().
-# You can use regular expressions in this variable like *.diff or
-# *.patch and the like.
-# NOTE: These patches will bei applied before EBZR_BOOTSTRAP is processed.
+# bzr.eclass can apply patches in bzr_bootstrap(). You can use regular
+# expressions in this variable like *.diff or *.patch and the like.
+# Note: These patches will be applied before EBZR_BOOTSTRAP is processed.
#
-# Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
-# location, the installation dies.
-EBZR_PATCHES="${EBZR_PATCHES:-}"
+# Patches are searched both in ${PWD} and ${FILESDIR}. If not found in
+# either location, the installation dies.
-# @ECLASS-VARIABLE: EBZR_REVISION
+# @ECLASS-VARIABLE: EBZR_PROJECT
# @DESCRIPTION:
-# Revision to fetch, defaults to the latest
-# (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
-# If you set this to a non-empty value, then it is recommended not to
-# use a lightweight checkout (see also EBZR_FETCH_CMD).
-EBZR_REVISION="${EBZR_REVISION:-}"
+# The project name of your ebuild. Normally, the branch will be stored
+# in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory.
+#
+# If EBZR_BRANCH is set (see below), then a shared repository will be
+# created in that directory, and the branch will be located in
+# ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}.
+: ${EBZR_PROJECT:=${PN}}
-# @ECLASS-VARIABLE: EBZR_CACHE_DIR
+# @ECLASS-VARIABLE: EBZR_BRANCH
+# @DEFAULT_UNSET
# @DESCRIPTION:
-# The directory to store the source for the package, relative to
-# EBZR_STORE_DIR.
+# The directory where to store the branch within a shared repository,
+# relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}.
+#
+# This variable should be set if there are several live ebuilds for
+# different branches of the same upstream project. The branches can
+# then share the same repository in EBZR_PROJECT, which will save both
+# data traffic volume and disk space.
#
-# default: ${PN}
-EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
+# If there is only a live ebuild for one single branch, EBZR_BRANCH
+# needs not be set. In this case, the branch will be stored in a
+# stand-alone repository directly in EBZR_PROJECT.
+
+# @ECLASS-VARIABLE: EBZR_REVISION
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Revision to fetch, defaults to the latest
+# (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
# @ECLASS-VARIABLE: EBZR_OFFLINE
# @DESCRIPTION:
-# Set this variable to a non-empty value to disable the automatic updating of
-# a bzr source tree. This is intended to be set outside the ebuild by users.
-EBZR_OFFLINE="${EBZR_OFFLINE:-${ESCM_OFFLINE}}"
+# Set this variable to a non-empty value to disable automatic updating
+# of a bzr source tree. This is intended to be set outside the ebuild
+# by users.
+: ${EBZR_OFFLINE:=${ESCM_OFFLINE}}
# @FUNCTION: bzr_initial_fetch
+# @USAGE: <repository URI> <branch directory>
# @DESCRIPTION:
-# Retrieves the source code from a repository for the first time, via
-# ${EBZR_FETCH_CMD}.
+# Internal function, retrieves the source code from a repository for the
+# first time, using ${EBZR_FETCH_CMD}.
bzr_initial_fetch() {
- local repository="${1}";
- local branch_dir="${2}";
+ local repo_uri=$1 branch_dir=$2
+
+ if [[ -n "${EBZR_OFFLINE}" ]]; then
+ ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet."
+ fi
# fetch branch
- einfo "bzr fetch start -->"
- einfo " repository: ${repository} => ${branch_dir}"
+ einfo "bzr branch start -->"
+ einfo " repository: ${repo_uri} => ${branch_dir}"
- ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \
- || die "${EBZR}: can't branch from ${repository}."
+ ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
+ || die "${EBZR}: can't branch from ${repo_uri}"
}
# @FUNCTION: bzr_update
+# @USAGE: <repository URI> <branch directory>
# @DESCRIPTION:
-# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
+# Internal function, updates the source code from a repository, using
+# ${EBZR_UPDATE_CMD}.
bzr_update() {
- local repository="${1}";
+ local repo_uri=$1 branch_dir=$2
if [[ -n "${EBZR_OFFLINE}" ]]; then
- einfo "skipping bzr update -->"
- einfo " repository: ${repository}"
+ einfo "skipping bzr pull -->"
+ einfo " repository: ${repo_uri}"
else
# update branch
- einfo "bzr update start -->"
- einfo " repository: ${repository}"
+ einfo "bzr pull start -->"
+ einfo " repository: ${repo_uri}"
- pushd "${EBZR_BRANCH_DIR}" > /dev/null
- ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
- || die "${EBZR}: can't update from ${repository}."
+ pushd "${branch_dir}" > /dev/null \
+ || die "${EBZR}: can't chdir to ${branch_dir}"
+ ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \
+ || die "${EBZR}: can't pull from ${repo_uri}"
popd > /dev/null
fi
}
# @FUNCTION: bzr_fetch
# @DESCRIPTION:
-# Wrapper function to fetch sources from a Bazaar repository via bzr
-# fetch or bzr update, depending on whether there is an existing
-# working copy in ${EBZR_BRANCH_DIR}.
+# Wrapper function to fetch sources from a Bazaar repository with
+# bzr branch or bzr pull, depending on whether there is an existing
+# working copy.
bzr_fetch() {
- local EBZR_BRANCH_DIR
-
- # EBZR_REPO_URI is empty.
- [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty."
-
- # check for the protocol or pull from a local repo.
- if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then
- case ${EBZR_REPO_URI%%:*} in
- # lp: seems to be an alias to https://launchpad.net
- http|https|rsync|lp)
- ;;
- sftp)
- if ! built_with_use --missing true dev-vcs/bzr sftp; then
- eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
- eerror "support in dev-vcs/bzr."
- die "Please, rebuild dev-vcs/bzr with the sftp USE flag enabled."
- fi
- ;;
- *)
- die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
- ;;
- esac
- fi
+ local repo_dir branch_dir
+
+ [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
- debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
local save_sandbox_write=${SANDBOX_WRITE}
addwrite /
mkdir -p "${EBZR_STORE_DIR}" \
- || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
+ || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
SANDBOX_WRITE=${save_sandbox_write}
fi
pushd "${EBZR_STORE_DIR}" > /dev/null \
|| die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
- EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
+ repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
+ branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
addwrite "${EBZR_STORE_DIR}"
- addwrite "${EBZR_BRANCH_DIR}"
-
- debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
- # Run bzr_initial_fetch() only if the branch has not been pulled
- # before or if the existing local copy is a full checkout (as did
- # an older version of bzr.eclass)
- if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
- bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
- else
- bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
+ # Clean up if the existing local copy is a checkout (as was the case
+ # with an older version of bzr.eclass).
+ # This test can be removed after 1 Mar 2012.
+ if [[ ${EBZR_FETCH_CMD} != *checkout* && -d ${repo_dir}/.bzr/checkout ]]
+ then
+ local tmpname=$(mktemp -u "${repo_dir}._old_.XXXXXX")
+ ewarn "checkout from old version of ${EBZR} found, moving it to:"
+ ewarn "${tmpname}"
+ ewarn "you may manually remove it"
+ mv "${repo_dir}" "${tmpname}" \
+ || die "${EBZR}: can't move old checkout out of the way"
fi
- cd "${EBZR_BRANCH_DIR}"
-
- einfo "exporting ..."
+ if [[ ! -d ${branch_dir}/.bzr ]]; then
+ if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
+ einfo "creating shared bzr repository"
+ ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
+ || die "${EBZR}: can't create shared repository"
+ fi
- if [[ -z ${EBZR_REVISION} ]]; then
- rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
- || die "${EBZR}: export failed"
+ if [[ -z ${EBZR_MIRROR_URI} ]]; then
+ bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
+ else
+ # Workaround for faster initial download. This clones the
+ # branch from a fast mirror (which may be out of date), and
+ # subsequently pulls from the slow original repository.
+ bzr_initial_fetch "${EBZR_MIRROR_URI}" "${branch_dir}"
+ EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
+ EBZR_OFFLINE="" bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
+ fi
else
- # revisions of a lightweight checkout are only available when online
- [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository ]] \
- || die "${EBZR}: No support for revisions when off-line"
- ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \
- || die "${EBZR}: export failed"
+ bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
fi
- export EBZR_TREE_CRC32=$(awk '$1 == "crc32:" { print $2; exit }' \
- .bzr/checkout/dirstate)
+ cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
+
+ # Save some variables in environment. #311101
+ export EBZR_REVNO=$(${EBZR_REVNO_CMD})
+ export EBZR_WC_PATH=${branch_dir}
+
+ einfo "exporting ..."
+ ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
+ "${WORKDIR}/${P}" . || die "${EBZR}: export failed"
+ einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}"
popd > /dev/null
}
@@ -243,7 +270,7 @@ bzr_fetch() {
bzr_bootstrap() {
local patch lpatch
- pushd "${S}" > /dev/null
+ pushd "${S}" > /dev/null || die "${EBZR}: can't chdir to ${S}"
if [[ -n ${EBZR_PATCHES} ]] ; then
einfo "apply patches -->"
@@ -271,11 +298,11 @@ bzr_bootstrap() {
if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
"./${EBZR_BOOTSTRAP}" \
- || die "${EBZR}: can't execute EBZR_BOOTSTRAP."
+ || die "${EBZR}: can't execute EBZR_BOOTSTRAP"
else
einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
"${EBZR_BOOTSTRAP}" \
- || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
+ || die "${EBZR}: can't eval EBZR_BOOTSTRAP"
fi
fi
@@ -284,15 +311,10 @@ bzr_bootstrap() {
# @FUNCTION: bzr_src_unpack
# @DESCRIPTION:
-# Default src_unpack(). Includes bzr_fetch() and bootstrap().
+# Default src_unpack(), calls bzr_fetch. For EAPIs 0 and 1, also calls
+# bzr_src_prepare.
bzr_src_unpack() {
- if ! [ -z ${EBZR_BRANCH} ]; then
- # This test will go away on 01 Jul 2010
- eerror "This ebuild uses EBZR_BRANCH which is not supported anymore"
- eerror "by the bzr.eclass. Please report this to the ebuild's maintainer."
- die "EBZR_BRANCH still defined"
- fi
- bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
+ bzr_fetch
case "${EAPI:-0}" in
0|1) bzr_src_prepare ;;
esac
@@ -300,8 +322,7 @@ bzr_src_unpack() {
# @FUNCTION: bzr_src_prepare
# @DESCRIPTION:
-# Default src_prepare(). Executes bzr_bootstrap() for patch
-# application and Make file generation (if needed).
+# Default src_prepare(), calls bzr_bootstrap.
bzr_src_prepare() {
- bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
+ bzr_bootstrap
}