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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Thu Jan 20 09:53:16 2005 UTC (9 years, 9 months ago) by hattya
Branch: MAIN
Changes since 1.17: +2 -2 lines
update copyright

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

  ViewVC Help
Powered by ViewVC 1.1.20