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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (hide annotations) (download)
Sun Apr 30 09:15:03 2006 UTC (8 years, 3 months ago) by hattya
Branch: MAIN
Changes since 1.29: +2 -2 lines
fixes bug #129178

1 vapier 1.27 # Copyright 1999-2006 Gentoo Foundation
2 hattya 1.1 # Distributed under the terms of the GNU General Public License v2
3 hattya 1.30 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.29 2006/04/28 14:20:03 hattya Exp $
4 hattya 1.1
5     ## --------------------------------------------------------------------------- #
6     # Author: Akinori Hattori <hattya@gentoo.org>
7 swegener 1.23 #
8 hattya 1.1 # The subversion eclass is written to fetch the software sources from
9     # subversion repositories like the cvs eclass.
10     #
11     #
12     # Description:
13     # If you use this eclass, the ${S} is ${WORKDIR}/${P}.
14 hattya 1.10 # It is necessary to define the ESVN_REPO_URI variable at least.
15 hattya 1.1 #
16     ## --------------------------------------------------------------------------- #
17    
18 hattya 1.8 inherit eutils
19 hattya 1.1
20 hattya 1.8 ESVN="subversion.eclass"
21 hattya 1.1
22     EXPORT_FUNCTIONS src_unpack
23    
24     HOMEPAGE="http://subversion.tigris.org/"
25 hattya 1.5 DESCRIPTION="Based on the ${ECLASS} eclass"
26 hattya 1.1
27    
28     ## -- add subversion in DEPEND
29     #
30 mr_bones_ 1.9 DEPEND="dev-util/subversion"
31 hattya 1.1
32    
33     ## -- ESVN_STORE_DIR: subversion sources store directory
34     #
35 ferringb 1.26 ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-src"
36 hattya 1.1
37    
38     ## -- ESVN_FETCH_CMD: subversion fetch command
39     #
40 hattya 1.25 ESVN_FETCH_CMD="svn checkout"
41    
42     ## -- ESVN_UPDATE_CMD: subversion update command
43 hattya 1.1 #
44 hattya 1.25 ESVN_UPDATE_CMD="svn update"
45 hattya 1.1
46 hattya 1.25
47     ## -- ESVN_OPTIONS:
48 hattya 1.1 #
49 hattya 1.25 # the options passed to checkout or update.
50 hattya 1.1 #
51 hattya 1.25 [ -z "${ESVN_OPTIONS}" ] && ESVN_OPTIONS=
52 hattya 1.1
53    
54     ## -- ESVN_REPO_URI: repository uri
55     #
56     # e.g. http://foo/trunk, svn://bar/trunk
57 hattya 1.12 #
58     # supported protocols:
59     # http://
60     # https://
61     # svn://
62 hattya 1.1 #
63     [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
64    
65    
66     ## -- ESVN_PROJECT: project name of your ebuild
67     #
68     # subversion eclass will check out the subversion repository like:
69     #
70     # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
71     #
72     # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
73     # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
74     # it will check out like:
75     #
76     # ${ESVN_STORE_DIR}/subversion/trunk
77     #
78     # default: ${PN/-svn}.
79     #
80     [ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
81    
82    
83     ## -- ESVN_BOOTSTRAP:
84     #
85 hattya 1.8 # bootstrap script or command like autogen.sh or etc..
86 hattya 1.1 #
87     [ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
88    
89    
90 hattya 1.8 ## -- 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    
104 hattya 1.1 ## -- subversion_svn_fetch() ------------------------------------------------- #
105    
106 hattya 1.17 function subversion_svn_fetch() {
107 hattya 1.1
108 hattya 1.25 local ESVN_CO_DIR
109    
110 hattya 1.5 # ESVN_REPO_URI is empty.
111 hattya 1.8 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
112 hattya 1.1
113 hattya 1.12 # check for the protocol.
114 hattya 1.5 case ${ESVN_REPO_URI%%:*} in
115 vapier 1.24 http|https)
116 hattya 1.25 if built_with_use dev-util/subversion nowebdav; then
117 vapier 1.24 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 hattya 1.25 svn) ;;
123 hattya 1.5 *)
124 hattya 1.8 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
125 hattya 1.5 ;;
126     esac
127 hattya 1.1
128 hattya 1.20 if [ ! -d "${ESVN_STORE_DIR}" ]; then
129 hattya 1.17 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
130 hattya 1.5
131 hattya 1.17 addwrite /
132 hattya 1.12 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
133 hattya 1.8 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
134 hattya 1.17 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
135 hattya 1.1 fi
136    
137 hattya 1.17 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
138     ESVN_STORE_DIR=${PWD}
139 hattya 1.1
140 hattya 1.17 # every time
141     addwrite "/etc/subversion"
142     addwrite "${ESVN_STORE_DIR}"
143 hattya 1.12
144 hattya 1.25 if ! has userpriv ${FEATURES}; then
145     # -userpriv
146     addwrite "/root/.subversion"
147    
148     else
149     # +userpriv
150     ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
151    
152     fi
153 hattya 1.12
154 hattya 1.17 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
155     ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
156 hattya 1.1
157 hattya 1.25 debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
158    
159 hattya 1.1 if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
160     # first check out
161     einfo "subversion check out start -->"
162 hattya 1.29 einfo " repository: ${ESVN_REPO_URI}"
163 hattya 1.1
164 hattya 1.12 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
165 hattya 1.8 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
166 hattya 1.5 cd "${ESVN_PROJECT}"
167 hattya 1.25 ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
168 hattya 1.12
169 hattya 1.1 else
170     # update working copy
171     einfo "subversion update start -->"
172 hattya 1.29 einfo " repository: ${ESVN_REPO_URI}"
173 hattya 1.25
174 hattya 1.8 cd "${ESVN_CO_DIR}"
175 hattya 1.25 ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
176 hattya 1.1
177 hattya 1.29 fi
178 hattya 1.8
179 hattya 1.29 einfo " working copy: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
180 hattya 1.1
181 hattya 1.25 # export to the ${WORKDIR}
182 hattya 1.29 # "svn export" has a bug. see http://bugs.gentoo.org/119236
183     #svn export "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't export to ${S}."
184 hattya 1.30 rsync -a --exclude=".svn" "${ESVN_STORE_DIR}/${ESVN_CO_DIR}/" "${S}" || die "${ESVN}: can't export to ${S}."
185 hattya 1.8 echo
186 hattya 1.1
187     }
188    
189    
190     ## -- subversion_bootstrap() ------------------------------------------------ #
191    
192 hattya 1.17 function subversion_bootstrap() {
193    
194     local patch lpatch
195 hattya 1.1
196 hattya 1.8 cd "${S}"
197    
198     if [ "${ESVN_PATCHES}" ]; then
199 hattya 1.15 einfo "apply patches -->"
200 hattya 1.12
201 hattya 1.17 for patch in ${ESVN_PATCHES}; do
202     if [ -f "${patch}" ]; then
203     epatch ${patch}
204 hattya 1.8
205     else
206 hattya 1.17 for lpatch in ${FILESDIR}/${patch}; do
207     if [ -f "${lpatch}" ]; then
208     epatch ${lpatch}
209 hattya 1.8
210     else
211 hattya 1.17 die "${ESVN}; ${patch} is not found"
212 hattya 1.8
213     fi
214     done
215     fi
216     done
217     echo
218     fi
219    
220     if [ "${ESVN_BOOTSTRAP}" ]; then
221     einfo "begin bootstrap -->"
222 hattya 1.12
223 hattya 1.8 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
224     einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
225     eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
226    
227     else
228 hattya 1.16 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
229 hattya 1.8 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
230 hattya 1.1
231     fi
232     fi
233    
234     }
235    
236    
237     ## -- subversion_src_unpack() ------------------------------------------------ #
238    
239 hattya 1.17 function subversion_src_unpack() {
240 hattya 1.1
241 hattya 1.8 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
242     subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
243 hattya 1.1
244     }

  ViewVC Help
Powered by ViewVC 1.1.20