/[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.23
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.23 2005/07/11 15:08:06 swegener 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" 20ESVN="subversion.eclass"
20INHERITED="${INHERITED} ${ECLASS}"
21 21
22EXPORT_FUNCTIONS src_unpack 22EXPORT_FUNCTIONS src_unpack
23 23
24HOMEPAGE="http://subversion.tigris.org/" 24HOMEPAGE="http://subversion.tigris.org/"
25DESCRIPTION="Based on the ${ECLASS} eclass" 25DESCRIPTION="Based on the ${ECLASS} eclass"
26 26
27 27
28## -- add subversion in DEPEND 28## -- add subversion in DEPEND
29# 29#
30newdepend "dev-util/subversion" 30DEPEND="dev-util/subversion"
31 31
32 32
33## -- ESVN_STORE_DIR: subversion sources store directory 33## -- ESVN_STORE_DIR: subversion sources store directory
34# 34#
35ESVN_STORE_DIR="${DISTDIR}/svn-src" 35ESVN_STORE_DIR="${DISTDIR}/svn-src"
49 49
50 50
51## -- ESVN_REPO_URI: repository uri 51## -- ESVN_REPO_URI: repository uri
52# 52#
53# e.g. http://foo/trunk, svn://bar/trunk 53# e.g. http://foo/trunk, svn://bar/trunk
54# but currentry support http and https only. 54#
55# supported protocols:
56# http://
57# https://
58# svn://
55# 59#
56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 60[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
57 61
58 62
59## -- ESVN_PROJECT: project name of your ebuild 63## -- ESVN_PROJECT: project name of your ebuild
73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 77[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
74 78
75 79
76## -- ESVN_BOOTSTRAP: 80## -- ESVN_BOOTSTRAP:
77# 81#
78# bootstrap script. like autogen.sh or etc.. 82# bootstrap script or command like autogen.sh or etc..
79# 83#
80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 84[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
81 85
82 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
83## -- subversion_svn_fetch() ------------------------------------------------- # 101## -- subversion_svn_fetch() ------------------------------------------------- #
84 102
85subversion_svn_fetch() { 103function subversion_svn_fetch() {
86 104
87 # ESVN_REPO_URI is empty. 105 # ESVN_REPO_URI is empty.
88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty." 106 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
89 107
90 # http and https only... 108 # check for the protocol.
91 case ${ESVN_REPO_URI%%:*} in 109 case ${ESVN_REPO_URI%%:*} in
92 http) ;; 110 http) ;;
93 https) ;; 111 https) ;;
112 svn) ;;
94 *) 113 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 114 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
96 ;; 115 ;;
97 esac 116 esac
98 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
99 # every time 130 # every time
131 addwrite "/etc/subversion"
100 addwrite "${ESVN_STORE_DIR}" 132 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 133
103 # -userpriv 134 # -userpriv
104 addwrite "/root/.subversion" 135 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
105 136
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then 137 [ -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##*/}" 138 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
122 139
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 140 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
124 # first check out 141 # first check out
125 einfo "subversion check out start -->" 142 einfo "subversion check out start -->"
126 einfo
127 einfo "check out from: ${ESVN_REPO_URI}" 143 einfo " checkout from: ${ESVN_REPO_URI}"
128 144
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 145 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}." 146 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 147 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 148 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
149
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 150 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 151
135 else 152 else
136 # update working copy 153 # update working copy
137 einfo "subversion update start -->" 154 einfo "subversion update start -->"
138 einfo
139 einfo " update from: ${ESVN_REPO_URI}" 155 einfo " update from: ${ESVN_REPO_URI}"
140
141 cd "${ESVN_CO_DIR}" 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
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 160 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
161
162 else
163 echo "Skip updating..."
164
165 fi
166
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 167 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 168
146 # permission fix 169 fi
147 chmod -Rf o+rw .
148 170
149 # copy to the ${WORKDIR} 171 # copy to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 172 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
151 einfo 173 einfo " copied to: ${S}"
174 echo
152 175
153} 176}
154 177
155 178
156## -- subversion_bootstrap() ------------------------------------------------ # 179## -- subversion_bootstrap() ------------------------------------------------ #
157 180
158subversion_bootstrap() { 181function subversion_bootstrap() {
159 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
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 209 if [ "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 210 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_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
166 fi 220 fi
167
168 fi 221 fi
169 222
170} 223}
171 224
172 225
173## -- subversion_src_unpack() ------------------------------------------------ # 226## -- subversion_src_unpack() ------------------------------------------------ #
174 227
175subversion_src_unpack() { 228function subversion_src_unpack() {
176 229
230 if [ "${A}" != "" ]; then
231 unpack ${A}
232 fi
233
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 234 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 235 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 236
180} 237}

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

  ViewVC Help
Powered by ViewVC 1.1.20