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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations) (download)
Sun Jun 13 12:58:03 2004 UTC (10 years, 2 months ago) by hattya
Branch: MAIN
Changes since 1.11: +18 -6 lines
update comment

1 hattya 1.1 # Copyright 1999-2004 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 hattya 1.12 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.11 2004/06/06 10:03:11 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     subversion_svn_fetch() {
106    
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.5 # every time
121     addwrite "${ESVN_STORE_DIR}"
122     addwrite "/etc/subversion"
123    
124     # -userpriv
125 hattya 1.8 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
126 hattya 1.1
127     if [ ! -d "${ESVN_STORE_DIR}" ]; then
128 hattya 1.12 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
129 hattya 1.8 chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
130 hattya 1.12
131 hattya 1.1 einfo "created store directory: ${ESVN_STORE_DIR}"
132     einfo
133     fi
134    
135 hattya 1.5 cd "${ESVN_STORE_DIR}"
136 hattya 1.1
137 hattya 1.12 if [ -z "${ESVN_REPO_URI##*/}" ]; then
138 hattya 1.5 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
139 hattya 1.12
140 hattya 1.5 else
141     ESVN_REPO_FIX="${ESVN_REPO_URI}"
142 hattya 1.12
143 hattya 1.1 fi
144    
145 hattya 1.5 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
146 hattya 1.1
147     if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
148     # first check out
149     einfo "subversion check out start -->"
150 hattya 1.8 einfo " checkout from: ${ESVN_REPO_URI}"
151 hattya 1.1
152 hattya 1.12 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
153 hattya 1.8 chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
154 hattya 1.5 cd "${ESVN_PROJECT}"
155 hattya 1.8 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
156 hattya 1.12
157 hattya 1.8 einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
158 hattya 1.1
159     else
160     # update working copy
161     einfo "subversion update start -->"
162     einfo " update from: ${ESVN_REPO_URI}"
163 hattya 1.8 cd "${ESVN_CO_DIR}"
164    
165     local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
166     if expr ${NOW} - ${UPDATE} \> ${INTERVAL} >/dev/null; then
167     ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
168 hattya 1.12
169 hattya 1.8 else
170     echo "Skip updating..."
171 hattya 1.12
172 hattya 1.8 fi
173 hattya 1.1
174     einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
175 hattya 1.8
176 hattya 1.1 fi
177    
178 hattya 1.8 # permission fix for NFS (root_squash) with -userpriv
179     find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
180 hattya 1.5
181 hattya 1.1 # copy to the ${WORKDIR}
182 hattya 1.8 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
183     einfo " copied to: ${S}"
184     echo
185 hattya 1.1
186     }
187    
188    
189     ## -- subversion_bootstrap() ------------------------------------------------ #
190    
191     subversion_bootstrap() {
192    
193 hattya 1.8 cd "${S}"
194    
195     if [ "${ESVN_PATCHES}" ]; then
196     einfo "apply paches -->"
197 hattya 1.12
198 hattya 1.8 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    
217     if [ "${ESVN_BOOTSTRAP}" ]; then
218     einfo "begin bootstrap -->"
219 hattya 1.12
220 hattya 1.8 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 hattya 1.1
228     fi
229     fi
230    
231     }
232    
233    
234     ## -- subversion_src_unpack() ------------------------------------------------ #
235    
236     subversion_src_unpack() {
237    
238 hattya 1.8 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
239     subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
240 hattya 1.1
241     }

  ViewVC Help
Powered by ViewVC 1.1.20