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

Contents of /eclass/subversion.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Fri Apr 30 12:07:04 2004 UTC (10 years, 3 months ago) by hattya
Branch: MAIN
Changes since 1.9: +2 -2 lines
fixes bug #49335

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.10 # $Header: /home/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.9 2004/04/11 05:46:09 mr_bones_ 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.5 # but currentry support http and https only.
57 hattya 1.1 #
58     [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI=""
59    
60    
61     ## -- ESVN_PROJECT: project name of your ebuild
62     #
63     # subversion eclass will check out the subversion repository like:
64     #
65     # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
66     #
67     # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
68     # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
69     # it will check out like:
70     #
71     # ${ESVN_STORE_DIR}/subversion/trunk
72     #
73     # default: ${PN/-svn}.
74     #
75     [ -z "${ESVN_PROJECT}" ] && ESVN_PROJECT="${PN/-svn}"
76    
77    
78     ## -- ESVN_BOOTSTRAP:
79     #
80 hattya 1.8 # bootstrap script or command like autogen.sh or etc..
81 hattya 1.1 #
82     [ -z "${ESVN_BOOTSTRAP}" ] && ESVN_BOOTSTRAP=""
83    
84    
85 hattya 1.8 ## -- ESVN_PATCHES:
86     #
87     # subversion eclass can apply pathces in subversion_bootstrap().
88     # you can use regexp in this valiable like *.diff or *.patch or etc.
89     # NOTE: this patches will apply before eval ESVN_BOOTSTRAP.
90     #
91     # the process of applying the patch is:
92     # 1. just epatch it, if the patch exists in the path.
93     # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR.
94     # 3. die.
95     #
96     [ -z "${ESVN_PATCHES}" ] && ESVN_PATCHES=""
97    
98    
99 hattya 1.1 ## -- subversion_svn_fetch() ------------------------------------------------- #
100    
101     subversion_svn_fetch() {
102    
103 hattya 1.5 # ESVN_REPO_URI is empty.
104 hattya 1.8 [ -z "${ESVN_REPO_URI}" ] && die "${ESVN}: ESVN_REPO_URI is empty."
105 hattya 1.1
106 hattya 1.5 # http and https only...
107     case ${ESVN_REPO_URI%%:*} in
108     http) ;;
109     https) ;;
110     *)
111 hattya 1.8 die "${ESVN}: fetch from "${ESVN_REPO_URI%:*}" is not yet implemented."
112 hattya 1.5 ;;
113     esac
114 hattya 1.1
115 hattya 1.5 # every time
116     addwrite "${ESVN_STORE_DIR}"
117     addwrite "/etc/subversion"
118    
119     # -userpriv
120 hattya 1.8 ! has userpriv ${FEATURE} && addwrite "/root/.subversion"
121 hattya 1.1
122     if [ ! -d "${ESVN_STORE_DIR}" ]; then
123 hattya 1.8 mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
124     chmod -f o+rw "${ESVN_STORE_DIR}" || die "${ESVN}: can't chmod ${ESVN_STORE_DIR}."
125 hattya 1.1 einfo "created store directory: ${ESVN_STORE_DIR}"
126     einfo
127     fi
128    
129 hattya 1.5 cd "${ESVN_STORE_DIR}"
130 hattya 1.1
131     if [ -z ${ESVN_REPO_URI##*/} ]; then
132 hattya 1.5 ESVN_REPO_FIX="${ESVN_REPO_URI%/}"
133     else
134     ESVN_REPO_FIX="${ESVN_REPO_URI}"
135 hattya 1.1 fi
136    
137 hattya 1.5 ESVN_CO_DIR="${ESVN_PROJECT}/${ESVN_REPO_FIX##*/}"
138 hattya 1.1
139     if [ ! -d "${ESVN_CO_DIR}/.svn" ]; then
140     # first check out
141     einfo "subversion check out start -->"
142 hattya 1.8 einfo " checkout from: ${ESVN_REPO_URI}"
143 hattya 1.1
144 hattya 1.8 mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
145     chmod -f o+rw "${ESVN_PROJECT}" || die "${ESVN}: can't chmod ${ESVN_PROJECT}."
146 hattya 1.5 cd "${ESVN_PROJECT}"
147 hattya 1.8 ${ESVN_FETCH_CMD} "${ESVN_REPO_URI}" || die "${ESVN}: can't fetch from ${ESVN_REPO_URI}."
148     einfo " checkouted in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
149 hattya 1.1
150     else
151     # update working copy
152     einfo "subversion update start -->"
153     einfo " update from: ${ESVN_REPO_URI}"
154 hattya 1.8 cd "${ESVN_CO_DIR}"
155    
156     local NOW=$(date +%s) UPDATE=$(date -r .svn/entries +%s) INTERVAL=3600
157     if expr ${NOW} - ${UPDATE} \> ${INTERVAL} >/dev/null; then
158     ${ESVN_UPDATE_CMD} || die "${ESVN}: can't update from ${ESVN_REPO_URI}."
159     else
160     echo "Skip updating..."
161     fi
162 hattya 1.1
163     einfo " updated in: ${ESVN_STORE_DIR}/${ESVN_CO_DIR}"
164 hattya 1.8
165 hattya 1.1 fi
166    
167 hattya 1.8 # permission fix for NFS (root_squash) with -userpriv
168     find ! -perm -o+rw -exec chmod o+rw {} \; 2>/dev/null
169 hattya 1.5
170 hattya 1.1 # copy to the ${WORKDIR}
171 hattya 1.8 cp -Rf "${ESVN_STORE_DIR}/${ESVN_CO_DIR}" "${S}" || die "${ESVN}: can't copy to ${S}."
172     einfo " copied to: ${S}"
173     echo
174 hattya 1.1
175     }
176    
177    
178     ## -- subversion_bootstrap() ------------------------------------------------ #
179    
180     subversion_bootstrap() {
181    
182 hattya 1.8 cd "${S}"
183    
184     if [ "${ESVN_PATCHES}" ]; then
185     einfo "apply paches -->"
186     for PATCH in ${ESVN_PATCHES}; do
187     if [ -f "${PATCH}" ]; then
188     epatch ${PATCH}
189    
190     else
191     for fPATCH in ${FILESDIR}/${PATCH}; do
192     if [ -f "${fPATCH}" ]; then
193     epatch ${fPATCH}
194    
195     else
196     die "${ESVN}; ${PATCH} is not found"
197    
198     fi
199     done
200     fi
201     done
202     echo
203     fi
204    
205     if [ "${ESVN_BOOTSTRAP}" ]; then
206     einfo "begin bootstrap -->"
207     if [ -f "${ESVN_BOOTSTRAP}" -a -x "${ESVN_BOOTSTRAP}" ]; then
208     einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
209     eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
210    
211     else
212     einfo " bootstrap with command: ESVN_BOOTSTRAP"
213     eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
214 hattya 1.1
215     fi
216     fi
217    
218     }
219    
220    
221     ## -- subversion_src_unpack() ------------------------------------------------ #
222    
223     subversion_src_unpack() {
224    
225 hattya 1.8 subversion_svn_fetch || die "${ESVN}: unknown problem in subversion_svn_fetch()."
226     subversion_bootstrap || die "${ESVN}: unknown problem in subversion_bootstrap()."
227 hattya 1.1
228     }

  ViewVC Help
Powered by ViewVC 1.1.20