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

Diff of /eclass/bzr.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.2
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2009 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.1 2008/10/25 12:17:23 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.2 2009/07/08 09:47:38 fauli Exp $
4# 4#
5# @ECLASS: bzr.eclass 5# @ECLASS: bzr.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>, 7# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>,
8# Ulrich Mueller <ulm@gentoo.org>, 8# Ulrich Mueller <ulm@gentoo.org>,
9# Christian Faulhammer <fauli@gentoo.org>
10# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>,
9# and anyone who wants to help 11# and anyone who wants to help
10# @BLURB: This eclass provides support to use the Bazaar DSCM 12# @BLURB: This eclass provides support to use the Bazaar DSCM
11# @DESCRIPTION: 13# @DESCRIPTION:
12# The bzr.eclass provides support for apps using the bazaar DSCM 14# The bzr.eclass provides support for apps using the bazaar DSCM
13# (distributed source control management system). 15# (distributed source control management system).
14# The eclass was originally derived from the git eclass. 16# The eclass was originally derived from the git eclass.
15# 17#
16# Note: Just set EBZR_REPO_URI to the url of the branch and the src_unpack 18# Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack()
17# this eclass provides will put an export of the branch in ${WORKDIR}/${PN}. 19# of this eclass will put an export of the branch in ${WORKDIR}/${PN}.
18 20
19inherit eutils 21inherit eutils
20 22
21EBZR="bzr.eclass" 23EBZR="bzr.eclass"
22 24
25case "${EAPI:-0}" in
23EXPORT_FUNCTIONS src_unpack 26 0|1) EXPORT_FUNCTIONS src_unpack ;;
27 *) EXPORT_FUNCTIONS src_unpack src_prepare ;;
28esac
24 29
25HOMEPAGE="http://bazaar-vcs.org/" 30HOMEPAGE="http://bazaar-vcs.org/"
26DESCRIPTION="Based on the ${EBZR} eclass" 31DESCRIPTION="Based on the ${EBZR} eclass"
27 32
28DEPEND=">=dev-util/bzr-1.5" 33DEPEND=">=dev-util/bzr-1.5"
29 34
30# @ECLASS-VARIABLE: EBZR_STORE_DIR 35# @ECLASS-VARIABLE: EBZR_STORE_DIR
31# @DESCRIPTION: 36# @DESCRIPTION:
32# The dir to store the bzr sources. 37# The directory to store all fetched Bazaar live sources.
33EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src" 38EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src"
34 39
35# @ECLASS-VARIABLE: EBZR_FETCH_CMD 40# @ECLASS-VARIABLE: EBZR_FETCH_CMD
36# @DESCRIPTION: 41# @DESCRIPTION:
37# The bzr command to fetch the sources. 42# The Bazaar command to fetch the sources.
38EBZR_FETCH_CMD="bzr branch" 43EBZR_FETCH_CMD="bzr checkout --lightweight"
39 44
40# @ECLASS-VARIABLE: EBZR_UPDATE_CMD 45# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
41# @DESCRIPTION: 46# @DESCRIPTION:
42# The bzr command to update the sources. 47# The Bazaar command to update the sources.
43EBZR_UPDATE_CMD="bzr pull" 48EBZR_UPDATE_CMD="bzr update"
44 49
45# @ECLASS-VARIABLE: EBZR_DIFFSTAT_CMD 50# @ECLASS-VARIABLE: EBZR_DIFF_CMD
46# @DESCRIPTION: 51# @DESCRIPTION:
47# The bzr command to get the diffstat output. 52# The Bazaar command to get the diff output.
48EBZR_DIFFSTAT_CMD="bzr diff" 53EBZR_DIFF_CMD="bzr diff"
49 54
50# @ECLASS-VARIABLE: EBZR_EXPORT_CMD 55# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
51# @DESCRIPTION: 56# @DESCRIPTION:
52# The bzr command to export a branch. 57# The Bazaar command to export a branch.
53EBZR_EXPORT_CMD="bzr export" 58EBZR_EXPORT_CMD="bzr export"
54 59
55# @ECLASS-VARIABLE: EBZR_REVNO_CMD 60# @ECLASS-VARIABLE: EBZR_REVNO_CMD
56# @DESCRIPTION: 61# @DESCRIPTION:
57# The bzr command to list revision number of the branch. 62# The Bazaar command to list a revision number of the branch.
58EBZR_REVNO_CMD="bzr revno" 63EBZR_REVNO_CMD="bzr revno"
59 64
60# @ECLASS-VARIABLE: EBZR_OPTIONS 65# @ECLASS-VARIABLE: EBZR_OPTIONS
61# @DESCRIPTION: 66# @DESCRIPTION:
62# The options passed to the fetch and update commands. 67# The options passed to the fetch and update commands.
63EBZR_OPTIONS="${EBZR_OPTIONS:-}" 68EBZR_OPTIONS="${EBZR_OPTIONS:-}"
64 69
65# @ECLASS-VARIABLE: EBZR_REPO_URI 70# @ECLASS-VARIABLE: EBZR_REPO_URI
66# @DESCRIPTION: 71# @DESCRIPTION:
67# The repository uri for the source package. 72# The repository URI for the source package.
68# 73#
69# @CODE 74# @CODE
70# Supported protocols: 75# Supported protocols:
71# - http:// 76# - http://
72# - https:// 77# - https://
73# - sftp:// 78# - sftp://
74# - rsync:// 79# - rsync://
75# - lp:// 80# - lp:
76# @CODE 81# @CODE
77# 82#
78# Note: lp = https://launchpad.net 83# Note: lp: seems to be an alias for https://launchpad.net
79EBZR_REPO_URI="${EBZR_REPO_URI:-}" 84EBZR_REPO_URI="${EBZR_REPO_URI:-}"
80 85
81# @ECLASS-VARIABLE: EBZR_BOOTSTRAP 86# @ECLASS-VARIABLE: EBZR_BOOTSTRAP
82# @DESCRIPTION: 87# @DESCRIPTION:
83# Bootstrap script or command like autogen.sh or etc. 88# Bootstrap script or command like autogen.sh or etc.
84EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}" 89EBZR_BOOTSTRAP="${EBZR_BOOTSTRAP:-}"
85 90
86# @ECLASS-VARIABLE: EBZR_PATCHES 91# @ECLASS-VARIABLE: EBZR_PATCHES
87# @DESCRIPTION: 92# @DESCRIPTION:
88# bzr eclass can apply patches in bzr_bootstrap(). 93# bzr eclass can apply patches in bzr_bootstrap().
89# you can use regexp in this valiable like *.diff or *.patch or etc. 94# You can use regular expressions in this variable like *.diff or
95# *.patch and the like.
90# NOTE: this patches will applied before EBZR_BOOTSTRAP is processed. 96# NOTE: These patches will bei applied before EBZR_BOOTSTRAP is processed.
91# 97#
92# Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either 98# Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
93# location, the installation dies. 99# location, the installation dies.
94EBZR_PATCHES="${EBZR_PATCHES:-}" 100EBZR_PATCHES="${EBZR_PATCHES:-}"
95 101
96# @ECLASS-VARIABLE: EBZR_BRANCH
97# @DESCRIPTION:
98# The branch to fetch in bzr_fetch().
99#
100# default: trunk
101EBZR_BRANCH="${EBZR_BRANCH:-trunk}"
102
103# @ECLASS-VARIABLE: EBZR_REVISION 102# @ECLASS-VARIABLE: EBZR_REVISION
104# @DESCRIPTION: 103# @DESCRIPTION:
105# Revision to get, if not latest (see http://bazaar-vcs.org/BzrRevisionSpec) 104# Revision to fetch, defaults to the latest (see
105# http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec)
106EBZR_REVISION="${EBZR_REVISION:-}" 106EBZR_REVISION="${EBZR_REVISION:-}"
107 107
108# @ECLASS-VARIABLE: EBZR_CACHE_DIR 108# @ECLASS-VARIABLE: EBZR_CACHE_DIR
109# @DESCRIPTION: 109# @DESCRIPTION:
110# The dir to store the source for the package, relative to EBZR_STORE_DIR. 110# The directory to store the source for the package, relative to
111# EBZR_STORE_DIR.
111# 112#
112# default: ${PN} 113# default: ${PN}
113EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}" 114EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
114 115
116# @FUNCTION: bzr_initial_fetch
117# @DESCRIPTION:
118# Retrieves the source code from a repository for the first time, via
119# ${EBZR_FETCH_CMD}.
120bzr_initial_fetch() {
121 local repository="${1}";
122 local branch_dir="${2}";
123
124 # fetch branch
125 einfo "bzr fetch start -->"
126 einfo " repository: ${repository} => ${branch_dir}"
127
128 ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \
129 || die "${EBZR}: can't branch from ${repository}."
130}
131
132# @FUNCTION: bzr_update
133# @DESCRIPTION:
134# Updates the source code from a repository, via ${EBZR_UPDATE_CMD}.
135bzr_update() {
136 local repository="${1}";
137
138 # update branch
139 einfo "bzr update start -->"
140 einfo " repository: ${repository}"
141
142 pushd "${EBZR_BRANCH_DIR}" > /dev/null
143 ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \
144 || die "${EBZR}: can't update from ${repository}."
145 popd > /dev/null
146}
147
148
115# @FUNCTION: bzr_fetch 149# @FUNCTION: bzr_fetch
116# @DESCRIPTION: 150# @DESCRIPTION:
117# Wrapper function to fetch sources from bazaar via bzr fetch or bzr update, 151# Wrapper function to fetch sources from a Bazaar repository via bzr
118# depending on whether there is an existing working copy in ${EBZR_BRANCH_DIR}. 152# fetch or bzr update, depending on whether there is an existing
153# working copy in ${EBZR_BRANCH_DIR}.
119bzr_fetch() { 154bzr_fetch() {
120 local EBZR_BRANCH_DIR 155 local EBZR_BRANCH_DIR
121 156
122 # EBZR_REPO_URI is empty. 157 # EBZR_REPO_URI is empty.
123 [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty." 158 [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty."
124 159
125 # check for the protocol or pull from a local repo. 160 # check for the protocol or pull from a local repo.
126 if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then 161 if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then
127 case ${EBZR_REPO_URI%%:*} in 162 case ${EBZR_REPO_URI%%:*} in
128 # lp:// is https://launchpad.net 163 # lp: seems to be an alias to https://launchpad.net
129 http|https|rsync|sftp|lp) 164 http|https|rsync|lp)
165 ;;
166 sftp)
167 if ! built_with_use --missing true dev-util/bzr sftp; then
168 eerror "To fetch sources from ${EBZR_REPO_URI} you need SFTP"
169 eerror "support in dev-util/bzr."
170 die "Please, rebuild dev-util/bzr with the sftp USE flag enabled."
171 fi
130 ;; 172 ;;
131 *) 173 *)
132 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented." 174 die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented."
133 ;; 175 ;;
134 esac 176 esac
135 fi 177 fi
136 178
137 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then 179 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
138 debug-print "${FUNCNAME}: initial branch. creating bzr directory" 180 debug-print "${FUNCNAME}: initial branch. Creating bzr directory"
139 addwrite / 181 addwrite /
140 mkdir -p "${EBZR_STORE_DIR}" \ 182 mkdir -p "${EBZR_STORE_DIR}" \
141 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}." 183 || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}."
142 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" 184 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
143 fi 185 fi
144 186
145 cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" 187 pushd "${EBZR_STORE_DIR}" > /dev/null || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
146 188
147 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" 189 EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
148 190
149 addwrite "${EBZR_STORE_DIR}" 191 addwrite "${EBZR_STORE_DIR}"
150 addwrite "${EBZR_BRANCH_DIR}" 192 addwrite "${EBZR_BRANCH_DIR}"
151 193
152 debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}" 194 debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
153 195
154 local repository 196 # Run bzr_initial_fetch() only if the branch has not been pulled
155 197 # before or if the existing local copy is a full checkout (as did
156 if [[ ${EBZR_REPO_URI} == */* ]]; then 198 # an older version of bzr.eclass)
157 repository="${EBZR_REPO_URI}${EBZR_BRANCH}" 199 if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
200 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
201 elif [[ -d "${EBZR_BRANCH_DIR}"/.bzr/repository/ ]]; then
202 einfo "Re-fetching the branch to save space..."
203 rm -rf "${EBZR_BRANCH_DIR}"
204 bzr_initial_fetch "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
158 else 205 else
159 repository="${EBZR_REPO_URI}" 206 bzr_update "${EBZR_REPO_URI}" "${EBZR_BRANCH_DIR}"
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 207 fi
180 208
181 cd "${EBZR_BRANCH_DIR}" 209 cd "${EBZR_BRANCH_DIR}"
182 210
183 einfo "exporting ..." 211 einfo "exporting ..."
191 revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}") 219 revision=$(${EBZR_REVNO_CMD} "${EBZR_BRANCH_DIR}")
192 fi 220 fi
193 221
194 einfo "Revision ${revision} is now in ${WORKDIR}/${P}" 222 einfo "Revision ${revision} is now in ${WORKDIR}/${P}"
195 223
196 cd "${WORKDIR}" 224 popd > /dev/null
197} 225}
198 226
199# @FUNCTION: bzr_bootstrap 227# @FUNCTION: bzr_bootstrap
200# @DESCRIPTION: 228# @DESCRIPTION:
201# Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified 229# Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified.
202bzr_bootstrap() { 230bzr_bootstrap() {
203 local patch lpatch 231 local patch lpatch
204 232
205 cd "${S}" 233 pushd "${S}" > /dev/null
206 234
207 if [[ -n ${EBZR_PATCHES} ]] ; then 235 if [[ -n ${EBZR_PATCHES} ]] ; then
208 einfo "apply patches -->" 236 einfo "apply patches -->"
209 237
210 for patch in ${EBZR_PATCHES} ; do 238 for patch in ${EBZR_PATCHES} ; do
211 if [[ -f ${patch} ]] ; then 239 if [[ -f ${patch} ]] ; then
212 epatch ${patch} 240 epatch ${patch}
213 else 241 else
242 # This loop takes care of wildcarded patches given via
243 # EBZR_PATCHES in an ebuild
214 for lpatch in "${FILESDIR}"/${patch} ; do 244 for lpatch in "${FILESDIR}"/${patch} ; do
215 if [[ -f ${lpatch} ]] ; then 245 if [[ -f ${lpatch} ]] ; then
216 epatch ${lpatch} 246 epatch ${lpatch}
217 else 247 else
218 die "${EBZR}: ${patch} is not found" 248 die "${EBZR}: ${patch} is not found"
233 einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}" 263 einfo " bootstrap with commands: ${EBZR_BOOTSTRAP}"
234 "${EBZR_BOOTSTRAP}" \ 264 "${EBZR_BOOTSTRAP}" \
235 || die "${EBZR}: can't eval EBZR_BOOTSTRAP." 265 || die "${EBZR}: can't eval EBZR_BOOTSTRAP."
236 fi 266 fi
237 fi 267 fi
268
269 popd > /dev/null
238} 270}
239 271
240# @FUNCTION: bzr_src_unpack 272# @FUNCTION: bzr_src_unpack
241# @DESCRIPTION: 273# @DESCRIPTION:
242# default src_unpack. fetch and bootstrap. 274# Default src_unpack(). Includes bzr_fetch() and bootstrap().
243bzr_src_unpack() { 275bzr_src_unpack() {
276 if ! [ -z ${EBZR_BRANCH} ]; then
277 # This test will go away on 01 Jul 2010
278 eerror "This ebuild uses EBZR_BRANCH which is not supported anymore"
279 eerror "by the bzr.eclass. Please report this to the ebuild's maintainer."
280 die "EBZR_BRANCH still defined"
281 fi
244 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()." 282 bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()."
283 case "${EAPI:-0}" in
284 0|1) bzr_src_prepare ;;
285 esac
286}
287
288# @FUNCTION: bzr_src_prepare
289# @DESCRIPTION:
290# Default src_prepare(). Executes bzr_bootstrap() for patch
291# application and Make file generation (if needed).
292bzr_src_prepare() {
245 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()." 293 bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()."
246} 294}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20