/[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.25
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.25 2005/12/24 14:18:18 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" 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"
36 36
37 37
38## -- ESVN_FETCH_CMD: subversion fetch command 38## -- ESVN_FETCH_CMD: subversion fetch command
39# 39#
40# default: svn checkout 40ESVN_FETCH_CMD="svn checkout"
41#
42[ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
43 41
44## -- ESVN_UPDATE_CMD: subversion update command 42## -- ESVN_UPDATE_CMD: subversion update command
45# 43#
46# default: svn update 44ESVN_UPDATE_CMD="svn update"
45
46
47## -- ESVN_OPTIONS:
47# 48#
48[ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update" 49# the options passed to checkout or update.
50#
51[ -z "${ESVN_OPTIONS}" ] && ESVN_OPTIONS=
49 52
50 53
51## -- ESVN_REPO_URI: repository uri 54## -- ESVN_REPO_URI: repository uri
52# 55#
53# e.g. http://foo/trunk, svn://bar/trunk 56# e.g. http://foo/trunk, svn://bar/trunk
54# but currentry support http and https only. 57#
58# supported protocols:
59# http://
60# https://
61# svn://
55# 62#
56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 63[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
57 64
58 65
59## -- ESVN_PROJECT: project name of your ebuild 66## -- ESVN_PROJECT: project name of your ebuild
73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 80[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
74 81
75 82
76## -- ESVN_BOOTSTRAP: 83## -- ESVN_BOOTSTRAP:
77# 84#
78# bootstrap script. like autogen.sh or etc.. 85# bootstrap script or command like autogen.sh or etc..
79# 86#
80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 87[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
81 88
82 89
90## -- ESVN_PATCHES:
91#
92# subversion eclass can apply pathces in subversion_bootstrap().
93# you can use regexp in this valiable like *.diff or *.patch or etc.
94# NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
95#
96# the process of applying the patch is:
97# 1. just epatch it, if the patch exists in the path.
98# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
99# 3. die.
100#
101[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
102
103
83## -- subversion_svn_fetch() ------------------------------------------------- # 104## -- subversion_svn_fetch() ------------------------------------------------- #
84 105
85subversion_svn_fetch() { 106function subversion_svn_fetch() {
107
108 local ESVN_CO_DIR
86 109
87 # ESVN_REPO_URI is empty. 110 # ESVN_REPO_URI is empty.
88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty." 111 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
89 112
90 # http and https only... 113 # check for the protocol.
91 case ${ESVN_REPO_URI%%:*} in 114 case ${ESVN_REPO_URI%%:*} in
92 http) ;; 115 http|https)
93 https) ;; 116 if built_with_use dev-util/subversion nowebdav; then
117 eerror "In order to emerge this package, you need to"
118 eerror "re-emerge subversion with USE=-nowebdav"
119 die "Please run 'USE=-nowebdav emerge subversion'"
120 fi
121 ;;
122 svn) ;;
94 *) 123 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
96 ;; 125 ;;
97 esac 126 esac
98 127
128 if [ ! -d "${ESVN_STORE_DIR}" ]; then
129 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
130
131 addwrite /
132 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
133 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
134 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
135 fi
136
137 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138 ESVN_STORE_DIR=${PWD}
139
99 # every time 140 # every time
141 addwrite "/etc/subversion"
100 addwrite "${ESVN_STORE_DIR}" 142 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion"
102 143
144 if ! has userpriv ${FEATURES}; then
103 # -userpriv 145 # -userpriv
104 addwrite "/root/.subversion" 146 addwrite "/root/.subversion"
105 147
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then
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 148 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}" 149 # +userpriv
119 fi 150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
120 151
152 fi
153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}" 155 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
156
157 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
122 158
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
124 # first check out 160 # first check out
125 einfo "subversion check out start -->" 161 einfo "subversion check out start -->"
126 einfo
127 einfo "check out from: ${ESVN_REPO_URI}" 162 einfo " checkout from: ${ESVN_REPO_URI}"
128 163
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 164 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}." 165 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 166 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 167 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
168
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 169 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 170
135 else 171 else
136 # update working copy 172 # update working copy
137 einfo "subversion update start -->" 173 einfo "subversion update start -->"
138 einfo
139 einfo " update from: ${ESVN_REPO_URI}" 174 einfo " update from: ${ESVN_REPO_URI}"
140 175
141 cd "${ESVN_CO_DIR}" 176 cd "${ESVN_CO_DIR}"
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 177 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
178
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 179 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 180
146 # permission fix 181 fi
147 chmod -Rf o+rw .
148 182
149 # copy to the ${WORKDIR} 183 # export to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 184 svn export "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't exportto ${S}."
151 einfo 185 einfo " exported to: ${S}"
186 echo
152 187
153} 188}
154 189
155 190
156## -- subversion_bootstrap() ------------------------------------------------ # 191## -- subversion_bootstrap() ------------------------------------------------ #
157 192
158subversion_bootstrap() { 193function subversion_bootstrap() {
159 194
195 local patch lpatch
196
197 cd "${S}"
198
199 if [ "${ESVN_PATCHES}" ]; then
200 einfo "apply patches -->"
201
202 for patch in ${ESVN_PATCHES}; do
203 if [ -f "${patch}" ]; then
204 epatch ${patch}
205
206 else
207 for lpatch in ${FILESDIR}/${patch}; do
208 if [ -f "${lpatch}" ]; then
209 epatch ${lpatch}
210
211 else
212 die "${ESVN}; ${patch} is not found"
213
214 fi
215 done
216 fi
217 done
218 echo
219 fi
220
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 221 if [ "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 222 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_BOOTSTRAP}." 223
224 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
225 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
226 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
227
228 else
229 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
230 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
231
166 fi 232 fi
167
168 fi 233 fi
169 234
170} 235}
171 236
172 237
173## -- subversion_src_unpack() ------------------------------------------------ # 238## -- subversion_src_unpack() ------------------------------------------------ #
174 239
175subversion_src_unpack() { 240function subversion_src_unpack() {
176 241
242 if [ -n "${A}" ]; then
243 unpack ${A}
244 fi
245
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 246 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 247 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 248
180} 249}

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

  ViewVC Help
Powered by ViewVC 1.1.20