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

Diff of /eclass/cvs.eclass

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

Revision 1.50 Revision 1.66
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2006 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.66 2006/12/11 00:09:31 vapier Exp $
4#
5# Maintainer: vapier@gentoo.org (and anyone who wants to help)
4 6
5# Current Maintainer: Tal Peer <coredumb@gentoo.org> 7inherit eutils
6# Original Author: Dan Armak <danarmak@gentoo.org>
7
8# SSH auth code by Danny <danny.milo@gmx.net>
9
10# SSH password authentication support and host key verification
11# support by Jeremy Maitin-Shepard <jbms@gentoo.org>
12
13 8
14# This eclass provides the generic cvs fetching functions. To use 9# This eclass provides the generic cvs fetching functions. To use
15# this from an ebuild, set the `ebuild-configurable settings' as 10# this from an ebuild, set the `ebuild-configurable settings' as
16# specified below in your ebuild before inheriting. Then either leave 11# specified below in your ebuild before inheriting. Then either leave
17# the default src_unpack or extend over cvs_src_unpack. If you find 12# the default src_unpack or extend over cvs_src_unpack. If you find
24 19
25# Support additional remote shells with `ext' authentication (does 20# Support additional remote shells with `ext' authentication (does
26# anyone actually need to use it with anything other than SSH?) 21# anyone actually need to use it with anything other than SSH?)
27 22
28 23
29ECLASS=cvs
30INHERITED="$INHERITED $ECLASS"
31 24
32# Users shouldn't change these settings! The ebuild/eclass inheriting 25# Users shouldn't change these settings! The ebuild/eclass inheriting
33# this eclass will take care of that. If you want to set the global 26# this eclass will take care of that. If you want to set the global
34# KDE cvs ebuilds' settings, see the comments in kde-source.eclass. 27# KDE cvs ebuilds' settings, see the comments in kde-source.eclass.
35 28
71 64
72 65
73# ECVS_TOP_DIR -- The directory under which CVS modules are checked 66# ECVS_TOP_DIR -- The directory under which CVS modules are checked
74# out. 67# out.
75 68
76[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 69[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src"
77 70
78# ECVS_NAME -- CVS path 71# ECVS_SERVER -- CVS path
79# 72#
80# The format is "server:/dir", e.g. "anoncvs.kde.org:/home/kde". 73# The format is "server:/dir", e.g. "anoncvs.kde.org:/home/kde".
81# Remove the other parts of the full CVSROOT, which might look like 74# Remove the other parts of the full CVSROOT, which might look like
82# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated 75# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated
83# using other settings also. 76# using other settings also.
108# 101#
109# Possible values are "pserver" and "ext". If `ext' authentication is 102# 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 103# 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 104# used by default). Currently, the only supported remote shell for
112# `ext' authentication is SSH. 105# `ext' authentication is SSH.
106#
107# Armando Di Cianno <fafhrd@gentoo.org> 2004/09/27
108# - Added "no" as a server type, which uses no AUTH method, nor
109# does it login
110# e.g.
111# "cvs -danoncvs@savannah.gnu.org:/cvsroot/backbone co System"
112# ( from gnustep-apps/textedit )
113[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 113[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
114 114
115# ECVS_USER -- Username to use for authentication on the remote server 115# ECVS_USER -- Username to use for authentication on the remote server
116[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 116[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
117
118 117
119# ECVS_PASS -- Password to use for authentication on the remote server 118# ECVS_PASS -- Password to use for authentication on the remote server
120[ -z "$ECVS_PASS" ] && ECVS_PASS="" 119[ -z "$ECVS_PASS" ] && ECVS_PASS=""
121 120
122 121
150# --- end ebuild-configurable settings --- 149# --- end ebuild-configurable settings ---
151 150
152# add cvs to deps 151# add cvs to deps
153# ssh is used for ext auth 152# ssh is used for ext auth
154# sudo is used to run as a specified user 153# sudo is used to run as a specified user
155DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 154DEPEND="dev-util/cvs"
155
156[ -n "$ECVS_RUNAS" ] && DEPEND="$DEPEND app-admin/sudo"
156 157
157if [ "$ECVS_AUTH" == "ext" ]; then 158if [ "$ECVS_AUTH" == "ext" ]; then
158 #default to ssh 159 #default to ssh
159 [ -z "$CVS_RSH" ] && export SSH_RSH="ssh" 160 [ -z "$CVS_RSH" ] && export CVS_RSH="ssh"
160 if [ "$CVS_RSH" != "ssh" ]; then 161 if [ "$CVS_RSH" != "ssh" ]; then
161 die "Support for ext auth with clients other than ssh has not been implemented yet" 162 die "Support for ext auth with clients other than ssh has not been implemented yet"
162 fi 163 fi
163 DEPEND="$DEPEND net-misc/openssh" 164 DEPEND="${DEPEND} net-misc/openssh"
164fi 165fi
165 166
166# called from cvs_src_unpack 167# called from cvs_src_unpack
167cvs_fetch() { 168cvs_fetch() {
168 169
183 184
184 # Update variables that are modified by ebuild parameters, which 185 # Update variables that are modified by ebuild parameters, which
185 # should be effective every time cvs_fetch is called, and not just 186 # should be effective every time cvs_fetch is called, and not just
186 # every time cvs.eclass is inherited 187 # every time cvs.eclass is inherited
187 188
188
189 # Handle parameter for local (non-recursive) fetching 189 # Handle parameter for local (non-recursive) fetching
190 190
191 if [ -n "$ECVS_LOCAL" ]; then 191 if [ -n "$ECVS_LOCAL" ]; then
192 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 192 ECVS_UP_OPTS="$ECVS_UP_OPTS -l"
193 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 193 ECVS_CO_OPTS="$ECVS_CO_OPTS -l"
194 fi 194 fi
195 195
196 # Handle ECVS_BRANCH option 196 # Handle ECVS_BRANCH option
197 # 197 #
198 # Because CVS auto-switches branches, we just have to pass the 198 # Because CVS auto-switches branches, we just have to pass the
199 # correct -rBRANCH option when updating. 199 # correct -rBRANCH option when updating.
200 200
201 if [ -n "$ECVS_BRANCH" ]; then 201 if [ -n "$ECVS_BRANCH" ]; then
202 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 202 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
268 fi 268 fi
269 269
270 270
271 # Our server string (i.e. CVSROOT) without the password so it can 271 # Our server string (i.e. CVSROOT) without the password so it can
272 # be put in Root 272 # be put in Root
273 if [ "$ECVS_AUTH" == "no" ]
274 then
273 local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 275 local server="${ECVS_USER}@${ECVS_SERVER}"
276 else
277 local connection="${ECVS_AUTH}"
278 [[ -n ${ECVS_PROXY} ]] && connection="${connection};proxy=${ECVS_PROXY}"
279 [[ -n ${ECVS_PROXY_PORT} ]] && connection="${connection};proxyport=${ECVS_PROXY_PORT}"
280 local server=":${connection}:${ECVS_USER}@${ECVS_SERVER}"
281 fi
274 282
275 # Switch servers automagically if needed 283 # Switch servers automagically if needed
276 if [ "$mode" == "update" ]; then 284 if [ "$mode" == "update" ]; then
277 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 285 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
278 local oldserver="`$run cat CVS/Root`" 286 local oldserver="`$run cat CVS/Root`"
279 if [ "$server" != "$oldserver" ]; then 287 if [ "$server" != "$oldserver" ]; then
280 288
281 einfo "Changing the CVS server from $oldserver to $server:" 289 einfo "Changing the CVS server from $oldserver to $server:"
282 debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:" 290 debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:"
283 291
284 einfo "Searching for CVS directories..." 292 einfo "Searching for CVS directories ..."
285 local cvsdirs="`$run find . -iname CVS -print`" 293 local cvsdirs="`$run find . -iname CVS -print`"
286 debug-print "$FUNCNAME: CVS directories found:" 294 debug-print "$FUNCNAME: CVS directories found:"
287 debug-print "$cvsdirs" 295 debug-print "$cvsdirs"
288 296
289 einfo "Modifying CVS directories..." 297 einfo "Modifying CVS directories ..."
290 for x in $cvsdirs; do 298 for x in $cvsdirs; do
291 debug-print "In $x" 299 debug-print "In $x"
292 $run echo "$server" > "$x/Root" 300 $run echo "$server" > "$x/Root"
293 done 301 done
294 302
306 # The server string with the password in it, for login 314 # The server string with the password in it, for login
307 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" 315 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
308 316
309 # Ditto without the password, for checkout/update after login, so 317 # Ditto without the password, for checkout/update after login, so
310 # that the CVS/Root files don't contain the password in plaintext 318 # that the CVS/Root files don't contain the password in plaintext
319 if [ "$ECVS_AUTH" == "no" ]
320 then
321 cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}"
322 else
311 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 323 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
324 fi
312 325
313 # Commands to run 326 # Commands to run
314 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" 327 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
315 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}" 328 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}" 329 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
323 eval $cmdlogin || die "cvs login command failed" 336 eval $cmdlogin || die "cvs login command failed"
324 if [ "${mode}" == "update" ]; then 337 if [ "${mode}" == "update" ]; then
325 einfo "Running $cmdupdate" 338 einfo "Running $cmdupdate"
326 eval $cmdupdate || die "cvs update command failed" 339 eval $cmdupdate || die "cvs update command failed"
327 elif [ "${mode}" == "checkout" ]; then 340 elif [ "${mode}" == "checkout" ]; then
328 einfo "Running $cmdcheckout" 341 einfo "Running $cmdcheckout"
329 eval $cmdcheckout|| die "cvs checkout command failed" 342 eval $cmdcheckout|| die "cvs checkout command failed"
330 fi 343 fi
331 elif [ "${ECVS_AUTH}" == "ext" ]; then 344 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then
332 345
333 # Hack to support SSH password authentication 346 # Hack to support SSH password authentication
334 347
335 # Backup environment variable values 348 # Backup environment variable values
336 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" 349 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}"
368except: 381except:
369 pass 382 pass
370newarglist = sys.argv[:] 383newarglist = sys.argv[:]
371EOF 384EOF
372 385
386 # disable X11 forwarding which causes .xauth access violations
387 # - 20041205 Armando Di Cianno <fafhrd@gentoo.org>
388 echo "newarglist.insert(1, '-oClearAllForwardings=yes')" \
389 >> "${CVS_RSH}"
390 echo "newarglist.insert(1, '-oForwardX11=no')" \
391 >> "${CVS_RSH}"
392
373 # Handle SSH host key checking 393 # Handle SSH host key checking
374 394
375 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" 395 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts"
376 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ 396 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \
377 >> "${CVS_RSH}" 397 >> "${CVS_RSH}"
379 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then 399 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then
380 ewarn "Warning: The SSH host key of the remote server will not be verified." 400 ewarn "Warning: The SSH host key of the remote server will not be verified."
381 einfo "A temporary known hosts list will be used." 401 einfo "A temporary known hosts list will be used."
382 local CVS_ECLASS_STRICT_HOST_CHECKING="no" 402 local CVS_ECLASS_STRICT_HOST_CHECKING="no"
383 touch "${CVS_ECLASS_KNOWN_HOSTS}" 403 touch "${CVS_ECLASS_KNOWN_HOSTS}"
384 echo "newarglist.insert(1, '-oStrictHostKeyChecking=no')" \
385 >> "${CVS_RSH}"
386 else 404 else
387 local CVS_ECLASS_STRICT_HOST_CHECKING="yes" 405 local CVS_ECLASS_STRICT_HOST_CHECKING="yes"
388 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" 406 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}"
389 fi 407 fi
390 408
393 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \ 411 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \
394 >> "${CVS_RSH}" 412 >> "${CVS_RSH}"
395 echo "os.execv('/usr/bin/ssh', newarglist)" \ 413 echo "os.execv('/usr/bin/ssh', newarglist)" \
396 >> "${CVS_RSH}" 414 >> "${CVS_RSH}"
397 415
398 chmod a+x "${CVS_RSH}" 416 chmod a+x "${CVS_RSH}"
399 417
400 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS 418 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS
401 # if DISPLAY is not set) 419 # if DISPLAY is not set)
402 420
403 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY" 421 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY"
404 export DISPLAY 422 export DISPLAY
405 423
406 # Create a dummy executable to echo $ECVS_PASS 424 # Create a dummy executable to echo $ECVS_PASS
407 425
408 export SSH_ASKPASS="${T}/cvs_sshechopass" 426 export SSH_ASKPASS="${T}/cvs_sshechopass"
409 427 if [ "${ECVS_AUTH}" != "no" ]; then
410 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ 428 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \
411 > "${SSH_ASKPASS}" 429 > "${SSH_ASKPASS}"
430 else
431 echo -en "#!/bin/bash\nreturn\n" \
432 > "${SSH_ASKPASS}"
412 433
434 fi
413 chmod a+x "${SSH_ASKPASS}" 435 chmod a+x "${SSH_ASKPASS}"
414 fi 436 fi
415 437
416 if [ "${mode}" == "update" ]; then 438 if [ "${mode}" == "update" ]; then
417 einfo "Running $cmdupdate" 439 einfo "Running $cmdupdate"
418 eval $cmdupdate || die "cvs update command failed" 440 eval $cmdupdate || die "cvs update command failed"
419 elif [ "${mode}" == "checkout" ]; then 441 elif [ "${mode}" == "checkout" ]; then
420 einfo "Running $cmdcheckout" 442 einfo "Running $cmdcheckout"
421 eval $cmdcheckout|| die "cvs checkout command failed" 443 eval $cmdcheckout|| die "cvs checkout command failed"
422 fi 444 fi
423 445
424 # Restore environment variable values 446 # Restore environment variable values
425 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" 447 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}"
426 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then 448 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then
427 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" 449 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}"
428 else 450 else
465 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 487 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
466 488
467 local ECVS_LOCALNAME="${ECVS_LOCALNAME}" 489 local ECVS_LOCALNAME="${ECVS_LOCALNAME}"
468 490
469 if [ -z "$ECVS_LOCALNAME" ]; then 491 if [ -z "$ECVS_LOCALNAME" ]; then
470 ECVS_LOCALNAME="$ECVS_MODULE" 492 ECVS_LOCALNAME="$ECVS_MODULE"
471 fi 493 fi
472 494
473 if [ "$ECVS_SERVER" == "offline" ]; then 495 local offline_pkg_var="ECVS_OFFLINE_${PN}"
496 if [ "${!offline_pkg_var}" == "1" -o "$ECVS_OFFLINE" == "1" -o "$ECVS_SERVER" == "offline" ]; then
474 # We're not required to fetch anything; the module already 497 # We're not required to fetch anything; the module already
475 # exists and shouldn't be updated. 498 # exists and shouldn't be updated.
476 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then 499 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
477 debug-print "$FUNCNAME: offline mode" 500 debug-print "$FUNCNAME: offline mode"
478 else 501 else
479 debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" 502 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." 503 die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
481 fi 504 fi
482 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 505 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
483 einfo "Fetching CVS module $ECVS_MODULE into $ECVS_TOP_DIR..." 506 einfo "Fetching CVS module $ECVS_MODULE into $ECVS_TOP_DIR ..."
484 cvs_fetch 507 cvs_fetch
485 else # ECVS_SERVER not set 508 else # ECVS_SERVER not set
486 die "ERROR: CVS server not specified, cannot continue." 509 die "ERROR: CVS server not specified, cannot continue."
487 fi 510 fi
488 511
489 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." 512 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR ..."
490 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 513 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR ..."
491 514
492 # This is probably redundant, but best to make sure. 515 # This is probably redundant, but best to make sure.
493 mkdir -p "$WORKDIR/$ECVS_LOCALNAME" 516 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
494 517
495 if [ -n "$ECVS_LOCAL" ]; then 518 if [ -n "$ECVS_LOCAL" ]; then
510 # Implement some of base_src_unpack's functionality; note however 533 # Implement some of base_src_unpack's functionality; note however
511 # that base.eclass may not have been inherited! 534 # that base.eclass may not have been inherited!
512 if [ -n "$PATCHES" ]; then 535 if [ -n "$PATCHES" ]; then
513 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 536 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
514 cd "$S" 537 cd "$S"
515 for x in $PATCHES; do 538 epatch ${PATCHES}
516 debug-print "patching from $x"
517 patch -p0 < "$x"
518 done
519 # Make sure we don't try to apply patches more than once, 539 # Make sure we don't try to apply patches more than once,
520 # since cvs_src_unpack is usually called several times from 540 # since cvs_src_unpack is usually called several times from
521 # e.g. kde-source_src_unpack 541 # e.g. kde-source_src_unpack
522 export PATCHES="" 542 export PATCHES=""
523 fi 543 fi
524 544
525 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}" 545 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}"
526} 546}
527 547
528EXPORT_FUNCTIONS src_unpack 548EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.66

  ViewVC Help
Powered by ViewVC 1.1.20