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

Diff of /eclass/subversion.eclass

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

Revision 1.4 Revision 1.31
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2006 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.4 2004/02/08 14:37:59 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.31 2006/04/30 09:26:56 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"
25 26
26 27
27## -- add subversion in DEPEND 28## -- add subversion in DEPEND
28# 29#
29newdepend "dev-util/subversion" 30DEPEND="dev-util/subversion"
30 31
31 32
32## -- ESVN_STORE_DIR: subversion sources store directory 33## -- ESVN_STORE_DIR: subversion sources store directory
33# 34#
34ESVN_STORE_DIR="${DISTDIR}/svn-src" 35ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
35 36
36 37
37## -- ESVN_FETCH_CMD: subversion fetch command 38## -- ESVN_FETCH_CMD: subversion fetch command
38# 39#
39# default: svn checkout 40ESVN_FETCH_CMD="svn checkout"
40#
41[ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
42 41
43## -- ESVN_UPDATE_CMD: subversion update command 42## -- ESVN_UPDATE_CMD: subversion update command
44# 43#
45# default: svn update 44ESVN_UPDATE_CMD="svn update"
45
46
47## -- ESVN_OPTIONS:
46# 48#
47[ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update" 49# the options passed to checkout or update.
50#
51[ -z "${ESVN_OPTIONS}" ] && ESVN_OPTIONS=
48 52
49 53
50## -- ESVN_REPO_URI: repository uri 54## -- ESVN_REPO_URI: repository uri
51# 55#
52# e.g. http://foo/trunk, svn://bar/trunk 56# e.g. http://foo/trunk, svn://bar/trunk
53# but currentry support http only. 57#
58# supported protocols:
59# http://
60# https://
61# svn://
54# 62#
55[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 63[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
56 64
57 65
58## -- ESVN_PROJECT: project name of your ebuild 66## -- ESVN_PROJECT: project name of your ebuild
72[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 80[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
73 81
74 82
75## -- ESVN_BOOTSTRAP: 83## -- ESVN_BOOTSTRAP:
76# 84#
77# bootstrap script. like autogen.sh or etc.. 85# bootstrap script or command like autogen.sh or etc..
78# 86#
79[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 87[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
80 88
81 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
82## -- subversion_svn_fetch() ------------------------------------------------- # 104## -- subversion_svn_fetch() ------------------------------------------------- #
83 105
84subversion_svn_fetch() { 106function subversion_svn_fetch() {
85 107
86 # http only... 108 local ESVN_CO_DIR
87 if [ "${ESVN_REPO_URI%%:*}" != "http" ]; then
88 if [ -z "${ESVN_REPO_URI}" ]; then
89 die "subversion.eclass: ESVN_REPO_URI is empty."
90 109
91 else 110 # ESVN_REPO_URI is empty.
92 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 111 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
93 112
113 # check for the protocol.
114 case ${ESVN_REPO_URI%%:*} in
115 http|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'"
94 fi 120 fi
95 fi 121 ;;
122 svn) ;;
123 *)
124 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
125 ;;
126 esac
96 127
97 if [ ! -d "${ESVN_STORE_DIR}" ]; then 128 if [ ! -d "${ESVN_STORE_DIR}" ]; then
98 # I don't know why this causes access violation. 129 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
99 addwrite "${ESVN_STORE_DIR}"
100 130
131 addwrite /
101 mkdir -p "${ESVN_STORE_DIR}" || die "subversion.eclass: can't mkdir ${ESVN_STORE_DIR}." 132 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
102 einfo "created store directory: ${ESVN_STORE_DIR}" 133 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
103 einfo 134 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
104 fi 135 fi
105 136
106 cd "${ESVN_STORE_DIR}" || die "subversion.eclass: can't cd to ${ESVN_STORE_DIR}." 137 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138 ESVN_STORE_DIR=${PWD}
107 139
108 # every time 140 # every time
109 addwrite "/etc/subversion" 141 addwrite "/etc/subversion"
142 addwrite "${ESVN_STORE_DIR}"
110 143
144 if ! has userpriv ${FEATURES}; then
111 # -userpriv 145 # -userpriv
112 addwrite "/root/.subversion" 146 addwrite "/root/.subversion"
113 147
114 einfo 148 else
149 # +userpriv
150 ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
115 151
116 if [ -z ${ESVN_REPO_URI##*/} ]; then
117 ESVN_REPO_FIX="${ESVN_REPO_FIX%/}"
118 fi 152 fi
119 153
154 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
120 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}" 155 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
156
157 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
121 158
122 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 159 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
123 # first check out 160 # first check out
124 einfo "subversion check out start -->" 161 einfo "subversion check out start -->"
125 einfo
126 einfo "check out from: ${ESVN_REPO_URI}" 162 einfo " repository: ${ESVN_REPO_URI}"
127 163
128 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 164 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
129 cd "${ESVN_PROJECT}" || die "subversion.eclass: can't cd to ${ESVN_PROJECT}." 165 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
130 166 cd "${ESVN_PROJECT}"
131 ${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}."
132 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
133 168
134 else 169 else
135 # update working copy 170 # update working copy
136 einfo "subversion update start -->" 171 einfo "subversion update start -->"
137 einfo
138 einfo " update from: ${ESVN_REPO_URI}" 172 einfo " repository: ${ESVN_REPO_URI}"
139 173
140 cd "${ESVN_CO_DIR}" || die "subversion.eclass: can't cd to ${ESVN_CO_DIR}." 174 cd "${ESVN_CO_DIR}"
141 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 175 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
176
177 fi
178
142 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 179 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
143 fi
144 180
145 # copy to the ${WORKDIR} 181 # export to the ${WORKDIR}
146 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 182 # "svn export" has a bug. see http://bugs.gentoo.org/119236
147 einfo 183 #svn export "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't export to ${S}."
184 rsync -a --exclude=".svn/" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}."
185 echo
148 186
149} 187}
150 188
151 189
152## -- subversion_bootstrap() ------------------------------------------------ # 190## -- subversion_bootstrap() ------------------------------------------------ #
153 191
154subversion_bootstrap() { 192function subversion_bootstrap() {
155 193
194 local patch lpatch
195
196 cd "${S}"
197
198 if [ "${ESVN_PATCHES}" ]; then
199 einfo "apply patches -->"
200
201 for patch in ${ESVN_PATCHES}; do
202 if [ -f "${patch}" ]; then
203 epatch ${patch}
204
205 else
206 for lpatch in ${FILESDIR}/${patch}; do
207 if [ -f "${lpatch}" ]; then
208 epatch ${lpatch}
209
210 else
211 die "${ESVN}; ${patch} is not found"
212
213 fi
214 done
215 fi
216 done
217 echo
218 fi
219
156 if [ -n "${ESVN_BOOTSTRAP}" ]; then 220 if [ "${ESVN_BOOTSTRAP}" ]; then
157 cd "${WORKDIR}/${P}" 221 einfo "begin bootstrap -->"
158 222
159 if [ -x "${ESVN_BOOTSTRAP}" ]; then 223 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
160 ./${ESVN_BOOTSTRAP} 224 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
225 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
226
227 else
228 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
229 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
230
161 fi 231 fi
162
163 fi 232 fi
164 233
165} 234}
166 235
167 236
168## -- subversion_src_unpack() ------------------------------------------------ # 237## -- subversion_src_unpack() ------------------------------------------------ #
169 238
170subversion_src_unpack() { 239function subversion_src_unpack() {
171 240
172 subversion_svn_fetch 241 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
173 subversion_bootstrap 242 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
174 243
175} 244}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20