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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide annotations) (download)
Thu Nov 13 07:15:54 2014 UTC (7 months, 2 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 ulm 1.21 # Copyright 1999-2014 Gentoo Foundation
2 ulm 1.1 # Distributed under the terms of the GNU General Public License v2
3 ulm 1.21 # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.20 2013/07/11 18:38:59 ulm Exp $
4 ulm 1.1 #
5     # @ECLASS: bzr.eclass
6     # @MAINTAINER:
7 ulm 1.16 # 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 ulm 1.11 # @BLURB: generic fetching functions for the Bazaar VCS
14 ulm 1.1 # @DESCRIPTION:
15 ulm 1.11 # 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 ulm 1.1 #
19 ulm 1.11 # 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 ulm 1.1
22     inherit eutils
23    
24     EBZR="bzr.eclass"
25    
26 fauli 1.2 case "${EAPI:-0}" in
27     0|1) EXPORT_FUNCTIONS src_unpack ;;
28     *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
29     esac
30 ulm 1.1
31 ulm 1.11 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 ulm 1.1
38     # @ECLASS-VARIABLE: EBZR_STORE_DIR
39     # @DESCRIPTION:
40 fauli 1.2 # The directory to store all fetched Bazaar live sources.
41 ulm 1.11 : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
42    
43 ulm 1.20 # @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 ulm 1.11 # @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 ulm 1.1
53     # @ECLASS-VARIABLE: EBZR_FETCH_CMD
54     # @DESCRIPTION:
55 fauli 1.2 # The Bazaar command to fetch the sources.
56 ulm 1.13 : ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
57 ulm 1.1
58     # @ECLASS-VARIABLE: EBZR_UPDATE_CMD
59     # @DESCRIPTION:
60 fauli 1.2 # The Bazaar command to update the sources.
61 ulm 1.11 : ${EBZR_UPDATE_CMD:="bzr pull"}
62 ulm 1.1
63     # @ECLASS-VARIABLE: EBZR_EXPORT_CMD
64     # @DESCRIPTION:
65 fauli 1.2 # The Bazaar command to export a branch.
66 ulm 1.11 : ${EBZR_EXPORT_CMD:="bzr export"}
67 ulm 1.1
68 ulm 1.19 # @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 ulm 1.1 # @ECLASS-VARIABLE: EBZR_REVNO_CMD
74     # @DESCRIPTION:
75 fauli 1.2 # The Bazaar command to list a revision number of the branch.
76 ulm 1.11 : ${EBZR_REVNO_CMD:="bzr revno"}
77 ulm 1.1
78     # @ECLASS-VARIABLE: EBZR_OPTIONS
79 ulm 1.11 # @DEFAULT_UNSET
80 ulm 1.1 # @DESCRIPTION:
81     # The options passed to the fetch and update commands.
82    
83     # @ECLASS-VARIABLE: EBZR_REPO_URI
84 ulm 1.11 # @DEFAULT_UNSET
85     # @REQUIRED
86 ulm 1.1 # @DESCRIPTION:
87 fauli 1.2 # The repository URI for the source package.
88 ulm 1.1 #
89 ulm 1.11 # 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 ulm 1.12 # @ECLASS-VARIABLE: EBZR_INITIAL_URI
94 ulm 1.11 # @DEFAULT_UNSET
95     # @DESCRIPTION:
96 ulm 1.12 # 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 ulm 1.1 #
102 ulm 1.11 # Normally, this variable needs not be set.
103 ulm 1.1
104     # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
105 ulm 1.11 # @DEFAULT_UNSET
106 ulm 1.1 # @DESCRIPTION:
107     # Bootstrap script or command like autogen.sh or etc.
108    
109     # @ECLASS-VARIABLE: EBZR_PATCHES
110 ulm 1.11 # @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 ulm 1.1 # @DESCRIPTION:
132 ulm 1.11 # The directory where to store the branch within a shared repository,
133     # relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}.
134 ulm 1.1 #
135 ulm 1.11 # 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 ulm 1.1
144     # @ECLASS-VARIABLE: EBZR_REVISION
145 ulm 1.11 # @DEFAULT_UNSET
146 ulm 1.1 # @DESCRIPTION:
147 ulm 1.7 # Revision to fetch, defaults to the latest
148     # (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
149 ulm 1.1
150 fauli 1.4 # @ECLASS-VARIABLE: EBZR_OFFLINE
151     # @DESCRIPTION:
152 ulm 1.11 # 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 ulm 1.14 : ${EBZR_OFFLINE=${EVCS_OFFLINE}}
156 fauli 1.4
157 ulm 1.19 # @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 fauli 1.2 # @FUNCTION: bzr_initial_fetch
164 ulm 1.11 # @USAGE: <repository URI> <branch directory>
165 fauli 1.2 # @DESCRIPTION:
166 ulm 1.11 # Internal function, retrieves the source code from a repository for the
167     # first time, using ${EBZR_FETCH_CMD}.
168 fauli 1.2 bzr_initial_fetch() {
169 ulm 1.11 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 fauli 1.2
175     # fetch branch
176 ulm 1.11 einfo "bzr branch start -->"
177     einfo " repository: ${repo_uri} => ${branch_dir}"
178 fauli 1.2
179 ulm 1.11 ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
180     || die "${EBZR}: can't branch from ${repo_uri}"
181 fauli 1.2 }
182    
183     # @FUNCTION: bzr_update
184 ulm 1.11 # @USAGE: <repository URI> <branch directory>
185 fauli 1.2 # @DESCRIPTION:
186 ulm 1.11 # Internal function, updates the source code from a repository, using
187     # ${EBZR_UPDATE_CMD}.
188 fauli 1.2 bzr_update() {
189 ulm 1.11 local repo_uri=$1 branch_dir=$2
190 fauli 1.2
191 fauli 1.5 if [[ -n "${EBZR_OFFLINE}" ]]; then
192 ulm 1.11 einfo "skipping bzr pull -->"
193     einfo " repository: ${repo_uri}"
194 fauli 1.4 else
195     # update branch
196 ulm 1.11 einfo "bzr pull start -->"
197     einfo " repository: ${repo_uri}"
198 fauli 1.4
199 ulm 1.11 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 fauli 1.4 popd > /dev/null
204     fi
205 fauli 1.2 }
206    
207 ulm 1.1 # @FUNCTION: bzr_fetch
208     # @DESCRIPTION:
209 ulm 1.11 # 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 ulm 1.1 bzr_fetch() {
213 ulm 1.11 local repo_dir branch_dir
214 ulm 1.19 local save_sandbox_write=${SANDBOX_WRITE}
215 ulm 1.1
216 ulm 1.11 [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
217 ulm 1.1
218     if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
219     addwrite /
220     mkdir -p "${EBZR_STORE_DIR}" \
221 ulm 1.11 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
222 ulm 1.7 SANDBOX_WRITE=${save_sandbox_write}
223 ulm 1.1 fi
224    
225 ulm 1.7 pushd "${EBZR_STORE_DIR}" > /dev/null \
226     || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
227 ulm 1.1
228 ulm 1.11 repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
229     branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
230 ulm 1.1
231     addwrite "${EBZR_STORE_DIR}"
232    
233 ulm 1.11 if [[ ! -d ${branch_dir}/.bzr ]]; then
234     if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
235 ulm 1.17 einfo "creating shared bzr repository: ${repo_dir}"
236 ulm 1.11 ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
237     || die "${EBZR}: can't create shared repository"
238     fi
239 ulm 1.1
240 ulm 1.12 if [[ -z ${EBZR_INITIAL_URI} ]]; then
241 ulm 1.11 bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
242     else
243     # Workaround for faster initial download. This clones the
244 ulm 1.12 # branch from a fast server (which may be out of date), and
245 ulm 1.11 # subsequently pulls from the slow original repository.
246 ulm 1.12 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 ulm 1.11 fi
253 ulm 1.1 else
254 ulm 1.11 bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
255 ulm 1.1 fi
256    
257 ulm 1.19 # Restore sandbox environment
258     SANDBOX_WRITE=${save_sandbox_write}
259    
260 ulm 1.11 cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
261    
262 ulm 1.15 # Save revision number in environment. #311101
263 ulm 1.11 export EBZR_REVNO=$(${EBZR_REVNO_CMD})
264 ulm 1.1
265 ulm 1.19 if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
266     einfo "checking out ..."
267     ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
268 ulm 1.20 . "${EBZR_UNPACK_DIR}" || die "${EBZR}: checkout failed"
269 ulm 1.19 else
270     einfo "exporting ..."
271     ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
272 ulm 1.20 "${EBZR_UNPACK_DIR}" . || die "${EBZR}: export failed"
273 ulm 1.19 fi
274 ulm 1.20 einfo \
275     "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${EBZR_UNPACK_DIR}"
276 fauli 1.10
277 fauli 1.2 popd > /dev/null
278 ulm 1.1 }
279    
280     # @FUNCTION: bzr_bootstrap
281     # @DESCRIPTION:
282 fauli 1.2 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
283 ulm 1.1 bzr_bootstrap() {
284     local patch lpatch
285    
286 ulm 1.11 pushd "${S}" > /dev/null || die "${EBZR}: can't chdir to ${S}"
287 ulm 1.1
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 fauli 1.2 # This loop takes care of wildcarded patches given via
296     # EBZR_PATCHES in an ebuild
297 ulm 1.1 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 ulm 1.11 || die "${EBZR}: can't execute EBZR_BOOTSTRAP"
315 ulm 1.1 else
316     einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
317     "${EBZR_BOOTSTRAP}" \
318 ulm 1.11 || die "${EBZR}: can't eval EBZR_BOOTSTRAP"
319 ulm 1.1 fi
320     fi
321 fauli 1.2
322     popd > /dev/null
323 ulm 1.1 }
324    
325     # @FUNCTION: bzr_src_unpack
326     # @DESCRIPTION:
327 ulm 1.11 # Default src_unpack(), calls bzr_fetch. For EAPIs 0 and 1, also calls
328     # bzr_src_prepare.
329 ulm 1.1 bzr_src_unpack() {
330 ulm 1.11 bzr_fetch
331 fauli 1.2 case "${EAPI:-0}" in
332     0|1) bzr_src_prepare ;;
333     esac
334     }
335    
336     # @FUNCTION: bzr_src_prepare
337     # @DESCRIPTION:
338 ulm 1.11 # Default src_prepare(), calls bzr_bootstrap.
339 fauli 1.2 bzr_src_prepare() {
340 ulm 1.11 bzr_bootstrap
341 ulm 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20