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

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

  ViewVC Help
Powered by ViewVC 1.1.20