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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Fri Mar 5 09:35:23 2010 UTC (4 years, 5 months ago) by fauli
Branch: MAIN
Changes since 1.7: +5 -5 lines
move bzr from dev-util to dev-vcs

1 fauli 1.2 # Copyright 1999-2009 Gentoo Foundation
2 ulm 1.1 # Distributed under the terms of the GNU General Public License v2
3 fauli 1.8 # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.7 2009/12/18 07:08:19 ulm Exp $
4 ulm 1.1 #
5     # @ECLASS: bzr.eclass
6     # @MAINTAINER:
7     # Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
8     # Ulrich Mueller <ulm@gentoo.org>,
9 ulm 1.7 # Christian Faulhammer <fauli@gentoo.org>,
10 fauli 1.2 # Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>,
11 ulm 1.1 # and anyone who wants to help
12 ulm 1.7 # @BLURB: This eclass provides support to use the Bazaar VCS
13 ulm 1.1 # @DESCRIPTION:
14 ulm 1.7 # The bzr.eclass provides support for apps using the Bazaar VCS
15     # (distributed version control system).
16 ulm 1.1 # The eclass was originally derived from the git eclass.
17     #
18 fauli 1.2 # 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 ulm 1.1
21     inherit eutils
22    
23     EBZR="bzr.eclass"
24    
25 fauli 1.2 case "${EAPI:-0}" in
26     0|1) EXPORT_FUNCTIONS src_unpack ;;
27     *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
28     esac
29 ulm 1.1
30     HOMEPAGE="http://bazaar-vcs.org/"
31     DESCRIPTION="Based on the ${EBZR} eclass"
32    
33 fauli 1.8 DEPEND=">=dev-vcs/bzr-1.5"
34 ulm 1.1
35     # @ECLASS-VARIABLE: EBZR_STORE_DIR
36     # @DESCRIPTION:
37 fauli 1.2 # The directory to store all fetched Bazaar live sources.
38 vapier 1.6 : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src}
39 ulm 1.1
40     # @ECLASS-VARIABLE: EBZR_FETCH_CMD
41     # @DESCRIPTION:
42 fauli 1.2 # The Bazaar command to fetch the sources.
43     EBZR_FETCH_CMD="bzr checkout --lightweight"
44 ulm 1.1
45     # @ECLASS-VARIABLE: EBZR_UPDATE_CMD
46     # @DESCRIPTION:
47 fauli 1.2 # The Bazaar command to update the sources.
48     EBZR_UPDATE_CMD="bzr update"
49 ulm 1.1
50 fauli 1.2 # @ECLASS-VARIABLE: EBZR_DIFF_CMD
51 ulm 1.1 # @DESCRIPTION:
52 fauli 1.2 # The Bazaar command to get the diff output.
53     EBZR_DIFF_CMD="bzr diff"
54 ulm 1.1
55     # @ECLASS-VARIABLE: EBZR_EXPORT_CMD
56     # @DESCRIPTION:
57 fauli 1.2 # The Bazaar command to export a branch.
58 ulm 1.1 EBZR_EXPORT_CMD="bzr export"
59    
60     # @ECLASS-VARIABLE: EBZR_REVNO_CMD
61     # @DESCRIPTION:
62 fauli 1.2 # The Bazaar command to list a revision number of the branch.
63 ulm 1.1 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 fauli 1.2 # The repository URI for the source package.
73 ulm 1.1 #
74     # @CODE
75     # Supported protocols:
76     # - http://
77     # - https://
78     # - sftp://
79     # - rsync://
80 fauli 1.2 # - lp:
81 ulm 1.1 # @CODE
82     #
83 fauli 1.2 # Note: lp: seems to be an alias for https://launchpad.net
84 ulm 1.1 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 fauli 1.2 # 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 ulm 1.1 #
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 ulm 1.7 # 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 ulm 1.1 EBZR_REVISION="${EBZR_REVISION:-}"
109    
110     # @ECLASS-VARIABLE: EBZR_CACHE_DIR
111     # @DESCRIPTION:
112 fauli 1.2 # The directory to store the source for the package, relative to
113     # EBZR_STORE_DIR.
114 ulm 1.1 #
115     # default: ${PN}
116     EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
117    
118 fauli 1.4 # @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 fauli 1.2 # @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 fauli 1.5 if [[ -n "${EBZR_OFFLINE}" ]]; then
147 fauli 1.4 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 fauli 1.2 }
160    
161 ulm 1.1 # @FUNCTION: bzr_fetch
162     # @DESCRIPTION:
163 fauli 1.2 # 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 ulm 1.1 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 fauli 1.2 # lp: seems to be an alias to https://launchpad.net
176     http|https|rsync|lp)
177     ;;
178     sftp)
179 fauli 1.8 if ! built_with_use --missing true dev-vcs/bzr sftp; then
180 fauli 1.2 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
181 fauli 1.8 eerror "support in dev-vcs/bzr."
182     die "Please, rebuild dev-vcs/bzr with the sftp USE flag enabled."
183 fauli 1.2 fi
184 ulm 1.1 ;;
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 fauli 1.2 debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
193 ulm 1.7 local save_sandbox_write=${SANDBOX_WRITE}
194 ulm 1.1 addwrite /
195     mkdir -p "${EBZR_STORE_DIR}" \
196     || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
197 ulm 1.7 SANDBOX_WRITE=${save_sandbox_write}
198 ulm 1.1 fi
199    
200 ulm 1.7 pushd "${EBZR_STORE_DIR}" > /dev/null \
201     || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
202 ulm 1.1
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 fauli 1.2 # 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 ulm 1.1 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
214 fauli 1.2 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
215 ulm 1.7 elif [[ ${EBZR_FETCH_CMD} == *lightweight* \
216     && -d ${EBZR_BRANCH_DIR}/.bzr/repository ]]; then
217 fauli 1.2 einfo "Re-fetching the branch to save space..."
218     rm -rf "${EBZR_BRANCH_DIR}"
219     bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
220 ulm 1.1 else
221 fauli 1.2 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
222 ulm 1.1 fi
223    
224     cd "${EBZR_BRANCH_DIR}"
225    
226     einfo "exporting ..."
227 ulm 1.7
228     if [[ -z ${EBZR_REVISION} ]]; then
229     rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
230 ulm 1.1 || die "${EBZR}: export failed"
231     else
232 ulm 1.7 # revisions of a lightweight checkout are only available when online
233     [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository ]] \
234     || die "${EBZR}: No support for revisions when off-line"
235     ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \
236     || die "${EBZR}: export failed"
237 ulm 1.1 fi
238    
239 fauli 1.2 popd > /dev/null
240 ulm 1.1 }
241    
242     # @FUNCTION: bzr_bootstrap
243     # @DESCRIPTION:
244 fauli 1.2 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
245 ulm 1.1 bzr_bootstrap() {
246     local patch lpatch
247    
248 fauli 1.2 pushd "${S}" > /dev/null
249 ulm 1.1
250     if [[ -n ${EBZR_PATCHES} ]] ; then
251     einfo "apply patches -->"
252    
253     for patch in ${EBZR_PATCHES} ; do
254     if [[ -f ${patch} ]] ; then
255     epatch ${patch}
256     else
257 fauli 1.2 # This loop takes care of wildcarded patches given via
258     # EBZR_PATCHES in an ebuild
259 ulm 1.1 for lpatch in "${FILESDIR}"/${patch} ; do
260     if [[ -f ${lpatch} ]] ; then
261     epatch ${lpatch}
262     else
263     die "${EBZR}: ${patch} is not found"
264     fi
265     done
266     fi
267     done
268     fi
269    
270     if [[ -n ${EBZR_BOOTSTRAP} ]] ; then
271     einfo "begin bootstrap -->"
272    
273     if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
274     einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
275     "./${EBZR_BOOTSTRAP}" \
276     || die "${EBZR}: can't execute EBZR_BOOTSTRAP."
277     else
278     einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
279     "${EBZR_BOOTSTRAP}" \
280     || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
281     fi
282     fi
283 fauli 1.2
284     popd > /dev/null
285 ulm 1.1 }
286    
287     # @FUNCTION: bzr_src_unpack
288     # @DESCRIPTION:
289 fauli 1.2 # Default src_unpack(). Includes bzr_fetch() and bootstrap().
290 ulm 1.1 bzr_src_unpack() {
291 fauli 1.2 if ! [ -z ${EBZR_BRANCH} ]; then
292     # This test will go away on 01 Jul 2010
293     eerror "This ebuild uses EBZR_BRANCH which is not supported anymore"
294     eerror "by the bzr.eclass. Please report this to the ebuild's maintainer."
295     die "EBZR_BRANCH still defined"
296     fi
297 ulm 1.1 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
298 fauli 1.2 case "${EAPI:-0}" in
299     0|1) bzr_src_prepare ;;
300     esac
301     }
302    
303     # @FUNCTION: bzr_src_prepare
304     # @DESCRIPTION:
305     # Default src_prepare(). Executes bzr_bootstrap() for patch
306     # application and Make file generation (if needed).
307     bzr_src_prepare() {
308 ulm 1.1 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
309     }

  ViewVC Help
Powered by ViewVC 1.1.20