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

Diff of /eclass/cvs.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.23 Revision 1.24
1# Copyright 1999-2000 Gentoo Technologies, Inc. 1# Copyright 1999-2000 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# Author Dan Armak <danarmak@gentoo.org> 3# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.23 2002/11/01 10:54:42 danarmak Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.24 2002/11/19 12:54:22 phoenix Exp $
5# This eclass provides the generic cvs fetching functions. 5# This eclass provides the generic cvs fetching functions.
6 6
7ECLASS=cvs 7ECLASS=cvs
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
9 9
37[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 37[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline"
38 38
39# Anonymous cvs login? 39# Anonymous cvs login?
40# if 'yes' uses :pserver: with empty password, if 'no' uses :ext: with $ECVS_PASS, other values not allowed 40# if 'yes' uses :pserver: with empty password, if 'no' uses :ext: with $ECVS_PASS, other values not allowed
41[ -z "$ECVS_ANON" ] && ECVS_ANON="yes" 41[ -z "$ECVS_ANON" ] && ECVS_ANON="yes"
42
43# Authentication method to use on ECVS_ANON="no" - possible values are "pserver" and "ext"
44[ -z "$ECVS_AUTH" ] && ECVS_AUTH="ext"
45
46# Use su to run cvs as user
47[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
42 48
43# Username to use 49# Username to use
44[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 50[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
45 51
46# Password to use if anonymous login is off 52# Password to use if anonymous login is off
127 133
128 # prepare a cvspass file just for this session so that cvs thinks we're logged 134 # prepare a cvspass file just for this session so that cvs thinks we're logged
129 # in at the cvs server. we don't want to mess with ~/.cvspass. 135 # in at the cvs server. we don't want to mess with ~/.cvspass.
130 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 136 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
131 export CVS_PASSFILE="${T}/cvspass" 137 export CVS_PASSFILE="${T}/cvspass"
138 chown $ECVS_RUNAS "${T}/cvspass"
132 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 139 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
133 140
134 # Note: cvs update and checkout commands are unified. 141 # Note: cvs update and checkout commands are unified.
135 # we make sure a CVS/ dir exists in our module subdir with the right 142 # we make sure a CVS/ dir exists in our module subdir with the right
136 # Root and Repository entries in it and cvs update. 143 # Root and Repository entries in it and cvs update.
137 144
138 [ "${ECVS_ANON}" == "yes" ] && \ 145 [ "${ECVS_ANON}" == "yes" ] && \
139 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \ 146 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
140 newserver=":ext:${ECVS_USER}@${ECVS_SERVER}" 147 newserver=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
141 148
142 149
143 # CVS/Repository files can't (I think) contain two concatenated slashes 150 # CVS/Repository files can't (I think) contain two concatenated slashes
144 if [ -n "$ECVS_SUBDIR" ]; then 151 if [ -n "$ECVS_SUBDIR" ]; then
145 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 152 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
199 206
200 # cvs auto-switches branches, how nice 207 # cvs auto-switches branches, how nice
201 # warning: if we do it this way we get multiple -rX options - harmless i think 208 # warning: if we do it this way we get multiple -rX options - harmless i think
202 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 209 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
203 210
211 # Chowning the directory
212 if [ "${ECVS_RUNAS}" != "root" ]; then
213 chown -R "$ECVS_RUNAS" /$DIR
214 fi
215
204 # finally run the cvs update command 216 # finally run the cvs update command
205 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 217 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
206 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR" 218 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
207 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..." 219 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
208 220
218/usr/bin/env python << EndOfFile 230/usr/bin/env python << EndOfFile
219 231
220import pexpect,os 232import pexpect,os
221 233
222mypasswd = "${ECVS_PASS}" 234mypasswd = "${ECVS_PASS}"
235myauth = "${ECVS_AUTH}"
223mytimeout = 10 236mytimeout = 10
224 237
238if myauth == "ext":
225mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}" 239 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
226child = pexpect.spawn(mycommand) 240 child = pexpect.spawn(mycommand)
227 241
228index = child.expect(['continue connecting','word:'], mytimeout) 242 index = child.expect(['continue connecting','word:'], mytimeout)
229if index == 0: 243 if index == 0:
230 child.sendline('yes') 244 child.sendline('yes')
231 ## Added server to ~/.ssh/known_hosts 245 ## Added server to ~/.ssh/known_hosts
232 child.expect('word:', mytimeout) 246 child.expect('word:', mytimeout)
233else: 247 else:
234 ## Server already is in ~/.ssh/known_hosts 248 ## Server already is in ~/.ssh/known_hosts
235 pass 249 pass
236 250
237child.sendline(mypasswd) 251 child.sendline(mypasswd)
252 child.expect(pexpect.EOF)
253
254elif myauth == "pserver":
255 mycommand = "su ${ECVS_RUNAS} -c \"cvs login\""
256 child = pexpect.spawn(mycommand)
257 child.expect("CVS password:",mytimeout)
258 child.sendline(mypasswd)
238child.expect(pexpect.EOF) 259 child.expect(pexpect.EOF)
239 260
261 # Logged in - checking out
262 os.system("su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\" &> /dev/null")
240EndOfFile 263EndOfFile
241########################### End of inline-python ################################## 264########################### End of inline-python ##################################
242 else 265 else
243 debug-print "$FUNCNAME: using anonymous cvs login" 266 debug-print "$FUNCNAME: using anonymous cvs login"
244 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update" 267 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update"
245 fi 268 fi
246 269
247 270 # log out and restore ownership
248 271 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
272 chown root ${T}/cvspass
249} 273}
250 274
251cvs_src_unpack() { 275cvs_src_unpack() {
252 276
253 debug-print-function $FUNCNAME $* 277 debug-print-function $FUNCNAME $*

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.20