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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (hide annotations) (download)
Mon Jul 11 15:08:06 2005 UTC (9 years, 2 months ago) by swegener
Branch: MAIN
Changes since 1.22: +2 -2 lines
QA: Apply whitespace checks from repoman to eclasses.

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

  ViewVC Help
Powered by ViewVC 1.1.20