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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed Nov 30 09:59:21 2005 UTC (8 years, 7 months ago) by chriswhite
Changes since 1.1: +121 -48 lines
*** empty log message ***

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.24 2005/09/21 23:32:21 vapier 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|https)
111 if built_with_use dev-util/subversion nowebdav ; then
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 *)
119 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
120 ;;
121 esac
122
123 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}."
128 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
129 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
130 fi
131
132 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
133 ESVN_STORE_DIR=${PWD}
134
135 # every time
136 addwrite "/etc/subversion"
137 addwrite "${ESVN_STORE_DIR}"
138
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##*/}"
144
145 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
146 # first check out
147 einfo "subversion check out start -->"
148 einfo " checkout from: ${ESVN_REPO_URI}"
149
150 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
151 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
152 cd "${ESVN_PROJECT}"
153 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
154
155 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
156
157 else
158 # update working copy
159 einfo "subversion update start -->"
160 einfo " update from: ${ESVN_REPO_URI}"
161 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}."
166
167 else
168 echo "Skip updating..."
169
170 fi
171
172 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
173
174 fi
175
176 # copy to the ${WORKDIR}
177 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
178 einfo " copied to: ${S}"
179 echo
180
181 }
182
183
184 ## -- subversion_bootstrap() ------------------------------------------------ #
185
186 function subversion_bootstrap() {
187
188 local patch lpatch
189
190 cd "${S}"
191
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
227
228 }
229
230
231 ## -- subversion_src_unpack() ------------------------------------------------ #
232
233 function subversion_src_unpack() {
234
235 if [[ -n ${A} ]] ; then
236 unpack ${A}
237 fi
238
239 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
240 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
241
242 }

  ViewVC Help
Powered by ViewVC 1.1.20