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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Mon Apr 5 14:25:28 2004 UTC (10 years, 5 months ago) by hattya
Branch: MAIN
Changes since 1.7: +76 -28 lines
update

1 # Copyright 1999-2004 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.7 2004/03/01 16:37:31 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_REPOURI 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 newdepend "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 # but currentry support http and https only.
57 #
58 [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
59
60
61 ## -- ESVN_PROJECT: project name of your ebuild
62 #
63 # subversion eclass will check out the subversion repository like:
64 #
65 # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
66 #
67 # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
68 # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
69 # it will check out like:
70 #
71 # ${ESVN_STORE_DIR}/subversion/trunk
72 #
73 # default: ${PN/-svn}.
74 #
75 [ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
76
77
78 ## -- ESVN_BOOTSTRAP:
79 #
80 # bootstrap script or command like autogen.sh or etc..
81 #
82 [ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
83
84
85 ## -- ESVN_PATCHES:
86 #
87 # subversion eclass can apply pathces in subversion_bootstrap().
88 # you can use regexp in this valiable like *.diff or *.patch or etc.
89 # NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
90 #
91 # the process of applying the patch is:
92 # 1. just epatch it, if the patch exists in the path.
93 # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
94 # 3. die.
95 #
96 [ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
97
98
99 ## -- subversion_svn_fetch() ------------------------------------------------- #
100
101 subversion_svn_fetch() {
102
103 # ESVN_REPO_URI is empty.
104 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
105
106 # http and https only...
107 case ${ESVN_REPO_URI%%:*} in
108 http) ;;
109 https) ;;
110 *)
111 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
112 ;;
113 esac
114
115 # every time
116 addwrite "${ESVN_STORE_DIR}"
117 addwrite "/etc/subversion"
118
119 # -userpriv
120 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
121
122 if [ ! -d "${ESVN_STORE_DIR}" ]; then
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 einfo "created store directory: ${ESVN_STORE_DIR}"
126 einfo
127 fi
128
129 cd "${ESVN_STORE_DIR}"
130
131 if [ -z ${ESVN_REPO_URI##*/} ]; then
132 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
133 else
134 ESVN_REPO_FIX="${ESVN_REPO_URI}"
135 fi
136
137 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
138
139 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
140 # first check out
141 einfo "subversion check out start -->"
142 einfo " checkout from: ${ESVN_REPO_URI}"
143
144 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
145 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
146 cd "${ESVN_PROJECT}"
147 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
148 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
149
150 else
151 # update working copy
152 einfo "subversion update start -->"
153 einfo " update from: ${ESVN_REPO_URI}"
154 cd "${ESVN_CO_DIR}"
155
156 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
157 if expr ${NOW} - ${UPDATE} \> ${INTERVAL} >/dev/null; then
158 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
159 else
160 echo "Skip updating..."
161 fi
162
163 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
164
165 fi
166
167 # permission fix for NFS (root_squash) with -userpriv
168 find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
169
170 # copy to the ${WORKDIR}
171 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
172 einfo " copied to: ${S}"
173 echo
174
175 }
176
177
178 ## -- subversion_bootstrap() ------------------------------------------------ #
179
180 subversion_bootstrap() {
181
182 cd "${S}"
183
184 if [ "${ESVN_PATCHES}" ]; then
185 einfo "apply paches -->"
186 for PATCH in ${ESVN_PATCHES}; do
187 if [ -f "${PATCH}" ]; then
188 epatch ${PATCH}
189
190 else
191 for fPATCH in ${FILESDIR}/${PATCH}; do
192 if [ -f "${fPATCH}" ]; then
193 epatch ${fPATCH}
194
195 else
196 die "${ESVN}; ${PATCH} is not found"
197
198 fi
199 done
200 fi
201 done
202 echo
203 fi
204
205 if [ "${ESVN_BOOTSTRAP}" ]; then
206 einfo "begin bootstrap -->"
207 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
208 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
209 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
210
211 else
212 einfo " bootstrap with command: ESVN_BOOTSTRAP"
213 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
214
215 fi
216 fi
217
218 }
219
220
221 ## -- subversion_src_unpack() ------------------------------------------------ #
222
223 subversion_src_unpack() {
224
225 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
226 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
227
228 }

  ViewVC Help
Powered by ViewVC 1.1.20