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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Thu Sep 24 08:11:45 2009 UTC (4 years, 11 months ago) by fauli
Branch: MAIN
Changes since 1.4: +2 -2 lines
bzr.eclass: move wrongly placed quote

1 # Copyright 1999-2009 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.4 2009/09/24 07:19:41 fauli Exp $
4 #
5 # @ECLASS: bzr.eclass
6 # @MAINTAINER:
7 # Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
8 # Ulrich Mueller <ulm@gentoo.org>,
9 # Christian Faulhammer <fauli@gentoo.org>
10 # Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>,
11 # and anyone who wants to help
12 # @BLURB: This eclass provides support to use the Bazaar DSCM
13 # @DESCRIPTION:
14 # The bzr.eclass provides support for apps using the bazaar DSCM
15 # (distributed source control management system).
16 # The eclass was originally derived from the git eclass.
17 #
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}.
20
21 inherit eutils
22
23 EBZR="bzr.eclass"
24
25 case "${EAPI:-0}" in
26 0|1) EXPORT_FUNCTIONS src_unpack ;;
27 *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
28 esac
29
30 HOMEPAGE="http://bazaar-vcs.org/"
31 DESCRIPTION="Based on the ${EBZR} eclass"
32
33 DEPEND=">=dev-util/bzr-1.5"
34
35 # @ECLASS-VARIABLE: EBZR_STORE_DIR
36 # @DESCRIPTION:
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"
40
41 # @ECLASS-VARIABLE: EBZR_FETCH_CMD
42 # @DESCRIPTION:
43 # The Bazaar command to fetch the sources.
44 EBZR_FETCH_CMD="bzr checkout --lightweight"
45
46 # @ECLASS-VARIABLE: EBZR_UPDATE_CMD
47 # @DESCRIPTION:
48 # The Bazaar command to update the sources.
49 EBZR_UPDATE_CMD="bzr update"
50
51 # @ECLASS-VARIABLE: EBZR_DIFF_CMD
52 # @DESCRIPTION:
53 # The Bazaar command to get the diff output.
54 EBZR_DIFF_CMD="bzr diff"
55
56 # @ECLASS-VARIABLE: EBZR_EXPORT_CMD
57 # @DESCRIPTION:
58 # The Bazaar command to export a branch.
59 EBZR_EXPORT_CMD="bzr export"
60
61 # @ECLASS-VARIABLE: EBZR_REVNO_CMD
62 # @DESCRIPTION:
63 # The Bazaar command to list a revision number of the branch.
64 EBZR_REVNO_CMD="bzr revno"
65
66 # @ECLASS-VARIABLE: EBZR_OPTIONS
67 # @DESCRIPTION:
68 # The options passed to the fetch and update commands.
69 EBZR_OPTIONS="${EBZR_OPTIONS:-}"
70
71 # @ECLASS-VARIABLE: EBZR_REPO_URI
72 # @DESCRIPTION:
73 # The repository URI for the source package.
74 #
75 # @CODE
76 # Supported protocols:
77 # - http://
78 # - https://
79 # - sftp://
80 # - rsync://
81 # - lp:
82 # @CODE
83 #
84 # Note: lp: seems to be an alias for https://launchpad.net
85 EBZR_REPO_URI="${EBZR_REPO_URI:-}"
86
87 # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
88 # @DESCRIPTION:
89 # Bootstrap script or command like autogen.sh or etc.
90 EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}"
91
92 # @ECLASS-VARIABLE: EBZR_PATCHES
93 # @DESCRIPTION:
94 # bzr eclass can apply patches in bzr_bootstrap().
95 # You can use regular expressions in this variable like *.diff or
96 # *.patch and the like.
97 # NOTE: These patches will bei applied before EBZR_BOOTSTRAP is processed.
98 #
99 # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
100 # location, the installation dies.
101 EBZR_PATCHES="${EBZR_PATCHES:-}"
102
103 # @ECLASS-VARIABLE: EBZR_REVISION
104 # @DESCRIPTION:
105 # Revision to fetch, defaults to the latest (see
106 # http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec)
107 EBZR_REVISION="${EBZR_REVISION:-}"
108
109 # @ECLASS-VARIABLE: EBZR_CACHE_DIR
110 # @DESCRIPTION:
111 # The directory to store the source for the package, relative to
112 # EBZR_STORE_DIR.
113 #
114 # default: ${PN}
115 EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
116
117 # @ECLASS-VARIABLE: EBZR_OFFLINE
118 # @DESCRIPTION:
119 # Set this variable to a non-empty value to disable the automatic updating of
120 # a bzr source tree. This is intended to be set outside the ebuild by users.
121 EBZR_OFFLINE="${EBZR_OFFLINE:-${ESCM_OFFLINE}}"
122
123 # @FUNCTION: bzr_initial_fetch
124 # @DESCRIPTION:
125 # Retrieves the source code from a repository for the first time, via
126 # ${EBZR_FETCH_CMD}.
127 bzr_initial_fetch() {
128 local repository="${1}";
129 local branch_dir="${2}";
130
131 # fetch branch
132 einfo "bzr fetch start -->"
133 einfo " repository: ${repository} => ${branch_dir}"
134
135 ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \
136 || die "${EBZR}: can't branch from ${repository}."
137 }
138
139 # @FUNCTION: bzr_update
140 # @DESCRIPTION:
141 # Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
142 bzr_update() {
143 local repository="${1}";
144
145 if [[ -n "${EBZR_OFFLINE}" ]]; then
146 einfo "skipping bzr update -->"
147 einfo " repository: ${repository}"
148 else
149 # update branch
150 einfo "bzr update start -->"
151 einfo " repository: ${repository}"
152
153 pushd "${EBZR_BRANCH_DIR}" > /dev/null
154 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
155 || die "${EBZR}: can't update from ${repository}."
156 popd > /dev/null
157 fi
158 }
159
160
161 # @FUNCTION: bzr_fetch
162 # @DESCRIPTION:
163 # Wrapper function to fetch sources from a Bazaar repository via bzr
164 # fetch or bzr update, depending on whether there is an existing
165 # working copy in ${EBZR_BRANCH_DIR}.
166 bzr_fetch() {
167 local EBZR_BRANCH_DIR
168
169 # EBZR_REPO_URI is empty.
170 [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty."
171
172 # check for the protocol or pull from a local repo.
173 if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then
174 case ${EBZR_REPO_URI%%:*} in
175 # lp: seems to be an alias to https://launchpad.net
176 http|https|rsync|lp)
177 ;;
178 sftp)
179 if ! built_with_use --missing true dev-util/bzr sftp; then
180 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
181 eerror "support in dev-util/bzr."
182 die "Please, rebuild dev-util/bzr with the sftp USE flag enabled."
183 fi
184 ;;
185 *)
186 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
187 ;;
188 esac
189 fi
190
191 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
192 debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
193 addwrite /
194 mkdir -p "${EBZR_STORE_DIR}" \
195 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
196 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
197 fi
198
199 pushd "${EBZR_STORE_DIR}" > /dev/null || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
200
201 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
202
203 addwrite "${EBZR_STORE_DIR}"
204 addwrite "${EBZR_BRANCH_DIR}"
205
206 debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
207
208 # 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
210 # an older version of bzr.eclass)
211 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
212 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
218 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
219 fi
220
221 cd "${EBZR_BRANCH_DIR}"
222
223 einfo "exporting ..."
224 ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} "${WORKDIR}/${P}" \
225 || die "${EBZR}: export failed"
226
227 local revision
228 if [[ -n "${EBZR_REVISION}" ]]; then
229 revision="${EBZR_REVISION}"
230 else
231 revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}")
232 fi
233
234 einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
235
236 popd > /dev/null
237 }
238
239 # @FUNCTION: bzr_bootstrap
240 # @DESCRIPTION:
241 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
242 bzr_bootstrap() {
243 local patch lpatch
244
245 pushd "${S}" > /dev/null
246
247 if [[ -n ${EBZR_PATCHES} ]] ; then
248 einfo "apply patches -->"
249
250 for patch in ${EBZR_PATCHES} ; do
251 if [[ -f ${patch} ]] ; then
252 epatch ${patch}
253 else
254 # This loop takes care of wildcarded patches given via
255 # EBZR_PATCHES in an ebuild
256 for lpatch in "${FILESDIR}"/${patch} ; do
257 if [[ -f ${lpatch} ]] ; then
258 epatch ${lpatch}
259 else
260 die "${EBZR}: ${patch} is not found"
261 fi
262 done
263 fi
264 done
265 fi
266
267 if [[ -n ${EBZR_BOOTSTRAP} ]] ; then
268 einfo "begin bootstrap -->"
269
270 if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
271 einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
272 "./${EBZR_BOOTSTRAP}" \
273 || die "${EBZR}: can't execute EBZR_BOOTSTRAP."
274 else
275 einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
276 "${EBZR_BOOTSTRAP}" \
277 || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
278 fi
279 fi
280
281 popd > /dev/null
282 }
283
284 # @FUNCTION: bzr_src_unpack
285 # @DESCRIPTION:
286 # Default src_unpack(). Includes bzr_fetch() and bootstrap().
287 bzr_src_unpack() {
288 if ! [ -z ${EBZR_BRANCH} ]; then
289 # This test will go away on 01 Jul 2010
290 eerror "This ebuild uses EBZR_BRANCH which is not supported anymore"
291 eerror "by the bzr.eclass. Please report this to the ebuild's maintainer."
292 die "EBZR_BRANCH still defined"
293 fi
294 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
295 case "${EAPI:-0}" in
296 0|1) bzr_src_prepare ;;
297 esac
298 }
299
300 # @FUNCTION: bzr_src_prepare
301 # @DESCRIPTION:
302 # Default src_prepare(). Executes bzr_bootstrap() for patch
303 # application and Make file generation (if needed).
304 bzr_src_prepare() {
305 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
306 }

  ViewVC Help
Powered by ViewVC 1.1.20