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

Diff of /eclass/bzr.eclass

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

Revision 1.2 Revision 1.9
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.2 2009/07/08 09:47:38 fauli Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.9 2010/07/01 09:23:37 fauli Exp $
4# 4#
5# @ECLASS: bzr.eclass 5# @ECLASS: bzr.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>, 7# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
8# Ulrich Mueller <ulm@gentoo.org>, 8# Ulrich Mueller <ulm@gentoo.org>,
9# Christian Faulhammer <fauli@gentoo.org> 9# Christian Faulhammer <fauli@gentoo.org>,
10# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>, 10# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>,
11# and anyone who wants to help 11# and anyone who wants to help
12# @BLURB: This eclass provides support to use the Bazaar DSCM 12# @BLURB: This eclass provides support to use the Bazaar VCS
13# @DESCRIPTION: 13# @DESCRIPTION:
14# The bzr.eclass provides support for apps using the bazaar DSCM 14# The bzr.eclass provides support for apps using the Bazaar VCS
15# (distributed source control management system). 15# (distributed version control system).
16# The eclass was originally derived from the git eclass. 16# The eclass was originally derived from the git eclass.
17# 17#
18# Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack() 18# Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack()
19# of this eclass will put an export of the branch in ${WORKDIR}/${PN}. 19# of this eclass will put an export of the branch in ${WORKDIR}/${PN}.
20 20
28esac 28esac
29 29
30HOMEPAGE="http://bazaar-vcs.org/" 30HOMEPAGE="http://bazaar-vcs.org/"
31DESCRIPTION="Based on the ${EBZR} eclass" 31DESCRIPTION="Based on the ${EBZR} eclass"
32 32
33DEPEND=">=dev-util/bzr-1.5" 33DEPEND=">=dev-vcs/bzr-1.5"
34 34
35# @ECLASS-VARIABLE: EBZR_STORE_DIR 35# @ECLASS-VARIABLE: EBZR_STORE_DIR
36# @DESCRIPTION: 36# @DESCRIPTION:
37# The directory to store all fetched Bazaar live sources. 37# The directory to store all fetched Bazaar live sources.
38EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src" 38: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src}
39 39
40# @ECLASS-VARIABLE: EBZR_FETCH_CMD 40# @ECLASS-VARIABLE: EBZR_FETCH_CMD
41# @DESCRIPTION: 41# @DESCRIPTION:
42# The Bazaar command to fetch the sources. 42# The Bazaar command to fetch the sources.
43EBZR_FETCH_CMD="bzr checkout --lightweight" 43EBZR_FETCH_CMD="bzr checkout --lightweight"
99# location, the installation dies. 99# location, the installation dies.
100EBZR_PATCHES="${EBZR_PATCHES:-}" 100EBZR_PATCHES="${EBZR_PATCHES:-}"
101 101
102# @ECLASS-VARIABLE: EBZR_REVISION 102# @ECLASS-VARIABLE: EBZR_REVISION
103# @DESCRIPTION: 103# @DESCRIPTION:
104# Revision to fetch, defaults to the latest (see 104# Revision to fetch, defaults to the latest
105# http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec) 105# (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
106# If you set this to a non-empty value, then it is recommended not to
107# use a lightweight checkout (see also EBZR_FETCH_CMD).
106EBZR_REVISION="${EBZR_REVISION:-}" 108EBZR_REVISION="${EBZR_REVISION:-}"
107 109
108# @ECLASS-VARIABLE: EBZR_CACHE_DIR 110# @ECLASS-VARIABLE: EBZR_CACHE_DIR
109# @DESCRIPTION: 111# @DESCRIPTION:
110# The directory to store the source for the package, relative to 112# The directory to store the source for the package, relative to
111# EBZR_STORE_DIR. 113# EBZR_STORE_DIR.
112# 114#
113# default: ${PN} 115# default: ${PN}
114EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}" 116EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
117
118# @ECLASS-VARIABLE: EBZR_OFFLINE
119# @DESCRIPTION:
120# Set this variable to a non-empty value to disable the automatic updating of
121# a bzr source tree. This is intended to be set outside the ebuild by users.
122EBZR_OFFLINE="${EBZR_OFFLINE:-${ESCM_OFFLINE}}"
115 123
116# @FUNCTION: bzr_initial_fetch 124# @FUNCTION: bzr_initial_fetch
117# @DESCRIPTION: 125# @DESCRIPTION:
118# Retrieves the source code from a repository for the first time, via 126# Retrieves the source code from a repository for the first time, via
119# ${EBZR_FETCH_CMD}. 127# ${EBZR_FETCH_CMD}.
133# @DESCRIPTION: 141# @DESCRIPTION:
134# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}. 142# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
135bzr_update() { 143bzr_update() {
136 local repository="${1}"; 144 local repository="${1}";
137 145
138 # update branch 146 if [[ -n "${EBZR_OFFLINE}" ]]; then
139 einfo "bzr update start -->" 147 einfo "skipping bzr update -->"
140 einfo " repository: ${repository}" 148 einfo " repository: ${repository}"
149 else
150 # update branch
151 einfo "bzr update start -->"
152 einfo " repository: ${repository}"
141 153
142 pushd "${EBZR_BRANCH_DIR}" > /dev/null 154 pushd "${EBZR_BRANCH_DIR}" > /dev/null
143 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \ 155 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
144 || die "${EBZR}: can't update from ${repository}." 156 || die "${EBZR}: can't update from ${repository}."
145 popd > /dev/null 157 popd > /dev/null
158 fi
146} 159}
147
148 160
149# @FUNCTION: bzr_fetch 161# @FUNCTION: bzr_fetch
150# @DESCRIPTION: 162# @DESCRIPTION:
151# Wrapper function to fetch sources from a Bazaar repository via bzr 163# Wrapper function to fetch sources from a Bazaar repository via bzr
152# fetch or bzr update, depending on whether there is an existing 164# fetch or bzr update, depending on whether there is an existing
162 case ${EBZR_REPO_URI%%:*} in 174 case ${EBZR_REPO_URI%%:*} in
163 # lp: seems to be an alias to https://launchpad.net 175 # lp: seems to be an alias to https://launchpad.net
164 http|https|rsync|lp) 176 http|https|rsync|lp)
165 ;; 177 ;;
166 sftp) 178 sftp)
167 if ! built_with_use --missing true dev-util/bzr sftp; then 179 if ! built_with_use --missing true dev-vcs/bzr sftp; then
168 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP" 180 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
169 eerror "support in dev-util/bzr." 181 eerror "support in dev-vcs/bzr."
170 die "Please, rebuild dev-util/bzr with the sftp USE flag enabled." 182 die "Please, rebuild dev-vcs/bzr with the sftp USE flag enabled."
171 fi 183 fi
172 ;; 184 ;;
173 *) 185 *)
174 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented." 186 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
175 ;; 187 ;;
176 esac 188 esac
177 fi 189 fi
178 190
179 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then 191 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
180 debug-print "${FUNCNAME}: initial branch. Creating bzr directory" 192 debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
193 local save_sandbox_write=${SANDBOX_WRITE}
181 addwrite / 194 addwrite /
182 mkdir -p "${EBZR_STORE_DIR}" \ 195 mkdir -p "${EBZR_STORE_DIR}" \
183 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}." 196 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
184 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" 197 SANDBOX_WRITE=${save_sandbox_write}
185 fi 198 fi
186 199
187 pushd "${EBZR_STORE_DIR}" > /dev/null || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" 200 pushd "${EBZR_STORE_DIR}" > /dev/null \
201 || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
188 202
189 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" 203 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
190 204
191 addwrite "${EBZR_STORE_DIR}" 205 addwrite "${EBZR_STORE_DIR}"
192 addwrite "${EBZR_BRANCH_DIR}" 206 addwrite "${EBZR_BRANCH_DIR}"
196 # Run bzr_initial_fetch() only if the branch has not been pulled 210 # Run bzr_initial_fetch() only if the branch has not been pulled
197 # before or if the existing local copy is a full checkout (as did 211 # before or if the existing local copy is a full checkout (as did
198 # an older version of bzr.eclass) 212 # an older version of bzr.eclass)
199 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then 213 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
200 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}" 214 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
201 elif [[ -d "${EBZR_BRANCH_DIR}"/.bzr/repository/ ]]; then
202 einfo "Re-fetching the branch to save space..."
203 rm -rf "${EBZR_BRANCH_DIR}"
204 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
205 else 215 else
206 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}" 216 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
207 fi 217 fi
208 218
209 cd "${EBZR_BRANCH_DIR}" 219 cd "${EBZR_BRANCH_DIR}"
210 220
211 einfo "exporting ..." 221 einfo "exporting ..."
212 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} "${WORKDIR}/${P}" \ 222
223 if [[ -z ${EBZR_REVISION} ]]; then
224 rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
213 || die "${EBZR}: export failed" 225 || die "${EBZR}: export failed"
214
215 local revision
216 if [[ -n "${EBZR_REVISION}" ]]; then
217 revision="${EBZR_REVISION}"
218 else 226 else
219 revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}") 227 # revisions of a lightweight checkout are only available when online
228 [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository ]] \
229 || die "${EBZR}: No support for revisions when off-line"
230 ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \
231 || die "${EBZR}: export failed"
220 fi 232 fi
221
222 einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
223 233
224 popd > /dev/null 234 popd > /dev/null
225} 235}
226 236
227# @FUNCTION: bzr_bootstrap 237# @FUNCTION: bzr_bootstrap

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20