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

Diff of /eclass/cvs.eclass

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

Revision 1.25 Revision 1.33
1# Copyright 1999-2000 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.33 2003/03/19 11:54:21 danarmak Exp $
4#
3# Author Dan Armak <danarmak@gentoo.org> 5# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.25 2002/11/22 13:35:29 cretin Exp $ 6#
5# This eclass provides the generic cvs fetching functions. 7# This eclass provides the generic cvs fetching functions.
6 8
7ECLASS=cvs 9ECLASS=cvs
8INHERITED="$INHERITED $ECLASS" 10INHERITED="$INHERITED $ECLASS"
9 11
47[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 49[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
48 50
49# Username to use 51# Username to use
50[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 52[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
51 53
52# 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
53[ -z "$ECVS_PASS" ] && ECVS_PASS="" 56[ -z "$ECVS_PASS" ] && ECVS_PASS=""
54 57
55# Module to be fetched, must be set explicitly - 58# Module to be fetched, must be set explicitly -
56# I don't like the former ="$PN" default setting 59# I don't like the former ="$PN" default setting
57[ -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"
75cvs_fetch() { 78cvs_fetch() {
76 79
77 debug-print-function $FUNCNAME $* 80 debug-print-function $FUNCNAME $*
78 81
79 debug-print "$FUNCNAME: init: 82 debug-print "$FUNCNAME: init:
80ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 839ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
81ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS 84ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS
82ECVS_TOP_DIR=$ECVS_TOP_DIR 85ECVS_TOP_DIR=$ECVS_TOP_DIR
83ECVS_SERVER=$ECVS_SERVER 86ECVS_SERVER=$ECVS_SERVER
84ECVS_ANON=$ECVS_ANON 87ECVS_ANON=$ECVS_ANON
85ECVS_USER=$ECVS_USER 88ECVS_USER=$ECVS_USER
109 if [ ! -d "$DIR" ]; then 112 if [ ! -d "$DIR" ]; then
110 debug-print "$FUNCNAME: creating cvs directory $DIR" 113 debug-print "$FUNCNAME: creating cvs directory $DIR"
111 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/" 114 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/"
112 addwrite /foobar 115 addwrite /foobar
113 addwrite / 116 addwrite /
114 mkdir -p /$DIR 117 mkdir -p "/$DIR"
115 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foobar:\/} 118 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
116 fi 119 fi
117 120
118 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path, 121 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
119 # otherwise addwrite() doesn't work. 122 # otherwise addwrite() doesn't work.
120 cd -P $ECVS_TOP_DIR > /dev/null 123 cd -P "$ECVS_TOP_DIR" > /dev/null
121 ECVS_TOP_DIR="`/bin/pwd`" 124 ECVS_TOP_DIR="`/bin/pwd`"
122 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" 125 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
123 cd $OLDPWD 126 cd "$OLDPWD"
124 127
125 debug-print "$FUNCNAME: now DIR=$DIR" 128 debug-print "$FUNCNAME: now DIR=$DIR"
126 129
127 # disable the sandbox for this dir 130 # disable the sandbox for this dir
128 # not just $DIR because we want to create moduletopdir/CVS too 131 # not just $DIR because we want to create moduletopdir/CVS too
129 addwrite $ECVS_TOP_DIR/$ECVS_MODULE 132 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE"
130 133
131 # add option for local (non-recursive) fetching 134 # add option for local (non-recursive) fetching
132 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" 135 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
133 136
134 # 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
135 # in at the cvs server. we don't want to mess with ~/.cvspass. 138 touch "${T}/cvspass"
136 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
137 export CVS_PASSFILE="${T}/cvspass" 139 export CVS_PASSFILE="${T}/cvspass"
138 chown $ECVS_RUNAS "${T}/cvspass" 140 chown $ECVS_RUNAS "${T}/cvspass"
139 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 141
140
141 # Note: cvs update and checkout commands are unified. 142 # Note: cvs update and checkout commands are unified.
142 # 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
143 # Root and Repository entries in it and cvs update. 144 # Root and Repository entries in it and cvs update.
144 145
145 [ "${ECVS_ANON}" == "yes" ] && \ 146 [ "${ECVS_ANON}" == "yes" ] && \
154 repository="${ECVS_MODULE}" 155 repository="${ECVS_MODULE}"
155 fi 156 fi
156 157
157 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" 158 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
158 debug-print "$FUNCNAME: entering directory $DIR" 159 debug-print "$FUNCNAME: entering directory $DIR"
159 cd /$DIR 160 cd "/$DIR"
160 161
161 if [ ! -d "CVS" ]; then 162 if [ ! -d "CVS" ]; then
162 # create a new CVS/ directory (checkout) 163 # create a new CVS/ directory (checkout)
163 debug-print "$FUNCNAME: creating new cvs directory" 164 debug-print "$FUNCNAME: creating new cvs directory"
164 165
170 # if we're checking out a subdirectory only, create a CVS/ dir 171 # if we're checking out a subdirectory only, create a CVS/ dir
171 # in the module's top dir so that the user (and we) can cvs update 172 # in the module's top dir so that the user (and we) can cvs update
172 # from there to get the full module. 173 # from there to get the full module.
173 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then 174 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then
174 debug-print "$FUNCNAME: Copying CVS/ directory to module top-level dir" 175 debug-print "$FUNCNAME: Copying CVS/ directory to module top-level dir"
175 cp -r CVS $ECVS_TOP_DIR/$ECVS_MODULE/ 176 cp -r CVS "$ECVS_TOP_DIR/$ECVS_MODULE/"
176 echo $ECVS_MODULE > $ECVS_TOP_DIR/$ECVS_MODULE/CVS/Repository 177 echo $ECVS_MODULE > "$ECVS_TOP_DIR/$ECVS_MODULE/CVS/Repository"
177 fi 178 fi
178 179
179 else 180 else
180 #update existing module 181 #update existing module
181 debug-print "$FUNCNAME: updating existing module/subdir" 182 debug-print "$FUNCNAME: updating existing module/subdir"
195 debug-print "$cvsdirs" 196 debug-print "$cvsdirs"
196 197
197 einfo "Modifying CVS dirs..." 198 einfo "Modifying CVS dirs..."
198 for x in $cvsdirs; do 199 for x in $cvsdirs; do
199 debug-print "In $x" 200 debug-print "In $x"
200 echo $newserver > $x/Root 201 echo $newserver > "$x/Root"
201 done 202 done
202 203
203 fi 204 fi
204 205
205 fi 206 fi
207 # cvs auto-switches branches, how nice 208 # cvs auto-switches branches, how nice
208 # warning: if we do it this way we get multiple -rX options - harmless i think 209 # warning: if we do it this way we get multiple -rX options - harmless i think
209 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 210 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
210 211
211 # Chowning the directory 212 # Chowning the directory
212 if [ "${ECVS_RUNAS}" != "root" ]; then 213 if [ "${ECVS_RUNAS}" != "`whoami`" ]; then
213 chown -R "$ECVS_RUNAS" /$DIR 214 chown -R "$ECVS_RUNAS" "/$DIR"
214 fi 215 fi
215 216
216 # finally run the cvs update command 217 # finally run the cvs update command
217 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 218 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
218 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR" 219 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
233 234
234mypasswd = "${ECVS_PASS}" 235mypasswd = "${ECVS_PASS}"
235myauth = "${ECVS_AUTH}" 236myauth = "${ECVS_AUTH}"
236mytimeout = 10 237mytimeout = 10
237 238
239if "${ECVS_RUNAS}" == "`whoami`":
240 mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}"
241else:
242 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
243
238if myauth == "ext": 244if myauth == "ext":
239 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
240 child = pexpect.spawn(mycommand) 245 child = pexpect.spawn(mycommand)
241 246
242 index = child.expect(['continue connecting','word:'], mytimeout) 247 index = child.expect(['continue connecting','word:'], mytimeout)
243 if index == 0: 248 if index == 0:
244 child.sendline('yes') 249 child.sendline('yes')
250 255
251 child.sendline(mypasswd) 256 child.sendline(mypasswd)
252 child.expect(pexpect.EOF) 257 child.expect(pexpect.EOF)
253 258
254elif myauth == "pserver": 259elif myauth == "pserver":
260 if "${ECVS_RUNAS}" == "`whoami`":
261 mycommand2 = "cvs login"
262 else:
255 mycommand = "su ${ECVS_RUNAS} -c \"cvs login\"" 263 mycommand2 = "su ${ECVS_RUNAS} -c \"cvs login\""
256 child = pexpect.spawn(mycommand) 264 child = pexpect.spawn(mycommand2)
257 child.expect("CVS password:",mytimeout) 265 child.expect("CVS password:",mytimeout)
258 child.sendline(mypasswd) 266 child.sendline(mypasswd)
259 child.expect(pexpect.EOF) 267 child.expect(pexpect.EOF)
260 268
261 # Logged in - checking out 269 # Logged in - checking out
262 os.system("su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\" &> /dev/null") 270 os.system(mycommand)
271
263EndOfFile 272EndOfFile
264########################### End of inline-python ################################## 273########################### End of inline-python ##################################
265 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
266 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"
267 $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"
268 fi
269 315
316 fi
317
270 # 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"
321 if [ "$ECVS_RUNAS" == "`whoami`" ]; then
322 cvs logout &> /dev/null
323 else
271 su $ECVS_RUNAS -c "cvs logout" &> /dev/null 324 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
325 fi
326 fi
272 chown `whoami` ${T}/cvspass 327 chown `whoami` "${T}/cvspass"
273} 328}
274 329
275cvs_src_unpack() { 330cvs_src_unpack() {
276 331
277 debug-print-function $FUNCNAME $* 332 debug-print-function $FUNCNAME $*
279 334
280 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..." 335 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
281 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 336 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
282 337
283 # probably redundant, but best to make sure 338 # probably redundant, but best to make sure
284 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 339 mkdir -p "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR"
285 340
286 if [ -n "$ECVS_SUBDIR" ]; then 341 if [ -n "$ECVS_SUBDIR" ]; then
287 if [ -n "$ECVS_LOCAL" ]; then 342 if [ -n "$ECVS_LOCAL" ]; then
288 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 343 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR"/* "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR"
289 else 344 else
290 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/.. 345 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR" "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/.."
291 fi 346 fi
292 else 347 else
293 if [ -n "$ECVS_LOCAL" ]; then 348 if [ -n "$ECVS_LOCAL" ]; then
294 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 349 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* $WORKDIR/$ECVS_MODULE
295 else 350 else
296 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 351 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR"
297 fi 352 fi
298 fi 353 fi
299 354
300 # if the directory is empty, remove it; empty directories cannot exist in cvs. 355 # if the directory is empty, remove it; empty directories cannot exist in cvs.
301 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist. 356 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist.
302 # still create the empty directory in workdir though. 357 # still create the empty directory in workdir though.
303 if [ "`ls -A $DIR`" == "CVS" ]; then 358 if [ "`ls -A \"$DIR\"`" == "CVS" ]; then
304 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 359 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
305 rm -rf $DIR 360 rm -rf "$DIR"
306 fi 361 fi
307 362
308 # implement some of base_src_unpack's functionality; 363 # implement some of base_src_unpack's functionality;
309 # note however that base.eclass may not have been inherited! 364 # note however that base.eclass may not have been inherited!
310 if [ -n "$PATCHES" ]; then 365 if [ -n "$PATCHES" ]; then
311 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 366 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
312 cd $S 367 cd "$S"
313 for x in $PATCHES; do 368 for x in $PATCHES; do
314 debug-print "patching from $x" 369 debug-print "patching from $x"
315 patch -p0 < $x 370 patch -p0 < "$x"
316 done 371 done
317 # make sure we don't try to apply patches more than once, since 372 # make sure we don't try to apply patches more than once, since
318 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack 373 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
319 export PATCHES="" 374 export PATCHES=""
320 fi 375 fi

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20