| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 Gentoo Foundation |
| 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.50 2004/01/04 14:35:12 coredumb Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.54 2004/12/13 06:35:06 fafhrd Exp $ |
| 4 | |
4 | |
| 5 | # Current Maintainer: Tal Peer <coredumb@gentoo.org> |
5 | # Current Maintainer: Tal Peer <coredumb@gentoo.org> |
| 6 | # Original Author: Dan Armak <danarmak@gentoo.org> |
6 | # Original Author: Dan Armak <danarmak@gentoo.org> |
| 7 | |
7 | |
| 8 | # SSH auth code by Danny <danny.milo@gmx.net> |
8 | # SSH auth code by Danny <danny.milo@gmx.net> |
| … | |
… | |
| 108 | # |
108 | # |
| 109 | # Possible values are "pserver" and "ext". If `ext' authentication is |
109 | # Possible values are "pserver" and "ext". If `ext' authentication is |
| 110 | # used, the remote shell to use can be specified in CVS_RSH (SSH is |
110 | # used, the remote shell to use can be specified in CVS_RSH (SSH is |
| 111 | # used by default). Currently, the only supported remote shell for |
111 | # used by default). Currently, the only supported remote shell for |
| 112 | # `ext' authentication is SSH. |
112 | # `ext' authentication is SSH. |
|
|
113 | # |
|
|
114 | # Armando Di Cianno <fafhrd@gentoo.org> 2004/09/27 |
|
|
115 | # - Added "no" as a server type, which uses no AUTH method, nor |
|
|
116 | # does it login |
|
|
117 | # e.g. |
|
|
118 | # "cvs -danoncvs@savannah.gnu.org:/cvsroot/backbone co System" |
|
|
119 | # ( from gnustep-apps/textedit ) |
| 113 | [ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" |
120 | [ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" |
| 114 | |
121 | |
| 115 | # ECVS_USER -- Username to use for authentication on the remote server |
122 | # ECVS_USER -- Username to use for authentication on the remote server |
| 116 | [ -z "$ECVS_USER" ] && ECVS_USER="anonymous" |
123 | [ -z "$ECVS_USER" ] && ECVS_USER="anonymous" |
| 117 | |
124 | |
| … | |
… | |
| 268 | fi |
275 | fi |
| 269 | |
276 | |
| 270 | |
277 | |
| 271 | # Our server string (i.e. CVSROOT) without the password so it can |
278 | # Our server string (i.e. CVSROOT) without the password so it can |
| 272 | # be put in Root |
279 | # be put in Root |
|
|
280 | if [ "$ECVS_AUTH" == "no" ] |
|
|
281 | then |
|
|
282 | local server="${ECVS_USER}@${ECVS_SERVER}" |
|
|
283 | else |
| 273 | local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" |
284 | local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" |
|
|
285 | fi |
| 274 | |
286 | |
| 275 | # Switch servers automagically if needed |
287 | # Switch servers automagically if needed |
| 276 | if [ "$mode" == "update" ]; then |
288 | if [ "$mode" == "update" ]; then |
| 277 | cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME |
289 | cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME |
| 278 | local oldserver="`$run cat CVS/Root`" |
290 | local oldserver="`$run cat CVS/Root`" |
| 279 | if [ "$server" != "$oldserver" ]; then |
291 | if [ "$server" != "$oldserver" ]; then |
| 280 | |
292 | |
| 281 | einfo "Changing the CVS server from $oldserver to $server:" |
293 | einfo "Changing the CVS server from $oldserver to $server:" |
| 282 | debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:" |
294 | debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:" |
| 283 | |
295 | |
| 284 | einfo "Searching for CVS directories..." |
296 | einfo "Searching for CVS directories ..." |
| 285 | local cvsdirs="`$run find . -iname CVS -print`" |
297 | local cvsdirs="`$run find . -iname CVS -print`" |
| 286 | debug-print "$FUNCNAME: CVS directories found:" |
298 | debug-print "$FUNCNAME: CVS directories found:" |
| 287 | debug-print "$cvsdirs" |
299 | debug-print "$cvsdirs" |
| 288 | |
300 | |
| 289 | einfo "Modifying CVS directories..." |
301 | einfo "Modifying CVS directories ..." |
| 290 | for x in $cvsdirs; do |
302 | for x in $cvsdirs; do |
| 291 | debug-print "In $x" |
303 | debug-print "In $x" |
| 292 | $run echo "$server" > "$x/Root" |
304 | $run echo "$server" > "$x/Root" |
| 293 | done |
305 | done |
| 294 | |
306 | |
| … | |
… | |
| 306 | # The server string with the password in it, for login |
318 | # The server string with the password in it, for login |
| 307 | cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" |
319 | cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" |
| 308 | |
320 | |
| 309 | # Ditto without the password, for checkout/update after login, so |
321 | # Ditto without the password, for checkout/update after login, so |
| 310 | # that the CVS/Root files don't contain the password in plaintext |
322 | # that the CVS/Root files don't contain the password in plaintext |
|
|
323 | if [ "$ECVS_AUTH" == "no" ] |
|
|
324 | then |
|
|
325 | cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}" |
|
|
326 | else |
| 311 | cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" |
327 | cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" |
|
|
328 | fi |
| 312 | |
329 | |
| 313 | # Commands to run |
330 | # Commands to run |
| 314 | cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" |
331 | cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" |
| 315 | cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}" |
332 | cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}" |
| 316 | cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}" |
333 | cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}" |
| … | |
… | |
| 326 | eval $cmdupdate || die "cvs update command failed" |
343 | eval $cmdupdate || die "cvs update command failed" |
| 327 | elif [ "${mode}" == "checkout" ]; then |
344 | elif [ "${mode}" == "checkout" ]; then |
| 328 | einfo "Running $cmdcheckout" |
345 | einfo "Running $cmdcheckout" |
| 329 | eval $cmdcheckout|| die "cvs checkout command failed" |
346 | eval $cmdcheckout|| die "cvs checkout command failed" |
| 330 | fi |
347 | fi |
| 331 | elif [ "${ECVS_AUTH}" == "ext" ]; then |
348 | elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then |
| 332 | |
349 | |
| 333 | # Hack to support SSH password authentication |
350 | # Hack to support SSH password authentication |
| 334 | |
351 | |
| 335 | # Backup environment variable values |
352 | # Backup environment variable values |
| 336 | local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" |
353 | local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" |
| … | |
… | |
| 368 | except: |
385 | except: |
| 369 | pass |
386 | pass |
| 370 | newarglist = sys.argv[:] |
387 | newarglist = sys.argv[:] |
| 371 | EOF |
388 | EOF |
| 372 | |
389 | |
|
|
390 | # disable X11 forwarding which causes .xauth access violations |
|
|
391 | # - 20041205 Armando Di Cianno <fafhrd@gentoo.org> |
|
|
392 | echo "newarglist.insert(1, '-oClearAllForwardings=yes')" \ |
|
|
393 | >> "${CVS_RSH}" |
|
|
394 | echo "newarglist.insert(1, '-oForwardX11=no')" \ |
|
|
395 | >> "${CVS_RSH}" |
|
|
396 | |
| 373 | # Handle SSH host key checking |
397 | # Handle SSH host key checking |
| 374 | |
398 | |
| 375 | local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" |
399 | local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" |
| 376 | echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ |
400 | echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ |
| 377 | >> "${CVS_RSH}" |
401 | >> "${CVS_RSH}" |
| … | |
… | |
| 379 | if [ -z "${ECVS_SSH_HOST_KEY}" ]; then |
403 | if [ -z "${ECVS_SSH_HOST_KEY}" ]; then |
| 380 | ewarn "Warning: The SSH host key of the remote server will not be verified." |
404 | ewarn "Warning: The SSH host key of the remote server will not be verified." |
| 381 | einfo "A temporary known hosts list will be used." |
405 | einfo "A temporary known hosts list will be used." |
| 382 | local CVS_ECLASS_STRICT_HOST_CHECKING="no" |
406 | local CVS_ECLASS_STRICT_HOST_CHECKING="no" |
| 383 | touch "${CVS_ECLASS_KNOWN_HOSTS}" |
407 | touch "${CVS_ECLASS_KNOWN_HOSTS}" |
| 384 | echo "newarglist.insert(1, '-oStrictHostKeyChecking=no')" \ |
|
|
| 385 | >> "${CVS_RSH}" |
|
|
| 386 | else |
408 | else |
| 387 | local CVS_ECLASS_STRICT_HOST_CHECKING="yes" |
409 | local CVS_ECLASS_STRICT_HOST_CHECKING="yes" |
| 388 | echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" |
410 | echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" |
| 389 | fi |
411 | fi |
| 390 | |
412 | |
| … | |
… | |
| 404 | export DISPLAY |
426 | export DISPLAY |
| 405 | |
427 | |
| 406 | # Create a dummy executable to echo $ECVS_PASS |
428 | # Create a dummy executable to echo $ECVS_PASS |
| 407 | |
429 | |
| 408 | export SSH_ASKPASS="${T}/cvs_sshechopass" |
430 | export SSH_ASKPASS="${T}/cvs_sshechopass" |
| 409 | |
431 | if [ "${ECVS_AUTH}" != "no" ]; then |
| 410 | echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ |
432 | echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ |
| 411 | > "${SSH_ASKPASS}" |
433 | > "${SSH_ASKPASS}" |
|
|
434 | else |
|
|
435 | echo -en "#!/bin/bash\nreturn\n" \ |
|
|
436 | > "${SSH_ASKPASS}" |
| 412 | |
437 | |
|
|
438 | fi |
| 413 | chmod a+x "${SSH_ASKPASS}" |
439 | chmod a+x "${SSH_ASKPASS}" |
| 414 | fi |
440 | fi |
| 415 | |
441 | |
| 416 | if [ "${mode}" == "update" ]; then |
442 | if [ "${mode}" == "update" ]; then |
| 417 | einfo "Running $cmdupdate" |
443 | einfo "Running $cmdupdate" |
| … | |
… | |
| 478 | else |
504 | else |
| 479 | debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" |
505 | debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" |
| 480 | die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting." |
506 | die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting." |
| 481 | fi |
507 | fi |
| 482 | elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode |
508 | elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode |
| 483 | einfo "Fetching CVS module $ECVS_MODULE into $ECVS_TOP_DIR..." |
509 | einfo "Fetching CVS module $ECVS_MODULE into $ECVS_TOP_DIR ..." |
| 484 | cvs_fetch |
510 | cvs_fetch |
| 485 | else # ECVS_SERVER not set |
511 | else # ECVS_SERVER not set |
| 486 | die "ERROR: CVS server not specified, cannot continue." |
512 | die "ERROR: CVS server not specified, cannot continue." |
| 487 | fi |
513 | fi |
| 488 | |
514 | |
| 489 | einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." |
515 | einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR ..." |
| 490 | debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." |
516 | debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR ..." |
| 491 | |
517 | |
| 492 | # This is probably redundant, but best to make sure. |
518 | # This is probably redundant, but best to make sure. |
| 493 | mkdir -p "$WORKDIR/$ECVS_LOCALNAME" |
519 | mkdir -p "$WORKDIR/$ECVS_LOCALNAME" |
| 494 | |
520 | |
| 495 | if [ -n "$ECVS_LOCAL" ]; then |
521 | if [ -n "$ECVS_LOCAL" ]; then |