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

Diff of /eclass/cvs.eclass

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

Revision 1.53 Revision 1.67
1# Copyright 1999-2004 Gentoo Foundation 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.53 2004/10/19 19:51:12 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.67 2006/12/11 00:11:46 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
40# You can set, for example, "cvs -t" for extensive debug information 33# You can set, for example, "cvs -t" for extensive debug information
41# on the cvs connection. The default of "cvs -q -f -z4" means to be 34# on the cvs connection. The default of "cvs -q -f -z4" means to be
42# quiet, to disregard the ~/.cvsrc config file and to use maximum 35# quiet, to disregard the ~/.cvsrc config file and to use maximum
43# compression. 36# compression.
44 37
45[ -z "$ECVS_CVS_COMMAND" ] && ECVS_CVS_COMMAND="cvs -q -f -z4" 38[[ -z ${ECVS_CVS_COMPRESS} ]] && ECVS_CVS_COMPRESS="-z1"
39[[ -z ${ECVS_CVS_OPTIONS} ]] && ECVS_CVS_OPTIONS="-q -f"
40[[ -z ${ECVS_CVS_COMMAND} ]] && ECVS_CVS_COMMAND="cvs ${ECVS_CVS_OPTIONS} ${ECVS_CVS_COMPRESS}"
46 41
47 42
48# ECVS_UP_OPTS, ECVS_CO_OPTS -- CVS options given after the cvs 43# ECVS_UP_OPTS, ECVS_CO_OPTS -- CVS options given after the cvs
49# command (update or checkout). 44# command (update or checkout).
50# 45#
71 66
72 67
73# ECVS_TOP_DIR -- The directory under which CVS modules are checked 68# ECVS_TOP_DIR -- The directory under which CVS modules are checked
74# out. 69# out.
75 70
76[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 71[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src"
77 72
78# ECVS_NAME -- CVS path 73# ECVS_SERVER -- CVS path
79# 74#
80# The format is "server:/dir", e.g. "anoncvs.kde.org:/home/kde". 75# 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 76# Remove the other parts of the full CVSROOT, which might look like
82# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated 77# ":pserver:anonymous@anoncvs.kde.org:/home/kde"; this is generated
83# using other settings also. 78# using other settings also.
120[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 115[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
121 116
122# ECVS_USER -- Username to use for authentication on the remote server 117# ECVS_USER -- Username to use for authentication on the remote server
123[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 118[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
124 119
125
126# ECVS_PASS -- Password to use for authentication on the remote server 120# ECVS_PASS -- Password to use for authentication on the remote server
127[ -z "$ECVS_PASS" ] && ECVS_PASS="" 121[ -z "$ECVS_PASS" ] && ECVS_PASS=""
128 122
129 123
130# ECVS_SSH_HOST_KEY 124# ECVS_SSH_HOST_KEY
157# --- end ebuild-configurable settings --- 151# --- end ebuild-configurable settings ---
158 152
159# add cvs to deps 153# add cvs to deps
160# ssh is used for ext auth 154# ssh is used for ext auth
161# sudo is used to run as a specified user 155# sudo is used to run as a specified user
162DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 156DEPEND="dev-util/cvs"
157
158[ -n "$ECVS_RUNAS" ] && DEPEND="$DEPEND app-admin/sudo"
163 159
164if [ "$ECVS_AUTH" == "ext" ]; then 160if [ "$ECVS_AUTH" == "ext" ]; then
165 #default to ssh 161 #default to ssh
166 [ -z "$CVS_RSH" ] && export SSH_RSH="ssh" 162 [ -z "$CVS_RSH" ] && export CVS_RSH="ssh"
167 if [ "$CVS_RSH" != "ssh" ]; then 163 if [ "$CVS_RSH" != "ssh" ]; then
168 die "Support for ext auth with clients other than ssh has not been implemented yet" 164 die "Support for ext auth with clients other than ssh has not been implemented yet"
169 fi 165 fi
170 DEPEND="$DEPEND net-misc/openssh" 166 DEPEND="${DEPEND} net-misc/openssh"
171fi 167fi
172 168
173# called from cvs_src_unpack 169# called from cvs_src_unpack
174cvs_fetch() { 170cvs_fetch() {
175 171
178 174
179 local ECVS_COMMAND="${ECVS_COMMAND}" 175 local ECVS_COMMAND="${ECVS_COMMAND}"
180 local ECVS_UP_OPTS="${ECVS_UP_OPTS}" 176 local ECVS_UP_OPTS="${ECVS_UP_OPTS}"
181 local ECVS_CO_OPTS="${ECVS_CO_OPTS}" 177 local ECVS_CO_OPTS="${ECVS_CO_OPTS}"
182 178
183 # Fix for sourceforge which doesnt want -z>3 anymore.
184
185 (echo $ECVS_SERVER | grep -q sourceforge) \
186 && [ "$ECVS_CVS_COMMAND" == "cvs -q -f -z4" ] \
187 && ECVS_CVS_COMMAND="cvs -q -f -z3"
188
189 debug-print-function $FUNCNAME $* 179 debug-print-function $FUNCNAME $*
190 180
191 # Update variables that are modified by ebuild parameters, which 181 # Update variables that are modified by ebuild parameters, which
192 # should be effective every time cvs_fetch is called, and not just 182 # should be effective every time cvs_fetch is called, and not just
193 # every time cvs.eclass is inherited 183 # every time cvs.eclass is inherited
194 184
195
196 # Handle parameter for local (non-recursive) fetching 185 # Handle parameter for local (non-recursive) fetching
197 186
198 if [ -n "$ECVS_LOCAL" ]; then 187 if [ -n "$ECVS_LOCAL" ]; then
199 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 188 ECVS_UP_OPTS="$ECVS_UP_OPTS -l"
200 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 189 ECVS_CO_OPTS="$ECVS_CO_OPTS -l"
201 fi 190 fi
202 191
203 # Handle ECVS_BRANCH option 192 # Handle ECVS_BRANCH option
204 # 193 #
205 # Because CVS auto-switches branches, we just have to pass the 194 # Because CVS auto-switches branches, we just have to pass the
206 # correct -rBRANCH option when updating. 195 # correct -rBRANCH option when updating.
207 196
208 if [ -n "$ECVS_BRANCH" ]; then 197 if [ -n "$ECVS_BRANCH" ]; then
209 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 198 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
279 # be put in Root 268 # be put in Root
280 if [ "$ECVS_AUTH" == "no" ] 269 if [ "$ECVS_AUTH" == "no" ]
281 then 270 then
282 local server="${ECVS_USER}@${ECVS_SERVER}" 271 local server="${ECVS_USER}@${ECVS_SERVER}"
283 else 272 else
273 local connection="${ECVS_AUTH}"
274 [[ -n ${ECVS_PROXY} ]] && connection="${connection};proxy=${ECVS_PROXY}"
275 [[ -n ${ECVS_PROXY_PORT} ]] && connection="${connection};proxyport=${ECVS_PROXY_PORT}"
284 local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 276 local server=":${connection}:${ECVS_USER}@${ECVS_SERVER}"
285 fi 277 fi
286 278
287 # Switch servers automagically if needed 279 # Switch servers automagically if needed
288 if [ "$mode" == "update" ]; then 280 if [ "$mode" == "update" ]; then
289 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 281 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
340 eval $cmdlogin || die "cvs login command failed" 332 eval $cmdlogin || die "cvs login command failed"
341 if [ "${mode}" == "update" ]; then 333 if [ "${mode}" == "update" ]; then
342 einfo "Running $cmdupdate" 334 einfo "Running $cmdupdate"
343 eval $cmdupdate || die "cvs update command failed" 335 eval $cmdupdate || die "cvs update command failed"
344 elif [ "${mode}" == "checkout" ]; then 336 elif [ "${mode}" == "checkout" ]; then
345 einfo "Running $cmdcheckout" 337 einfo "Running $cmdcheckout"
346 eval $cmdcheckout|| die "cvs checkout command failed" 338 eval $cmdcheckout|| die "cvs checkout command failed"
347 fi 339 fi
348 elif [ "${ECVS_AUTH}" == "ext" ]; then 340 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then
349 341
350 # Hack to support SSH password authentication 342 # Hack to support SSH password authentication
351 343
352 # Backup environment variable values 344 # Backup environment variable values
353 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}" 345 local CVS_ECLASS_ORIG_CVS_RSH="${CVS_RSH}"
385except: 377except:
386 pass 378 pass
387newarglist = sys.argv[:] 379newarglist = sys.argv[:]
388EOF 380EOF
389 381
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
390 # Handle SSH host key checking 389 # Handle SSH host key checking
391 390
392 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts" 391 local CVS_ECLASS_KNOWN_HOSTS="${T}/cvs_ssh_known_hosts"
393 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \ 392 echo "newarglist.insert(1, '-oUserKnownHostsFile=${CVS_ECLASS_KNOWN_HOSTS}')" \
394 >> "${CVS_RSH}" 393 >> "${CVS_RSH}"
396 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then 395 if [ -z "${ECVS_SSH_HOST_KEY}" ]; then
397 ewarn "Warning: The SSH host key of the remote server will not be verified." 396 ewarn "Warning: The SSH host key of the remote server will not be verified."
398 einfo "A temporary known hosts list will be used." 397 einfo "A temporary known hosts list will be used."
399 local CVS_ECLASS_STRICT_HOST_CHECKING="no" 398 local CVS_ECLASS_STRICT_HOST_CHECKING="no"
400 touch "${CVS_ECLASS_KNOWN_HOSTS}" 399 touch "${CVS_ECLASS_KNOWN_HOSTS}"
401 echo "newarglist.insert(1, '-oStrictHostKeyChecking=no')" \
402 >> "${CVS_RSH}"
403 else 400 else
404 local CVS_ECLASS_STRICT_HOST_CHECKING="yes" 401 local CVS_ECLASS_STRICT_HOST_CHECKING="yes"
405 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}" 402 echo "${ECVS_SSH_HOST_KEY}" > "${CVS_ECLASS_KNOWN_HOSTS}"
406 fi 403 fi
407 404
410 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \ 407 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \
411 >> "${CVS_RSH}" 408 >> "${CVS_RSH}"
412 echo "os.execv('/usr/bin/ssh', newarglist)" \ 409 echo "os.execv('/usr/bin/ssh', newarglist)" \
413 >> "${CVS_RSH}" 410 >> "${CVS_RSH}"
414 411
415 chmod a+x "${CVS_RSH}" 412 chmod a+x "${CVS_RSH}"
416 413
417 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS 414 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS
418 # if DISPLAY is not set) 415 # if DISPLAY is not set)
419 416
420 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY" 417 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY"
421 export DISPLAY 418 export DISPLAY
422 419
423 # Create a dummy executable to echo $ECVS_PASS 420 # Create a dummy executable to echo $ECVS_PASS
424 421
425 export SSH_ASKPASS="${T}/cvs_sshechopass" 422 export SSH_ASKPASS="${T}/cvs_sshechopass"
426 423 if [ "${ECVS_AUTH}" != "no" ]; then
427 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ 424 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \
428 > "${SSH_ASKPASS}" 425 > "${SSH_ASKPASS}"
426 else
427 echo -en "#!/bin/bash\nreturn\n" \
428 > "${SSH_ASKPASS}"
429 429
430 fi
430 chmod a+x "${SSH_ASKPASS}" 431 chmod a+x "${SSH_ASKPASS}"
431 fi 432 fi
432 433
433 if [ "${mode}" == "update" ]; then 434 if [ "${mode}" == "update" ]; then
434 einfo "Running $cmdupdate" 435 einfo "Running $cmdupdate"
435 eval $cmdupdate || die "cvs update command failed" 436 eval $cmdupdate || die "cvs update command failed"
436 elif [ "${mode}" == "checkout" ]; then 437 elif [ "${mode}" == "checkout" ]; then
437 einfo "Running $cmdcheckout" 438 einfo "Running $cmdcheckout"
438 eval $cmdcheckout|| die "cvs checkout command failed" 439 eval $cmdcheckout|| die "cvs checkout command failed"
439 fi 440 fi
440 441
441 # Restore environment variable values 442 # Restore environment variable values
442 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" 443 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}"
443 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then 444 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then
444 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" 445 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}"
445 else 446 else
448 449
449 if [ "${CVS_ECLASS_ORIG_DISPLAY+set}" == "set" ]; then 450 if [ "${CVS_ECLASS_ORIG_DISPLAY+set}" == "set" ]; then
450 export DISPLAY="${CVS_ECLASS_ORIG_DISPLAY}" 451 export DISPLAY="${CVS_ECLASS_ORIG_DISPLAY}"
451 else 452 else
452 unset DISPLAY 453 unset DISPLAY
453 fi
454 elif [ "${ECVS_AUTH}" == "no" ]; then
455 if [ "${mode}" == "update" ]; then
456 einfo "Running $cmdupdate"
457 eval $cmdupdate || die "cvs update command failed"
458 elif [ "${mode}" == "checkout" ]; then
459 einfo "Running $cmdcheckout"
460 eval $cmdcheckout|| die "cvs checkout command failed"
461 fi 454 fi
462 fi 455 fi
463 456
464 # Restore ownership. Not sure why this is needed, but someone 457 # Restore ownership. Not sure why this is needed, but someone
465 # added it in the orig ECVS_RUNAS stuff. 458 # added it in the orig ECVS_RUNAS stuff.
490 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 483 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
491 484
492 local ECVS_LOCALNAME="${ECVS_LOCALNAME}" 485 local ECVS_LOCALNAME="${ECVS_LOCALNAME}"
493 486
494 if [ -z "$ECVS_LOCALNAME" ]; then 487 if [ -z "$ECVS_LOCALNAME" ]; then
495 ECVS_LOCALNAME="$ECVS_MODULE" 488 ECVS_LOCALNAME="$ECVS_MODULE"
496 fi 489 fi
497 490
498 if [ "$ECVS_SERVER" == "offline" ]; then 491 local offline_pkg_var="ECVS_OFFLINE_${PN}"
492 if [ "${!offline_pkg_var}" == "1" -o "$ECVS_OFFLINE" == "1" -o "$ECVS_SERVER" == "offline" ]; then
499 # We're not required to fetch anything; the module already 493 # We're not required to fetch anything; the module already
500 # exists and shouldn't be updated. 494 # exists and shouldn't be updated.
501 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then 495 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
502 debug-print "$FUNCNAME: offline mode" 496 debug-print "$FUNCNAME: offline mode"
503 else 497 else
504 debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" 498 debug-print "$FUNCNAME: Offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
505 die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting." 499 die "ERROR: Offline mode specified, but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
506 fi 500 fi
535 # Implement some of base_src_unpack's functionality; note however 529 # Implement some of base_src_unpack's functionality; note however
536 # that base.eclass may not have been inherited! 530 # that base.eclass may not have been inherited!
537 if [ -n "$PATCHES" ]; then 531 if [ -n "$PATCHES" ]; then
538 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 532 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
539 cd "$S" 533 cd "$S"
540 for x in $PATCHES; do 534 epatch ${PATCHES}
541 debug-print "patching from $x"
542 patch -p0 < "$x"
543 done
544 # Make sure we don't try to apply patches more than once, 535 # Make sure we don't try to apply patches more than once,
545 # since cvs_src_unpack is usually called several times from 536 # since cvs_src_unpack is usually called several times from
546 # e.g. kde-source_src_unpack 537 # e.g. kde-source_src_unpack
547 export PATCHES="" 538 export PATCHES=""
548 fi 539 fi
549 540
550 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}" 541 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}"
551} 542}
552 543
553EXPORT_FUNCTIONS src_unpack 544EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.67

  ViewVC Help
Powered by ViewVC 1.1.20