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

Diff of /eclass/cvs.eclass

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

Revision 1.22 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.22 2002/10/25 19:55:52 vapier 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
34# parts of the full CVSROOT (which looks like 34# parts of the full CVSROOT (which looks like
35# ":pserver:anonymous@anoncvs.kde.org:/home/kde"); these are added from 35# ":pserver:anonymous@anoncvs.kde.org:/home/kde"); these are added from
36# other settings 36# other settings
37[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 37[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline"
38 38
39# Anonymous cvs login?
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"
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`"
48
39# Username to use 49# Username to use
40[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 50[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
41 51
42# Password to use (NOT (YET) SUPPORTED, because cvs doesn't store passwords in plaintext in .cvspass) 52# Password to use if anonymous login is off
43[ -z "$ECVS_PASS" ] && ECVS_PASS="" 53[ -z "$ECVS_PASS" ] && ECVS_PASS=""
44 54
45# Module to be fetched, must be set explicitly - 55# Module to be fetched, must be set explicitly -
46# I don't like the former ="$PN" default setting 56# I don't like the former ="$PN" default setting
47[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue" 57[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue"
56#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR="" 66#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR=""
57 67
58# --- end ebuild-configurable settings --- 68# --- end ebuild-configurable settings ---
59 69
60# add cvs to deps 70# add cvs to deps
61DEPEND="$DEPEND dev-util/cvs" 71DEPEND="$DEPEND dev-util/cvs dev-python/pexpect"
62 72
63# since we now longer have src_fetch as a redefinable ebuild function, 73# since we now longer have src_fetch as a redefinable ebuild function,
64# we are forced to call this function from cvs_src_unpack 74# we are forced to call this function from cvs_src_unpack
65cvs_fetch() { 75cvs_fetch() {
66 76
69 debug-print "$FUNCNAME: init: 79 debug-print "$FUNCNAME: init:
70ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 80ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
71ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 81ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
72ECVS_TOP_DIR=$ECVS_TOP_DIR 82ECVS_TOP_DIR=$ECVS_TOP_DIR
73ECVS_SERVER=$ECVS_SERVER 83ECVS_SERVER=$ECVS_SERVER
84ECVS_ANON=$ECVS_ANON
74ECVS_USER=$ECVS_USER 85ECVS_USER=$ECVS_USER
75ECVS_PASS=$ECVS_PASS 86ECVS_PASS=$ECVS_PASS
76ECS_MODULE=$ECVS_MODULE 87ECS_MODULE=$ECVS_MODULE
77ECVS_SUBDIR=$ECVS_SUBDIR 88ECVS_SUBDIR=$ECVS_SUBDIR
78ECVS_LOCAL=$ECVS_LOCAL 89ECVS_LOCAL=$ECVS_LOCAL
122 133
123 # 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
124 # 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.
125 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 136 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
126 export CVS_PASSFILE="${T}/cvspass" 137 export CVS_PASSFILE="${T}/cvspass"
138 chown $ECVS_RUNAS "${T}/cvspass"
127 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 139 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
128 140
129 # Note: cvs update and checkout commands are unified. 141 # Note: cvs update and checkout commands are unified.
130 # 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
131 # Root and Repository entries in it and cvs update. 143 # Root and Repository entries in it and cvs update.
132 144
145 [ "${ECVS_ANON}" == "yes" ] && \
133 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" 146 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
147 newserver=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
148
134 149
135 # CVS/Repository files can't (I think) contain two concatenated slashes 150 # CVS/Repository files can't (I think) contain two concatenated slashes
136 if [ -n "$ECVS_SUBDIR" ]; then 151 if [ -n "$ECVS_SUBDIR" ]; then
137 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 152 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
138 else 153 else
191 206
192 # cvs auto-switches branches, how nice 207 # cvs auto-switches branches, how nice
193 # 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
194 [ -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"
195 210
211 # Chowning the directory
212 if [ "${ECVS_RUNAS}" != "root" ]; then
213 chown -R "$ECVS_RUNAS" /$DIR
214 fi
215
196 # finally run the cvs update command 216 # finally run the cvs update command
197 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 217 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
198 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"
199 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..."
220
221 if [ "${ECVS_ANON}" == "no" ]; then
222
223 debug-print "$FUNCNAME: starting non-anonymous cvs login..."
224 # CVS Login - written in python :: the right way ;)
225 # Tilman Klar, <phoenix@gentoo.org>
226
227 export CVS_RSH="/usr/bin/ssh"
228
229############################## inline-python #####################################
230/usr/bin/env python << EndOfFile
231
232import pexpect,os
233
234mypasswd = "${ECVS_PASS}"
235myauth = "${ECVS_AUTH}"
236mytimeout = 10
237
238if myauth == "ext":
239 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
240 child = pexpect.spawn(mycommand)
241
242 index = child.expect(['continue connecting','word:'], mytimeout)
243 if index == 0:
244 child.sendline('yes')
245 ## Added server to ~/.ssh/known_hosts
246 child.expect('word:', mytimeout)
247 else:
248 ## Server already is in ~/.ssh/known_hosts
249 pass
250
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)
259 child.expect(pexpect.EOF)
260
261 # Logged in - checking out
262 os.system("su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\" &> /dev/null")
263EndOfFile
264########################### End of inline-python ##################################
265 else
266 debug-print "$FUNCNAME: using anonymous cvs login"
200 $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"
268 fi
201 269
270 # log out and restore ownership
271 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
272 chown root ${T}/cvspass
202} 273}
203 274
204cvs_src_unpack() { 275cvs_src_unpack() {
205 276
206 debug-print-function $FUNCNAME $* 277 debug-print-function $FUNCNAME $*

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

  ViewVC Help
Powered by ViewVC 1.1.20