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

Diff of /eclass/subversion.eclass

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

Revision 1.6 Revision 1.37
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2006 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/subversion.eclass,v 1.6 2004/03/01 16:34:42 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.37 2006/09/06 15:22:34 joker Exp $
4 4
5## --------------------------------------------------------------------------- # 5## --------------------------------------------------------------------------- #
6# Author: Akinori Hattori <hattya@gentoo.org> 6# Author: Akinori Hattori <hattya@gentoo.org>
7# 7#
8# The subversion eclass is written to fetch the software sources from 8# The subversion eclass is written to fetch the software sources from
9# subversion repositories like the cvs eclass. 9# subversion repositories like the cvs eclass.
10# 10#
11# 11#
12# Description: 12# Description:
13# If you use this eclass, the ${S} is ${WORKDIR}/${P}. 13# If you use this eclass, the ${S} is ${WORKDIR}/${P}.
14# It is necessary to define the ESVN_REPOURI variable at least. 14# It is necessary to define the ESVN_REPO_URI variable at least.
15# 15#
16## --------------------------------------------------------------------------- # 16## --------------------------------------------------------------------------- #
17 17
18inherit eutils
18 19
19ECLASS="subversion" 20ESVN="subversion.eclass"
20INHERITED="${INHERITED} ${ECLASS}"
21 21
22EXPORT_FUNCTIONS src_unpack 22EXPORT_FUNCTIONS src_unpack
23 23
24HOMEPAGE="http://subversion.tigris.org/" 24HOMEPAGE="http://subversion.tigris.org/"
25DESCRIPTION="Based on the ${ECLASS} eclass" 25DESCRIPTION="Based on the ${ECLASS} eclass"
26 26
27 27
28## -- add subversion in DEPEND 28## -- add subversion in DEPEND
29# 29#
30newdepend "dev-util/subversion" 30DEPEND="dev-util/subversion"
31 31
32 32
33## -- ESVN_STORE_DIR: subversion sources store directory 33## -- ESVN_STORE_DIR: subversion sources store directory
34# 34#
35ESVN_STORE_DIR="${DISTDIR}/svn-src" 35ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
36 36
37 37
38## -- ESVN_FETCH_CMD: subversion fetch command 38## -- ESVN_FETCH_CMD: subversion fetch command
39# 39#
40# default: svn checkout 40ESVN_FETCH_CMD="svn checkout"
41#
42[ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
43 41
44## -- ESVN_UPDATE_CMD: subversion update command 42## -- ESVN_UPDATE_CMD: subversion update command
45# 43#
46# default: svn update 44ESVN_UPDATE_CMD="svn update"
45
46
47## -- ESVN_OPTIONS:
47# 48#
48[ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update" 49# the options passed to checkout or update.
50#
51: ESVN_OPTIONS=${ESVN_OPTIONS:=}
49 52
50 53
51## -- ESVN_REPO_URI: repository uri 54## -- ESVN_REPO_URI: repository uri
52# 55#
53# e.g. http://foo/trunk, svn://bar/trunk 56# e.g. http://foo/trunk, svn://bar/trunk
54# but currentry support http and https only.
55# 57#
56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 58# supported protocols:
59# http://
60# https://
61# svn://
62# svn+ssh://
63#
64: ESVN_REPO_URI=${ESVN_REPO_URI:=}
57 65
58 66
59## -- ESVN_PROJECT: project name of your ebuild 67## -- ESVN_PROJECT: project name of your ebuild (= name space)
60# 68#
61# subversion eclass will check out the subversion repository like: 69# subversion eclass will check out the subversion repository like:
62# 70#
63# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} 71# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
64# 72#
66# http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn. 74# http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
67# it will check out like: 75# it will check out like:
68# 76#
69# ${ESVN_STORE_DIR}/subversion/trunk 77# ${ESVN_STORE_DIR}/subversion/trunk
70# 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#
71# default: ${PN/-svn}. 85# default: ${PN/-svn}.
72# 86#
73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 87: ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}}
74 88
75 89
76## -- ESVN_BOOTSTRAP: 90## -- ESVN_BOOTSTRAP:
77# 91#
78# bootstrap script. like autogen.sh or etc.. 92# bootstrap script or command like autogen.sh or etc..
79# 93#
80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 94: ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=}
81 95
82 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
83## -- subversion_svn_fetch() ------------------------------------------------- # 120## -- subversion_fetch() ----------------------------------------------------- #
84 121
85subversion_svn_fetch() { 122function subversion_fetch() {
86 123
124 local repo_uri=${1:-${ESVN_REPO_URI}}
125
126 if [[ -z "${repo_uri}" ]]; then
87 # ESVN_REPO_URI is empty. 127 die "${ESVN}: ESVN_REPO_URI is empty."
88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty." 128 fi
89 129
90 # http and https only... 130 # delete trailing slash
91 case ${ESVN_REPO_URI%%:*} in 131 if [[ -z "${repo_uri##*/}" ]]; then
92 http) ;; 132 repo_uri=${repo_uri%/}
93 https) ;; 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 ;;
94 *) 150 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 151 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
96 ;; 152 ;;
97 esac 153 esac
98 154
155 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
156 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
157
158 # Fix sandbox violations
159 addwrite ${ESVN_STORE_DIR%/*}
160
161 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
162 fi
163
164 cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
165
99 # every time 166 # every time
167 addread "/etc/subversion"
168
169 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
170
171 local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
172
173 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
174
175 # Fix sandbox violations
100 addwrite "${ESVN_STORE_DIR}" 176 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 177
103 # -userpriv
104 addwrite "/root/.subversion"
105
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then
107 mkdir -p "${ESVN_STORE_DIR}" || die "subversion.eclass: can't mkdir ${ESVN_STORE_DIR}."
108 chmod -f o+rw "${ESVN_STORE_DIR}" || die "subversion.eclass: can't chmod ${ESVN_STORE_DIR}."
109 einfo "created store directory: ${ESVN_STORE_DIR}"
110 einfo
111 fi
112
113 cd "${ESVN_STORE_DIR}"
114
115 if [ -z ${ESVN_REPO_URI##*/} ]; then
116 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
117 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}"
119 fi
120
121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
122
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 178 if [[ ! -d "${wc_path}/.svn" ]]; then
124 # first check out 179 # first check out
125 einfo "subversion check out start -->" 180 einfo "subversion check out start -->"
126 einfo 181 einfo " repository: ${repo_uri}"
127 einfo "check out from: ${ESVN_REPO_URI}"
128 182
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 183 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
130 chmod -f o+rw "${ESVN_PROJECT}" || die "subversion.eclass: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 184 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 185 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 186
135 else 187 else
188 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
136 # update working copy 194 # update working copy
137 einfo "subversion update start -->" 195 einfo "subversion update start -->"
138 einfo 196 einfo " repository: ${repo_uri}"
139 einfo " update from: ${ESVN_REPO_URI}"
140 197
141 cd "${ESVN_CO_DIR}" 198 cd "${wc_path}"
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 199 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${repo_uri}."
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 200
146 # permission fix 201 fi
147 chmod -Rf o+rw .
148 202
203 einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
204
205 if ! has "export" ${ESVN_RESTRICT}; then
206 cd "${ESVN_STORE_DIR}/${wc_path}"
207
149 # copy to the ${WORKDIR} 208 # export to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 209 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
151 einfo 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
214 echo
152 215
153} 216}
154 217
155 218
156## -- subversion_bootstrap() ------------------------------------------------ # 219## -- subversion_bootstrap() ------------------------------------------------ #
157 220
158subversion_bootstrap() { 221function subversion_bootstrap() {
159 222
223 if has "export" ${ESVN_RESTRICT}; then
224 return
225 fi
226
227 cd "${S}"
228
229 if [[ -n "${ESVN_PATCHES}" ]]; then
230 einfo "apply patches -->"
231
232 local p=
233
234 for p in ${ESVN_PATCHES}; do
235 if [[ -f "${p}" ]]; then
236 epatch "${p}"
237
238 else
239 local q=
240
241 for q in ${FILESDIR}/${p}; do
242 if [[ -f "${q}" ]]; then
243 epatch "${q}"
244
245 else
246 die "${ESVN}; ${p} is not found"
247
248 fi
249 done
250 fi
251 done
252
253 echo
254
255 fi
256
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 257 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 258 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_BOOTSTRAP}." 259
260 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
261 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
262 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
263
264 else
265 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
266 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
267
166 fi 268 fi
167
168 fi 269 fi
169 270
170} 271}
171 272
172 273
173## -- subversion_src_unpack() ------------------------------------------------ # 274## -- subversion_src_unpack() ------------------------------------------------ #
174 275
175subversion_src_unpack() { 276function subversion_src_unpack() {
176 277
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 278 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 279 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
179 280
180} 281}
282
283
284## -- subversion_wc_info() --------------------------------------------------- #
285
286function 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}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.20