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

Diff of /eclass/subversion.eclass

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

Revision 1.1 Revision 1.1.1.1
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.1 2004/01/25 12:27:18 hattya Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.1.1.1 2005/11/30 09:59:21 chriswhite 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="${DISTDIR}/svn-src"
48 49
49 50
50## -- ESVN_REPO_URI: repository uri 51## -- ESVN_REPO_URI: repository uri
51# 52#
52# e.g. http://foo/trunk, svn://bar/trunk 53# e.g. http://foo/trunk, svn://bar/trunk
53# but currentry support http only. 54#
55# supported protocols:
56# http://
57# https://
58# svn://
54# 59#
55[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 60[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
56 61
57 62
58## -- ESVN_PROJECT: project name of your ebuild 63## -- ESVN_PROJECT: project name of your ebuild
72[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 77[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
73 78
74 79
75## -- ESVN_BOOTSTRAP: 80## -- ESVN_BOOTSTRAP:
76# 81#
77# bootstrap script. like autogen.sh or etc.. 82# bootstrap script or command like autogen.sh or etc..
78# 83#
79[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 84[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
80 85
81 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
82## -- subversion_svn_fetch() ------------------------------------------------- # 101## -- subversion_svn_fetch() ------------------------------------------------- #
83 102
84subversion_svn_fetch() { 103function subversion_svn_fetch() {
85 104
86 # http only... 105 # ESVN_REPO_URI is empty.
87 if [ "${ESVN_REPO_URI%%:*}" != "http" ]; then 106 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
88 if [ -z "${ESVN_REPO_URI}" ]; then
89 die "subversion.eclass: ESVN_REPO_URI is not empty."
90 107
91 elif [ "${ESVN_REPO_URI}" = "none" ]; then 108 # check for the protocol.
92 die "subversion.eclass: ESVN_REPO_URI is not define." 109 case ${ESVN_REPO_URI%%:*} in
93 110 http|https)
94 else 111 if built_with_use dev-util/subversion nowebdav ; then
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 112 eerror "In order to emerge this package, you need to"
96 113 eerror "re-emerge subversion with USE=-nowebdav"
114 die "Please run 'USE=-nowebdav emerge subversion'"
97 fi 115 fi
98 fi 116 ;;
117 svn) ;;
118 *)
119 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
120 ;;
121 esac
99 122
100 if [ ! -d "${ESVN_STORE_DIR}" ]; then 123 if [ ! -d "${ESVN_STORE_DIR}" ]; then
101 mkdir -p "${ESVN_STORE_DIR}" 124 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
102 einfo "created store directory: ${ESVN_STORE_DIR}"
103 einfo
104 fi
105 125
106 cd "${ESVN_STORE_DIR}" 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
135 # every time
107 addwrite "/etc/subversion" 136 addwrite "/etc/subversion"
108 einfo 137 addwrite "${ESVN_STORE_DIR}"
109 138
110 if [ -z ${ESVN_REPO_URI##*/} ]; then 139 # -userpriv
111 ESVN_REPO_FIX="${ESVN_REPO_FIX%/}" 140 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
112 fi
113 141
142 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
114 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}" 143 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
115 144
116 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 145 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
117 # first check out 146 # first check out
118 einfo "subversion check out start -->" 147 einfo "subversion check out start -->"
119 einfo
120 einfo "check out from: ${ESVN_REPO_URI}" 148 einfo " checkout from: ${ESVN_REPO_URI}"
121 149
122 mkdir -p "${ESVN_PROJECT}" 150 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
151 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
123 cd "${ESVN_PROJECT}" 152 cd "${ESVN_PROJECT}"
153 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
124 154
125 #${ESVN_FETCH_CMD} "${ESVN_REPO_URI}"
126 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 155 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
127 156
128 else 157 else
129 # update working copy 158 # update working copy
130 einfo "subversion update start -->" 159 einfo "subversion update start -->"
131 einfo
132 einfo " update from: ${ESVN_REPO_URI}" 160 einfo " update from: ${ESVN_REPO_URI}"
133
134 cd "${ESVN_CO_DIR}" 161 cd "${ESVN_CO_DIR}"
135 #${ESVN_UPDATE_CMD} 162
163 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
164 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
165 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
166
167 else
168 echo "Skip updating..."
169
170 fi
171
136 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 172 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
173
137 fi 174 fi
138 175
139 # copy to the ${WORKDIR} 176 # copy to the ${WORKDIR}
140 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" 177 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
141 einfo 178 einfo " copied to: ${S}"
179 echo
142 180
143} 181}
144 182
145 183
146## -- subversion_bootstrap() ------------------------------------------------ # 184## -- subversion_bootstrap() ------------------------------------------------ #
147 185
148subversion_bootstrap() { 186function subversion_bootstrap() {
149 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
150 if [ -n "${ESVN_BOOTSTRAP}" ]; then 214 if [ "${ESVN_BOOTSTRAP}" ]; then
151 cd "${WORKDIR}/${P}" 215 einfo "begin bootstrap -->"
152 216
153 if [ -x "${ESVN_BOOTSTRAP}" ]; then 217 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
154 ./${ESVN_BOOTSTRAP} 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
155 fi 225 fi
156
157 fi 226 fi
158 227
159} 228}
160 229
161 230
162## -- subversion_src_unpack() ------------------------------------------------ # 231## -- subversion_src_unpack() ------------------------------------------------ #
163 232
164subversion_src_unpack() { 233function subversion_src_unpack() {
165 234
166 subversion_svn_fetch 235 if [[ -n ${A} ]] ; then
167 subversion_bootstrap 236 unpack ${A}
237 fi
238
239 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
240 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
168 241
169} 242}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.1.1

  ViewVC Help
Powered by ViewVC 1.1.20