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

Diff of /eclass/subversion.eclass

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

Revision 1.1.1.1 Revision 1.6
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Technologies, Inc.
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.1.1.1 2005/11/30 09:59:21 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.6 2004/03/01 16:34:42 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_REPO_URI variable at least. 14# It is necessary to define the ESVN_REPOURI variable at least.
15# 15#
16## --------------------------------------------------------------------------- # 16## --------------------------------------------------------------------------- #
17 17
18inherit eutils
19 18
20ESVN="subversion.eclass" 19ECLASS="subversion"
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#
30DEPEND="dev-util/subversion" 30newdepend "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="${DISTDIR}/svn-src"
49 49
50 50
51## -- ESVN_REPO_URI: repository uri 51## -- ESVN_REPO_URI: repository uri
52# 52#
53# e.g. http://foo/trunk, svn://bar/trunk 53# e.g. http://foo/trunk, svn://bar/trunk
54# 54# but currentry support http and https only.
55# supported protocols:
56# http://
57# https://
58# svn://
59# 55#
60[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
61 57
62 58
63## -- ESVN_PROJECT: project name of your ebuild 59## -- ESVN_PROJECT: project name of your ebuild
77[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
78 74
79 75
80## -- ESVN_BOOTSTRAP: 76## -- ESVN_BOOTSTRAP:
81# 77#
82# bootstrap script or command like autogen.sh or etc.. 78# bootstrap script. like autogen.sh or etc..
83# 79#
84[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
85 81
86 82
87## -- ESVN_PATCHES:
88#
89# subversion eclass can apply pathces in subversion_bootstrap().
90# you can use regexp in this valiable like *.diff or *.patch or etc.
91# NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
92#
93# the process of applying the patch is:
94# 1. just epatch it, if the patch exists in the path.
95# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
96# 3. die.
97#
98[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
99
100
101## -- subversion_svn_fetch() ------------------------------------------------- # 83## -- subversion_svn_fetch() ------------------------------------------------- #
102 84
103function subversion_svn_fetch() { 85subversion_svn_fetch() {
104 86
105 # ESVN_REPO_URI is empty. 87 # ESVN_REPO_URI is empty.
106 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty." 88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty."
107 89
108 # check for the protocol. 90 # http and https only...
109 case ${ESVN_REPO_URI%%:*} in 91 case ${ESVN_REPO_URI%%:*} in
110 http|https) 92 http) ;;
111 if built_with_use dev-util/subversion nowebdav ; then 93 https) ;;
112 eerror "In order to emerge this package, you need to"
113 eerror "re-emerge subversion with USE=-nowebdav"
114 die "Please run 'USE=-nowebdav emerge subversion'"
115 fi
116 ;;
117 svn) ;;
118 *) 94 *)
119 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
120 ;; 96 ;;
121 esac 97 esac
122 98
99 # every time
100 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102
103 # -userpriv
104 addwrite "/root/.subversion"
105
123 if [ ! -d "${ESVN_STORE_DIR}" ]; then 106 if [ ! -d "${ESVN_STORE_DIR}" ]; then
124 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
125
126 addwrite /
127 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." 107 mkdir -p "${ESVN_STORE_DIR}" || die "subversion.eclass: can't mkdir ${ESVN_STORE_DIR}."
128 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}." 108 chmod -f o+rw "${ESVN_STORE_DIR}" || die "subversion.eclass: can't chmod ${ESVN_STORE_DIR}."
129 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" 109 einfo "created store directory: ${ESVN_STORE_DIR}"
110 einfo
130 fi 111 fi
131 112
132 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" 113 cd "${ESVN_STORE_DIR}"
133 ESVN_STORE_DIR=${PWD}
134 114
135 # every time 115 if [ -z ${ESVN_REPO_URI##*/} ]; then
136 addwrite "/etc/subversion" 116 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
137 addwrite "${ESVN_STORE_DIR}" 117 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}"
119 fi
138 120
139 # -userpriv
140 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
141
142 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
143 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}" 121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
144 122
145 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
146 # first check out 124 # first check out
147 einfo "subversion check out start -->" 125 einfo "subversion check out start -->"
126 einfo
148 einfo " checkout from: ${ESVN_REPO_URI}" 127 einfo "check out from: ${ESVN_REPO_URI}"
149 128
150 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}." 129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}."
151 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}." 130 chmod -f o+rw "${ESVN_PROJECT}" || die "subversion.eclass: can't chmod ${ESVN_PROJECT}."
152 cd "${ESVN_PROJECT}" 131 cd "${ESVN_PROJECT}"
153 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}." 132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}."
154
155 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
156 134
157 else 135 else
158 # update working copy 136 # update working copy
159 einfo "subversion update start -->" 137 einfo "subversion update start -->"
138 einfo
160 einfo " update from: ${ESVN_REPO_URI}" 139 einfo " update from: ${ESVN_REPO_URI}"
140
161 cd "${ESVN_CO_DIR}" 141 cd "${ESVN_CO_DIR}"
162
163 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
164 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
165 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}." 142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}."
166
167 else
168 echo "Skip updating..."
169
170 fi
171
172 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
173
174 fi 144 fi
175 145
146 # permission fix
147 chmod -Rf o+rw .
148
176 # copy to the ${WORKDIR} 149 # copy to the ${WORKDIR}
177 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}." 150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}."
178 einfo " copied to: ${S}" 151 einfo
179 echo
180 152
181} 153}
182 154
183 155
184## -- subversion_bootstrap() ------------------------------------------------ # 156## -- subversion_bootstrap() ------------------------------------------------ #
185 157
186function subversion_bootstrap() { 158subversion_bootstrap() {
187 159
188 local patch lpatch 160 if [ -n "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
189 162
190 cd "${S}" 163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_BOOTSTRAP}."
166 fi
191 167
192 if [ "${ESVN_PATCHES}" ]; then
193 einfo "apply patches -->"
194
195 for patch in ${ESVN_PATCHES}; do
196 if [ -f "${patch}" ]; then
197 epatch ${patch}
198
199 else
200 for lpatch in ${FILESDIR}/${patch}; do
201 if [ -f "${lpatch}" ]; then
202 epatch ${lpatch}
203
204 else
205 die "${ESVN}; ${patch} is not found"
206
207 fi
208 done
209 fi
210 done
211 echo
212 fi
213
214 if [ "${ESVN_BOOTSTRAP}" ]; then
215 einfo "begin bootstrap -->"
216
217 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
218 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
219 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
220
221 else
222 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
223 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
224
225 fi
226 fi 168 fi
227 169
228} 170}
229 171
230 172
231## -- subversion_src_unpack() ------------------------------------------------ # 173## -- subversion_src_unpack() ------------------------------------------------ #
232 174
233function subversion_src_unpack() { 175subversion_src_unpack() {
234 176
235 if [[ -n ${A} ]] ; then
236 unpack ${A}
237 fi
238
239 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()." 177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()."
240 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()." 178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()."
241 179
242} 180}

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

  ViewVC Help
Powered by ViewVC 1.1.20