| 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.30 2002/12/31 21:30:19 cretin Exp $ |
6 | # |
| 5 | # This eclass provides the generic cvs fetching functions. |
7 | # This eclass provides the generic cvs fetching functions. |
| 6 | |
8 | |
| 7 | ECLASS=cvs |
9 | ECLASS=cvs |
| 8 | INHERITED="$INHERITED $ECLASS" |
10 | INHERITED="$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" |
| … | |
… | |
| 75 | cvs_fetch() { |
78 | cvs_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: |
| 80 | ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND |
83 | 9ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND |
| 81 | ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS |
84 | ECVS_CVS_OPTIONS=$ECVS_CVS_OPTIONS |
| 82 | ECVS_TOP_DIR=$ECVS_TOP_DIR |
85 | ECVS_TOP_DIR=$ECVS_TOP_DIR |
| 83 | ECVS_SERVER=$ECVS_SERVER |
86 | ECVS_SERVER=$ECVS_SERVER |
| 84 | ECVS_ANON=$ECVS_ANON |
87 | ECVS_ANON=$ECVS_ANON |
| 85 | ECVS_USER=$ECVS_USER |
88 | ECVS_USER=$ECVS_USER |
| … | |
… | |
| 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" ] && \ |
| … | |
… | |
| 269 | os.system(mycommand) |
270 | os.system(mycommand) |
| 270 | |
271 | |
| 271 | EndOfFile |
272 | EndOfFile |
| 272 | ########################### End of inline-python ################################## |
273 | ########################### End of inline-python ################################## |
| 273 | 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 |
| 274 | 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 | |
|
|
283 | import pexpect,os |
|
|
284 | |
|
|
285 | myuser = "${ECVS_USER}" |
|
|
286 | mypasswd = "${ECVS_PASS}" |
|
|
287 | |
|
|
288 | mytimeout = 10 |
|
|
289 | |
|
|
290 | # implicitly myauth == "pserver" here. |
|
|
291 | mycommand = "cvs login" |
|
|
292 | child = pexpect.spawn(mycommand) |
|
|
293 | child.expect("CVS password:",mytimeout) |
|
|
294 | child.sendline(mypasswd) |
|
|
295 | child.expect(pexpect.EOF) |
|
|
296 | EndOfFile |
|
|
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" |
| 275 | $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" |
| 276 | fi |
|
|
| 277 | |
315 | |
|
|
316 | fi |
|
|
317 | |
| 278 | # 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" |
| 279 | if [ "$ECVS_RUNAS" == "`whoami`" ]; then |
321 | if [ "$ECVS_RUNAS" == "`whoami`" ]; then |
| 280 | cvs logout &> /dev/null |
322 | cvs logout &> /dev/null |
| 281 | else |
323 | else |
| 282 | su $ECVS_RUNAS -c "cvs logout" &> /dev/null |
324 | su $ECVS_RUNAS -c "cvs logout" &> /dev/null |
|
|
325 | fi |
| 283 | fi |
326 | fi |
| 284 | chown `whoami` "${T}/cvspass" |
327 | chown `whoami` "${T}/cvspass" |
| 285 | } |
328 | } |
| 286 | |
329 | |
| 287 | cvs_src_unpack() { |
330 | cvs_src_unpack() { |