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

Contents of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Oct 25 12:17:23 2008 UTC (6 years ago) by ulm
Branch: MAIN
Initial import.

1 ulm 1.1 # Copyright 1999-2008 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4     #
5     # @ECLASS: bzr.eclass
6     # @MAINTAINER:
7     # Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
8     # Ulrich Mueller <ulm@gentoo.org>,
9     # and anyone who wants to help
10     # @BLURB: This eclass provides support to use the Bazaar DSCM
11     # @DESCRIPTION:
12     # The bzr.eclass provides support for apps using the bazaar DSCM
13     # (distributed source control management system).
14     # The eclass was originally derived from the git eclass.
15     #
16     # Note: Just set EBZR_REPO_URI to the url of the branch and the src_unpack
17     # this eclass provides will put an export of the branch in ${WORKDIR}/${PN}.
18    
19     inherit eutils
20    
21     EBZR="bzr.eclass"
22    
23     EXPORT_FUNCTIONS src_unpack
24    
25     HOMEPAGE="http://bazaar-vcs.org/"
26     DESCRIPTION="Based on the ${EBZR} eclass"
27    
28     DEPEND=">=dev-util/bzr-1.5"
29    
30     # @ECLASS-VARIABLE: EBZR_STORE_DIR
31     # @DESCRIPTION:
32     # The dir to store the bzr sources.
33     EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src"
34    
35     # @ECLASS-VARIABLE: EBZR_FETCH_CMD
36     # @DESCRIPTION:
37     # The bzr command to fetch the sources.
38     EBZR_FETCH_CMD="bzr branch"
39    
40     # @ECLASS-VARIABLE: EBZR_UPDATE_CMD
41     # @DESCRIPTION:
42     # The bzr command to update the sources.
43     EBZR_UPDATE_CMD="bzr pull"
44    
45     # @ECLASS-VARIABLE: EBZR_DIFFSTAT_CMD
46     # @DESCRIPTION:
47     # The bzr command to get the diffstat output.
48     EBZR_DIFFSTAT_CMD="bzr diff"
49    
50     # @ECLASS-VARIABLE: EBZR_EXPORT_CMD
51     # @DESCRIPTION:
52     # The bzr command to export a branch.
53     EBZR_EXPORT_CMD="bzr export"
54    
55     # @ECLASS-VARIABLE: EBZR_REVNO_CMD
56     # @DESCRIPTION:
57     # The bzr command to list revision number of the branch.
58     EBZR_REVNO_CMD="bzr revno"
59    
60     # @ECLASS-VARIABLE: EBZR_OPTIONS
61     # @DESCRIPTION:
62     # The options passed to the fetch and update commands.
63     EBZR_OPTIONS="${EBZR_OPTIONS:-}"
64    
65     # @ECLASS-VARIABLE: EBZR_REPO_URI
66     # @DESCRIPTION:
67     # The repository uri for the source package.
68     #
69     # @CODE
70     # Supported protocols:
71     # - http://
72     # - https://
73     # - sftp://
74     # - rsync://
75     # - lp://
76     # @CODE
77     #
78     # Note: lp = https://launchpad.net
79     EBZR_REPO_URI="${EBZR_REPO_URI:-}"
80    
81     # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
82     # @DESCRIPTION:
83     # Bootstrap script or command like autogen.sh or etc.
84     EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}"
85    
86     # @ECLASS-VARIABLE: EBZR_PATCHES
87     # @DESCRIPTION:
88     # bzr eclass can apply patches in bzr_bootstrap().
89     # you can use regexp in this valiable like *.diff or *.patch or etc.
90     # NOTE: this patches will applied before EBZR_BOOTSTRAP is processed.
91     #
92     # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
93     # location, the installation dies.
94     EBZR_PATCHES="${EBZR_PATCHES:-}"
95    
96     # @ECLASS-VARIABLE: EBZR_BRANCH
97     # @DESCRIPTION:
98     # The branch to fetch in bzr_fetch().
99     #
100     # default: trunk
101     EBZR_BRANCH="${EBZR_BRANCH:-trunk}"
102    
103     # @ECLASS-VARIABLE: EBZR_REVISION
104     # @DESCRIPTION:
105     # Revision to get, if not latest (see http://bazaar-vcs.org/BzrRevisionSpec)
106     EBZR_REVISION="${EBZR_REVISION:-}"
107    
108     # @ECLASS-VARIABLE: EBZR_CACHE_DIR
109     # @DESCRIPTION:
110     # The dir to store the source for the package, relative to EBZR_STORE_DIR.
111     #
112     # default: ${PN}
113     EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
114    
115     # @FUNCTION: bzr_fetch
116     # @DESCRIPTION:
117     # Wrapper function to fetch sources from bazaar via bzr fetch or bzr update,
118     # depending on whether there is an existing working copy in ${EBZR_BRANCH_DIR}.
119     bzr_fetch() {
120     local EBZR_BRANCH_DIR
121    
122     # EBZR_REPO_URI is empty.
123     [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty."
124    
125     # check for the protocol or pull from a local repo.
126     if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then
127     case ${EBZR_REPO_URI%%:*} in
128     # lp:// is https://launchpad.net
129     http|https|rsync|sftp|lp)
130     ;;
131     *)
132     die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
133     ;;
134     esac
135     fi
136    
137     if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
138     debug-print "${FUNCNAME}: initial branch. creating bzr directory"
139     addwrite /
140     mkdir -p "${EBZR_STORE_DIR}" \
141     || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
142     export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
143     fi
144    
145     cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
146    
147     EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
148    
149     addwrite "${EBZR_STORE_DIR}"
150     addwrite "${EBZR_BRANCH_DIR}"
151    
152     debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
153    
154     local repository
155    
156     if [[ ${EBZR_REPO_URI} == */* ]]; then
157     repository="${EBZR_REPO_URI}${EBZR_BRANCH}"
158     else
159     repository="${EBZR_REPO_URI}"
160     fi
161    
162     if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
163     # fetch branch
164     einfo "bzr branch start -->"
165     einfo " repository: ${repository} => ${EBZR_BRANCH_DIR}"
166    
167     ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${EBZR_BRANCH_DIR}" \
168     || die "${EBZR}: can't branch from ${repository}."
169    
170     else
171     # update branch
172     einfo "bzr pull start -->"
173     einfo " repository: ${repository}"
174    
175     cd "${EBZR_BRANCH_DIR}"
176     ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repository}" \
177     || die "${EBZR}: can't merge from ${repository}."
178     ${EBZR_DIFFSTAT_CMD}
179     fi
180    
181     cd "${EBZR_BRANCH_DIR}"
182    
183     einfo "exporting ..."
184     ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} "${WORKDIR}/${P}" \
185     || die "${EBZR}: export failed"
186    
187     local revision
188     if [[ -n "${EBZR_REVISION}" ]]; then
189     revision="${EBZR_REVISION}"
190     else
191     revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}")
192     fi
193    
194     einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
195    
196     cd "${WORKDIR}"
197     }
198    
199     # @FUNCTION: bzr_bootstrap
200     # @DESCRIPTION:
201     # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified
202     bzr_bootstrap() {
203     local patch lpatch
204    
205     cd "${S}"
206    
207     if [[ -n ${EBZR_PATCHES} ]] ; then
208     einfo "apply patches -->"
209    
210     for patch in ${EBZR_PATCHES} ; do
211     if [[ -f ${patch} ]] ; then
212     epatch ${patch}
213     else
214     for lpatch in "${FILESDIR}"/${patch} ; do
215     if [[ -f ${lpatch} ]] ; then
216     epatch ${lpatch}
217     else
218     die "${EBZR}: ${patch} is not found"
219     fi
220     done
221     fi
222     done
223     fi
224    
225     if [[ -n ${EBZR_BOOTSTRAP} ]] ; then
226     einfo "begin bootstrap -->"
227    
228     if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then
229     einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}"
230     "./${EBZR_BOOTSTRAP}" \
231     || die "${EBZR}: can't execute EBZR_BOOTSTRAP."
232     else
233     einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
234     "${EBZR_BOOTSTRAP}" \
235     || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
236     fi
237     fi
238     }
239    
240     # @FUNCTION: bzr_src_unpack
241     # @DESCRIPTION:
242     # default src_unpack. fetch and bootstrap.
243     bzr_src_unpack() {
244     bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
245     bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
246     }

  ViewVC Help
Powered by ViewVC 1.1.20