/[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.33
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.33 2006/07/22 13:52:38 hattya 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 eerror "In order to emerge this package, you need to"
142 eerror "re-emerge subversion with USE=-nowebdav"
143 die "Please run 'USE=-nowebdav emerge subversion'"
144 fi
145 ;;
146 svn|svn+ssh)
147 ;;
94 *) 148 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 149 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
96 ;; 150 ;;
97 esac 151 esac
98 152
153 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
154 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
155
156 addwrite /
157 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
158 export SANDBOX_WRITE=${SANDBOX_WRITE%%:/}
159 fi
160
161 cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
162
99 # every time 163 # every time
164 addwrite "/etc/subversion"
100 addwrite "${ESVN_STORE_DIR}" 165 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 166
167 if ! has userpriv ${FEATURES}; then
103 # -userpriv 168 # -userpriv
104 addwrite "/root/.subversion" 169 addwrite "/root/.subversion"
105 170
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 171 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}" 172 # +userpriv
119 fi 173 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
120 174
121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}" 175 fi
122 176
177 local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
178
179 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
180
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 181 if [[ ! -d "${wc_path}/.svn" ]]; then
124 # first check out 182 # first check out
125 einfo "subversion check out start -->" 183 einfo "subversion check out start -->"
126 einfo 184 einfo " repository: ${repo_uri}"
127 einfo "check out from: ${ESVN_REPO_URI}"
128 185
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 186 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}" 187 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 188 ${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 189
135 else 190 else
136 # update working copy 191 # update working copy
137 einfo "subversion update start -->" 192 einfo "subversion update start -->"
138 einfo 193 einfo " repository: ${repo_uri}"
139 einfo " update from: ${ESVN_REPO_URI}"
140 194
141 cd "${ESVN_CO_DIR}" 195 cd "${wc_path}"
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 196 ${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 197
146 # permission fix 198 fi
147 chmod -Rf o+rw .
148 199
200 einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
201
202 if ! has "export" ${ESVN_RESTRICT}; then
203 cd "${ESVN_STORE_DIR}/${wc_path}"
204
149 # copy to the ${WORKDIR} 205 # export to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 206 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
151 einfo 207 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
208 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
209 fi
210
211 echo
152 212
153} 213}
154 214
155 215
156## -- subversion_bootstrap() ------------------------------------------------ # 216## -- subversion_bootstrap() ------------------------------------------------ #
157 217
158subversion_bootstrap() { 218function subversion_bootstrap() {
159 219
220 if has "export" ${ESVN_RESTRICT}; then
221 return
222 fi
223
224 cd "${S}"
225
226 if [[ -n "${ESVN_PATCHES}" ]]; then
227 einfo "apply patches -->"
228
229 local p=
230
231 for p in ${ESVN_PATCHES}; do
232 if [[ -f "${p}" ]]; then
233 epatch "${p}"
234
235 else
236 local q=
237
238 for q in ${FILESDIR}/${p}; do
239 if [[ -f "${q}" ]]; then
240 epatch "${q}"
241
242 else
243 die "${ESVN}; ${p} is not found"
244
245 fi
246 done
247 fi
248 done
249
250 echo
251
252 fi
253
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 254 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 255 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_BOOTSTRAP}." 256
257 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
258 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
259 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
260
261 else
262 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
263 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
264
166 fi 265 fi
167
168 fi 266 fi
169 267
170} 268}
171 269
172 270
173## -- subversion_src_unpack() ------------------------------------------------ # 271## -- subversion_src_unpack() ------------------------------------------------ #
174 272
175subversion_src_unpack() { 273function subversion_src_unpack() {
176 274
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 275 subversion_fetch || die "${ESVN}: unknown problem in subversion_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 276 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 277
180} 278}
279
280
281## -- subversion_wc_info() --------------------------------------------------- #
282
283function subversion_wc_info() {
284
285 local repo_uri=${ESVN_REPO_URI}
286
287 # delete trailing slash
288 if [[ -z "${repo_uri##*/}" ]]; then
289 repo_uri="${repo_uri%/}"
290 fi
291
292 local wc_path=${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}
293
294 if [[ ! -e "${wc_path}" ]]; then
295 return 1
296 fi
297
298 local k=
299
300 for k in url revision; do
301 export ESVN_WC_$(echo "${k}" | tr [a-z] [A-Z])=$(env LANG=C svn info "${wc_path}" | grep -i "^${k}" | cut -d" " -f2)
302 done
303
304}

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

  ViewVC Help
Powered by ViewVC 1.1.20