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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Thu Jul 1 09:23:37 2010 UTC (3 years, 9 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 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.9 # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.8 2010/03/05 09:35:23 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 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.1 else
216 fauli 1.2 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
217 ulm 1.1 fi
218    
219     cd "${EBZR_BRANCH_DIR}"
220    
221     einfo "exporting ..."
222 ulm 1.7
223     if [[ -z ${EBZR_REVISION} ]]; then
224     rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \
225 ulm 1.1 || die "${EBZR}: export failed"
226     else
227 ulm 1.7 # 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 ulm 1.1 fi
233    
234 fauli 1.2 popd > /dev/null
235 ulm 1.1 }
236    
237     # @FUNCTION: bzr_bootstrap
238     # @DESCRIPTION:
239 fauli 1.2 # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
240 ulm 1.1 bzr_bootstrap() {
241     local patch lpatch
242    
243 fauli 1.2 pushd "${S}" > /dev/null
244 ulm 1.1
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 fauli 1.2 # This loop takes care of wildcarded patches given via
253     # EBZR_PATCHES in an ebuild
254 ulm 1.1 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 fauli 1.2
279     popd > /dev/null
280 ulm 1.1 }
281    
282     # @FUNCTION: bzr_src_unpack
283     # @DESCRIPTION:
284 fauli 1.2 # Default src_unpack(). Includes bzr_fetch() and bootstrap().
285 ulm 1.1 bzr_src_unpack() {
286 fauli 1.2 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 ulm 1.1 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
293 fauli 1.2 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 ulm 1.1 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
304     }

  ViewVC Help
Powered by ViewVC 1.1.20