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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Wed Jul 18 15:12:54 2012 UTC (2 years, 2 months ago) by ulm
Branch: MAIN
Changes since 1.17: +2 -5 lines
Don't assign useless values to DESCRIPTION and HOMEPAGE variables.

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

  ViewVC Help
Powered by ViewVC 1.1.20