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

Diff of /eclass/cvs.eclass

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20