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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20