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

Diff of /eclass/cvs.eclass

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

Revision 1.18 Revision 1.23
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 or later 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.18 2002/09/15 14:15:54 danarmak Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.23 2002/11/01 10:54:42 danarmak 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
39# Username to use 43# Username to use
40[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 44[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
41 45
42# Password to use (NOT (YET) SUPPORTED, because cvs doesn't store passwords in plaintext in .cvspass) 46# Password to use if anonymous login is off
43[ -z "$ECVS_PASS" ] && ECVS_PASS="" 47[ -z "$ECVS_PASS" ] && ECVS_PASS=""
44 48
45# Module to be fetched, must be set explicitly - 49# Module to be fetched, must be set explicitly -
46# I don't like the former ="$PN" default setting 50# I don't like the former ="$PN" default setting
47[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue" 51[ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue"
56#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR="" 60#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR=""
57 61
58# --- end ebuild-configurable settings --- 62# --- end ebuild-configurable settings ---
59 63
60# add cvs to deps 64# add cvs to deps
61DEPEND="$DEPEND dev-util/cvs" 65DEPEND="$DEPEND dev-util/cvs dev-python/pexpect"
62 66
63# since we now longer have src_fetch as a redefinable ebuild function, 67# since we now longer have src_fetch as a redefinable ebuild function,
64# we are forced to call this function from cvs_src_unpack 68# we are forced to call this function from cvs_src_unpack
65cvs_fetch() { 69cvs_fetch() {
66 70
69 debug-print "$FUNCNAME: init: 73 debug-print "$FUNCNAME: init:
70ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 74ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
71ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 75ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
72ECVS_TOP_DIR=$ECVS_TOP_DIR 76ECVS_TOP_DIR=$ECVS_TOP_DIR
73ECVS_SERVER=$ECVS_SERVER 77ECVS_SERVER=$ECVS_SERVER
78ECVS_ANON=$ECVS_ANON
74ECVS_USER=$ECVS_USER 79ECVS_USER=$ECVS_USER
75ECVS_PASS=$ECVS_PASS 80ECVS_PASS=$ECVS_PASS
76ECS_MODULE=$ECVS_MODULE 81ECS_MODULE=$ECVS_MODULE
77ECVS_SUBDIR=$ECVS_SUBDIR 82ECVS_SUBDIR=$ECVS_SUBDIR
78ECVS_LOCAL=$ECVS_LOCAL 83ECVS_LOCAL=$ECVS_LOCAL
82 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" 87 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
83 debug-print "$FUNCNAME: now DIR=$DIR" 88 debug-print "$FUNCNAME: now DIR=$DIR"
84 89
85 if [ "$ECVS_SERVER" == "offline" ]; then 90 if [ "$ECVS_SERVER" == "offline" ]; then
86 # we're not required to fetch anything, the module already exists and shouldn't be updated 91 # we're not required to fetch anything, the module already exists and shouldn't be updated
87 if [ -d "$DIR" ]; then 92 if [ -d "$DIR" ]; then
88 debug-print "$FUNCNAME: offline mode, exiting" 93 debug-print "$FUNCNAME: offline mode, exiting"
89 return 0 94 return 0
90 else 95 else
91 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting." 96 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting."
92 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error" 97 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error"
93 return 1 98 return 1
94 fi 99 fi
95 fi 100 fi
96 101
97 # create target directory as needed 102 # create target directory as needed
98 if [ ! -d "$DIR" ]; then 103 if [ ! -d "$DIR" ]; then
99 debug-print "$FUNCNAME: creating cvs directory $DIR" 104 debug-print "$FUNCNAME: creating cvs directory $DIR"
123 # prepare a cvspass file just for this session so that cvs thinks we're logged 128 # 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. 129 # in at the cvs server. we don't want to mess with ~/.cvspass.
125 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 130 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
126 export CVS_PASSFILE="${T}/cvspass" 131 export CVS_PASSFILE="${T}/cvspass"
127 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 132 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
128 133
129 # Note: cvs update and checkout commands are unified. 134 # Note: cvs update and checkout commands are unified.
130 # we make sure a CVS/ dir exists in our module subdir with the right 135 # we make sure a CVS/ dir exists in our module subdir with the right
131 # Root and Repository entries in it and cvs update. 136 # Root and Repository entries in it and cvs update.
132 137
138 [ "${ECVS_ANON}" == "yes" ] && \
133 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" 139 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
140 newserver=":ext:${ECVS_USER}@${ECVS_SERVER}"
141
134 142
135 # CVS/Repository files can't (I think) contain two concatenated slashes 143 # CVS/Repository files can't (I think) contain two concatenated slashes
136 if [ -n "$ECVS_SUBDIR" ]; then 144 if [ -n "$ECVS_SUBDIR" ]; then
137 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 145 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
138 else 146 else
195 203
196 # finally run the cvs update command 204 # finally run the cvs update command
197 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 205 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" 206 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..." 207 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
208
209 if [ "${ECVS_ANON}" == "no" ]; then
210
211 debug-print "$FUNCNAME: starting non-anonymous cvs login..."
212 # CVS Login - written in python :: the right way ;)
213 # Tilman Klar, <phoenix@gentoo.org>
214
215 export CVS_RSH="/usr/bin/ssh"
216
217############################## inline-python #####################################
218/usr/bin/env python << EndOfFile
219
220import pexpect,os
221
222mypasswd = "${ECVS_PASS}"
223mytimeout = 10
224
225mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}"
226child = pexpect.spawn(mycommand)
227
228index = child.expect(['continue connecting','word:'], mytimeout)
229if index == 0:
230 child.sendline('yes')
231 ## Added server to ~/.ssh/known_hosts
232 child.expect('word:', mytimeout)
233else:
234 ## Server already is in ~/.ssh/known_hosts
235 pass
236
237child.sendline(mypasswd)
238child.expect(pexpect.EOF)
239
240EndOfFile
241########################### End of inline-python ##################################
242 else
243 debug-print "$FUNCNAME: using anonymous cvs login"
200 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update" 244 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update"
245 fi
246
247
201 248
202} 249}
203 250
204cvs_src_unpack() { 251cvs_src_unpack() {
205 252
206 debug-print-function $FUNCNAME $* 253 debug-print-function $FUNCNAME $*
207 cvs_fetch || die "died running cvs_fetch" 254 cvs_fetch || die "died running cvs_fetch"
208 255
209 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 256 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
210 debug-print "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 257 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
258
259 # probably redundant, but best to make sure
260 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR
211 261
212 if [ -n "$ECVS_SUBDIR" ]; then 262 if [ -n "$ECVS_SUBDIR" ]; then
213 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 263 if [ -n "$ECVS_LOCAL" ]; then
214 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/ 264 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR
265 else
266 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/..
267 fi
215 else 268 else
216 if [ -n "$ECVS_LOCAL" ]; then 269 if [ -n "$ECVS_LOCAL" ]; then
217 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 270 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE
218 else 271 else
219 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 272 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
226 if [ "`ls -A $DIR`" == "CVS" ]; then 279 if [ "`ls -A $DIR`" == "CVS" ]; then
227 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 280 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
228 rm -rf $DIR 281 rm -rf $DIR
229 fi 282 fi
230 283
231 # implement some of base_src_unpack's functionality; 284 # implement some of base_src_unpack's functionality;
232 # note however that base.eclass may not have been inherited! 285 # note however that base.eclass may not have been inherited!
233 if [ -n "$PATCHES" ]; then 286 if [ -n "$PATCHES" ]; then
234 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 287 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
235 cd $S 288 cd $S
236 for x in $PATCHES; do 289 for x in $PATCHES; do
237 debug-print "patching from $x" 290 debug-print "patching from $x"
238 patch -p0 < $x 291 patch -p0 < $x
239 done 292 done
240 # make sure we don't try to apply patches more than once, since 293 # make sure we don't try to apply patches more than once, since
241 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack 294 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
242 export PATCHES="" 295 export PATCHES=""
243 fi 296 fi
244 297
245} 298}
246 299
247EXPORT_FUNCTIONS src_unpack 300EXPORT_FUNCTIONS src_unpack
248
249

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

  ViewVC Help
Powered by ViewVC 1.1.20