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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Tue Aug 4 20:18:23 2009 UTC (5 years ago) by fauli
Branch: MAIN
Changes since 1.2: +3 -2 lines
bzr.eclass: Added patch from Justin Lecher (jlec) <jlec AT j-schmitz DOT net> provided in bug 279770 for a custom setting of EBZR_STORE_DIR

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

  ViewVC Help
Powered by ViewVC 1.1.20