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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Thu Jul 1 09:23:37 2010 UTC (4 years, 5 months ago) by fauli
Branch: MAIN
Changes since 1.8: +1 -6 lines
Remove check for old fetch directory, people should have migrated up to now

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.8 2010/03/05 09:35:23 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 VCS
13 # @DESCRIPTION:
14 # The bzr.eclass provides support for apps using the Bazaar VCS
15 # (distributed version control 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-vcs/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
105 # (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
106 # If you set this to a non-empty value, then it is recommended not to
107 # use a lightweight checkout (see also EBZR_FETCH_CMD).
108 EBZR_REVISION="${EBZR_REVISION:-}"
109
110 # @ECLASS-VARIABLE: EBZR_CACHE_DIR
111 # @DESCRIPTION:
112 # The directory to store the source for the package, relative to
113 # EBZR_STORE_DIR.
114 #
115 # default: ${PN}
116 EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
117
118 # @ECLASS-VARIABLE: EBZR_OFFLINE
119 # @DESCRIPTION:
120 # Set this variable to a non-empty value to disable the automatic updating of
121 # a bzr source tree. This is intended to be set outside the ebuild by users.
122 EBZR_OFFLINE="${EBZR_OFFLINE:-${ESCM_OFFLINE}}"
123
124 # @FUNCTION: bzr_initial_fetch
125 # @DESCRIPTION:
126 # Retrieves the source code from a repository for the first time, via
127 # ${EBZR_FETCH_CMD}.
128 bzr_initial_fetch() {
129 local repository="${1}";
130 local branch_dir="${2}";
131
132 # fetch branch
133 einfo "bzr fetch start -->"
134 einfo " repository: ${repository} => ${branch_dir}"
135
136 ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \
137 || die "${EBZR}: can't branch from ${repository}."
138 }
139
140 # @FUNCTION: bzr_update
141 # @DESCRIPTION:
142 # Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
143 bzr_update() {
144 local repository="${1}";
145
146 if [[ -n "${EBZR_OFFLINE}" ]]; then
147 einfo "skipping bzr update -->"
148 einfo " repository: ${repository}"
149 else
150 # update branch
151 einfo "bzr update start -->"
152 einfo " repository: ${repository}"
153
154 pushd "${EBZR_BRANCH_DIR}" > /dev/null
155 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
156 || die "${EBZR}: can't update from ${repository}."
157 popd > /dev/null
158 fi
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-vcs/bzr sftp; then
180 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
181 eerror "support in dev-vcs/bzr."
182 die "Please, rebuild dev-vcs/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 local save_sandbox_write=${SANDBOX_WRITE}
194 addwrite /
195 mkdir -p "${EBZR_STORE_DIR}" \
196 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
197 SANDBOX_WRITE=${save_sandbox_write}
198 fi
199
200 pushd "${EBZR_STORE_DIR}" > /dev/null \
201 || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
202
203 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
204
205 addwrite "${EBZR_STORE_DIR}"
206 addwrite "${EBZR_BRANCH_DIR}"
207
208 debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
209
210 # Run bzr_initial_fetch() only if the branch has not been pulled
211 # before or if the existing local copy is a full checkout (as did
212 # an older version of bzr.eclass)
213 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
214 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
215 else
216 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
217 fi
218
219 cd "${EBZR_BRANCH_DIR}"
220
221 einfo "exporting ..."
222
223 if [[ -z ${EBZR_REVISION} ]]; then
224 rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
225 || die "${EBZR}: export failed"
226 else
227 # revisions of a lightweight checkout are only available when online
228 [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository ]] \
229 || die "${EBZR}: No support for revisions when off-line"
230 ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \
231 || die "${EBZR}: export failed"
232 fi
233
234 popd > /dev/null
235 }
236
237 # @FUNCTION: bzr_bootstrap
238 # @DESCRIPTION:
239 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
240 bzr_bootstrap() {
241 local patch lpatch
242
243 pushd "${S}" > /dev/null
244
245 if [[ -n ${EBZR_PATCHES} ]] ; then
246 einfo "apply patches -->"
247
248 for patch in ${EBZR_PATCHES} ; do
249 if [[ -f ${patch} ]] ; then
250 epatch ${patch}
251 else
252 # This loop takes care of wildcarded patches given via
253 # EBZR_PATCHES in an ebuild
254 for lpatch in "${FILESDIR}"/${patch} ; do
255 if [[ -f ${lpatch} ]] ; then
256 epatch ${lpatch}
257 else
258 die "${EBZR}: ${patch} is not found"
259 fi
260 done
261 fi
262 done
263 fi
264
265 if [[ -n ${EBZR_BOOTSTRAP} ]] ; then
266 einfo "begin bootstrap -->"
267
268 if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
269 einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
270 "./${EBZR_BOOTSTRAP}" \
271 || die "${EBZR}: can't execute EBZR_BOOTSTRAP."
272 else
273 einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
274 "${EBZR_BOOTSTRAP}" \
275 || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
276 fi
277 fi
278
279 popd > /dev/null
280 }
281
282 # @FUNCTION: bzr_src_unpack
283 # @DESCRIPTION:
284 # Default src_unpack(). Includes bzr_fetch() and bootstrap().
285 bzr_src_unpack() {
286 if ! [ -z ${EBZR_BRANCH} ]; then
287 # This test will go away on 01 Jul 2010
288 eerror "This ebuild uses EBZR_BRANCH which is not supported anymore"
289 eerror "by the bzr.eclass. Please report this to the ebuild's maintainer."
290 die "EBZR_BRANCH still defined"
291 fi
292 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
293 case "${EAPI:-0}" in
294 0|1) bzr_src_prepare ;;
295 esac
296 }
297
298 # @FUNCTION: bzr_src_prepare
299 # @DESCRIPTION:
300 # Default src_prepare(). Executes bzr_bootstrap() for patch
301 # application and Make file generation (if needed).
302 bzr_src_prepare() {
303 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
304 }

  ViewVC Help
Powered by ViewVC 1.1.20