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

Diff of /eclass/cvs.eclass

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

Revision 1.12 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.12 2002/08/18 23:54:59 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
24 24
25# set this for the module/subdir to be fetched non-recursively 25# set this for the module/subdir to be fetched non-recursively
26#[ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" 26#[ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
27 27
28# Where the cvs modules are stored/accessed 28# Where the cvs modules are stored/accessed
29[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="/usr/src" 29[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src"
30 30
31# Name of cvs server, set to "offline" to disable fetching 31# Name of cvs server, set to "offline" to disable fetching
32# (i.e. to assume module is checked out already and don't update it). 32# (i.e. to assume module is checked out already and don't update it).
33# Format is server:/dir e.g. "anoncvs.kde.org:/home/kde". remove the other 33# Format is server:/dir e.g. "anoncvs.kde.org:/home/kde". remove the other
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"
48 52
53# Branch/tag to use, default is HEAD
54# uncomment the following line to enable the reset-branch-to-HEAD behaviour
55[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD"
56
49# 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
50# 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!
51# don't uncomment following line! 59# don't uncomment following line!
52#[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR="" 60#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR=""
53 61
54# --- end ebuild-configurable settings --- 62# --- end ebuild-configurable settings ---
55 63
56# add cvs to deps 64# add cvs to deps
57DEPEND="$DEPEND dev-util/cvs" 65DEPEND="$DEPEND dev-util/cvs dev-python/pexpect"
58 66
59# 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,
60# we are forced to call this function from cvs_src_unpack 68# we are forced to call this function from cvs_src_unpack
61cvs_fetch() { 69cvs_fetch() {
62 70
65 debug-print "$FUNCNAME: init: 73 debug-print "$FUNCNAME: init:
66ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 74ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
67ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 75ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
68ECVS_TOP_DIR=$ECVS_TOP_DIR 76ECVS_TOP_DIR=$ECVS_TOP_DIR
69ECVS_SERVER=$ECVS_SERVER 77ECVS_SERVER=$ECVS_SERVER
78ECVS_ANON=$ECVS_ANON
70ECVS_USER=$ECVS_USER 79ECVS_USER=$ECVS_USER
71ECVS_PASS=$ECVS_PASS 80ECVS_PASS=$ECVS_PASS
72ECS_MODULE=$ECVS_MODULE 81ECS_MODULE=$ECVS_MODULE
73ECVS_MODULE_SUBDIR=$ECVS_SUBDIR 82ECVS_SUBDIR=$ECVS_SUBDIR
74ECVS_LOCAL=$ECVS_LOCAL 83ECVS_LOCAL=$ECVS_LOCAL
75DIR=$DIR" 84DIR=$DIR"
76 85
77 # a shorthand 86 # a shorthand
78 [ -n "$ECVS_SUBDIR" ] && DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" || \
79 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}" 87 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
88 debug-print "$FUNCNAME: now DIR=$DIR"
80 89
81 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
82
83 addread $DIR
84
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
95 fi 99 fi
100 fi
96 101
102 # create target directory as needed
103 if [ ! -d "$DIR" ]; then
104 debug-print "$FUNCNAME: creating cvs directory $DIR"
105 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/"
106 addwrite /foobar
107 addwrite /
108 mkdir -p /$DIR
109 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foobar:\/}
110 fi
111
112 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
113 # otherwise addwrite() doesn't work.
114 cd -P $ECVS_TOP_DIR > /dev/null
115 ECVS_TOP_DIR="`/bin/pwd`"
116 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
117 cd $OLDPWD
118
119 debug-print "$FUNCNAME: now DIR=$DIR"
120
97 # disable the sandbox for this dir 121 # disable the sandbox for this dir
98
99 # not just $DIR because we want to create moduletopdir/CVS too 122 # not just $DIR because we want to create moduletopdir/CVS too
100 addwrite $ECVS_TOP_DIR/$ECVS_MODULE 123 addwrite $ECVS_TOP_DIR/$ECVS_MODULE
101
102 if [ ! -d "$DIR" ]; then
103 debug-print "$FUNCNAME: creating cvs directory $DIR"
104 einfo "Creating directory $DIR"
105 export SANDBOX_WRITE="$SANDBOX_WRITE:/foo:/"
106 mkdir -p /$DIR
107 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foo:\/}
108 fi
109 124
125 # add option for local (non-recursive) fetching
126 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
127
110 # 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
111 # 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.
112 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 130 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
113 export CVS_PASSFILE="${T}/cvspass" 131 export CVS_PASSFILE="${T}/cvspass"
114 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 132 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
115 133
116 # Note: cvs update and checkout commands are unified. 134 # Note: cvs update and checkout commands are unified.
117 # 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
118 # Root and Repository entries in it and cvs update. 136 # Root and Repository entries in it and cvs update.
119 137
120 newserver=":pserver:anonymous@${ECVS_SERVER}" 138 [ "${ECVS_ANON}" == "yes" ] && \
139 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
140 newserver=":ext:${ECVS_USER}@${ECVS_SERVER}"
141
121 142
122 # CVS/Repository files can't (I think) contain two concatenated slashes 143 # CVS/Repository files can't (I think) contain two concatenated slashes
123 if [ -n "$ECVS_SUBDIR" ]; then 144 if [ -n "$ECVS_SUBDIR" ]; then
124 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 145 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
125 else 146 else
126 repository="${ECVS_MODULE}" 147 repository="${ECVS_MODULE}"
127 fi 148 fi
128 149
129 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" 150 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
130 151 debug-print "$FUNCNAME: entering directory $DIR"
131 cd $DIR 152 cd /$DIR
153
132 if [ ! -d "$DIR/CVS" ]; then 154 if [ ! -d "CVS" ]; then
133 # create a new CVS/ directory (checkout) 155 # create a new CVS/ directory (checkout)
134 debug-print "$FUNCNAME: creating new cvs directory" 156 debug-print "$FUNCNAME: creating new cvs directory"
135 157
136 mkdir CVS 158 mkdir CVS
137 echo $newserver > CVS/Root 159 echo $newserver > CVS/Root
173 195
174 fi 196 fi
175 197
176 fi 198 fi
177 199
200 # cvs auto-switches branches, how nice
201 # warning: if we do it this way we get multiple -rX options - harmless i think
202 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
203
178 # finally run the cvs update command 204 # finally run the cvs update command
205 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
179 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"
180 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"
181 $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
182 248
183} 249}
184 250
185cvs_src_unpack() { 251cvs_src_unpack() {
186 252
187 debug-print-function $FUNCNAME $* 253 debug-print-function $FUNCNAME $*
188 cvs_fetch || die "died running cvs_fetch" 254 cvs_fetch || die "died running cvs_fetch"
189 255
190 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 256 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
191 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
192 261
193 if [ -n "$ECVS_SUBDIR" ]; then 262 if [ -n "$ECVS_SUBDIR" ]; then
194 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 263 if [ -n "$ECVS_LOCAL" ]; then
195 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
196 else 268 else
197 if [ -n "$ECVS_LOCAL" ]; then 269 if [ -n "$ECVS_LOCAL" ]; then
198 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 270 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE
199 else 271 else
200 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 272 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
207 if [ "`ls -A $DIR`" == "CVS" ]; then 279 if [ "`ls -A $DIR`" == "CVS" ]; then
208 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 280 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
209 rm -rf $DIR 281 rm -rf $DIR
210 fi 282 fi
211 283
212 # implement some of base_src_unpack's functionality; 284 # implement some of base_src_unpack's functionality;
213 # note however that base.eclass may not have been inherited! 285 # note however that base.eclass may not have been inherited!
214 if [ -n "$PATCHES" ]; then 286 if [ -n "$PATCHES" ]; then
215 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 287 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
216 cd $S 288 cd $S
217 for x in $PATCHES; do 289 for x in $PATCHES; do
218 debug-print "patching from $x" 290 debug-print "patching from $x"
219 patch -p0 < $x 291 patch -p0 < $x
220 done 292 done
221 # 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
222 # 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
223 export PATCHES="" 295 export PATCHES=""
224 fi 296 fi
225 297
226} 298}
227 299
228EXPORT_FUNCTIONS src_unpack 300EXPORT_FUNCTIONS src_unpack
229
230

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

  ViewVC Help
Powered by ViewVC 1.1.20