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

Diff of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 Revision 1.20
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.6 2004/03/01 16:34:42 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.20 2005/05/15 08:25:23 hattya Exp $
4 4
5## --------------------------------------------------------------------------- # 5## --------------------------------------------------------------------------- #
6# Author: Akinori Hattori <hattya@gentoo.org> 6# Author: Akinori Hattori <hattya@gentoo.org>
7# 7#
8# The subversion eclass is written to fetch the software sources from 8# The subversion eclass is written to fetch the software sources from
9# subversion repositories like the cvs eclass. 9# subversion repositories like the cvs eclass.
10# 10#
11# 11#
12# Description: 12# Description:
13# If you use this eclass, the ${S} is ${WORKDIR}/${P}. 13# If you use this eclass, the ${S} is ${WORKDIR}/${P}.
14# It is necessary to define the ESVN_REPOURI variable at least. 14# It is necessary to define the ESVN_REPO_URI variable at least.
15# 15#
16## --------------------------------------------------------------------------- # 16## --------------------------------------------------------------------------- #
17 17
18inherit eutils
18 19
19ECLASS="subversion" 20ECLASS="subversion"
20INHERITED="${INHERITED} ${ECLASS}" 21INHERITED="${INHERITED} ${ECLASS}"
22ESVN="subversion.eclass"
21 23
22EXPORT_FUNCTIONS src_unpack 24EXPORT_FUNCTIONS src_unpack
23 25
24HOMEPAGE="http://subversion.tigris.org/" 26HOMEPAGE="http://subversion.tigris.org/"
25DESCRIPTION="Based on the ${ECLASS} eclass" 27DESCRIPTION="Based on the ${ECLASS} eclass"
26 28
27 29
28## -- add subversion in DEPEND 30## -- add subversion in DEPEND
29# 31#
30newdepend "dev-util/subversion" 32DEPEND="dev-util/subversion"
31 33
32 34
33## -- ESVN_STORE_DIR: subversion sources store directory 35## -- ESVN_STORE_DIR: subversion sources store directory
34# 36#
35ESVN_STORE_DIR="${DISTDIR}/svn-src" 37ESVN_STORE_DIR="${DISTDIR}/svn-src"
49 51
50 52
51## -- ESVN_REPO_URI: repository uri 53## -- ESVN_REPO_URI: repository uri
52# 54#
53# e.g. http://foo/trunk, svn://bar/trunk 55# e.g. http://foo/trunk, svn://bar/trunk
54# but currentry support http and https only. 56#
57# supported protocols:
58# http://
59# https://
60# svn://
55# 61#
56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 62[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
57 63
58 64
59## -- ESVN_PROJECT: project name of your ebuild 65## -- ESVN_PROJECT: project name of your ebuild
73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 79[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
74 80
75 81
76## -- ESVN_BOOTSTRAP: 82## -- ESVN_BOOTSTRAP:
77# 83#
78# bootstrap script. like autogen.sh or etc.. 84# bootstrap script or command like autogen.sh or etc..
79# 85#
80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 86[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
81 87
82 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
83## -- subversion_svn_fetch() ------------------------------------------------- # 103## -- subversion_svn_fetch() ------------------------------------------------- #
84 104
85subversion_svn_fetch() { 105function subversion_svn_fetch() {
86 106
87 # ESVN_REPO_URI is empty. 107 # ESVN_REPO_URI is empty.
88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty." 108 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
89 109
90 # http and https only... 110 # check for the protocol.
91 case ${ESVN_REPO_URI%%:*} in 111 case ${ESVN_REPO_URI%%:*} in
92 http) ;; 112 http) ;;
93 https) ;; 113 https) ;;
114 svn) ;;
94 *) 115 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 116 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
96 ;; 117 ;;
97 esac 118 esac
98 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
99 # every time 132 # every time
133 addwrite "/etc/subversion"
100 addwrite "${ESVN_STORE_DIR}" 134 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 135
103 # -userpriv 136 # -userpriv
104 addwrite "/root/.subversion" 137 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
105 138
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then 139 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
107 mkdir -p "${ESVN_STORE_DIR}" || die "subversion.eclass: can't mkdir ${ESVN_STORE_DIR}."
108 chmod -f o+rw "${ESVN_STORE_DIR}" || die "subversion.eclass: can't chmod ${ESVN_STORE_DIR}."
109 einfo "created store directory: ${ESVN_STORE_DIR}"
110 einfo
111 fi
112
113 cd "${ESVN_STORE_DIR}"
114
115 if [ -z ${ESVN_REPO_URI##*/} ]; then
116 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
117 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}"
119 fi
120
121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}" 140 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
122 141
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 142 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
124 # first check out 143 # first check out
125 einfo "subversion check out start -->" 144 einfo "subversion check out start -->"
126 einfo
127 einfo "check out from: ${ESVN_REPO_URI}" 145 einfo " checkout from: ${ESVN_REPO_URI}"
128 146
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 147 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
130 chmod -f o+rw "${ESVN_PROJECT}" || die "subversion.eclass: can't chmod ${ESVN_PROJECT}." 148 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 149 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 150 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
151
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 152 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 153
135 else 154 else
136 # update working copy 155 # update working copy
137 einfo "subversion update start -->" 156 einfo "subversion update start -->"
138 einfo
139 einfo " update from: ${ESVN_REPO_URI}" 157 einfo " update from: ${ESVN_REPO_URI}"
140
141 cd "${ESVN_CO_DIR}" 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
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 162 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
163
164 else
165 echo "Skip updating..."
166
167 fi
168
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 169 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 170
146 # permission fix 171 fi
147 chmod -Rf o+rw .
148 172
149 # copy to the ${WORKDIR} 173 # copy to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 174 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
151 einfo 175 einfo " copied to: ${S}"
176 echo
152 177
153} 178}
154 179
155 180
156## -- subversion_bootstrap() ------------------------------------------------ # 181## -- subversion_bootstrap() ------------------------------------------------ #
157 182
158subversion_bootstrap() { 183function subversion_bootstrap() {
159 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
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 211 if [ "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 212 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_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
166 fi 222 fi
167
168 fi 223 fi
169 224
170} 225}
171 226
172 227
173## -- subversion_src_unpack() ------------------------------------------------ # 228## -- subversion_src_unpack() ------------------------------------------------ #
174 229
175subversion_src_unpack() { 230function subversion_src_unpack() {
176 231
232 if [ "${A}" != "" ]; then
233 unpack ${A}
234 fi
235
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 236 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 237 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 238
180} 239}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20