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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Wed Dec 9 10:04:16 2009 UTC (5 years ago) by vapier
Branch: MAIN
Changes since 1.5: +2 -3 lines
tweak default EBZR_STORE_DIR value to something eclass-manpages can easily parse

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

  ViewVC Help
Powered by ViewVC 1.1.20