| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.9 2010/07/01 09:23:37 fauli Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.19 2012/09/18 06:41:45 ulm Exp $ |
| 4 | # |
4 | # |
| 5 | # @ECLASS: bzr.eclass |
5 | # @ECLASS: bzr.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
|
|
7 | # Emacs team <emacs@gentoo.org> |
|
|
8 | # Bazaar team <bazaar@gentoo.org> |
|
|
9 | # @AUTHOR: |
| 7 | # Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>, |
10 | # 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 | # Mark Lee <bzr-gentoo-overlay@lazymalevolence.com> |
| 11 | # and anyone who wants to help |
12 | # Ulrich Müller <ulm@gentoo.org> |
| 12 | # @BLURB: This eclass provides support to use the Bazaar VCS |
13 | # Christian Faulhammer <fauli@gentoo.org> |
|
|
14 | # @BLURB: generic fetching functions for the Bazaar VCS |
| 13 | # @DESCRIPTION: |
15 | # @DESCRIPTION: |
| 14 | # The bzr.eclass provides support for apps using the Bazaar VCS |
16 | # The bzr.eclass provides functions to fetch, unpack, patch, and |
| 15 | # (distributed version control system). |
17 | # bootstrap sources from repositories of the Bazaar distributed version |
| 16 | # The eclass was originally derived from the git eclass. |
18 | # control system. The eclass was originally derived from git.eclass. |
| 17 | # |
19 | # |
| 18 | # Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack() |
20 | # Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack() |
| 19 | # of this eclass will put an export of the branch in ${WORKDIR}/${PN}. |
21 | # of this eclass will export the branch to ${WORKDIR}/${P}. |
| 20 | |
22 | |
| 21 | inherit eutils |
23 | inherit eutils |
| 22 | |
24 | |
| 23 | EBZR="bzr.eclass" |
25 | EBZR="bzr.eclass" |
| 24 | |
26 | |
| 25 | case "${EAPI:-0}" in |
27 | case "${EAPI:-0}" in |
| 26 | 0|1) EXPORT_FUNCTIONS src_unpack ;; |
28 | 0|1) EXPORT_FUNCTIONS src_unpack ;; |
| 27 | *) EXPORT_FUNCTIONS src_unpack src_prepare ;; |
29 | *) EXPORT_FUNCTIONS src_unpack src_prepare ;; |
| 28 | esac |
30 | esac |
| 29 | |
31 | |
| 30 | HOMEPAGE="http://bazaar-vcs.org/" |
|
|
| 31 | DESCRIPTION="Based on the ${EBZR} eclass" |
|
|
| 32 | |
|
|
| 33 | DEPEND=">=dev-vcs/bzr-1.5" |
32 | DEPEND=">=dev-vcs/bzr-2.0.1" |
|
|
33 | case "${EAPI:-0}" in |
|
|
34 | 0|1) ;; |
|
|
35 | *) [[ ${EBZR_REPO_URI%%:*} = sftp ]] \ |
|
|
36 | && DEPEND=">=dev-vcs/bzr-2.0.1[sftp]" ;; |
|
|
37 | esac |
| 34 | |
38 | |
| 35 | # @ECLASS-VARIABLE: EBZR_STORE_DIR |
39 | # @ECLASS-VARIABLE: EBZR_STORE_DIR |
| 36 | # @DESCRIPTION: |
40 | # @DESCRIPTION: |
| 37 | # The directory to store all fetched Bazaar live sources. |
41 | # The directory to store all fetched Bazaar live sources. |
| 38 | : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src} |
42 | : ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src} |
|
|
43 | |
|
|
44 | # @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD |
|
|
45 | # @DESCRIPTION: |
|
|
46 | # The Bazaar command to initialise a shared repository. |
|
|
47 | : ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"} |
| 39 | |
48 | |
| 40 | # @ECLASS-VARIABLE: EBZR_FETCH_CMD |
49 | # @ECLASS-VARIABLE: EBZR_FETCH_CMD |
| 41 | # @DESCRIPTION: |
50 | # @DESCRIPTION: |
| 42 | # The Bazaar command to fetch the sources. |
51 | # The Bazaar command to fetch the sources. |
| 43 | EBZR_FETCH_CMD="bzr checkout --lightweight" |
52 | : ${EBZR_FETCH_CMD:="bzr branch --no-tree"} |
| 44 | |
53 | |
| 45 | # @ECLASS-VARIABLE: EBZR_UPDATE_CMD |
54 | # @ECLASS-VARIABLE: EBZR_UPDATE_CMD |
| 46 | # @DESCRIPTION: |
55 | # @DESCRIPTION: |
| 47 | # The Bazaar command to update the sources. |
56 | # The Bazaar command to update the sources. |
| 48 | EBZR_UPDATE_CMD="bzr update" |
57 | : ${EBZR_UPDATE_CMD:="bzr pull"} |
| 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 | |
58 | |
| 55 | # @ECLASS-VARIABLE: EBZR_EXPORT_CMD |
59 | # @ECLASS-VARIABLE: EBZR_EXPORT_CMD |
| 56 | # @DESCRIPTION: |
60 | # @DESCRIPTION: |
| 57 | # The Bazaar command to export a branch. |
61 | # The Bazaar command to export a branch. |
| 58 | EBZR_EXPORT_CMD="bzr export" |
62 | : ${EBZR_EXPORT_CMD:="bzr export"} |
|
|
63 | |
|
|
64 | # @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD |
|
|
65 | # @DESCRIPTION: |
|
|
66 | # The Bazaar command to checkout a branch. |
|
|
67 | : ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"} |
| 59 | |
68 | |
| 60 | # @ECLASS-VARIABLE: EBZR_REVNO_CMD |
69 | # @ECLASS-VARIABLE: EBZR_REVNO_CMD |
| 61 | # @DESCRIPTION: |
70 | # @DESCRIPTION: |
| 62 | # The Bazaar command to list a revision number of the branch. |
71 | # The Bazaar command to list a revision number of the branch. |
| 63 | EBZR_REVNO_CMD="bzr revno" |
72 | : ${EBZR_REVNO_CMD:="bzr revno"} |
| 64 | |
73 | |
| 65 | # @ECLASS-VARIABLE: EBZR_OPTIONS |
74 | # @ECLASS-VARIABLE: EBZR_OPTIONS |
|
|
75 | # @DEFAULT_UNSET |
| 66 | # @DESCRIPTION: |
76 | # @DESCRIPTION: |
| 67 | # The options passed to the fetch and update commands. |
77 | # The options passed to the fetch and update commands. |
| 68 | EBZR_OPTIONS="${EBZR_OPTIONS:-}" |
|
|
| 69 | |
78 | |
| 70 | # @ECLASS-VARIABLE: EBZR_REPO_URI |
79 | # @ECLASS-VARIABLE: EBZR_REPO_URI |
|
|
80 | # @DEFAULT_UNSET |
|
|
81 | # @REQUIRED |
| 71 | # @DESCRIPTION: |
82 | # @DESCRIPTION: |
| 72 | # The repository URI for the source package. |
83 | # The repository URI for the source package. |
| 73 | # |
84 | # |
| 74 | # @CODE |
85 | # Note: If the ebuild uses an sftp:// URI, then in EAPI 0 or 1 it must |
| 75 | # Supported protocols: |
86 | # make sure that dev-vcs/bzr was built with USE="sftp". In EAPI 2 or |
| 76 | # - http:// |
87 | # later, the eclass will depend on dev-vcs/bzr[sftp]. |
| 77 | # - https:// |
88 | |
| 78 | # - sftp:// |
89 | # @ECLASS-VARIABLE: EBZR_INITIAL_URI |
| 79 | # - rsync:// |
90 | # @DEFAULT_UNSET |
| 80 | # - lp: |
91 | # @DESCRIPTION: |
| 81 | # @CODE |
92 | # The URI used for initial branching of the source repository. If this |
|
|
93 | # variable is set, the initial branch will be cloned from the location |
|
|
94 | # specified, followed by a pull from ${EBZR_REPO_URI}. This is intended |
|
|
95 | # for special cases, e.g. when download from the original repository is |
|
|
96 | # slow, but a fast mirror exists but may be out of date. |
| 82 | # |
97 | # |
| 83 | # Note: lp: seems to be an alias for https://launchpad.net |
98 | # Normally, this variable needs not be set. |
| 84 | EBZR_REPO_URI="${EBZR_REPO_URI:-}" |
|
|
| 85 | |
99 | |
| 86 | # @ECLASS-VARIABLE: EBZR_BOOTSTRAP |
100 | # @ECLASS-VARIABLE: EBZR_BOOTSTRAP |
|
|
101 | # @DEFAULT_UNSET |
| 87 | # @DESCRIPTION: |
102 | # @DESCRIPTION: |
| 88 | # Bootstrap script or command like autogen.sh or etc. |
103 | # Bootstrap script or command like autogen.sh or etc. |
| 89 | EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}" |
|
|
| 90 | |
104 | |
| 91 | # @ECLASS-VARIABLE: EBZR_PATCHES |
105 | # @ECLASS-VARIABLE: EBZR_PATCHES |
|
|
106 | # @DEFAULT_UNSET |
| 92 | # @DESCRIPTION: |
107 | # @DESCRIPTION: |
| 93 | # bzr eclass can apply patches in bzr_bootstrap(). |
108 | # bzr.eclass can apply patches in bzr_bootstrap(). You can use regular |
| 94 | # You can use regular expressions in this variable like *.diff or |
109 | # expressions in this variable like *.diff or *.patch and the like. |
| 95 | # *.patch and the like. |
|
|
| 96 | # NOTE: These patches will bei applied before EBZR_BOOTSTRAP is processed. |
110 | # Note: These patches will be applied before EBZR_BOOTSTRAP is processed. |
| 97 | # |
111 | # |
| 98 | # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either |
112 | # Patches are searched both in ${PWD} and ${FILESDIR}. If not found in |
| 99 | # location, the installation dies. |
113 | # either location, the installation dies. |
| 100 | EBZR_PATCHES="${EBZR_PATCHES:-}" |
114 | |
|
|
115 | # @ECLASS-VARIABLE: EBZR_PROJECT |
|
|
116 | # @DESCRIPTION: |
|
|
117 | # The project name of your ebuild. Normally, the branch will be stored |
|
|
118 | # in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory. |
|
|
119 | # |
|
|
120 | # If EBZR_BRANCH is set (see below), then a shared repository will be |
|
|
121 | # created in that directory, and the branch will be located in |
|
|
122 | # ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}. |
|
|
123 | : ${EBZR_PROJECT:=${PN}} |
|
|
124 | |
|
|
125 | # @ECLASS-VARIABLE: EBZR_BRANCH |
|
|
126 | # @DEFAULT_UNSET |
|
|
127 | # @DESCRIPTION: |
|
|
128 | # The directory where to store the branch within a shared repository, |
|
|
129 | # relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}. |
|
|
130 | # |
|
|
131 | # This variable should be set if there are several live ebuilds for |
|
|
132 | # different branches of the same upstream project. The branches can |
|
|
133 | # then share the same repository in EBZR_PROJECT, which will save both |
|
|
134 | # data traffic volume and disk space. |
|
|
135 | # |
|
|
136 | # If there is only a live ebuild for one single branch, EBZR_BRANCH |
|
|
137 | # needs not be set. In this case, the branch will be stored in a |
|
|
138 | # stand-alone repository directly in EBZR_PROJECT. |
| 101 | |
139 | |
| 102 | # @ECLASS-VARIABLE: EBZR_REVISION |
140 | # @ECLASS-VARIABLE: EBZR_REVISION |
|
|
141 | # @DEFAULT_UNSET |
| 103 | # @DESCRIPTION: |
142 | # @DESCRIPTION: |
| 104 | # Revision to fetch, defaults to the latest |
143 | # Revision to fetch, defaults to the latest |
| 105 | # (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec). |
144 | # (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 | |
145 | |
| 118 | # @ECLASS-VARIABLE: EBZR_OFFLINE |
146 | # @ECLASS-VARIABLE: EBZR_OFFLINE |
| 119 | # @DESCRIPTION: |
147 | # @DESCRIPTION: |
| 120 | # Set this variable to a non-empty value to disable the automatic updating of |
148 | # Set this variable to a non-empty value to disable automatic updating |
| 121 | # a bzr source tree. This is intended to be set outside the ebuild by users. |
149 | # of a bzr source tree. This is intended to be set outside the ebuild |
| 122 | EBZR_OFFLINE="${EBZR_OFFLINE:-${ESCM_OFFLINE}}" |
150 | # by users. |
|
|
151 | : ${EBZR_OFFLINE=${EVCS_OFFLINE}} |
|
|
152 | |
|
|
153 | # @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT |
|
|
154 | # @DEFAULT_UNSET |
|
|
155 | # @DESCRIPTION: |
|
|
156 | # If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will |
|
|
157 | # be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR. |
| 123 | |
158 | |
| 124 | # @FUNCTION: bzr_initial_fetch |
159 | # @FUNCTION: bzr_initial_fetch |
|
|
160 | # @USAGE: <repository URI> <branch directory> |
| 125 | # @DESCRIPTION: |
161 | # @DESCRIPTION: |
| 126 | # Retrieves the source code from a repository for the first time, via |
162 | # Internal function, retrieves the source code from a repository for the |
| 127 | # ${EBZR_FETCH_CMD}. |
163 | # first time, using ${EBZR_FETCH_CMD}. |
| 128 | bzr_initial_fetch() { |
164 | bzr_initial_fetch() { |
| 129 | local repository="${1}"; |
165 | local repo_uri=$1 branch_dir=$2 |
| 130 | local branch_dir="${2}"; |
166 | |
|
|
167 | if [[ -n "${EBZR_OFFLINE}" ]]; then |
|
|
168 | ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet." |
|
|
169 | fi |
| 131 | |
170 | |
| 132 | # fetch branch |
171 | # fetch branch |
| 133 | einfo "bzr fetch start -->" |
172 | einfo "bzr branch start -->" |
| 134 | einfo " repository: ${repository} => ${branch_dir}" |
173 | einfo " repository: ${repo_uri} => ${branch_dir}" |
| 135 | |
174 | |
| 136 | ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \ |
175 | ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \ |
| 137 | || die "${EBZR}: can't branch from ${repository}." |
176 | || die "${EBZR}: can't branch from ${repo_uri}" |
| 138 | } |
177 | } |
| 139 | |
178 | |
| 140 | # @FUNCTION: bzr_update |
179 | # @FUNCTION: bzr_update |
|
|
180 | # @USAGE: <repository URI> <branch directory> |
| 141 | # @DESCRIPTION: |
181 | # @DESCRIPTION: |
| 142 | # Updates the source code from a repository, via ${EBZR_UPDATE_CMD}. |
182 | # Internal function, updates the source code from a repository, using |
|
|
183 | # ${EBZR_UPDATE_CMD}. |
| 143 | bzr_update() { |
184 | bzr_update() { |
| 144 | local repository="${1}"; |
185 | local repo_uri=$1 branch_dir=$2 |
| 145 | |
186 | |
| 146 | if [[ -n "${EBZR_OFFLINE}" ]]; then |
187 | if [[ -n "${EBZR_OFFLINE}" ]]; then |
| 147 | einfo "skipping bzr update -->" |
188 | einfo "skipping bzr pull -->" |
| 148 | einfo " repository: ${repository}" |
189 | einfo " repository: ${repo_uri}" |
| 149 | else |
190 | else |
| 150 | # update branch |
191 | # update branch |
| 151 | einfo "bzr update start -->" |
192 | einfo "bzr pull start -->" |
| 152 | einfo " repository: ${repository}" |
193 | einfo " repository: ${repo_uri}" |
| 153 | |
194 | |
| 154 | pushd "${EBZR_BRANCH_DIR}" > /dev/null |
195 | pushd "${branch_dir}" > /dev/null \ |
|
|
196 | || die "${EBZR}: can't chdir to ${branch_dir}" |
| 155 | ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \ |
197 | ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \ |
| 156 | || die "${EBZR}: can't update from ${repository}." |
198 | || die "${EBZR}: can't pull from ${repo_uri}" |
| 157 | popd > /dev/null |
199 | popd > /dev/null |
| 158 | fi |
200 | fi |
| 159 | } |
201 | } |
| 160 | |
202 | |
| 161 | # @FUNCTION: bzr_fetch |
203 | # @FUNCTION: bzr_fetch |
| 162 | # @DESCRIPTION: |
204 | # @DESCRIPTION: |
| 163 | # Wrapper function to fetch sources from a Bazaar repository via bzr |
205 | # Wrapper function to fetch sources from a Bazaar repository with |
| 164 | # fetch or bzr update, depending on whether there is an existing |
206 | # bzr branch or bzr pull, depending on whether there is an existing |
| 165 | # working copy in ${EBZR_BRANCH_DIR}. |
207 | # working copy. |
| 166 | bzr_fetch() { |
208 | bzr_fetch() { |
| 167 | local EBZR_BRANCH_DIR |
209 | local repo_dir branch_dir |
|
|
210 | local save_sandbox_write=${SANDBOX_WRITE} |
| 168 | |
211 | |
| 169 | # EBZR_REPO_URI is empty. |
|
|
| 170 | [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty." |
212 | [[ -n ${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 | |
213 | |
| 191 | if [[ ! -d ${EBZR_STORE_DIR} ]] ; then |
214 | if [[ ! -d ${EBZR_STORE_DIR} ]] ; then |
| 192 | debug-print "${FUNCNAME}: initial branch. Creating bzr directory" |
|
|
| 193 | local save_sandbox_write=${SANDBOX_WRITE} |
|
|
| 194 | addwrite / |
215 | addwrite / |
| 195 | mkdir -p "${EBZR_STORE_DIR}" \ |
216 | mkdir -p "${EBZR_STORE_DIR}" \ |
| 196 | || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}." |
217 | || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}" |
| 197 | SANDBOX_WRITE=${save_sandbox_write} |
218 | SANDBOX_WRITE=${save_sandbox_write} |
| 198 | fi |
219 | fi |
| 199 | |
220 | |
| 200 | pushd "${EBZR_STORE_DIR}" > /dev/null \ |
221 | pushd "${EBZR_STORE_DIR}" > /dev/null \ |
| 201 | || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" |
222 | || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" |
| 202 | |
223 | |
| 203 | EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" |
224 | repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT} |
|
|
225 | branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}} |
| 204 | |
226 | |
| 205 | addwrite "${EBZR_STORE_DIR}" |
227 | addwrite "${EBZR_STORE_DIR}" |
| 206 | addwrite "${EBZR_BRANCH_DIR}" |
|
|
| 207 | |
228 | |
| 208 | debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}" |
229 | if [[ ! -d ${branch_dir}/.bzr ]]; then |
|
|
230 | if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then |
|
|
231 | einfo "creating shared bzr repository: ${repo_dir}" |
|
|
232 | ${EBZR_INIT_REPO_CMD} "${repo_dir}" \ |
|
|
233 | || die "${EBZR}: can't create shared repository" |
|
|
234 | fi |
| 209 | |
235 | |
| 210 | # Run bzr_initial_fetch() only if the branch has not been pulled |
236 | if [[ -z ${EBZR_INITIAL_URI} ]]; then |
| 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}" |
237 | bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}" |
|
|
238 | else |
|
|
239 | # Workaround for faster initial download. This clones the |
|
|
240 | # branch from a fast server (which may be out of date), and |
|
|
241 | # subsequently pulls from the slow original repository. |
|
|
242 | bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}" |
|
|
243 | if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then |
|
|
244 | EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \ |
|
|
245 | EBZR_OFFLINE="" \ |
|
|
246 | bzr_update "${EBZR_REPO_URI}" "${branch_dir}" |
|
|
247 | fi |
|
|
248 | fi |
| 215 | else |
249 | else |
| 216 | bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}" |
250 | bzr_update "${EBZR_REPO_URI}" "${branch_dir}" |
| 217 | fi |
251 | fi |
| 218 | |
252 | |
| 219 | cd "${EBZR_BRANCH_DIR}" |
253 | # Restore sandbox environment |
|
|
254 | SANDBOX_WRITE=${save_sandbox_write} |
| 220 | |
255 | |
| 221 | einfo "exporting ..." |
256 | cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}" |
| 222 | |
257 | |
| 223 | if [[ -z ${EBZR_REVISION} ]]; then |
258 | # Save revision number in environment. #311101 |
| 224 | rsync -rlpgo --exclude=".bzr/" . "${WORKDIR}/${P}" \ |
259 | export EBZR_REVNO=$(${EBZR_REVNO_CMD}) |
| 225 | || die "${EBZR}: export failed" |
260 | |
|
|
261 | if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then |
|
|
262 | einfo "checking out ..." |
|
|
263 | ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ |
|
|
264 | . "${WORKDIR}/${P}" || die "${EBZR}: checkout failed" |
| 226 | else |
265 | else |
| 227 | # revisions of a lightweight checkout are only available when online |
266 | einfo "exporting ..." |
| 228 | [[ -z ${EBZR_OFFLINE} || -d ${EBZR_BRANCH_DIR}/.bzr/repository ]] \ |
267 | ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ |
| 229 | || die "${EBZR}: No support for revisions when off-line" |
|
|
| 230 | ${EBZR_EXPORT_CMD} -r "${EBZR_REVISION}" "${WORKDIR}/${P}" \ |
|
|
| 231 | || die "${EBZR}: export failed" |
268 | "${WORKDIR}/${P}" . || die "${EBZR}: export failed" |
| 232 | fi |
269 | fi |
|
|
270 | einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}" |
| 233 | |
271 | |
| 234 | popd > /dev/null |
272 | popd > /dev/null |
| 235 | } |
273 | } |
| 236 | |
274 | |
| 237 | # @FUNCTION: bzr_bootstrap |
275 | # @FUNCTION: bzr_bootstrap |
| 238 | # @DESCRIPTION: |
276 | # @DESCRIPTION: |
| 239 | # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified. |
277 | # Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified. |
| 240 | bzr_bootstrap() { |
278 | bzr_bootstrap() { |
| 241 | local patch lpatch |
279 | local patch lpatch |
| 242 | |
280 | |
| 243 | pushd "${S}" > /dev/null |
281 | pushd "${S}" > /dev/null || die "${EBZR}: can't chdir to ${S}" |
| 244 | |
282 | |
| 245 | if [[ -n ${EBZR_PATCHES} ]] ; then |
283 | if [[ -n ${EBZR_PATCHES} ]] ; then |
| 246 | einfo "apply patches -->" |
284 | einfo "apply patches -->" |
| 247 | |
285 | |
| 248 | for patch in ${EBZR_PATCHES} ; do |
286 | for patch in ${EBZR_PATCHES} ; do |
| … | |
… | |
| 266 | einfo "begin bootstrap -->" |
304 | einfo "begin bootstrap -->" |
| 267 | |
305 | |
| 268 | if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then |
306 | if [[ -f ${EBZR_BOOTSTRAP} ]] && [[ -x ${EBZR_BOOTSTRAP} ]] ; then |
| 269 | einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}" |
307 | einfo " bootstrap with a file: ${EBZR_BOOTSTRAP}" |
| 270 | "./${EBZR_BOOTSTRAP}" \ |
308 | "./${EBZR_BOOTSTRAP}" \ |
| 271 | || die "${EBZR}: can't execute EBZR_BOOTSTRAP." |
309 | || die "${EBZR}: can't execute EBZR_BOOTSTRAP" |
| 272 | else |
310 | else |
| 273 | einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}" |
311 | einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}" |
| 274 | "${EBZR_BOOTSTRAP}" \ |
312 | "${EBZR_BOOTSTRAP}" \ |
| 275 | || die "${EBZR}: can't eval EBZR_BOOTSTRAP." |
313 | || die "${EBZR}: can't eval EBZR_BOOTSTRAP" |
| 276 | fi |
314 | fi |
| 277 | fi |
315 | fi |
| 278 | |
316 | |
| 279 | popd > /dev/null |
317 | popd > /dev/null |
| 280 | } |
318 | } |
| 281 | |
319 | |
| 282 | # @FUNCTION: bzr_src_unpack |
320 | # @FUNCTION: bzr_src_unpack |
| 283 | # @DESCRIPTION: |
321 | # @DESCRIPTION: |
| 284 | # Default src_unpack(). Includes bzr_fetch() and bootstrap(). |
322 | # Default src_unpack(), calls bzr_fetch. For EAPIs 0 and 1, also calls |
|
|
323 | # bzr_src_prepare. |
| 285 | bzr_src_unpack() { |
324 | bzr_src_unpack() { |
| 286 | if ! [ -z ${EBZR_BRANCH} ]; then |
325 | bzr_fetch |
| 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 |
326 | case "${EAPI:-0}" in |
| 294 | 0|1) bzr_src_prepare ;; |
327 | 0|1) bzr_src_prepare ;; |
| 295 | esac |
328 | esac |
| 296 | } |
329 | } |
| 297 | |
330 | |
| 298 | # @FUNCTION: bzr_src_prepare |
331 | # @FUNCTION: bzr_src_prepare |
| 299 | # @DESCRIPTION: |
332 | # @DESCRIPTION: |
| 300 | # Default src_prepare(). Executes bzr_bootstrap() for patch |
333 | # Default src_prepare(), calls bzr_bootstrap. |
| 301 | # application and Make file generation (if needed). |
|
|
| 302 | bzr_src_prepare() { |
334 | bzr_src_prepare() { |
| 303 | bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()." |
335 | bzr_bootstrap |
| 304 | } |
336 | } |