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

Diff of /eclass/bzr.eclass

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

Revision 1.4 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.4 2009/09/24 07:19:41 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.
38[[ -z ${EBZR_STORE_DIR} ]] && \
39 EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src" 38: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src}
40 39
41# @ECLASS-VARIABLE: EBZR_FETCH_CMD 40# @ECLASS-VARIABLE: EBZR_FETCH_CMD
42# @DESCRIPTION: 41# @DESCRIPTION:
43# The Bazaar command to fetch the sources. 42# The Bazaar command to fetch the sources.
44EBZR_FETCH_CMD="bzr checkout --lightweight" 43EBZR_FETCH_CMD="bzr checkout --lightweight"
100# location, the installation dies. 99# location, the installation dies.
101EBZR_PATCHES="${EBZR_PATCHES:-}" 100EBZR_PATCHES="${EBZR_PATCHES:-}"
102 101
103# @ECLASS-VARIABLE: EBZR_REVISION 102# @ECLASS-VARIABLE: EBZR_REVISION
104# @DESCRIPTION: 103# @DESCRIPTION:
105# Revision to fetch, defaults to the latest (see 104# Revision to fetch, defaults to the latest
106# 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).
107EBZR_REVISION="${EBZR_REVISION:-}" 108EBZR_REVISION="${EBZR_REVISION:-}"
108 109
109# @ECLASS-VARIABLE: EBZR_CACHE_DIR 110# @ECLASS-VARIABLE: EBZR_CACHE_DIR
110# @DESCRIPTION: 111# @DESCRIPTION:
111# The directory to store the source for the package, relative to 112# The directory to store the source for the package, relative to
140# @DESCRIPTION: 141# @DESCRIPTION:
141# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}. 142# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
142bzr_update() { 143bzr_update() {
143 local repository="${1}"; 144 local repository="${1}";
144 145
145 if [[ -n "${EBZR_OFFLINE"} ]]; then 146 if [[ -n "${EBZR_OFFLINE}" ]]; then
146 einfo "skipping bzr update -->" 147 einfo "skipping bzr update -->"
147 einfo " repository: ${repository}" 148 einfo " repository: ${repository}"
148 else 149 else
149 # update branch 150 # update branch
150 einfo "bzr update start -->" 151 einfo "bzr update start -->"
154 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \ 155 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
155 || die "${EBZR}: can't update from ${repository}." 156 || die "${EBZR}: can't update from ${repository}."
156 popd > /dev/null 157 popd > /dev/null
157 fi 158 fi
158} 159}
159
160 160
161# @FUNCTION: bzr_fetch 161# @FUNCTION: bzr_fetch
162# @DESCRIPTION: 162# @DESCRIPTION:
163# Wrapper function to fetch sources from a Bazaar repository via bzr 163# Wrapper function to fetch sources from a Bazaar repository via bzr
164# fetch or bzr update, depending on whether there is an existing 164# fetch or bzr update, depending on whether there is an existing
174 case ${EBZR_REPO_URI%%:*} in 174 case ${EBZR_REPO_URI%%:*} in
175 # lp: seems to be an alias to https://launchpad.net 175 # lp: seems to be an alias to https://launchpad.net
176 http|https|rsync|lp) 176 http|https|rsync|lp)
177 ;; 177 ;;
178 sftp) 178 sftp)
179 if ! built_with_use --missing true dev-util/bzr sftp; then 179 if ! built_with_use --missing true dev-vcs/bzr sftp; then
180 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP" 180 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
181 eerror "support in dev-util/bzr." 181 eerror "support in dev-vcs/bzr."
182 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."
183 fi 183 fi
184 ;; 184 ;;
185 *) 185 *)
186 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented." 186 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
187 ;; 187 ;;
188 esac 188 esac
189 fi 189 fi
190 190
191 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then 191 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
192 debug-print "${FUNCNAME}: initial branch. Creating bzr directory" 192 debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
193 local save_sandbox_write=${SANDBOX_WRITE}
193 addwrite / 194 addwrite /
194 mkdir -p "${EBZR_STORE_DIR}" \ 195 mkdir -p "${EBZR_STORE_DIR}" \
195 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}." 196 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
196 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" 197 SANDBOX_WRITE=${save_sandbox_write}
197 fi 198 fi
198 199
199 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}"
200 202
201 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" 203 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
202 204
203 addwrite "${EBZR_STORE_DIR}" 205 addwrite "${EBZR_STORE_DIR}"
204 addwrite "${EBZR_BRANCH_DIR}" 206 addwrite "${EBZR_BRANCH_DIR}"
208 # 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
209 # 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
210 # an older version of bzr.eclass) 212 # an older version of bzr.eclass)
211 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then 213 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
212 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}" 214 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
213 elif [[ -d "${EBZR_BRANCH_DIR}"/.bzr/repository/ ]]; then
214 einfo "Re-fetching the branch to save space..."
215 rm -rf "${EBZR_BRANCH_DIR}"
216 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
217 else 215 else
218 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}" 216 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
219 fi 217 fi
220 218
221 cd "${EBZR_BRANCH_DIR}" 219 cd "${EBZR_BRANCH_DIR}"
222 220
223 einfo "exporting ..." 221 einfo "exporting ..."
224 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} "${WORKDIR}/${P}" \ 222
223 if [[ -z ${EBZR_REVISION} ]]; then
224 rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
225 || die "${EBZR}: export failed" 225 || die "${EBZR}: export failed"
226
227 local revision
228 if [[ -n "${EBZR_REVISION}" ]]; then
229 revision="${EBZR_REVISION}"
230 else 226 else
231 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"
232 fi 232 fi
233
234 einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
235 233
236 popd > /dev/null 234 popd > /dev/null
237} 235}
238 236
239# @FUNCTION: bzr_bootstrap 237# @FUNCTION: bzr_bootstrap

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

  ViewVC Help
Powered by ViewVC 1.1.20