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

Diff of /eclass/subversion.eclass

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

Revision 1.31 Revision 1.36
1# Copyright 1999-2006 Gentoo Foundation 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.31 2006/04/30 09:26:56 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.36 2006/09/06 15:15:53 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
46 46
47## -- ESVN_OPTIONS: 47## -- ESVN_OPTIONS:
48# 48#
49# the options passed to checkout or update. 49# the options passed to checkout or update.
50# 50#
51[ -z "${ESVN_OPTIONS}" ] && ESVN_OPTIONS= 51: ESVN_OPTIONS=${ESVN_OPTIONS:=}
52 52
53 53
54## -- ESVN_REPO_URI: repository uri 54## -- ESVN_REPO_URI: repository uri
55# 55#
56# e.g. http://foo/trunk, svn://bar/trunk 56# e.g. http://foo/trunk, svn://bar/trunk
57# 57#
58# supported protocols: 58# supported protocols:
59# http:// 59# http://
60# https:// 60# https://
61# svn:// 61# svn://
62# svn+ssh://
62# 63#
63[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 64: ESVN_REPO_URI=${ESVN_REPO_URI:=}
64 65
65 66
66## -- ESVN_PROJECT: project name of your ebuild 67## -- ESVN_PROJECT: project name of your ebuild (= name space)
67# 68#
68# subversion eclass will check out the subversion repository like: 69# subversion eclass will check out the subversion repository like:
69# 70#
70# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} 71# ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
71# 72#
73# 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.
74# it will check out like: 75# it will check out like:
75# 76#
76# ${ESVN_STORE_DIR}/subversion/trunk 77# ${ESVN_STORE_DIR}/subversion/trunk
77# 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#
78# default: ${PN/-svn}. 85# default: ${PN/-svn}.
79# 86#
80[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 87: ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}}
81 88
82 89
83## -- ESVN_BOOTSTRAP: 90## -- ESVN_BOOTSTRAP:
84# 91#
85# bootstrap script or command like autogen.sh or etc.. 92# bootstrap script or command like autogen.sh or etc..
86# 93#
87[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 94: ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=}
88 95
89 96
90## -- ESVN_PATCHES: 97## -- ESVN_PATCHES:
91# 98#
92# subversion eclass can apply pathces in subversion_bootstrap(). 99# subversion eclass can apply pathces in subversion_bootstrap().
96# the process of applying the patch is: 103# the process of applying the patch is:
97# 1. just epatch it, if the patch exists in the path. 104# 1. just epatch it, if the patch exists in the path.
98# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR. 105# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
99# 3. die. 106# 3. die.
100# 107#
101[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES="" 108: ESVN_PATCHES=${ESVN_PATCHES:=}
102 109
103 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
104## -- subversion_svn_fetch() ------------------------------------------------- # 120## -- subversion_fetch() ----------------------------------------------------- #
105 121
106function subversion_svn_fetch() { 122function subversion_fetch() {
107 123
108 local ESVN_CO_DIR 124 local repo_uri=${1:-${ESVN_REPO_URI}}
109 125
126 if [[ -z "${repo_uri}" ]]; then
110 # ESVN_REPO_URI is empty. 127 die "${ESVN}: ESVN_REPO_URI is empty."
111 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty." 128 fi
112 129
130 # delete trailing slash
131 if [[ -z "${repo_uri##*/}" ]]; then
132 repo_uri=${repo_uri%/}
133 fi
134
113 # check for the protocol. 135 # check for the protocol
114 case ${ESVN_REPO_URI%%:*} in 136 local protocol=${repo_uri%%:*}
137
138 case "${protocol}" in
115 http|https) 139 http|https)
116 if built_with_use dev-util/subversion nowebdav; then 140 if built_with_use dev-util/subversion nowebdav; then
141 echo
117 eerror "In order to emerge this package, you need to" 142 eerror "In order to emerge this package, you need to"
118 eerror "re-emerge subversion with USE=-nowebdav" 143 eerror "re-emerge subversion with USE=-nowebdav"
144 echo
119 die "Please run 'USE=-nowebdav emerge subversion'" 145 die "${ESVN}: please run 'USE=-nowebdav emerge subversion'"
120 fi 146 fi
121 ;; 147 ;;
122 svn) ;; 148 svn|svn+ssh)
149 ;;
123 *) 150 *)
124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 151 die "${ESVN}: fetch from "${protocol}" is not yet implemented."
125 ;; 152 ;;
126 esac 153 esac
127 154
128 if [ ! -d "${ESVN_STORE_DIR}" ]; then 155 if [[ ! -d "${ESVN_STORE_DIR}" ]]; then
129 debug-print "${FUNCNAME}: initial checkout. creating subversion directory" 156 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
130 157
131 addwrite / 158 # Fix sandbox violations
159 addwrite ${ESVN_STORE_DIR%/*}
160
132 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." 161 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
133 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
134 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
135 fi 162 fi
136 163
137 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" 164 cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138 ESVN_STORE_DIR=${PWD}
139 165
140 # every time 166 # every time
141 addwrite "/etc/subversion" 167 addread "/etc/subversion"
142 addwrite "${ESVN_STORE_DIR}"
143 168
144 if ! has userpriv ${FEATURES}; then
145 # -userpriv
146 addwrite "/root/.subversion"
147
148 else
149 # +userpriv
150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion" 169 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
151 170
152 fi 171 local wc_path=${ESVN_PROJECT}/${repo_uri##*/}
153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
155 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
156 172
157 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" 173 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
158 174
159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 175 if [[ ! -d "${wc_path}/.svn" ]]; then
160 # first check out 176 # first check out
161 einfo "subversion check out start -->" 177 einfo "subversion check out start -->"
162 einfo " repository: ${ESVN_REPO_URI}" 178 einfo " repository: ${repo_uri}"
179
180 # Fix sandbox violations
181 addwrite "${ESVN_STORE_DIR}"
163 182
164 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 183 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
165 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
166 cd "${ESVN_PROJECT}" 184 cd "${ESVN_PROJECT}"
167 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}." 185 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${repo_uri}" || die "${ESVN}: can't fetch from ${repo_uri}."
168 186
169 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
170 # update working copy 194 # update working copy
171 einfo "subversion update start -->" 195 einfo "subversion update start -->"
172 einfo " repository: ${ESVN_REPO_URI}" 196 einfo " repository: ${repo_uri}"
173 197
174 cd "${ESVN_CO_DIR}" 198 cd "${wc_path}"
175 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${ESVN_REPO_URI}." 199 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${repo_uri}."
176 200
177 fi 201 fi
178 202
179 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 203 einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}"
180 204
205 if ! has "export" ${ESVN_RESTRICT}; then
206 cd "${ESVN_STORE_DIR}/${wc_path}"
207
181 # export to the ${WORKDIR} 208 # export to the ${WORKDIR}
182 # "svn export" has a bug. see http://bugs.gentoo.org/119236 209 #* "svn export" has a bug. see http://bugs.gentoo.org/119236
183 #svn export "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't export to ${S}." 210 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
184 rsync -a --exclude=".svn/" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}." 211 rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
212 fi
213
185 echo 214 echo
186 215
187} 216}
188 217
189 218
190## -- subversion_bootstrap() ------------------------------------------------ # 219## -- subversion_bootstrap() ------------------------------------------------ #
191 220
192function subversion_bootstrap() { 221function subversion_bootstrap() {
193 222
194 local patch lpatch 223 if has "export" ${ESVN_RESTRICT}; then
224 return
225 fi
195 226
196 cd "${S}" 227 cd "${S}"
197 228
198 if [ "${ESVN_PATCHES}" ]; then 229 if [[ -n "${ESVN_PATCHES}" ]]; then
199 einfo "apply patches -->" 230 einfo "apply patches -->"
200 231
232 local p=
233
201 for patch in ${ESVN_PATCHES}; do 234 for p in ${ESVN_PATCHES}; do
202 if [ -f "${patch}" ]; then 235 if [[ -f "${p}" ]]; then
203 epatch ${patch} 236 epatch "${p}"
204 237
205 else 238 else
239 local q=
240
206 for lpatch in ${FILESDIR}/${patch}; do 241 for q in ${FILESDIR}/${p}; do
207 if [ -f "${lpatch}" ]; then 242 if [[ -f "${q}" ]]; then
208 epatch ${lpatch} 243 epatch "${q}"
209 244
210 else 245 else
211 die "${ESVN}; ${patch} is not found" 246 die "${ESVN}; ${p} is not found"
212 247
213 fi 248 fi
214 done 249 done
215 fi 250 fi
216 done 251 done
252
217 echo 253 echo
218 fi
219 254
255 fi
256
220 if [ "${ESVN_BOOTSTRAP}" ]; then 257 if [[ -n "${ESVN_BOOTSTRAP}" ]]; then
221 einfo "begin bootstrap -->" 258 einfo "begin bootstrap -->"
222 259
223 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then 260 if [[ -f "${ESVN_BOOTSTRAP}" && -x "${ESVN_BOOTSTRAP}" ]]; then
224 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" 261 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
225 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." 262 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
226 263
227 else 264 else
228 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}" 265 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
236 273
237## -- subversion_src_unpack() ------------------------------------------------ # 274## -- subversion_src_unpack() ------------------------------------------------ #
238 275
239function subversion_src_unpack() { 276function subversion_src_unpack() {
240 277
241 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()." 278 subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
242 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()." 279 subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
243 280
244} 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.31  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.20