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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations) (download)
Wed Jul 6 20:23:20 2005 UTC (9 years, 5 months ago) by agriffis
Branch: MAIN
Changes since 1.21: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

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

  ViewVC Help
Powered by ViewVC 1.1.20