/[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.24
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.24 2005/09/21 23:32:21 vapier 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|https)
93 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) ;;
94 *) 118 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 119 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
96 ;; 120 ;;
97 esac 121 esac
98 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
99 # every time 135 # every time
136 addwrite "/etc/subversion"
100 addwrite "${ESVN_STORE_DIR}" 137 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 138
103 # -userpriv 139 # -userpriv
104 addwrite "/root/.subversion" 140 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
105 141
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then 142 [ -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##*/}" 143 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
122 144
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 145 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
124 # first check out 146 # first check out
125 einfo "subversion check out start -->" 147 einfo "subversion check out start -->"
126 einfo
127 einfo "check out from: ${ESVN_REPO_URI}" 148 einfo " checkout from: ${ESVN_REPO_URI}"
128 149
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 150 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}." 151 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 152 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 153 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
154
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 155 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 156
135 else 157 else
136 # update working copy 158 # update working copy
137 einfo "subversion update start -->" 159 einfo "subversion update start -->"
138 einfo
139 einfo " update from: ${ESVN_REPO_URI}" 160 einfo " update from: ${ESVN_REPO_URI}"
140
141 cd "${ESVN_CO_DIR}" 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
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 165 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
166
167 else
168 echo "Skip updating..."
169
170 fi
171
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 172 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 173
146 # permission fix 174 fi
147 chmod -Rf o+rw .
148 175
149 # copy to the ${WORKDIR} 176 # copy to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 177 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
151 einfo 178 einfo " copied to: ${S}"
179 echo
152 180
153} 181}
154 182
155 183
156## -- subversion_bootstrap() ------------------------------------------------ # 184## -- subversion_bootstrap() ------------------------------------------------ #
157 185
158subversion_bootstrap() { 186function subversion_bootstrap() {
159 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
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 214 if [ "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 215 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_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
166 fi 225 fi
167
168 fi 226 fi
169 227
170} 228}
171 229
172 230
173## -- subversion_src_unpack() ------------------------------------------------ # 231## -- subversion_src_unpack() ------------------------------------------------ #
174 232
175subversion_src_unpack() { 233function subversion_src_unpack() {
176 234
235 if [[ -n ${A} ]] ; then
236 unpack ${A}
237 fi
238
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 239 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 240 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 241
180} 242}

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

  ViewVC Help
Powered by ViewVC 1.1.20