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

Diff of /eclass/subversion.eclass

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

Revision 1.8 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.8 2004/04/05 14:25:28 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:
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 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/"
27DESCRIPTION="Based on the ${ECLASS} eclass" 25DESCRIPTION="Based on the ${ECLASS} eclass"
28 26
29 27
30## -- add subversion in DEPEND 28## -- add subversion in DEPEND
31# 29#
32newdepend "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 ;;
122 svn) ;;
110 *) 123 *)
111 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
112 ;; 125 ;;
113 esac 126 esac
114 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
115 # every time 140 # every time
141 addwrite "/etc/subversion"
116 addwrite "${ESVN_STORE_DIR}" 142 addwrite "${ESVN_STORE_DIR}"
117 addwrite "/etc/subversion"
118 143
144 if ! has userpriv ${FEATURES}; then
119 # -userpriv 145 # -userpriv
120 ! has userpriv ${FEATURE} && addwrite "/root/.subversion" 146 addwrite "/root/.subversion"
121 147
122 if [ ! -d "${ESVN_STORE_DIR}" ]; then
123 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
124 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
125 einfo "created store directory: ${ESVN_STORE_DIR}"
126 einfo
127 fi
128
129 cd "${ESVN_STORE_DIR}"
130
131 if [ -z ${ESVN_REPO_URI##*/} ]; then
132 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
133 else 148 else
134 ESVN_REPO_FIX="${ESVN_REPO_URI}" 149 # +userpriv
135 fi 150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
136 151
152 fi
153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
137 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}\""
138 158
139 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
140 # first check out 160 # first check out
141 einfo "subversion check out start -->" 161 einfo "subversion check out start -->"
142 einfo " checkout from: ${ESVN_REPO_URI}" 162 einfo " repository: ${ESVN_REPO_URI}"
143 163
144 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 164 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
145 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}."
146 cd "${ESVN_PROJECT}" 166 cd "${ESVN_PROJECT}"
147 ${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}."
148 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
149 168
150 else 169 else
151 # update working copy 170 # update working copy
152 einfo "subversion update start -->" 171 einfo "subversion update start -->"
153 einfo " update from: ${ESVN_REPO_URI}" 172 einfo " repository: ${ESVN_REPO_URI}"
173
154 cd "${ESVN_CO_DIR}" 174 cd "${ESVN_CO_DIR}"
155
156 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
157 if expr ${NOW} - ${UPDATE} \> ${INTERVAL} >/dev/null; then
158 ${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}."
159 else 176
160 echo "Skip updating..."
161 fi 177 fi
162 178
163 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 179 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
164 180
165 fi
166
167 # permission fix for NFS (root_squash) with -userpriv
168 find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
169
170 # copy to the ${WORKDIR} 181 # export to the ${WORKDIR}
182 # "svn export" has a bug. see http://bugs.gentoo.org/119236
171 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}."
172 einfo " copied to: ${S}" 184 rsync -a --exclude=".svn/" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}."
173 echo 185 echo
174 186
175} 187}
176 188
177 189
178## -- subversion_bootstrap() ------------------------------------------------ # 190## -- subversion_bootstrap() ------------------------------------------------ #
179 191
180subversion_bootstrap() { 192function subversion_bootstrap() {
193
194 local patch lpatch
181 195
182 cd "${S}" 196 cd "${S}"
183 197
184 if [ "${ESVN_PATCHES}" ]; then 198 if [ "${ESVN_PATCHES}" ]; then
185 einfo "apply paches -->" 199 einfo "apply patches -->"
200
186 for PATCH in ${ESVN_PATCHES}; do 201 for patch in ${ESVN_PATCHES}; do
187 if [ -f "${PATCH}" ]; then 202 if [ -f "${patch}" ]; then
188 epatch ${PATCH} 203 epatch ${patch}
189 204
190 else 205 else
191 for fPATCH in ${FILESDIR}/${PATCH}; do 206 for lpatch in ${FILESDIR}/${patch}; do
192 if [ -f "${fPATCH}" ]; then 207 if [ -f "${lpatch}" ]; then
193 epatch ${fPATCH} 208 epatch ${lpatch}
194 209
195 else 210 else
196 die "${ESVN}; ${PATCH} is not found" 211 die "${ESVN}; ${patch} is not found"
197 212
198 fi 213 fi
199 done 214 done
200 fi 215 fi
201 done 216 done
202 echo 217 echo
203 fi 218 fi
204 219
205 if [ "${ESVN_BOOTSTRAP}" ]; then 220 if [ "${ESVN_BOOTSTRAP}" ]; then
206 einfo "begin bootstrap -->" 221 einfo "begin bootstrap -->"
222
207 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then 223 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
208 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}" 224 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
209 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP." 225 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
210 226
211 else 227 else
212 einfo " bootstrap with command: ESVN_BOOTSTRAP" 228 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
213 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP." 229 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
214 230
215 fi 231 fi
216 fi 232 fi
217 233
218} 234}
219 235
220 236
221## -- subversion_src_unpack() ------------------------------------------------ # 237## -- subversion_src_unpack() ------------------------------------------------ #
222 238
223subversion_src_unpack() { 239function subversion_src_unpack() {
224 240
225 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()." 241 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
226 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()." 242 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
227 243
228} 244}

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

  ViewVC Help
Powered by ViewVC 1.1.20