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

Diff of /eclass/cvs.eclass

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

Revision 1.31 Revision 1.35
1# Copyright 1999-2003 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.31 2003/02/16 04:26:21 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.35 2003/04/17 09:05:03 cretin Exp $
4# 4#
5# Author Dan Armak <danarmak@gentoo.org> 5# Author Dan Armak <danarmak@gentoo.org>
6# 6#
7# This eclass provides the generic cvs fetching functions. 7# This eclass provides the generic cvs fetching functions.
8 8
49[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 49[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
50 50
51# Username to use 51# Username to use
52[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 52[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
53 53
54# 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
55[ -z "$ECVS_PASS" ] && ECVS_PASS="" 56[ -z "$ECVS_PASS" ] && ECVS_PASS=""
56 57
57# Module to be fetched, must be set explicitly - 58# Module to be fetched, must be set explicitly -
58# I don't like the former ="$PN" default setting 59# I don't like the former ="$PN" default setting
59[ -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"
60 61
61# Branch/tag to use, default is HEAD 62# Branch/tag to use, default is HEAD
62# uncomment the following line to enable the reset-branch-to-HEAD behaviour 63# uncomment the following line to enable the reset-branch-to-HEAD behaviour
63[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD" 64# [ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD"
64 65
65# Subdirectory in module to be fetched, default is not defined = whole module 66# Subdirectory in module to be fetched, default is not defined = whole module
66# DO NOT set default to "", if it's defined at all code will break! 67# DO NOT set default to "", if it's defined at all code will break!
67# don't uncomment following line! 68# don't uncomment following line!
68#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR="" 69#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR=""
70# --- end ebuild-configurable settings --- 71# --- end ebuild-configurable settings ---
71 72
72# add cvs to deps 73# add cvs to deps
73DEPEND="$DEPEND dev-util/cvs dev-python/pexpect" 74DEPEND="$DEPEND dev-util/cvs dev-python/pexpect"
74 75
75# since we now longer have src_fetch as a redefinable ebuild function, 76# since we no longer have src_fetch as a redefinable ebuild function,
76# we are forced to call this function from cvs_src_unpack 77# we are forced to call this function from cvs_src_unpack
77cvs_fetch() { 78cvs_fetch() {
78 79
79 debug-print-function $FUNCNAME $* 80 debug-print-function $FUNCNAME $*
80 81
81 debug-print "$FUNCNAME: init: 82 debug-print "$FUNCNAME: init:
82ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 839ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
83ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 84ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
84ECVS_TOP_DIR=$ECVS_TOP_DIR 85ECVS_TOP_DIR=$ECVS_TOP_DIR
85ECVS_SERVER=$ECVS_SERVER 86ECVS_SERVER=$ECVS_SERVER
86ECVS_ANON=$ECVS_ANON 87ECVS_ANON=$ECVS_ANON
87ECVS_USER=$ECVS_USER 88ECVS_USER=$ECVS_USER
131 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE" 132 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE"
132 133
133 # add option for local (non-recursive) fetching 134 # add option for local (non-recursive) fetching
134 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" 135 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
135 136
136 # 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
137 # in at the cvs server. we don't want to mess with ~/.cvspass. 138 touch "${T}/cvspass"
138 echo ":pserver:${ECVS_SERVER} A" > "${T}/cvspass"
139 export CVS_PASSFILE="${T}/cvspass" 139 export CVS_PASSFILE="${T}/cvspass"
140 chown $ECVS_RUNAS "${T}/cvspass" 140 chown $ECVS_RUNAS "${T}/cvspass"
141 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 141
142
143 # Note: cvs update and checkout commands are unified. 142 # Note: cvs update and checkout commands are unified.
144 # 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
145 # Root and Repository entries in it and cvs update. 144 # Root and Repository entries in it and cvs update.
146 145
147 [ "${ECVS_ANON}" == "yes" ] && \ 146 [ "${ECVS_ANON}" == "yes" ] && \
271 os.system(mycommand) 270 os.system(mycommand)
272 271
273EndOfFile 272EndOfFile
274########################### End of inline-python ################################## 273########################### End of inline-python ##################################
275 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
276 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"
277 $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"
278 fi
279 315
316 fi
317
280 # 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"
281 if [ "$ECVS_RUNAS" == "`whoami`" ]; then 321 if [ "$ECVS_RUNAS" == "`whoami`" ]; then
282 cvs logout &> /dev/null 322 cvs logout &> /dev/null
283 else 323 else
284 su $ECVS_RUNAS -c "cvs logout" &> /dev/null 324 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
325 fi
285 fi 326 fi
286 chown `whoami` "${T}/cvspass" 327 chown `whoami` "${T}/cvspass"
287} 328}
288 329
289cvs_src_unpack() { 330cvs_src_unpack() {

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20