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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Thu Nov 13 07:15:54 2014 UTC (7 months, 3 weeks ago) by ulm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.20: +2 -3 lines
Remove Emacs team from maintainers of bzr.eclass.

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.20 2013/07/11 18:38:59 ulm Exp $
4 #
5 # @ECLASS: bzr.eclass
6 # @MAINTAINER:
7 # Bazaar team <bazaar@gentoo.org>
8 # @AUTHOR:
9 # Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
10 # Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>
11 # Ulrich Müller <ulm@gentoo.org>
12 # Christian Faulhammer <fauli@gentoo.org>
13 # @BLURB: generic fetching functions for the Bazaar VCS
14 # @DESCRIPTION:
15 # The bzr.eclass provides functions to fetch, unpack, patch, and
16 # bootstrap sources from repositories of the Bazaar distributed version
17 # control system. The eclass was originally derived from git.eclass.
18 #
19 # Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack()
20 # of this eclass will export the branch to ${WORKDIR}/${P}.
21
22 inherit eutils
23
24 EBZR="bzr.eclass"
25
26 case "${EAPI:-0}" in
27 0|1) EXPORT_FUNCTIONS src_unpack ;;
28 *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
29 esac
30
31 DEPEND=">=dev-vcs/bzr-2.0.1"
32 case "${EAPI:-0}" in
33 0|1) ;;
34 *) [[ ${EBZR_REPO_URI%%:*} = sftp ]] \
35 && DEPEND=">=dev-vcs/bzr-2.0.1[sftp]" ;;
36 esac
37
38 # @ECLASS-VARIABLE: EBZR_STORE_DIR
39 # @DESCRIPTION:
40 # The directory to store all fetched Bazaar live sources.
41 : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
42
43 # @ECLASS-VARIABLE: EBZR_UNPACK_DIR
44 # @DESCRIPTION:
45 # The working directory where the sources are copied to.
46 : ${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}
47
48 # @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
49 # @DESCRIPTION:
50 # The Bazaar command to initialise a shared repository.
51 : ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
52
53 # @ECLASS-VARIABLE: EBZR_FETCH_CMD
54 # @DESCRIPTION:
55 # The Bazaar command to fetch the sources.
56 : ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
57
58 # @ECLASS-VARIABLE: EBZR_UPDATE_CMD
59 # @DESCRIPTION:
60 # The Bazaar command to update the sources.
61 : ${EBZR_UPDATE_CMD:="bzr pull"}
62
63 # @ECLASS-VARIABLE: EBZR_EXPORT_CMD
64 # @DESCRIPTION:
65 # The Bazaar command to export a branch.
66 : ${EBZR_EXPORT_CMD:="bzr export"}
67
68 # @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
69 # @DESCRIPTION:
70 # The Bazaar command to checkout a branch.
71 : ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
72
73 # @ECLASS-VARIABLE: EBZR_REVNO_CMD
74 # @DESCRIPTION:
75 # The Bazaar command to list a revision number of the branch.
76 : ${EBZR_REVNO_CMD:="bzr revno"}
77
78 # @ECLASS-VARIABLE: EBZR_OPTIONS
79 # @DEFAULT_UNSET
80 # @DESCRIPTION:
81 # The options passed to the fetch and update commands.
82
83 # @ECLASS-VARIABLE: EBZR_REPO_URI
84 # @DEFAULT_UNSET
85 # @REQUIRED
86 # @DESCRIPTION:
87 # The repository URI for the source package.
88 #
89 # Note: If the ebuild uses an sftp:// URI, then in EAPI 0 or 1 it must
90 # make sure that dev-vcs/bzr was built with USE="sftp". In EAPI 2 or
91 # later, the eclass will depend on dev-vcs/bzr[sftp].
92
93 # @ECLASS-VARIABLE: EBZR_INITIAL_URI
94 # @DEFAULT_UNSET
95 # @DESCRIPTION:
96 # The URI used for initial branching of the source repository. If this
97 # variable is set, the initial branch will be cloned from the location
98 # specified, followed by a pull from ${EBZR_REPO_URI}. This is intended
99 # for special cases, e.g. when download from the original repository is
100 # slow, but a fast mirror exists but may be out of date.
101 #
102 # Normally, this variable needs not be set.
103
104 # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
105 # @DEFAULT_UNSET
106 # @DESCRIPTION:
107 # Bootstrap script or command like autogen.sh or etc.
108
109 # @ECLASS-VARIABLE: EBZR_PATCHES
110 # @DEFAULT_UNSET
111 # @DESCRIPTION:
112 # bzr.eclass can apply patches in bzr_bootstrap(). You can use regular
113 # expressions in this variable like *.diff or *.patch and the like.
114 # Note: These patches will be applied before EBZR_BOOTSTRAP is processed.
115 #
116 # Patches are searched both in ${PWD} and ${FILESDIR}. If not found in
117 # either location, the installation dies.
118
119 # @ECLASS-VARIABLE: EBZR_PROJECT
120 # @DESCRIPTION:
121 # The project name of your ebuild. Normally, the branch will be stored
122 # in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory.
123 #
124 # If EBZR_BRANCH is set (see below), then a shared repository will be
125 # created in that directory, and the branch will be located in
126 # ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}.
127 : ${EBZR_PROJECT:=${PN}}
128
129 # @ECLASS-VARIABLE: EBZR_BRANCH
130 # @DEFAULT_UNSET
131 # @DESCRIPTION:
132 # The directory where to store the branch within a shared repository,
133 # relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}.
134 #
135 # This variable should be set if there are several live ebuilds for
136 # different branches of the same upstream project. The branches can
137 # then share the same repository in EBZR_PROJECT, which will save both
138 # data traffic volume and disk space.
139 #
140 # If there is only a live ebuild for one single branch, EBZR_BRANCH
141 # needs not be set. In this case, the branch will be stored in a
142 # stand-alone repository directly in EBZR_PROJECT.
143
144 # @ECLASS-VARIABLE: EBZR_REVISION
145 # @DEFAULT_UNSET
146 # @DESCRIPTION:
147 # Revision to fetch, defaults to the latest
148 # (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
149
150 # @ECLASS-VARIABLE: EBZR_OFFLINE
151 # @DESCRIPTION:
152 # Set this variable to a non-empty value to disable automatic updating
153 # of a bzr source tree. This is intended to be set outside the ebuild
154 # by users.
155 : ${EBZR_OFFLINE=${EVCS_OFFLINE}}
156
157 # @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT
158 # @DEFAULT_UNSET
159 # @DESCRIPTION:
160 # If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will
161 # be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR.
162
163 # @FUNCTION: bzr_initial_fetch
164 # @USAGE: <repository URI> <branch directory>
165 # @DESCRIPTION:
166 # Internal function, retrieves the source code from a repository for the
167 # first time, using ${EBZR_FETCH_CMD}.
168 bzr_initial_fetch() {
169 local repo_uri=$1 branch_dir=$2
170
171 if [[ -n "${EBZR_OFFLINE}" ]]; then
172 ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet."
173 fi
174
175 # fetch branch
176 einfo "bzr branch start -->"
177 einfo " repository: ${repo_uri} => ${branch_dir}"
178
179 ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
180 || die "${EBZR}: can't branch from ${repo_uri}"
181 }
182
183 # @FUNCTION: bzr_update
184 # @USAGE: <repository URI> <branch directory>
185 # @DESCRIPTION:
186 # Internal function, updates the source code from a repository, using
187 # ${EBZR_UPDATE_CMD}.
188 bzr_update() {
189 local repo_uri=$1 branch_dir=$2
190
191 if [[ -n "${EBZR_OFFLINE}" ]]; then
192 einfo "skipping bzr pull -->"
193 einfo " repository: ${repo_uri}"
194 else
195 # update branch
196 einfo "bzr pull start -->"
197 einfo " repository: ${repo_uri}"
198
199 pushd "${branch_dir}" > /dev/null \
200 || die "${EBZR}: can't chdir to ${branch_dir}"
201 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \
202 || die "${EBZR}: can't pull from ${repo_uri}"
203 popd > /dev/null
204 fi
205 }
206
207 # @FUNCTION: bzr_fetch
208 # @DESCRIPTION:
209 # Wrapper function to fetch sources from a Bazaar repository with
210 # bzr branch or bzr pull, depending on whether there is an existing
211 # working copy.
212 bzr_fetch() {
213 local repo_dir branch_dir
214 local save_sandbox_write=${SANDBOX_WRITE}
215
216 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
217
218 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
219 addwrite /
220 mkdir -p "${EBZR_STORE_DIR}" \
221 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
222 SANDBOX_WRITE=${save_sandbox_write}
223 fi
224
225 pushd "${EBZR_STORE_DIR}" > /dev/null \
226 || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
227
228 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
229 branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
230
231 addwrite "${EBZR_STORE_DIR}"
232
233 if [[ ! -d ${branch_dir}/.bzr ]]; then
234 if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
235 einfo "creating shared bzr repository: ${repo_dir}"
236 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
237 || die "${EBZR}: can't create shared repository"
238 fi
239
240 if [[ -z ${EBZR_INITIAL_URI} ]]; then
241 bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
242 else
243 # Workaround for faster initial download. This clones the
244 # branch from a fast server (which may be out of date), and
245 # subsequently pulls from the slow original repository.
246 bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}"
247 if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then
248 EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
249 EBZR_OFFLINE="" \
250 bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
251 fi
252 fi
253 else
254 bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
255 fi
256
257 # Restore sandbox environment
258 SANDBOX_WRITE=${save_sandbox_write}
259
260 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
261
262 # Save revision number in environment. #311101
263 export EBZR_REVNO=$(${EBZR_REVNO_CMD})
264
265 if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
266 einfo "checking out ..."
267 ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
268 . "${EBZR_UNPACK_DIR}" || die "${EBZR}: checkout failed"
269 else
270 einfo "exporting ..."
271 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
272 "${EBZR_UNPACK_DIR}" . || die "${EBZR}: export failed"
273 fi
274 einfo \
275 "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${EBZR_UNPACK_DIR}"
276
277 popd > /dev/null
278 }
279
280 # @FUNCTION: bzr_bootstrap
281 # @DESCRIPTION:
282 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
283 bzr_bootstrap() {
284 local patch lpatch
285
286 pushd "${S}" > /dev/null || die "${EBZR}: can't chdir to ${S}"
287
288 if [[ -n ${EBZR_PATCHES} ]] ; then
289 einfo "apply patches -->"
290
291 for patch in ${EBZR_PATCHES} ; do
292 if [[ -f ${patch} ]] ; then
293 epatch ${patch}
294 else
295 # This loop takes care of wildcarded patches given via
296 # EBZR_PATCHES in an ebuild
297 for lpatch in "${FILESDIR}"/${patch} ; do
298 if [[ -f ${lpatch} ]] ; then
299 epatch ${lpatch}
300 else
301 die "${EBZR}: ${patch} is not found"
302 fi
303 done
304 fi
305 done
306 fi
307
308 if [[ -n ${EBZR_BOOTSTRAP} ]] ; then
309 einfo "begin bootstrap -->"
310
311 if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
312 einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
313 "./${EBZR_BOOTSTRAP}" \
314 || die "${EBZR}: can't execute EBZR_BOOTSTRAP"
315 else
316 einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
317 "${EBZR_BOOTSTRAP}" \
318 || die "${EBZR}: can't eval EBZR_BOOTSTRAP"
319 fi
320 fi
321
322 popd > /dev/null
323 }
324
325 # @FUNCTION: bzr_src_unpack
326 # @DESCRIPTION:
327 # Default src_unpack(), calls bzr_fetch. For EAPIs 0 and 1, also calls
328 # bzr_src_prepare.
329 bzr_src_unpack() {
330 bzr_fetch
331 case "${EAPI:-0}" in
332 0|1) bzr_src_prepare ;;
333 esac
334 }
335
336 # @FUNCTION: bzr_src_prepare
337 # @DESCRIPTION:
338 # Default src_prepare(), calls bzr_bootstrap.
339 bzr_src_prepare() {
340 bzr_bootstrap
341 }

  ViewVC Help
Powered by ViewVC 1.1.20