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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download)
Sun May 15 08:25:23 2005 UTC (9 years, 1 month ago) by hattya
Branch: MAIN
Changes since 1.19: +2 -2 lines
fixes bug #92611

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.19 2005/05/05 14:55:23 hattya Exp $
4
5 ## --------------------------------------------------------------------------- #
6 # Author: Akinori Hattori <hattya@gentoo.org>
7 #
8 # The subversion eclass is written to fetch the software sources from
9 # subversion repositories like the cvs eclass.
10 #
11 #
12 # Description:
13 # If you use this eclass, the ${S} is ${WORKDIR}/${P}.
14 # It is necessary to define the ESVN_REPO_URI variable at least.
15 #
16 ## --------------------------------------------------------------------------- #
17
18 inherit eutils
19
20 ECLASS="subversion"
21 INHERITED="${INHERITED} ${ECLASS}"
22 ESVN="subversion.eclass"
23
24 EXPORT_FUNCTIONS src_unpack
25
26 HOMEPAGE="http://subversion.tigris.org/"
27 DESCRIPTION="Based on the ${ECLASS} eclass"
28
29
30 ## -- add subversion in DEPEND
31 #
32 DEPEND="dev-util/subversion"
33
34
35 ## -- ESVN_STORE_DIR: subversion sources store directory
36 #
37 ESVN_STORE_DIR="${DISTDIR}/svn-src"
38
39
40 ## -- ESVN_FETCH_CMD: subversion fetch command
41 #
42 # default: svn checkout
43 #
44 [ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
45
46 ## -- ESVN_UPDATE_CMD: subversion update command
47 #
48 # default: svn update
49 #
50 [ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update"
51
52
53 ## -- ESVN_REPO_URI: repository uri
54 #
55 # e.g. http://foo/trunk, svn://bar/trunk
56 #
57 # supported protocols:
58 # http://
59 # https://
60 # svn://
61 #
62 [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
63
64
65 ## -- ESVN_PROJECT: project name of your ebuild
66 #
67 # subversion eclass will check out the subversion repository like:
68 #
69 # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
70 #
71 # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
72 # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
73 # it will check out like:
74 #
75 # ${ESVN_STORE_DIR}/subversion/trunk
76 #
77 # default: ${PN/-svn}.
78 #
79 [ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
80
81
82 ## -- ESVN_BOOTSTRAP:
83 #
84 # bootstrap script or command like autogen.sh or etc..
85 #
86 [ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
87
88
89 ## -- ESVN_PATCHES:
90 #
91 # subversion eclass can apply pathces in subversion_bootstrap().
92 # you can use regexp in this valiable like *.diff or *.patch or etc.
93 # NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
94 #
95 # the process of applying the patch is:
96 # 1. just epatch it, if the patch exists in the path.
97 # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
98 # 3. die.
99 #
100 [ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
101
102
103 ## -- subversion_svn_fetch() ------------------------------------------------- #
104
105 function subversion_svn_fetch() {
106
107 # ESVN_REPO_URI is empty.
108 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
109
110 # check for the protocol.
111 case ${ESVN_REPO_URI%%:*} in
112 http) ;;
113 https) ;;
114 svn) ;;
115 *)
116 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
117 ;;
118 esac
119
120 if [ ! -d "${ESVN_STORE_DIR}" ]; then
121 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
122
123 addwrite /
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 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
127 fi
128
129 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
130 ESVN_STORE_DIR=${PWD}
131
132 # every time
133 addwrite "/etc/subversion"
134 addwrite "${ESVN_STORE_DIR}"
135
136 # -userpriv
137 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
138
139 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
140 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
141
142 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
143 # first check out
144 einfo "subversion check out start -->"
145 einfo " checkout from: ${ESVN_REPO_URI}"
146
147 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
148 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
149 cd "${ESVN_PROJECT}"
150 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
151
152 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
153
154 else
155 # update working copy
156 einfo "subversion update start -->"
157 einfo " update from: ${ESVN_REPO_URI}"
158 cd "${ESVN_CO_DIR}"
159
160 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
161 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
162 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
163
164 else
165 echo "Skip updating..."
166
167 fi
168
169 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
170
171 fi
172
173 # copy to the ${WORKDIR}
174 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
175 einfo " copied to: ${S}"
176 echo
177
178 }
179
180
181 ## -- subversion_bootstrap() ------------------------------------------------ #
182
183 function subversion_bootstrap() {
184
185 local patch lpatch
186
187 cd "${S}"
188
189 if [ "${ESVN_PATCHES}" ]; then
190 einfo "apply patches -->"
191
192 for patch in ${ESVN_PATCHES}; do
193 if [ -f "${patch}" ]; then
194 epatch ${patch}
195
196 else
197 for lpatch in ${FILESDIR}/${patch}; do
198 if [ -f "${lpatch}" ]; then
199 epatch ${lpatch}
200
201 else
202 die "${ESVN}; ${patch} is not found"
203
204 fi
205 done
206 fi
207 done
208 echo
209 fi
210
211 if [ "${ESVN_BOOTSTRAP}" ]; then
212 einfo "begin bootstrap -->"
213
214 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
215 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
216 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
217
218 else
219 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
220 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
221
222 fi
223 fi
224
225 }
226
227
228 ## -- subversion_src_unpack() ------------------------------------------------ #
229
230 function subversion_src_unpack() {
231
232 if [ "${A}" != "" ]; then
233 unpack ${A}
234 fi
235
236 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
237 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
238
239 }

  ViewVC Help
Powered by ViewVC 1.1.20