/[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.59
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.59 2005/08/13 08:10:53 phreak 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>
24 24
25# Support additional remote shells with `ext' authentication (does 25# Support additional remote shells with `ext' authentication (does
26# anyone actually need to use it with anything other than SSH?) 26# anyone actually need to use it with anything other than SSH?)
27 27
28 28
29ECLASS=cvs
30INHERITED="$INHERITED $ECLASS"
31 29
32# Users shouldn't change these settings! The ebuild/eclass inheriting 30# 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 31# 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. 32# KDE cvs ebuilds' settings, see the comments in kde-source.eclass.
35 33
73# ECVS_TOP_DIR -- The directory under which CVS modules are checked 71# ECVS_TOP_DIR -- The directory under which CVS modules are checked
74# out. 72# out.
75 73
76[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 74[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src"
77 75
78# ECVS_NAME -- CVS path 76# ECVS_SERVER -- CVS path
79# 77#
80# The format is "server:/dir", e.g. "anoncvs.kde.org:/home/kde". 78# 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 79# Remove the other parts of the full CVSROOT, which might look like
82# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated 80# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated
83# using other settings also. 81# using other settings also.
108# 106#
109# Possible values are "pserver" and "ext". If `ext' authentication is 107# 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 108# 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 109# used by default). Currently, the only supported remote shell for
112# `ext' authentication is SSH. 110# `ext' authentication is SSH.
111#
112# Armando Di Cianno <fafhrd@gentoo.org> 2004/09/27
113# - Added "no" as a server type, which uses no AUTH method, nor
114# does it login
115# e.g.
116# "cvs -danoncvs@savannah.gnu.org:/cvsroot/backbone co System"
117# ( from gnustep-apps/textedit )
113[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 118[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
114 119
115# ECVS_USER -- Username to use for authentication on the remote server 120# ECVS_USER -- Username to use for authentication on the remote server
116[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 121[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
117 122
150# --- end ebuild-configurable settings --- 155# --- end ebuild-configurable settings ---
151 156
152# add cvs to deps 157# add cvs to deps
153# ssh is used for ext auth 158# ssh is used for ext auth
154# sudo is used to run as a specified user 159# sudo is used to run as a specified user
155DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 160DEPEND="dev-util/cvs app-admin/sudo"
156 161
157if [ "$ECVS_AUTH" == "ext" ]; then 162if [ "$ECVS_AUTH" == "ext" ]; then
158 #default to ssh 163 #default to ssh
159 [ -z "$CVS_RSH" ] && export SSH_RSH="ssh" 164 [ -z "$CVS_RSH" ] && export CVS_RSH="ssh"
160 if [ "$CVS_RSH" != "ssh" ]; then 165 if [ "$CVS_RSH" != "ssh" ]; then
161 die "Support for ext auth with clients other than ssh has not been implemented yet" 166 die "Support for ext auth with clients other than ssh has not been implemented yet"
162 fi 167 fi
163 DEPEND="$DEPEND net-misc/openssh" 168 DEPEND="${DEPEND} net-misc/openssh"
164fi 169fi
165 170
166# called from cvs_src_unpack 171# called from cvs_src_unpack
167cvs_fetch() { 172cvs_fetch() {
168 173
183 188
184 # Update variables that are modified by ebuild parameters, which 189 # Update variables that are modified by ebuild parameters, which
185 # should be effective every time cvs_fetch is called, and not just 190 # should be effective every time cvs_fetch is called, and not just
186 # every time cvs.eclass is inherited 191 # every time cvs.eclass is inherited
187 192
188
189 # Handle parameter for local (non-recursive) fetching 193 # Handle parameter for local (non-recursive) fetching
190 194
191 if [ -n "$ECVS_LOCAL" ]; then 195 if [ -n "$ECVS_LOCAL" ]; then
192 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 196 ECVS_UP_OPTS="$ECVS_UP_OPTS -l"
193 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 197 ECVS_CO_OPTS="$ECVS_CO_OPTS -l"
194 fi 198 fi
195 199
196 # Handle ECVS_BRANCH option 200 # Handle ECVS_BRANCH option
197 # 201 #
198 # Because CVS auto-switches branches, we just have to pass the 202 # Because CVS auto-switches branches, we just have to pass the
199 # correct -rBRANCH option when updating. 203 # correct -rBRANCH option when updating.
200 204
201 if [ -n "$ECVS_BRANCH" ]; then 205 if [ -n "$ECVS_BRANCH" ]; then
202 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 206 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
268 fi 272 fi
269 273
270 274
271 # Our server string (i.e. CVSROOT) without the password so it can 275 # Our server string (i.e. CVSROOT) without the password so it can
272 # be put in Root 276 # be put in Root
277 if [ "$ECVS_AUTH" == "no" ]
278 then
279 local server="${ECVS_USER}@${ECVS_SERVER}"
280 else
273 local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 281 local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
282 fi
274 283
275 # Switch servers automagically if needed 284 # Switch servers automagically if needed
276 if [ "$mode" == "update" ]; then 285 if [ "$mode" == "update" ]; then
277 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 286 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
278 local oldserver="`$run cat CVS/Root`" 287 local oldserver="`$run cat CVS/Root`"
279 if [ "$server" != "$oldserver" ]; then 288 if [ "$server" != "$oldserver" ]; then
280 289
281 einfo "Changing the CVS server from $oldserver to $server:" 290 einfo "Changing the CVS server from $oldserver to $server:"
282 debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:" 291 debug-print "$FUNCNAME: Changing the CVS server from $oldserver to $server:"
283 292
284 einfo "Searching for CVS directories..." 293 einfo "Searching for CVS directories ..."
285 local cvsdirs="`$run find . -iname CVS -print`" 294 local cvsdirs="`$run find . -iname CVS -print`"
286 debug-print "$FUNCNAME: CVS directories found:" 295 debug-print "$FUNCNAME: CVS directories found:"
287 debug-print "$cvsdirs" 296 debug-print "$cvsdirs"
288 297
289 einfo "Modifying CVS directories..." 298 einfo "Modifying CVS directories ..."
290 for x in $cvsdirs; do 299 for x in $cvsdirs; do
291 debug-print "In $x" 300 debug-print "In $x"
292 $run echo "$server" > "$x/Root" 301 $run echo "$server" > "$x/Root"
293 done 302 done
294 303
306 # The server string with the password in it, for login 315 # The server string with the password in it, for login
307 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}" 316 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
308 317
309 # Ditto without the password, for checkout/update after login, so 318 # Ditto without the password, for checkout/update after login, so
310 # that the CVS/Root files don't contain the password in plaintext 319 # that the CVS/Root files don't contain the password in plaintext
320 if [ "$ECVS_AUTH" == "no" ]
321 then
322 cvsroot_nopass="${ECVS_USER}@${ECVS_SERVER}"
323 else
311 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 324 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
325 fi
312 326
313 # Commands to run 327 # Commands to run
314 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" 328 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
315 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}" 329 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}" 330 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
323 eval $cmdlogin || die "cvs login command failed" 337 eval $cmdlogin || die "cvs login command failed"
324 if [ "${mode}" == "update" ]; then 338 if [ "${mode}" == "update" ]; then
325 einfo "Running $cmdupdate" 339 einfo "Running $cmdupdate"
326 eval $cmdupdate || die "cvs update command failed" 340 eval $cmdupdate || die "cvs update command failed"
327 elif [ "${mode}" == "checkout" ]; then 341 elif [ "${mode}" == "checkout" ]; then
328 einfo "Running $cmdcheckout" 342 einfo "Running $cmdcheckout"
329 eval $cmdcheckout|| die "cvs checkout command failed" 343 eval $cmdcheckout|| die "cvs checkout command failed"
330 fi 344 fi
331 elif [ "${ECVS_AUTH}" == "ext" ]; then 345 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then
332 346
333 # Hack to support SSH password authentication 347 # Hack to support SSH password authentication
334 348
335 # Backup environment variable values 349 # Backup environment variable values
336 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" 350 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}"
368except: 382except:
369 pass 383 pass
370newarglist = sys.argv[:] 384newarglist = sys.argv[:]
371EOF 385EOF
372 386
387 # disable X11 forwarding which causes .xauth access violations
388 # - 20041205 Armando Di Cianno <fafhrd@gentoo.org>
389 echo "newarglist.insert(1, '-oClearAllForwardings=yes')" \
390 >> "${CVS_RSH}"
391 echo "newarglist.insert(1, '-oForwardX11=no')" \
392 >> "${CVS_RSH}"
393
373 # Handle SSH host key checking 394 # Handle SSH host key checking
374 395
375 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" 396 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts"
376 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ 397 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \
377 >> "${CVS_RSH}" 398 >> "${CVS_RSH}"
379 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then 400 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then
380 ewarn "Warning: The SSH host key of the remote server will not be verified." 401 ewarn "Warning: The SSH host key of the remote server will not be verified."
381 einfo "A temporary known hosts list will be used." 402 einfo "A temporary known hosts list will be used."
382 local CVS_ECLASS_STRICT_HOST_CHECKING="no" 403 local CVS_ECLASS_STRICT_HOST_CHECKING="no"
383 touch "${CVS_ECLASS_KNOWN_HOSTS}" 404 touch "${CVS_ECLASS_KNOWN_HOSTS}"
384 echo "newarglist.insert(1, '-oStrictHostKeyChecking=no')" \
385 >> "${CVS_RSH}"
386 else 405 else
387 local CVS_ECLASS_STRICT_HOST_CHECKING="yes" 406 local CVS_ECLASS_STRICT_HOST_CHECKING="yes"
388 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" 407 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}"
389 fi 408 fi
390 409
393 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \ 412 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \
394 >> "${CVS_RSH}" 413 >> "${CVS_RSH}"
395 echo "os.execv('/usr/bin/ssh', newarglist)" \ 414 echo "os.execv('/usr/bin/ssh', newarglist)" \
396 >> "${CVS_RSH}" 415 >> "${CVS_RSH}"
397 416
398 chmod a+x "${CVS_RSH}" 417 chmod a+x "${CVS_RSH}"
399 418
400 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS 419 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS
401 # if DISPLAY is not set) 420 # if DISPLAY is not set)
402 421
403 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY" 422 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY"
404 export DISPLAY 423 export DISPLAY
405 424
406 # Create a dummy executable to echo $ECVS_PASS 425 # Create a dummy executable to echo $ECVS_PASS
407 426
408 export SSH_ASKPASS="${T}/cvs_sshechopass" 427 export SSH_ASKPASS="${T}/cvs_sshechopass"
409 428 if [ "${ECVS_AUTH}" != "no" ]; then
410 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ 429 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \
411 > "${SSH_ASKPASS}" 430 > "${SSH_ASKPASS}"
431 else
432 echo -en "#!/bin/bash\nreturn\n" \
433 > "${SSH_ASKPASS}"
412 434
435 fi
413 chmod a+x "${SSH_ASKPASS}" 436 chmod a+x "${SSH_ASKPASS}"
414 fi 437 fi
415 438
416 if [ "${mode}" == "update" ]; then 439 if [ "${mode}" == "update" ]; then
417 einfo "Running $cmdupdate" 440 einfo "Running $cmdupdate"
418 eval $cmdupdate || die "cvs update command failed" 441 eval $cmdupdate || die "cvs update command failed"
419 elif [ "${mode}" == "checkout" ]; then 442 elif [ "${mode}" == "checkout" ]; then
420 einfo "Running $cmdcheckout" 443 einfo "Running $cmdcheckout"
421 eval $cmdcheckout|| die "cvs checkout command failed" 444 eval $cmdcheckout|| die "cvs checkout command failed"
422 fi 445 fi
423 446
424 # Restore environment variable values 447 # Restore environment variable values
425 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" 448 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}"
426 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then 449 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then
427 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" 450 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}"
428 else 451 else
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
519 # Make sure we don't try to apply patches more than once, 542 # Make sure we don't try to apply patches more than once,
520 # since cvs_src_unpack is usually called several times from 543 # since cvs_src_unpack is usually called several times from
521 # e.g. kde-source_src_unpack 544 # e.g. kde-source_src_unpack
522 export PATCHES="" 545 export PATCHES=""
523 fi 546 fi
524 547
525 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}" 548 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}"
526} 549}
527 550
528EXPORT_FUNCTIONS src_unpack 551EXPORT_FUNCTIONS src_unpack

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

  ViewVC Help
Powered by ViewVC 1.1.20