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

Diff of /eclass/cvs.eclass

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

Revision 1.56 Revision 1.66
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.56 2005/07/06 20:20:03 agriffis 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
29INHERITED="$INHERITED $ECLASS"
30 24
31# Users shouldn't change these settings! The ebuild/eclass inheriting 25# Users shouldn't change these settings! The ebuild/eclass inheriting
32# 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
33# KDE cvs ebuilds' settings, see the comments in kde-source.eclass. 27# KDE cvs ebuilds' settings, see the comments in kde-source.eclass.
34 28
70 64
71 65
72# ECVS_TOP_DIR -- The directory under which CVS modules are checked 66# ECVS_TOP_DIR -- The directory under which CVS modules are checked
73# out. 67# out.
74 68
75[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 69[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src"
76 70
77# ECVS_SERVER -- CVS path 71# ECVS_SERVER -- CVS path
78# 72#
79# 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".
80# 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
119[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 113[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
120 114
121# ECVS_USER -- Username to use for authentication on the remote server 115# ECVS_USER -- Username to use for authentication on the remote server
122[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 116[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
123 117
124
125# ECVS_PASS -- Password to use for authentication on the remote server 118# ECVS_PASS -- Password to use for authentication on the remote server
126[ -z "$ECVS_PASS" ] && ECVS_PASS="" 119[ -z "$ECVS_PASS" ] && ECVS_PASS=""
127 120
128 121
129# ECVS_SSH_HOST_KEY 122# ECVS_SSH_HOST_KEY
156# --- end ebuild-configurable settings --- 149# --- end ebuild-configurable settings ---
157 150
158# add cvs to deps 151# add cvs to deps
159# ssh is used for ext auth 152# ssh is used for ext auth
160# sudo is used to run as a specified user 153# sudo is used to run as a specified user
161DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 154DEPEND="dev-util/cvs"
155
156[ -n "$ECVS_RUNAS" ] && DEPEND="$DEPEND app-admin/sudo"
162 157
163if [ "$ECVS_AUTH" == "ext" ]; then 158if [ "$ECVS_AUTH" == "ext" ]; then
164 #default to ssh 159 #default to ssh
165 [ -z "$CVS_RSH" ] && export SSH_RSH="ssh" 160 [ -z "$CVS_RSH" ] && export CVS_RSH="ssh"
166 if [ "$CVS_RSH" != "ssh" ]; then 161 if [ "$CVS_RSH" != "ssh" ]; then
167 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"
168 fi 163 fi
169 DEPEND="$DEPEND net-misc/openssh" 164 DEPEND="${DEPEND} net-misc/openssh"
170fi 165fi
171 166
172# called from cvs_src_unpack 167# called from cvs_src_unpack
173cvs_fetch() { 168cvs_fetch() {
174 169
189 184
190 # Update variables that are modified by ebuild parameters, which 185 # Update variables that are modified by ebuild parameters, which
191 # 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
192 # every time cvs.eclass is inherited 187 # every time cvs.eclass is inherited
193 188
194
195 # Handle parameter for local (non-recursive) fetching 189 # Handle parameter for local (non-recursive) fetching
196 190
197 if [ -n "$ECVS_LOCAL" ]; then 191 if [ -n "$ECVS_LOCAL" ]; then
198 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 192 ECVS_UP_OPTS="$ECVS_UP_OPTS -l"
199 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 193 ECVS_CO_OPTS="$ECVS_CO_OPTS -l"
200 fi 194 fi
201 195
202 # Handle ECVS_BRANCH option 196 # Handle ECVS_BRANCH option
203 # 197 #
204 # Because CVS auto-switches branches, we just have to pass the 198 # Because CVS auto-switches branches, we just have to pass the
205 # correct -rBRANCH option when updating. 199 # correct -rBRANCH option when updating.
206 200
207 if [ -n "$ECVS_BRANCH" ]; then 201 if [ -n "$ECVS_BRANCH" ]; then
208 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 202 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
278 # be put in Root 272 # be put in Root
279 if [ "$ECVS_AUTH" == "no" ] 273 if [ "$ECVS_AUTH" == "no" ]
280 then 274 then
281 local server="${ECVS_USER}@${ECVS_SERVER}" 275 local server="${ECVS_USER}@${ECVS_SERVER}"
282 else 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}"
283 local server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 280 local server=":${connection}:${ECVS_USER}@${ECVS_SERVER}"
284 fi 281 fi
285 282
286 # Switch servers automagically if needed 283 # Switch servers automagically if needed
287 if [ "$mode" == "update" ]; then 284 if [ "$mode" == "update" ]; then
288 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 285 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
339 eval $cmdlogin || die "cvs login command failed" 336 eval $cmdlogin || die "cvs login command failed"
340 if [ "${mode}" == "update" ]; then 337 if [ "${mode}" == "update" ]; then
341 einfo "Running $cmdupdate" 338 einfo "Running $cmdupdate"
342 eval $cmdupdate || die "cvs update command failed" 339 eval $cmdupdate || die "cvs update command failed"
343 elif [ "${mode}" == "checkout" ]; then 340 elif [ "${mode}" == "checkout" ]; then
344 einfo "Running $cmdcheckout" 341 einfo "Running $cmdcheckout"
345 eval $cmdcheckout|| die "cvs checkout command failed" 342 eval $cmdcheckout|| die "cvs checkout command failed"
346 fi 343 fi
347 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then 344 elif [ "${ECVS_AUTH}" == "ext" ] || [ "${ECVS_AUTH}" == "no" ]; then
348 345
349 # Hack to support SSH password authentication 346 # Hack to support SSH password authentication
414 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \ 411 echo "${CVS_ECLASS_STRICT_HOST_CHECKING}')" \
415 >> "${CVS_RSH}" 412 >> "${CVS_RSH}"
416 echo "os.execv('/usr/bin/ssh', newarglist)" \ 413 echo "os.execv('/usr/bin/ssh', newarglist)" \
417 >> "${CVS_RSH}" 414 >> "${CVS_RSH}"
418 415
419 chmod a+x "${CVS_RSH}" 416 chmod a+x "${CVS_RSH}"
420 417
421 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS 418 # Make sure DISPLAY is set (SSH will not use SSH_ASKPASS
422 # if DISPLAY is not set) 419 # if DISPLAY is not set)
423 420
424 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY" 421 [ -z "${DISPLAY}" ] && DISPLAY="DISPLAY"
425 export DISPLAY 422 export DISPLAY
426 423
427 # Create a dummy executable to echo $ECVS_PASS 424 # Create a dummy executable to echo $ECVS_PASS
428 425
429 export SSH_ASKPASS="${T}/cvs_sshechopass" 426 export SSH_ASKPASS="${T}/cvs_sshechopass"
430 if [ "${ECVS_AUTH}" != "no" ]; then 427 if [ "${ECVS_AUTH}" != "no" ]; then
431 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \ 428 echo -en "#!/bin/bash\necho \"$ECVS_PASS\"\n" \
432 > "${SSH_ASKPASS}" 429 > "${SSH_ASKPASS}"
433 else 430 else
434 echo -en "#!/bin/bash\nreturn\n" \ 431 echo -en "#!/bin/bash\nreturn\n" \
435 > "${SSH_ASKPASS}" 432 > "${SSH_ASKPASS}"
436 433
437 fi 434 fi
438 chmod a+x "${SSH_ASKPASS}" 435 chmod a+x "${SSH_ASKPASS}"
439 fi 436 fi
440 437
441 if [ "${mode}" == "update" ]; then 438 if [ "${mode}" == "update" ]; then
442 einfo "Running $cmdupdate" 439 einfo "Running $cmdupdate"
443 eval $cmdupdate || die "cvs update command failed" 440 eval $cmdupdate || die "cvs update command failed"
444 elif [ "${mode}" == "checkout" ]; then 441 elif [ "${mode}" == "checkout" ]; then
445 einfo "Running $cmdcheckout" 442 einfo "Running $cmdcheckout"
446 eval $cmdcheckout|| die "cvs checkout command failed" 443 eval $cmdcheckout|| die "cvs checkout command failed"
447 fi 444 fi
448 445
449 # Restore environment variable values 446 # Restore environment variable values
450 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}" 447 export CVS_RSH="${CVS_ECLASS_ORIG_CVS_RSH}"
451 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then 448 if [ "${CVS_ECLASS_ORIG_SSH_ASKPASS+set}" == "set" ]; then
452 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}" 449 export SSH_ASKPASS="${CVS_ECLASS_ORIG_SSH_ASKPASS}"
453 else 450 else
490 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 487 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
491 488
492 local ECVS_LOCALNAME="${ECVS_LOCALNAME}" 489 local ECVS_LOCALNAME="${ECVS_LOCALNAME}"
493 490
494 if [ -z "$ECVS_LOCALNAME" ]; then 491 if [ -z "$ECVS_LOCALNAME" ]; then
495 ECVS_LOCALNAME="$ECVS_MODULE" 492 ECVS_LOCALNAME="$ECVS_MODULE"
496 fi 493 fi
497 494
498 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
499 # We're not required to fetch anything; the module already 497 # We're not required to fetch anything; the module already
500 # exists and shouldn't be updated. 498 # exists and shouldn't be updated.
501 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then 499 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
502 debug-print "$FUNCNAME: offline mode" 500 debug-print "$FUNCNAME: offline mode"
503 else 501 else
504 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"
505 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."
506 fi 504 fi
535 # Implement some of base_src_unpack's functionality; note however 533 # Implement some of base_src_unpack's functionality; note however
536 # that base.eclass may not have been inherited! 534 # that base.eclass may not have been inherited!
537 if [ -n "$PATCHES" ]; then 535 if [ -n "$PATCHES" ]; then
538 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 536 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
539 cd "$S" 537 cd "$S"
540 for x in $PATCHES; do 538 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, 539 # Make sure we don't try to apply patches more than once,
545 # since cvs_src_unpack is usually called several times from 540 # since cvs_src_unpack is usually called several times from
546 # e.g. kde-source_src_unpack 541 # e.g. kde-source_src_unpack
547 export PATCHES="" 542 export PATCHES=""
548 fi 543 fi
549 544
550 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}" 545 einfo "CVS module ${ECVS_MODULE} is now in ${WORKDIR}"
551} 546}
552 547
553EXPORT_FUNCTIONS src_unpack 548EXPORT_FUNCTIONS src_unpack

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

  ViewVC Help
Powered by ViewVC 1.1.20