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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (hide annotations) (download)
Wed Sep 6 15:22:34 2006 UTC (7 years, 10 months ago) by joker
Branch: MAIN
Changes since 1.36: +4 -4 lines
Moved addwrite() outside the if statement since it's needed in both cases.

1 vapier 1.27 # Copyright 1999-2006 Gentoo Foundation
2 hattya 1.1 # Distributed under the terms of the GNU General Public License v2
3 joker 1.37 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.36 2006/09/06 15:15:53 joker Exp $
4 hattya 1.1
5     ## --------------------------------------------------------------------------- #
6     # Author: Akinori Hattori <hattya@gentoo.org>
7 swegener 1.23 #
8 hattya 1.1 # 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 hattya 1.10 # It is necessary to define the ESVN_REPO_URI variable at least.
15 hattya 1.1 #
16     ## --------------------------------------------------------------------------- #
17    
18 hattya 1.8 inherit eutils
19 hattya 1.1
20 hattya 1.8 ESVN="subversion.eclass"
21 hattya 1.1
22     EXPORT_FUNCTIONS src_unpack
23    
24     HOMEPAGE="http://subversion.tigris.org/"
25 hattya 1.5 DESCRIPTION="Based on the ${ECLASS} eclass"
26 hattya 1.1
27    
28     ## -- add subversion in DEPEND
29     #
30 mr_bones_ 1.9 DEPEND="dev-util/subversion"
31 hattya 1.1
32    
33     ## -- ESVN_STORE_DIR: subversion sources store directory
34     #
35 ferringb 1.26 ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
36 hattya 1.1
37    
38     ## -- ESVN_FETCH_CMD: subversion fetch command
39     #
40 hattya 1.25 ESVN_FETCH_CMD="svn checkout"
41    
42     ## -- ESVN_UPDATE_CMD: subversion update command
43 hattya 1.1 #
44 hattya 1.25 ESVN_UPDATE_CMD="svn update"
45 hattya 1.1
46 hattya 1.25
47     ## -- ESVN_OPTIONS:
48 hattya 1.1 #
49 hattya 1.25 # the options passed to checkout or update.
50 hattya 1.1 #
51 hattya 1.33 : ESVN_OPTIONS=${ESVN_OPTIONS:=}
52 hattya 1.1
53    
54     ## -- ESVN_REPO_URI: repository uri
55     #
56     # e.g. http://foo/trunk, svn://bar/trunk
57 hattya 1.12 #
58     # supported protocols:
59     # http://
60     # https://
61     # svn://
62 hattya 1.33 # svn+ssh://
63 hattya 1.1 #
64 hattya 1.33 : ESVN_REPO_URI=${ESVN_REPO_URI:=}
65 hattya 1.1
66    
67 hattya 1.33 ## -- ESVN_PROJECT: project name of your ebuild (= name space)
68 hattya 1.1 #
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 hattya 1.33 # 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 hattya 1.1 # default: ${PN/-svn}.
86     #
87 hattya 1.33 : ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}}
88 hattya 1.1
89    
90     ## -- ESVN_BOOTSTRAP:
91     #
92 hattya 1.8 # bootstrap script or command like autogen.sh or etc..
93 hattya 1.1 #
94 hattya 1.33 : ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=}
95 hattya 1.1
96    
97 hattya 1.8 ## -- 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 hattya 1.33 : 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 hattya 1.8
122 hattya 1.33 function subversion_fetch() {
123 hattya 1.8
124 hattya 1.33 local repo_uri=${1:-${ESVN_REPO_URI}}
125 hattya 1.1
126 hattya 1.33 if [[ -z "${repo_uri}" ]]; then
127     die "${ESVN}: ESVN_REPO_URI is empty."
128     fi
129 hattya 1.1
130 hattya 1.33 # delete trailing slash
131     if [[ -z "${repo_uri##*/}" ]]; then
132     repo_uri=${repo_uri%/}
133     fi
134 hattya 1.25
135 hattya 1.33 # check for the protocol
136     local protocol=${repo_uri%%:*}
137 hattya 1.1
138 hattya 1.33 case "${protocol}" in
139 vapier 1.24 http|https)
140 hattya 1.25 if built_with_use dev-util/subversion nowebdav; then
141 hattya 1.34 echo
142 vapier 1.24 eerror "In order to emerge this package, you need to"
143     eerror "re-emerge subversion with USE=-nowebdav"
144 hattya 1.34 echo
145     die "${ESVN}: please run 'USE=-nowebdav emerge subversion'"
146 vapier 1.24 fi
147     ;;
148 hattya 1.33 svn|svn+ssh)
149     ;;
150 hattya 1.5 *)
151 hattya 1.33 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
152 hattya 1.5 ;;
153     esac
154 hattya 1.1
155 hattya 1.33 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
156 hattya 1.17 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
157 hattya 1.5
158 spb 1.35 # Fix sandbox violations
159     addwrite ${ESVN_STORE_DIR%/*}
160    
161 hattya 1.33 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
162 hattya 1.1 fi
163    
164 hattya 1.33 cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
165 hattya 1.1
166 hattya 1.17 # every time
167 hattya 1.34 addread "/etc/subversion"
168 hattya 1.12
169 hattya 1.34 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
170 hattya 1.12
171 hattya 1.33 local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
172 hattya 1.1
173 hattya 1.25 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
174    
175 joker 1.37 # Fix sandbox violations
176     addwrite "${ESVN_STORE_DIR}"
177    
178 hattya 1.33 if [[ ! -d "${wc_path}/.svn" ]]; then
179 hattya 1.1 # first check out
180     einfo "subversion check out start -->"
181 hattya 1.33 einfo " repository: ${repo_uri}"
182 hattya 1.1
183 hattya 1.12 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
184 hattya 1.5 cd "${ESVN_PROJECT}"
185 hattya 1.33 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
186 hattya 1.12
187 hattya 1.1 else
188 hattya 1.34 subversion_wc_info || die "${ESVN}: unknown problem occurred while accessing working copy."
189    
190     if [[ "${ESVN_WC_URL}" != "${ESVN_REPO_URI}" ]]; then
191     die "${ESVN}: ESVN_REPO_URI and working copy's URL are not matched."
192     fi
193    
194 hattya 1.1 # update working copy
195     einfo "subversion update start -->"
196 hattya 1.33 einfo " repository: ${repo_uri}"
197 hattya 1.25
198 hattya 1.33 cd "${wc_path}"
199     ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${repo_uri}."
200 hattya 1.1
201 hattya 1.29 fi
202 hattya 1.8
203 hattya 1.33 einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
204    
205     if ! has "export" ${ESVN_RESTRICT}; then
206     cd "${ESVN_STORE_DIR}/${wc_path}"
207    
208     # export to the ${WORKDIR}
209     #* "svn export" has a bug. see http://bugs.gentoo.org/119236
210     #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
211     rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
212     fi
213 hattya 1.1
214 hattya 1.8 echo
215 hattya 1.1
216     }
217    
218    
219     ## -- subversion_bootstrap() ------------------------------------------------ #
220    
221 hattya 1.17 function subversion_bootstrap() {
222    
223 hattya 1.33 if has "export" ${ESVN_RESTRICT}; then
224     return
225     fi
226 hattya 1.1
227 hattya 1.8 cd "${S}"
228    
229 hattya 1.33 if [[ -n "${ESVN_PATCHES}" ]]; then
230 hattya 1.15 einfo "apply patches -->"
231 hattya 1.12
232 hattya 1.33 local p=
233    
234     for p in ${ESVN_PATCHES}; do
235     if [[ -f "${p}" ]]; then
236     epatch "${p}"
237 hattya 1.8
238     else
239 hattya 1.33 local q=
240    
241     for q in ${FILESDIR}/${p}; do
242     if [[ -f "${q}" ]]; then
243     epatch "${q}"
244 hattya 1.8
245     else
246 hattya 1.33 die "${ESVN}; ${p} is not found"
247 hattya 1.8
248     fi
249     done
250     fi
251     done
252 hattya 1.33
253 hattya 1.8 echo
254 hattya 1.33
255 hattya 1.8 fi
256    
257 hattya 1.33 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
258 hattya 1.8 einfo "begin bootstrap -->"
259 hattya 1.12
260 hattya 1.33 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
261 hattya 1.8 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
262     eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
263    
264     else
265 hattya 1.16 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
266 hattya 1.8 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
267 hattya 1.1
268     fi
269     fi
270    
271     }
272    
273    
274     ## -- subversion_src_unpack() ------------------------------------------------ #
275    
276 hattya 1.17 function subversion_src_unpack() {
277 hattya 1.1
278 hattya 1.34 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
279     subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
280 hattya 1.1
281     }
282 hattya 1.33
283    
284     ## -- subversion_wc_info() --------------------------------------------------- #
285    
286     function subversion_wc_info() {
287    
288     local repo_uri=${ESVN_REPO_URI}
289    
290     # delete trailing slash
291     if [[ -z "${repo_uri##*/}" ]]; then
292     repo_uri="${repo_uri%/}"
293     fi
294    
295     local wc_path=${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}
296    
297     if [[ ! -e "${wc_path}" ]]; then
298     return 1
299     fi
300    
301     local k=
302    
303     for k in url revision; do
304     export ESVN_WC_$(echo "${k}" | tr [a-z] [A-Z])=$(env LANG=C svn info "${wc_path}" | grep -i "^${k}" | cut -d" " -f2)
305     done
306    
307     }

  ViewVC Help
Powered by ViewVC 1.1.20