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

Diff of /eclass/cvs.eclass

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

Revision 1.28 Revision 1.33
1# Copyright 1999-2000 Gentoo Technologies, Inc. 1# Copyright 1999-2003 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# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.33 2003/03/19 11:54:21 danarmak Exp $
4#
3# Author Dan Armak <danarmak@gentoo.org> 5# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.28 2002/11/30 19:44:18 danarmak Exp $ 6#
5# This eclass provides the generic cvs fetching functions. 7# This eclass provides the generic cvs fetching functions.
6 8
7ECLASS=cvs 9ECLASS=cvs
8INHERITED="$INHERITED $ECLASS" 10INHERITED="$INHERITED $ECLASS"
9 11
47[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 49[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
48 50
49# Username to use 51# Username to use
50[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 52[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
51 53
52# Password to use if anonymous login is off 54# Password to use if anonymous login is off, or if 'anonymous' pserver access
55# uses a password and ECVS_ANON = yes
53[ -z "$ECVS_PASS" ] && ECVS_PASS="" 56[ -z "$ECVS_PASS" ] && ECVS_PASS=""
54 57
55# Module to be fetched, must be set explicitly - 58# Module to be fetched, must be set explicitly -
56# I don't like the former ="$PN" default setting 59# I don't like the former ="$PN" default setting
57[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue" 60[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue"
75cvs_fetch() { 78cvs_fetch() {
76 79
77 debug-print-function $FUNCNAME $* 80 debug-print-function $FUNCNAME $*
78 81
79 debug-print "$FUNCNAME: init: 82 debug-print "$FUNCNAME: init:
80ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 839ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
81ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 84ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
82ECVS_TOP_DIR=$ECVS_TOP_DIR 85ECVS_TOP_DIR=$ECVS_TOP_DIR
83ECVS_SERVER=$ECVS_SERVER 86ECVS_SERVER=$ECVS_SERVER
84ECVS_ANON=$ECVS_ANON 87ECVS_ANON=$ECVS_ANON
85ECVS_USER=$ECVS_USER 88ECVS_USER=$ECVS_USER
129 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE" 132 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE"
130 133
131 # add option for local (non-recursive) fetching 134 # add option for local (non-recursive) fetching
132 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" 135 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
133 136
134 # prepare a cvspass file just for this session so that cvs thinks we're logged 137 # prepare a cvspass file just for this session, we don't want to mess with ~/.cvspass
135 # in at the cvs server. we don't want to mess with ~/.cvspass. 138 touch "${T}/cvspass"
136 echo ":pserver:${ECVS_SERVER} A" > "${T}/cvspass"
137 export CVS_PASSFILE="${T}/cvspass" 139 export CVS_PASSFILE="${T}/cvspass"
138 chown $ECVS_RUNAS "${T}/cvspass" 140 chown $ECVS_RUNAS "${T}/cvspass"
139 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 141
140
141 # Note: cvs update and checkout commands are unified. 142 # Note: cvs update and checkout commands are unified.
142 # we make sure a CVS/ dir exists in our module subdir with the right 143 # we make sure a CVS/ dir exists in our module subdir with the right
143 # Root and Repository entries in it and cvs update. 144 # Root and Repository entries in it and cvs update.
144 145
145 [ "${ECVS_ANON}" == "yes" ] && \ 146 [ "${ECVS_ANON}" == "yes" ] && \
207 # cvs auto-switches branches, how nice 208 # cvs auto-switches branches, how nice
208 # warning: if we do it this way we get multiple -rX options - harmless i think 209 # warning: if we do it this way we get multiple -rX options - harmless i think
209 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 210 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
210 211
211 # Chowning the directory 212 # Chowning the directory
212 if [ "${ECVS_RUNAS}" != "root" ]; then 213 if [ "${ECVS_RUNAS}" != "`whoami`" ]; then
213 chown -R "$ECVS_RUNAS" "/$DIR" 214 chown -R "$ECVS_RUNAS" "/$DIR"
214 fi 215 fi
215 216
216 # finally run the cvs update command 217 # finally run the cvs update command
217 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 218 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
233 234
234mypasswd = "${ECVS_PASS}" 235mypasswd = "${ECVS_PASS}"
235myauth = "${ECVS_AUTH}" 236myauth = "${ECVS_AUTH}"
236mytimeout = 10 237mytimeout = 10
237 238
239if "${ECVS_RUNAS}" == "`whoami`":
240 mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}"
241else:
242 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
243
238if myauth == "ext": 244if myauth == "ext":
239 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
240 child = pexpect.spawn(mycommand) 245 child = pexpect.spawn(mycommand)
241 246
242 index = child.expect(['continue connecting','word:'], mytimeout) 247 index = child.expect(['continue connecting','word:'], mytimeout)
243 if index == 0: 248 if index == 0:
244 child.sendline('yes') 249 child.sendline('yes')
250 255
251 child.sendline(mypasswd) 256 child.sendline(mypasswd)
252 child.expect(pexpect.EOF) 257 child.expect(pexpect.EOF)
253 258
254elif myauth == "pserver": 259elif myauth == "pserver":
260 if "${ECVS_RUNAS}" == "`whoami`":
261 mycommand2 = "cvs login"
262 else:
255 mycommand = "su ${ECVS_RUNAS} -c \"cvs login\"" 263 mycommand2 = "su ${ECVS_RUNAS} -c \"cvs login\""
256 child = pexpect.spawn(mycommand) 264 child = pexpect.spawn(mycommand2)
257 child.expect("CVS password:",mytimeout) 265 child.expect("CVS password:",mytimeout)
258 child.sendline(mypasswd) 266 child.sendline(mypasswd)
259 child.expect(pexpect.EOF) 267 child.expect(pexpect.EOF)
260 268
261 # Logged in - checking out 269 # Logged in - checking out
262 os.system("su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\" &> /dev/null") 270 os.system(mycommand)
271
263EndOfFile 272EndOfFile
264########################### End of inline-python ################################## 273########################### End of inline-python ##################################
265 else 274 else
275 # is anonymous cvs.
276 # is there a password to use for login with this "anonymous" login
277 if [ -n "$ECVS_PASS" ]; then
266 debug-print "$FUNCNAME: using anonymous cvs login" 278 debug-print "$FUNCNAME: using anonymous cvs login with password"
279
280# inline-python #
281/usr/bin/env python << EndOfFile
282
283import pexpect,os
284
285myuser = "${ECVS_USER}"
286mypasswd = "${ECVS_PASS}"
287
288mytimeout = 10
289
290# implicitly myauth == "pserver" here.
291mycommand = "cvs login"
292child = pexpect.spawn(mycommand)
293child.expect("CVS password:",mytimeout)
294child.sendline(mypasswd)
295child.expect(pexpect.EOF)
296EndOfFile
297# End of inline-python #
298
299 else
300 debug-print "$FUNCNAME: using anonymous cvs login (without password)"
301 # passwordless, truly anonymous login; or login with empty (but existing)
302 # password.
303 # make cvs think we're logged in at the cvs server,
304 # because i don't trust myself to write the right code for the case
305 # where the password is empty but still required (what's the bash test
306 # to see if a variable is defined? -n returns false if it is defined
307 # but empty...)
308 echo ":pserver:${ECVS_SERVER} A" > "${T}/cvspass"
309 # remember we did this so we don't try to run cvs logout later
310 DONT_LOGOUT=yes
311 fi
312
313 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS"
267 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update" 314 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update"
268 fi
269 315
316 fi
317
270 # log out and restore ownership 318 # log out and restore ownership as needed
319 if [ -z "$DONT_LOGOUT" ]; then
320 debug-print "$FUNCNAME: cvs logout stuff"
321 if [ "$ECVS_RUNAS" == "`whoami`" ]; then
322 cvs logout &> /dev/null
323 else
271 su $ECVS_RUNAS -c "cvs logout" &> /dev/null 324 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
325 fi
326 fi
272 chown `whoami` "${T}/cvspass" 327 chown `whoami` "${T}/cvspass"
273} 328}
274 329
275cvs_src_unpack() { 330cvs_src_unpack() {
276 331

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20