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

Diff of /eclass/subversion.eclass

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

Revision 1.11 Revision 1.31
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.11 2004/06/06 10:03:11 hattya 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
56# but currentry support http and https only. 57#
58# supported protocols:
59# http://
60# https://
61# svn://
57# 62#
58[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 63[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
59 64
60 65
61## -- ESVN_PROJECT: project name of your ebuild 66## -- ESVN_PROJECT: project name of your ebuild
96[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES="" 101[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
97 102
98 103
99## -- subversion_svn_fetch() ------------------------------------------------- # 104## -- subversion_svn_fetch() ------------------------------------------------- #
100 105
101subversion_svn_fetch() { 106function subversion_svn_fetch() {
107
108 local ESVN_CO_DIR
102 109
103 # ESVN_REPO_URI is empty. 110 # ESVN_REPO_URI is empty.
104 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty." 111 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
105 112
106 # http and https only... 113 # check for the protocol.
107 case ${ESVN_REPO_URI%%:*} in 114 case ${ESVN_REPO_URI%%:*} in
108 http) ;; 115 http|https)
109 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 ;;
110 svn) ;; 122 svn) ;;
111 *) 123 *)
112 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
113 ;; 125 ;;
114 esac 126 esac
115 127
128 if [ ! -d "${ESVN_STORE_DIR}" ]; then
129 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
130
131 addwrite /
132 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
136
137 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138 ESVN_STORE_DIR=${PWD}
139
116 # every time 140 # every time
141 addwrite "/etc/subversion"
117 addwrite "${ESVN_STORE_DIR}" 142 addwrite "${ESVN_STORE_DIR}"
118 addwrite "/etc/subversion"
119 143
144 if ! has userpriv ${FEATURES}; then
120 # -userpriv 145 # -userpriv
121 ! has userpriv ${FEATURE} && addwrite "/root/.subversion" 146 addwrite "/root/.subversion"
122 147
123 if [ ! -d "${ESVN_STORE_DIR}" ]; then
124 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
125 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
126 einfo "created store directory: ${ESVN_STORE_DIR}"
127 einfo
128 fi
129
130 cd "${ESVN_STORE_DIR}"
131
132 if [ -z ${ESVN_REPO_URI##*/} ]; then
133 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
134 else 148 else
135 ESVN_REPO_FIX="${ESVN_REPO_URI}" 149 # +userpriv
136 fi 150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
137 151
152 fi
153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
138 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}\""
139 158
140 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
141 # first check out 160 # first check out
142 einfo "subversion check out start -->" 161 einfo "subversion check out start -->"
143 einfo " checkout from: ${ESVN_REPO_URI}" 162 einfo " repository: ${ESVN_REPO_URI}"
144 163
145 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 164 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
146 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}."
147 cd "${ESVN_PROJECT}" 166 cd "${ESVN_PROJECT}"
148 ${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}."
149 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
150 168
151 else 169 else
152 # update working copy 170 # update working copy
153 einfo "subversion update start -->" 171 einfo "subversion update start -->"
154 einfo " update from: ${ESVN_REPO_URI}" 172 einfo " repository: ${ESVN_REPO_URI}"
173
155 cd "${ESVN_CO_DIR}" 174 cd "${ESVN_CO_DIR}"
156
157 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
158 if expr ${NOW} - ${UPDATE} \> ${INTERVAL} >/dev/null; then
159 ${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}."
160 else 176
161 echo "Skip updating..."
162 fi 177 fi
163 178
164 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 179 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
165 180
166 fi
167
168 # permission fix for NFS (root_squash) with -userpriv
169 find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
170
171 # copy to the ${WORKDIR} 181 # export to the ${WORKDIR}
182 # "svn export" has a bug. see http://bugs.gentoo.org/119236
172 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}."
173 einfo " copied to: ${S}" 184 rsync -a --exclude=".svn/" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}."
174 echo 185 echo
175 186
176} 187}
177 188
178 189
179## -- subversion_bootstrap() ------------------------------------------------ # 190## -- subversion_bootstrap() ------------------------------------------------ #
180 191
181subversion_bootstrap() { 192function subversion_bootstrap() {
193
194 local patch lpatch
182 195
183 cd "${S}" 196 cd "${S}"
184 197
185 if [ "${ESVN_PATCHES}" ]; then 198 if [ "${ESVN_PATCHES}" ]; then
186 einfo "apply paches -->" 199 einfo "apply patches -->"
200
187 for PATCH in ${ESVN_PATCHES}; do 201 for patch in ${ESVN_PATCHES}; do
188 if [ -f "${PATCH}" ]; then 202 if [ -f "${patch}" ]; then
189 epatch ${PATCH} 203 epatch ${patch}
190 204
191 else 205 else
192 for fPATCH in ${FILESDIR}/${PATCH}; do 206 for lpatch in ${FILESDIR}/${patch}; do
193 if [ -f "${fPATCH}" ]; then 207 if [ -f "${lpatch}" ]; then
194 epatch ${fPATCH} 208 epatch ${lpatch}
195 209
196 else 210 else
197 die "${ESVN}; ${PATCH} is not found" 211 die "${ESVN}; ${patch} is not found"
198 212
199 fi 213 fi
200 done 214 done
201 fi 215 fi
202 done 216 done
203 echo 217 echo
204 fi 218 fi
205 219
206 if [ "${ESVN_BOOTSTRAP}" ]; then 220 if [ "${ESVN_BOOTSTRAP}" ]; then
207 einfo "begin bootstrap -->" 221 einfo "begin bootstrap -->"
222
208 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then 223 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
209 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" 224 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
210 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." 225 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
211 226
212 else 227 else
213 einfo " bootstrap with command: ESVN_BOOTSTRAP" 228 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
214 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 229 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
215 230
216 fi 231 fi
217 fi 232 fi
218 233
219} 234}
220 235
221 236
222## -- subversion_src_unpack() ------------------------------------------------ # 237## -- subversion_src_unpack() ------------------------------------------------ #
223 238
224subversion_src_unpack() { 239function subversion_src_unpack() {
225 240
226 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()." 241 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
227 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()." 242 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
228 243
229} 244}

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

  ViewVC Help
Powered by ViewVC 1.1.20