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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide annotations) (download)
Wed Jul 6 20:20:04 2005 UTC (9 years, 1 month ago) by agriffis
Branch: MAIN
Changes since 1.20: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

1 hattya 1.18 # Copyright 1999-2005 Gentoo Foundation
2 hattya 1.1 # Distributed under the terms of the GNU General Public License v2
3 agriffis 1.21 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.20 2005/05/15 08:25:23 hattya Exp $
4 hattya 1.1
5     ## --------------------------------------------------------------------------- #
6     # Author: Akinori Hattori <hattya@gentoo.org>
7     #
8     # 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     INHERITED="${INHERITED} ${ECLASS}"
21 hattya 1.8 ESVN="subversion.eclass"
22 hattya 1.1
23     EXPORT_FUNCTIONS src_unpack
24    
25     HOMEPAGE="http://subversion.tigris.org/"
26 hattya 1.5 DESCRIPTION="Based on the ${ECLASS} eclass"
27 hattya 1.1
28    
29     ## -- add subversion in DEPEND
30     #
31 mr_bones_ 1.9 DEPEND="dev-util/subversion"
32 hattya 1.1
33    
34     ## -- ESVN_STORE_DIR: subversion sources store directory
35     #
36     ESVN_STORE_DIR="${DISTDIR}/svn-src"
37    
38    
39     ## -- ESVN_FETCH_CMD: subversion fetch command
40     #
41     # default: svn checkout
42     #
43     [ -z "${ESVN_FETCH_CMD}" ] && ESVN_FETCH_CMD="svn checkout"
44    
45     ## -- ESVN_UPDATE_CMD: subversion update command
46     #
47     # default: svn update
48     #
49     [ -z "${ESVN_UPDATE_CMD}" ] && ESVN_UPDATE_CMD="svn update"
50    
51    
52     ## -- ESVN_REPO_URI: repository uri
53     #
54     # e.g. http://foo/trunk, svn://bar/trunk
55 hattya 1.12 #
56     # supported protocols:
57     # http://
58     # https://
59     # svn://
60 hattya 1.1 #
61     [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
62    
63    
64     ## -- ESVN_PROJECT: project name of your ebuild
65     #
66     # subversion eclass will check out the subversion repository like:
67     #
68     # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
69     #
70     # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
71     # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
72     # it will check out like:
73     #
74     # ${ESVN_STORE_DIR}/subversion/trunk
75     #
76     # default: ${PN/-svn}.
77     #
78     [ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
79    
80    
81     ## -- ESVN_BOOTSTRAP:
82     #
83 hattya 1.8 # bootstrap script or command like autogen.sh or etc..
84 hattya 1.1 #
85     [ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
86    
87    
88 hattya 1.8 ## -- ESVN_PATCHES:
89     #
90     # subversion eclass can apply pathces in subversion_bootstrap().
91     # you can use regexp in this valiable like *.diff or *.patch or etc.
92     # NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
93     #
94     # the process of applying the patch is:
95     # 1. just epatch it, if the patch exists in the path.
96     # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
97     # 3. die.
98     #
99     [ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
100    
101    
102 hattya 1.1 ## -- subversion_svn_fetch() ------------------------------------------------- #
103    
104 hattya 1.17 function subversion_svn_fetch() {
105 hattya 1.1
106 hattya 1.5 # ESVN_REPO_URI is empty.
107 hattya 1.8 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
108 hattya 1.1
109 hattya 1.12 # check for the protocol.
110 hattya 1.5 case ${ESVN_REPO_URI%%:*} in
111     http) ;;
112     https) ;;
113 hattya 1.11 svn) ;;
114 hattya 1.5 *)
115 hattya 1.8 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
116 hattya 1.5 ;;
117     esac
118 hattya 1.1
119 hattya 1.20 if [ ! -d "${ESVN_STORE_DIR}" ]; then
120 hattya 1.17 debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
121 hattya 1.5
122 hattya 1.17 addwrite /
123 hattya 1.12 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
124 hattya 1.8 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
125 hattya 1.17 export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}"
126 hattya 1.1 fi
127    
128 hattya 1.17 cd -P "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
129     ESVN_STORE_DIR=${PWD}
130 hattya 1.1
131 hattya 1.17 # every time
132     addwrite "/etc/subversion"
133     addwrite "${ESVN_STORE_DIR}"
134 hattya 1.12
135 hattya 1.17 # -userpriv
136     ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
137 hattya 1.12
138 hattya 1.17 [ -z "${ESVN_REPO_URI##*/}" ] && ESVN_REPO_URI="${ESVN_REPO_URI%/}"
139     ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_URI##*/}"
140 hattya 1.1
141     if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
142     # first check out
143     einfo "subversion check out start -->"
144 hattya 1.8 einfo " checkout from: ${ESVN_REPO_URI}"
145 hattya 1.1
146 hattya 1.12 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
147 hattya 1.8 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
148 hattya 1.5 cd "${ESVN_PROJECT}"
149 hattya 1.8 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
150 hattya 1.12
151 hattya 1.8 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
152 hattya 1.1
153     else
154     # update working copy
155     einfo "subversion update start -->"
156     einfo " update from: ${ESVN_REPO_URI}"
157 hattya 1.8 cd "${ESVN_CO_DIR}"
158    
159     local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
160 hattya 1.13 if (( ${NOW} - ${UPDATE} > ${INTERVAL} )); then
161 hattya 1.8 ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
162 hattya 1.12
163 hattya 1.8 else
164     echo "Skip updating..."
165 hattya 1.12
166 hattya 1.8 fi
167 hattya 1.1
168     einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
169 hattya 1.8
170 hattya 1.1 fi
171    
172     # copy to the ${WORKDIR}
173 hattya 1.8 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
174     einfo " copied to: ${S}"
175     echo
176 hattya 1.1
177     }
178    
179    
180     ## -- subversion_bootstrap() ------------------------------------------------ #
181    
182 hattya 1.17 function subversion_bootstrap() {
183    
184     local patch lpatch
185 hattya 1.1
186 hattya 1.8 cd "${S}"
187    
188     if [ "${ESVN_PATCHES}" ]; then
189 hattya 1.15 einfo "apply patches -->"
190 hattya 1.12
191 hattya 1.17 for patch in ${ESVN_PATCHES}; do
192     if [ -f "${patch}" ]; then
193     epatch ${patch}
194 hattya 1.8
195     else
196 hattya 1.17 for lpatch in ${FILESDIR}/${patch}; do
197     if [ -f "${lpatch}" ]; then
198     epatch ${lpatch}
199 hattya 1.8
200     else
201 hattya 1.17 die "${ESVN}; ${patch} is not found"
202 hattya 1.8
203     fi
204     done
205     fi
206     done
207     echo
208     fi
209    
210     if [ "${ESVN_BOOTSTRAP}" ]; then
211     einfo "begin bootstrap -->"
212 hattya 1.12
213 hattya 1.8 if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
214     einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
215     eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
216    
217     else
218 hattya 1.16 einfo " bootstrap with commands: ${ESVN_BOOTSTRAP}"
219 hattya 1.8 eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
220 hattya 1.1
221     fi
222     fi
223    
224     }
225    
226    
227     ## -- subversion_src_unpack() ------------------------------------------------ #
228    
229 hattya 1.17 function subversion_src_unpack() {
230 hattya 1.1
231 hattya 1.19 if [ "${A}" != "" ]; then
232     unpack ${A}
233     fi
234    
235 hattya 1.8 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
236     subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
237 hattya 1.1
238     }

  ViewVC Help
Powered by ViewVC 1.1.20