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

Diff of /eclass/subversion.eclass

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

Revision 1.14 Revision 1.31
1# Copyright 1999-2004 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.14 2004/06/25 00:39:48 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.31 2006/04/30 09:26:56 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:
15# 15#
16## --------------------------------------------------------------------------- # 16## --------------------------------------------------------------------------- #
17 17
18inherit eutils 18inherit eutils
19 19
20ECLASS="subversion"
21INHERITED="${INHERITED} ${ECLASS}"
22ESVN="subversion.eclass" 20ESVN="subversion.eclass"
23 21
24EXPORT_FUNCTIONS src_unpack 22EXPORT_FUNCTIONS src_unpack
25 23
26HOMEPAGE="http://subversion.tigris.org/" 24HOMEPAGE="http://subversion.tigris.org/"
32DEPEND="dev-util/subversion" 30DEPEND="dev-util/subversion"
33 31
34 32
35## -- ESVN_STORE_DIR: subversion sources store directory 33## -- ESVN_STORE_DIR: subversion sources store directory
36# 34#
37ESVN_STORE_DIR="${DISTDIR}/svn-src" 35ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
38 36
39 37
40## -- ESVN_FETCH_CMD: subversion fetch command 38## -- ESVN_FETCH_CMD: subversion fetch command
41# 39#
42# default: svn checkout 40ESVN_FETCH_CMD="svn checkout"
43#
44[ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
45 41
46## -- ESVN_UPDATE_CMD: subversion update command 42## -- ESVN_UPDATE_CMD: subversion update command
47# 43#
48# default: svn update 44ESVN_UPDATE_CMD="svn update"
45
46
47## -- ESVN_OPTIONS:
49# 48#
50[ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update" 49# the options passed to checkout or update.
50#
51[ -z "${ESVN_OPTIONS}" ] && ESVN_OPTIONS=
51 52
52 53
53## -- ESVN_REPO_URI: repository uri 54## -- ESVN_REPO_URI: repository uri
54# 55#
55# e.g. http://foo/trunk, svn://bar/trunk 56# e.g. http://foo/trunk, svn://bar/trunk
100[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES="" 101[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
101 102
102 103
103## -- subversion_svn_fetch() ------------------------------------------------- # 104## -- subversion_svn_fetch() ------------------------------------------------- #
104 105
105subversion_svn_fetch() { 106function subversion_svn_fetch() {
107
108 local ESVN_CO_DIR
106 109
107 # ESVN_REPO_URI is empty. 110 # ESVN_REPO_URI is empty.
108 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty." 111 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
109 112
110 # check for the protocol. 113 # check for the protocol.
111 case ${ESVN_REPO_URI%%:*} in 114 case ${ESVN_REPO_URI%%:*} in
112 http) ;; 115 http|https)
113 https) ;; 116 if built_with_use dev-util/subversion nowebdav; then
117 eerror "In order to emerge this package, you need to"
118 eerror "re-emerge subversion with USE=-nowebdav"
119 die "Please run 'USE=-nowebdav emerge subversion'"
120 fi
121 ;;
114 svn) ;; 122 svn) ;;
115 *) 123 *)
116 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
117 ;; 125 ;;
118 esac 126 esac
119 127
120 # every time
121 addwrite "${ESVN_STORE_DIR}"
122 addwrite "/etc/subversion"
123
124 # -userpriv
125 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
126
127 if [ ! -d "${ESVN_STORE_DIR}" ]; then 128 if [ ! -d "${ESVN_STORE_DIR}" ]; then
129 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
130
131 addwrite /
128 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." 132 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
129 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}." 133 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
130 134 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
131 einfo "created store directory: ${ESVN_STORE_DIR}"
132 einfo
133 fi 135 fi
134 136
137 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138 ESVN_STORE_DIR=${PWD}
139
140 # every time
141 addwrite "/etc/subversion"
135 cd "${ESVN_STORE_DIR}" 142 addwrite "${ESVN_STORE_DIR}"
136 143
137 if [ -z "${ESVN_REPO_URI##*/}" ]; then 144 if ! has userpriv ${FEATURES}; then
138 ESVN_REPO_FIX="${ESVN_REPO_URI%/}" 145 # -userpriv
146 addwrite "/root/.subversion"
139 147
140 else 148 else
141 ESVN_REPO_FIX="${ESVN_REPO_URI}" 149 # +userpriv
150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
142 151
143 fi 152 fi
144 153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
145 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}" 155 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
156
157 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
146 158
147 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
148 # first check out 160 # first check out
149 einfo "subversion check out start -->" 161 einfo "subversion check out start -->"
150 einfo " checkout from: ${ESVN_REPO_URI}" 162 einfo " repository: ${ESVN_REPO_URI}"
151 163
152 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 164 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
153 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}." 165 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
154 cd "${ESVN_PROJECT}" 166 cd "${ESVN_PROJECT}"
155 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}." 167 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
156
157 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
158 168
159 else 169 else
160 # update working copy 170 # update working copy
161 einfo "subversion update start -->" 171 einfo "subversion update start -->"
162 einfo " update from: ${ESVN_REPO_URI}" 172 einfo " repository: ${ESVN_REPO_URI}"
173
163 cd "${ESVN_CO_DIR}" 174 cd "${ESVN_CO_DIR}"
164
165 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
166 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
167 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}." 175 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
168 176
169 else
170 echo "Skip updating..."
171
172 fi 177 fi
173 178
174 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 179 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
175 180
176 fi
177
178 # permission fix for NFS (root_squash) with -userpriv
179 find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
180
181 # copy to the ${WORKDIR} 181 # export to the ${WORKDIR}
182 # "svn export" has a bug. see http://bugs.gentoo.org/119236
182 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}." 183 #svn export "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't export to ${S}."
183 einfo " copied to: ${S}" 184 rsync -a --exclude=".svn/" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}."
184 echo 185 echo
185 186
186} 187}
187 188
188 189
189## -- subversion_bootstrap() ------------------------------------------------ # 190## -- subversion_bootstrap() ------------------------------------------------ #
190 191
191subversion_bootstrap() { 192function subversion_bootstrap() {
193
194 local patch lpatch
192 195
193 cd "${S}" 196 cd "${S}"
194 197
195 if [ "${ESVN_PATCHES}" ]; then 198 if [ "${ESVN_PATCHES}" ]; then
196 einfo "apply paches -->" 199 einfo "apply patches -->"
197 200
198 for PATCH in ${ESVN_PATCHES}; do 201 for patch in ${ESVN_PATCHES}; do
199 if [ -f "${PATCH}" ]; then 202 if [ -f "${patch}" ]; then
200 epatch ${PATCH} 203 epatch ${patch}
201 204
202 else 205 else
203 for fPATCH in ${FILESDIR}/${PATCH}; do 206 for lpatch in ${FILESDIR}/${patch}; do
204 if [ -f "${fPATCH}" ]; then 207 if [ -f "${lpatch}" ]; then
205 epatch ${fPATCH} 208 epatch ${lpatch}
206 209
207 else 210 else
208 die "${ESVN}; ${PATCH} is not found" 211 die "${ESVN}; ${patch} is not found"
209 212
210 fi 213 fi
211 done 214 done
212 fi 215 fi
213 done 216 done
220 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then 223 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
221 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" 224 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
222 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." 225 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
223 226
224 else 227 else
225 einfo " bootstrap with command: ESVN_BOOTSTRAP" 228 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
226 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 229 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
227 230
228 fi 231 fi
229 fi 232 fi
230 233
231} 234}
232 235
233 236
234## -- subversion_src_unpack() ------------------------------------------------ # 237## -- subversion_src_unpack() ------------------------------------------------ #
235 238
236subversion_src_unpack() { 239function subversion_src_unpack() {
237 240
238 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()." 241 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
239 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()." 242 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
240 243
241} 244}

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20