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

Diff of /eclass/cvs.eclass

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

Revision 1.17 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.17 2002/09/10 16:59:26 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"
51[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD" 55[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD"
52 56
53# Subdirectory in module to be fetched, default is not defined = whole module 57# Subdirectory in module to be fetched, default is not defined = whole module
54# DO NOT set default to "", if it's defined at all code will break! 58# DO NOT set default to "", if it's defined at all code will break!
55# don't uncomment following line! 59# don't uncomment following line!
56#[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_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_MODULE_SUBDIR=$ECVS_SUBDIR 82ECVS_SUBDIR=$ECVS_SUBDIR
78ECVS_LOCAL=$ECVS_LOCAL 83ECVS_LOCAL=$ECVS_LOCAL
79DIR=$DIR" 84DIR=$DIR"
80 85
81 # a shorthand 86 # a shorthand
82 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" 87 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
88 debug-print "$FUNCNAME: now DIR=$DIR"
83 89
84 if [ "$ECVS_SERVER" == "offline" ]; then 90 if [ "$ECVS_SERVER" == "offline" ]; then
85 # 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
86 if [ -d "$DIR" ]; then 92 if [ -d "$DIR" ]; then
87 debug-print "$FUNCNAME: offline mode, exiting" 93 debug-print "$FUNCNAME: offline mode, exiting"
88 return 0 94 return 0
89 else 95 else
90 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting." 96 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting."
91 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"
92 return 1 98 return 1
93 fi
94 fi 99 fi
95 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}" 100 fi
101
96 # create target directory as needed 102 # create target directory as needed
97 if [ ! -d "$DIR" ]; then 103 if [ ! -d "$DIR" ]; then
98 debug-print "$FUNCNAME: creating cvs directory $DIR" 104 debug-print "$FUNCNAME: creating cvs directory $DIR"
99 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/" 105 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/"
100 addwrite /foobar 106 addwrite /foobar
105 111
106 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path, 112 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
107 # otherwise addwrite() doesn't work. 113 # otherwise addwrite() doesn't work.
108 cd -P $ECVS_TOP_DIR > /dev/null 114 cd -P $ECVS_TOP_DIR > /dev/null
109 ECVS_TOP_DIR="`/bin/pwd`" 115 ECVS_TOP_DIR="`/bin/pwd`"
116 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
110 cd $OLDPWD 117 cd $OLDPWD
118
119 debug-print "$FUNCNAME: now DIR=$DIR"
111 120
112 # disable the sandbox for this dir 121 # disable the sandbox for this dir
113 # not just $DIR because we want to create moduletopdir/CVS too 122 # not just $DIR because we want to create moduletopdir/CVS too
114 addwrite $ECVS_TOP_DIR/$ECVS_MODULE 123 addwrite $ECVS_TOP_DIR/$ECVS_MODULE
115 124
119 # 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
120 # 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.
121 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 130 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
122 export CVS_PASSFILE="${T}/cvspass" 131 export CVS_PASSFILE="${T}/cvspass"
123 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 132 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
124 133
125 # Note: cvs update and checkout commands are unified. 134 # Note: cvs update and checkout commands are unified.
126 # 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
127 # Root and Repository entries in it and cvs update. 136 # Root and Repository entries in it and cvs update.
128 137
138 [ "${ECVS_ANON}" == "yes" ] && \
129 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" 139 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
140 newserver=":ext:${ECVS_USER}@${ECVS_SERVER}"
141
130 142
131 # CVS/Repository files can't (I think) contain two concatenated slashes 143 # CVS/Repository files can't (I think) contain two concatenated slashes
132 if [ -n "$ECVS_SUBDIR" ]; then 144 if [ -n "$ECVS_SUBDIR" ]; then
133 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 145 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
134 else 146 else
135 repository="${ECVS_MODULE}" 147 repository="${ECVS_MODULE}"
136 fi 148 fi
137 149
138 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" 150 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
139 151 debug-print "$FUNCNAME: entering directory $DIR"
140 cd /$DIR 152 cd /$DIR
141 153
142 if [ ! -d "$DIR/CVS" ]; then 154 if [ ! -d "CVS" ]; then
143 # create a new CVS/ directory (checkout) 155 # create a new CVS/ directory (checkout)
144 debug-print "$FUNCNAME: creating new cvs directory" 156 debug-print "$FUNCNAME: creating new cvs directory"
145 157
146 mkdir CVS 158 mkdir CVS
147 echo $newserver > CVS/Root 159 echo $newserver > CVS/Root
188 # cvs auto-switches branches, how nice 200 # cvs auto-switches branches, how nice
189 # warning: if we do it this way we get multiple -rX options - harmless i think 201 # warning: if we do it this way we get multiple -rX options - harmless i think
190 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 202 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
191 203
192 # finally run the cvs update command 204 # finally run the cvs update command
205 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
193 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"
194 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"
195 $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
196 248
197} 249}
198 250
199cvs_src_unpack() { 251cvs_src_unpack() {
200 252
201 debug-print-function $FUNCNAME $* 253 debug-print-function $FUNCNAME $*
202 cvs_fetch || die "died running cvs_fetch" 254 cvs_fetch || die "died running cvs_fetch"
203 255
204 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 256 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
205 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
206 261
207 if [ -n "$ECVS_SUBDIR" ]; then 262 if [ -n "$ECVS_SUBDIR" ]; then
208 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 263 if [ -n "$ECVS_LOCAL" ]; then
209 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
210 else 268 else
211 if [ -n "$ECVS_LOCAL" ]; then 269 if [ -n "$ECVS_LOCAL" ]; then
212 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 270 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE
213 else 271 else
214 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 272 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
221 if [ "`ls -A $DIR`" == "CVS" ]; then 279 if [ "`ls -A $DIR`" == "CVS" ]; then
222 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 280 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
223 rm -rf $DIR 281 rm -rf $DIR
224 fi 282 fi
225 283
226 # implement some of base_src_unpack's functionality; 284 # implement some of base_src_unpack's functionality;
227 # note however that base.eclass may not have been inherited! 285 # note however that base.eclass may not have been inherited!
228 if [ -n "$PATCHES" ]; then 286 if [ -n "$PATCHES" ]; then
229 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 287 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
230 cd $S 288 cd $S
231 for x in $PATCHES; do 289 for x in $PATCHES; do
232 debug-print "patching from $x" 290 debug-print "patching from $x"
233 patch -p0 < $x 291 patch -p0 < $x
234 done 292 done
235 # 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
236 # 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
237 export PATCHES="" 295 export PATCHES=""
238 fi 296 fi
239 297
240} 298}
241 299
242EXPORT_FUNCTIONS src_unpack 300EXPORT_FUNCTIONS src_unpack
243
244

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

  ViewVC Help
Powered by ViewVC 1.1.20