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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.38 - (show annotations) (download)
Wed Sep 27 16:20:20 2006 UTC (7 years, 9 months ago) by hattya
Branch: MAIN
Changes since 1.37: +13 -17 lines
fixes bug #146915 and bug #148598.

1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.37 2006/09/06 15:22:34 joker Exp $
4
5 ## --------------------------------------------------------------------------- #
6 # Author: Akinori Hattori <hattya@gentoo.org>
7 #
8 # The subversion eclass is written to fetch the software sources from
9 # subversion repositories like the cvs eclass.
10 #
11 #
12 # Description:
13 # If you use this eclass, the ${S} is ${WORKDIR}/${P}.
14 # It is necessary to define the ESVN_REPO_URI variable at least.
15 #
16 ## --------------------------------------------------------------------------- #
17
18 inherit eutils
19
20 ESVN="subversion.eclass"
21
22 EXPORT_FUNCTIONS src_unpack
23
24 HOMEPAGE="http://subversion.tigris.org/"
25 DESCRIPTION="Based on the ${ECLASS} eclass"
26
27
28 ## -- add subversion in DEPEND
29 #
30 DEPEND="dev-util/subversion"
31
32
33 ## -- ESVN_STORE_DIR: subversion sources store directory
34 #
35 ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
36
37
38 ## -- ESVN_FETCH_CMD: subversion fetch command
39 #
40 ESVN_FETCH_CMD="svn checkout"
41
42 ## -- ESVN_UPDATE_CMD: subversion update command
43 #
44 ESVN_UPDATE_CMD="svn update"
45
46
47 ## -- ESVN_OPTIONS:
48 #
49 # the options passed to checkout or update.
50 #
51 : ESVN_OPTIONS=${ESVN_OPTIONS:=}
52
53
54 ## -- ESVN_REPO_URI: repository uri
55 #
56 # e.g. http://foo/trunk, svn://bar/trunk
57 #
58 # supported protocols:
59 # http://
60 # https://
61 # svn://
62 # svn+ssh://
63 #
64 : ESVN_REPO_URI=${ESVN_REPO_URI:=}
65
66
67 ## -- ESVN_PROJECT: project name of your ebuild (= name space)
68 #
69 # subversion eclass will check out the subversion repository like:
70 #
71 # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
72 #
73 # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
74 # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
75 # it will check out like:
76 #
77 # ${ESVN_STORE_DIR}/subversion/trunk
78 #
79 # this is not used in order to declare the name of the upstream project.
80 # so that you can declare this like:
81 #
82 # # jakarta commons-loggin
83 # ESVN_PROJECT=commons/logging
84 #
85 # default: ${PN/-svn}.
86 #
87 : ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}}
88
89
90 ## -- ESVN_BOOTSTRAP:
91 #
92 # bootstrap script or command like autogen.sh or etc..
93 #
94 : ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=}
95
96
97 ## -- ESVN_PATCHES:
98 #
99 # subversion eclass can apply pathces in subversion_bootstrap().
100 # you can use regexp in this valiable like *.diff or *.patch or etc.
101 # NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
102 #
103 # the process of applying the patch is:
104 # 1. just epatch it, if the patch exists in the path.
105 # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
106 # 3. die.
107 #
108 : ESVN_PATCHES=${ESVN_PATCHES:=}
109
110
111 ## -- ESVN_RESTRICT:
112 #
113 # this should be a space delimited list of subversion eclass features to restrict.
114 # export)
115 # don't export the working copy to S.
116 #
117 : ESVN_RESTRICT=${ESVN_RESTRICT:=}
118
119
120 ## -- subversion_fetch() ----------------------------------------------------- #
121
122 function subversion_fetch() {
123
124 local repo_uri=${1:-${ESVN_REPO_URI}}
125
126 if [[ -z "${repo_uri}" ]]; then
127 die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
128 fi
129
130 # delete trailing slash
131 if [[ -z "${repo_uri##*/}" ]]; then
132 repo_uri=${repo_uri%/}
133 fi
134
135 # check for the protocol
136 local protocol=${repo_uri%%:*}
137
138 case "${protocol}" in
139 http|https)
140 if built_with_use dev-util/subversion nowebdav; then
141 echo
142 eerror "In order to emerge this package, you need to"
143 eerror "re-emerge subversion with USE=-nowebdav"
144 echo
145 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'"
146 fi
147 ;;
148 svn|svn+ssh)
149 ;;
150 *)
151 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
152 ;;
153 esac
154
155 # every time
156 addread "/etc/subversion"
157 addwrite "${ESVN_STORE_DIR}"
158
159 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
160 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
161
162 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
163 fi
164
165 cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
166
167
168 local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
169 local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
170
171 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
172 debug-print "${FUNCNAME}: options = \"${options}\""
173
174 if [[ ! -d "${wc_path}/.svn" ]]; then
175 # first check out
176 einfo "subversion check out start -->"
177 einfo " repository: ${repo_uri}"
178
179 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
180 cd "${ESVN_PROJECT}"
181 ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
182
183 else
184 subversion_wc_info || die "${ESVN}: unknown problem occurred while accessing working copy."
185
186 if [[ "${ESVN_WC_URL}" != "${repo_uri}" ]]; then
187 die "${ESVN}: ESVN_REPO_URI (or specified URI) and working copy's URL are not matched."
188 fi
189
190 # update working copy
191 einfo "subversion update start -->"
192 einfo " repository: ${repo_uri}"
193
194 cd "${wc_path}"
195 ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update from ${repo_uri}."
196
197 fi
198
199 einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
200
201 if ! has "export" ${ESVN_RESTRICT}; then
202 cd "${ESVN_STORE_DIR}/${wc_path}"
203
204 # export to the ${WORKDIR}
205 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
206 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
207 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
208 fi
209
210 echo
211
212 }
213
214
215 ## -- subversion_bootstrap() ------------------------------------------------ #
216
217 function subversion_bootstrap() {
218
219 if has "export" ${ESVN_RESTRICT}; then
220 return
221 fi
222
223 cd "${S}"
224
225 if [[ -n "${ESVN_PATCHES}" ]]; then
226 einfo "apply patches -->"
227
228 local p=
229
230 for p in ${ESVN_PATCHES}; do
231 if [[ -f "${p}" ]]; then
232 epatch "${p}"
233
234 else
235 local q=
236
237 for q in ${FILESDIR}/${p}; do
238 if [[ -f "${q}" ]]; then
239 epatch "${q}"
240
241 else
242 die "${ESVN}; ${p} is not found"
243
244 fi
245 done
246 fi
247 done
248
249 echo
250
251 fi
252
253 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
254 einfo "begin bootstrap -->"
255
256 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
257 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
258 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
259
260 else
261 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
262 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
263
264 fi
265 fi
266
267 }
268
269
270 ## -- subversion_src_unpack() ------------------------------------------------ #
271
272 function subversion_src_unpack() {
273
274 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
275 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
276
277 }
278
279
280 ## -- subversion_wc_info() --------------------------------------------------- #
281
282 function subversion_wc_info() {
283
284 local repo_uri=${ESVN_REPO_URI}
285
286 # delete trailing slash
287 if [[ -z "${repo_uri##*/}" ]]; then
288 repo_uri="${repo_uri%/}"
289 fi
290
291 local wc_path=${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}
292
293 if [[ ! -e "${wc_path}" ]]; then
294 return 1
295 fi
296
297 local k=
298
299 for k in url revision; do
300 export ESVN_WC_$(echo "${k}" | tr [a-z] [A-Z])=$(env LC_ALL=C svn info "${wc_path}" | grep -i "^${k}" | cut -d" " -f2)
301 done
302
303 }

  ViewVC Help
Powered by ViewVC 1.1.20