/[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.14
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2004 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.14 2004/06/25 00:39:48 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" 20ECLASS="subversion"
20INHERITED="${INHERITED} ${ECLASS}" 21INHERITED="${INHERITED} ${ECLASS}"
22ESVN="subversion.eclass"
21 23
22EXPORT_FUNCTIONS src_unpack 24EXPORT_FUNCTIONS src_unpack
23 25
24HOMEPAGE="http://subversion.tigris.org/" 26HOMEPAGE="http://subversion.tigris.org/"
25DESCRIPTION="Based on the ${ECLASS} eclass" 27DESCRIPTION="Based on the ${ECLASS} eclass"
26 28
27 29
28## -- add subversion in DEPEND 30## -- add subversion in DEPEND
29# 31#
30newdepend "dev-util/subversion" 32DEPEND="dev-util/subversion"
31 33
32 34
33## -- ESVN_STORE_DIR: subversion sources store directory 35## -- ESVN_STORE_DIR: subversion sources store directory
34# 36#
35ESVN_STORE_DIR="${DISTDIR}/svn-src" 37ESVN_STORE_DIR="${DISTDIR}/svn-src"
49 51
50 52
51## -- ESVN_REPO_URI: repository uri 53## -- ESVN_REPO_URI: repository uri
52# 54#
53# e.g. http://foo/trunk, svn://bar/trunk 55# e.g. http://foo/trunk, svn://bar/trunk
54# but currentry support http and https only. 56#
57# supported protocols:
58# http://
59# https://
60# svn://
55# 61#
56[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="" 62[ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
57 63
58 64
59## -- ESVN_PROJECT: project name of your ebuild 65## -- ESVN_PROJECT: project name of your ebuild
73[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}" 79[ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
74 80
75 81
76## -- ESVN_BOOTSTRAP: 82## -- ESVN_BOOTSTRAP:
77# 83#
78# bootstrap script. like autogen.sh or etc.. 84# bootstrap script or command like autogen.sh or etc..
79# 85#
80[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP="" 86[ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
81 87
82 88
89## -- ESVN_PATCHES:
90#
91# subversion eclass can apply pathces in subversion_bootstrap().
92# you can use regexp in this valiable like *.diff or *.patch or etc.
93# NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
94#
95# the process of applying the patch is:
96# 1. just epatch it, if the patch exists in the path.
97# 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
98# 3. die.
99#
100[ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
101
102
83## -- subversion_svn_fetch() ------------------------------------------------- # 103## -- subversion_svn_fetch() ------------------------------------------------- #
84 104
85subversion_svn_fetch() { 105subversion_svn_fetch() {
86 106
87 # ESVN_REPO_URI is empty. 107 # ESVN_REPO_URI is empty.
88 [ -z "${ESVN_REPO_URI}" ] && die "subversion.eclass: ESVN_REPO_URI is empty." 108 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
89 109
90 # http and https only... 110 # check for the protocol.
91 case ${ESVN_REPO_URI%%:*} in 111 case ${ESVN_REPO_URI%%:*} in
92 http) ;; 112 http) ;;
93 https) ;; 113 https) ;;
114 svn) ;;
94 *) 115 *)
95 die "subversion.eclass: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented." 116 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
96 ;; 117 ;;
97 esac 118 esac
98 119
99 # every time 120 # every time
100 addwrite "${ESVN_STORE_DIR}" 121 addwrite "${ESVN_STORE_DIR}"
101 addwrite "/etc/subversion" 122 addwrite "/etc/subversion"
102 123
103 # -userpriv 124 # -userpriv
104 addwrite "/root/.subversion" 125 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
105 126
106 if [ ! -d "${ESVN_STORE_DIR}" ]; then 127 if [ ! -d "${ESVN_STORE_DIR}" ]; then
107 mkdir -p "${ESVN_STORE_DIR}" || die "subversion.eclass: can't mkdir ${ESVN_STORE_DIR}." 128 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
108 chmod -f o+rw "${ESVN_STORE_DIR}" || die "subversion.eclass: can't chmod ${ESVN_STORE_DIR}." 129 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
130
109 einfo "created store directory: ${ESVN_STORE_DIR}" 131 einfo "created store directory: ${ESVN_STORE_DIR}"
110 einfo 132 einfo
111 fi 133 fi
112 134
113 cd "${ESVN_STORE_DIR}" 135 cd "${ESVN_STORE_DIR}"
114 136
115 if [ -z ${ESVN_REPO_URI##*/} ]; then 137 if [ -z "${ESVN_REPO_URI##*/}" ]; then
116 ESVN_REPO_FIX="${ESVN_REPO_URI%/}" 138 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
139
117 else 140 else
118 ESVN_REPO_FIX="${ESVN_REPO_URI}" 141 ESVN_REPO_FIX="${ESVN_REPO_URI}"
142
119 fi 143 fi
120 144
121 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}" 145 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
122 146
123 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then 147 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
124 # first check out 148 # first check out
125 einfo "subversion check out start -->" 149 einfo "subversion check out start -->"
126 einfo
127 einfo "check out from: ${ESVN_REPO_URI}" 150 einfo " checkout from: ${ESVN_REPO_URI}"
128 151
129 mkdir -p "${ESVN_PROJECT}" || die "subversion.eclass: can't mkdir ${ESVN_PROJECT}." 152 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}." 153 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
131 cd "${ESVN_PROJECT}" 154 cd "${ESVN_PROJECT}"
132 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "subversion.eclass: can't fetch from ${ESVN_REPO_URI}." 155 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
156
133 einfo " stored in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 157 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
134 158
135 else 159 else
136 # update working copy 160 # update working copy
137 einfo "subversion update start -->" 161 einfo "subversion update start -->"
138 einfo
139 einfo " update from: ${ESVN_REPO_URI}" 162 einfo " update from: ${ESVN_REPO_URI}"
140
141 cd "${ESVN_CO_DIR}" 163 cd "${ESVN_CO_DIR}"
164
165 local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
166 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
142 ${ESVN_UPDATE_CMD} || die "subversion.eclass: can't update from ${ESVN_REPO_URI}." 167 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
168
169 else
170 echo "Skip updating..."
171
172 fi
173
143 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}" 174 einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
144 fi
145 175
146 # permission fix 176 fi
147 chmod -Rf o+rw . 177
178 # permission fix for NFS (root_squash) with -userpriv
179 find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
148 180
149 # copy to the ${WORKDIR} 181 # copy to the ${WORKDIR}
150 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${WORKDIR}/${P}" || die "subversion.eclass: can't copy to ${WORKDIR}/${P}." 182 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
151 einfo 183 einfo " copied to: ${S}"
184 echo
152 185
153} 186}
154 187
155 188
156## -- subversion_bootstrap() ------------------------------------------------ # 189## -- subversion_bootstrap() ------------------------------------------------ #
157 190
158subversion_bootstrap() { 191subversion_bootstrap() {
159 192
193 cd "${S}"
194
195 if [ "${ESVN_PATCHES}" ]; then
196 einfo "apply paches -->"
197
198 for PATCH in ${ESVN_PATCHES}; do
199 if [ -f "${PATCH}" ]; then
200 epatch ${PATCH}
201
202 else
203 for fPATCH in ${FILESDIR}/${PATCH}; do
204 if [ -f "${fPATCH}" ]; then
205 epatch ${fPATCH}
206
207 else
208 die "${ESVN}; ${PATCH} is not found"
209
210 fi
211 done
212 fi
213 done
214 echo
215 fi
216
160 if [ -n "${ESVN_BOOTSTRAP}" ]; then 217 if [ "${ESVN_BOOTSTRAP}" ]; then
161 cd "${WORKDIR}/${P}"
162
163 if [ -x "${ESVN_BOOTSTRAP}" ]; then
164 einfo "begin bootstrap -->" 218 einfo "begin bootstrap -->"
165 ./${ESVN_BOOTSTRAP} || die "subversion.eclass: can't bootstrap with ${ESVN_BOOTSTRAP}." 219
220 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
221 einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
222 eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
223
224 else
225 einfo " bootstrap with command: ESVN_BOOTSTRAP"
226 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
227
166 fi 228 fi
167
168 fi 229 fi
169 230
170} 231}
171 232
172 233
173## -- subversion_src_unpack() ------------------------------------------------ # 234## -- subversion_src_unpack() ------------------------------------------------ #
174 235
175subversion_src_unpack() { 236subversion_src_unpack() {
176 237
177 subversion_svn_fetch || die "subversion.eclass: unknown problem in subversion_svn_fetch()." 238 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
178 subversion_bootstrap || die "subversion.eclass: unknown problem in subversion_bootstrap()." 239 subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
179 240
180} 241}

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

  ViewVC Help
Powered by ViewVC 1.1.20