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

Diff of /eclass/cvs.eclass

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

Revision 1.46 Revision 1.47
1# Copyright 1999-2003 Gentoo Technologies, Inc. 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.46 2003/08/07 02:58:18 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.47 2003/09/28 17:08:35 coredumb Exp $
4# 4#
5# Current Maintainer: Tal Peer <coredumb@gentoo.org>
5# Author Dan Armak <danarmak@gentoo.org> 6# Original Author: Dan Armak <danarmak@gentoo.org>
7#
8# SSH auth code by Danny <danny.milo@gmx.net>
6# 9#
7# This eclass provides the generic cvs fetching functions. 10# This eclass provides the generic cvs fetching functions.
8# to use from an ebuild, set the 'ebuild-configurable settings' below in your ebuild before inheriting. 11# to use from an ebuild, set the 'ebuild-configurable settings' below in your ebuild before inheriting.
9# then either leave the default src_unpack or extend over cvs_src_unpack. 12# then either leave the default src_unpack or extend over cvs_src_unpack.
10# if you find that you need to call the cvs_* functions directly, i'd be interested to hear about it. 13# if you find that you need to call the cvs_* functions directly, i'd be interested to hear about it.
14
15# TODO:
16# Implement more auth types (gserver?, kserver?)
17# Implement more 'ext' auth methods (do anyone actually use it with anything other than ssh?)
11 18
12ECLASS=cvs 19ECLASS=cvs
13INHERITED="$INHERITED $ECLASS" 20INHERITED="$INHERITED $ECLASS"
14 21
15# You shouldn't change these settings yourself! The ebuild/eclass inheriting this eclass 22# You shouldn't change these settings yourself! The ebuild/eclass inheriting this eclass
50[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 57[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline"
51 58
52# Authentication method to use - possible values are "pserver" and "ext" 59# Authentication method to use - possible values are "pserver" and "ext"
53# WARNING ext is NOT supported! (never was, despite what earlier version of this file said) 60# WARNING ext is NOT supported! (never was, despite what earlier version of this file said)
54[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 61[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
55[ "$ECVS_AUTH" == ext ] && die "ERROR: ext auth not supported. If you want it, please contact danarmak@gentoo.org."
56 62
57# Use su to run cvs as user 63# Use su to run cvs as user
58# Currently b0rked and wouldn't work with portage userpriv anyway without special magic 64# Currently b0rked and wouldn't work with portage userpriv anyway without special magic
59# [ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 65# [ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
60 66
79 85
80# add cvs to deps 86# add cvs to deps
81# ssh is used for ext auth 87# ssh is used for ext auth
82# sudo is used to run as a specified user 88# sudo is used to run as a specified user
83DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 89DEPEND="$DEPEND dev-util/cvs app-admin/sudo"
84#[ "$ECVS_AUTH" == "ext" ] && DEPEND="$DEPEND net-misc/openssh" 90
91if [ "$ECVS_AUTH" == "ext" ]; then
92 #default to ssh
93 [ -z "$CVS_RSH" ] && export SSH_RSH="ssh"
94 if [ "$CVS_RSH" != "ssh" ]; then
95 die "Support for ext auth with clients other than ssh has not been implemented yet"
96 fi
97 DEPEND="$DEPEND net-misc/openssh"
98fi
85 99
86# calls cvs_contorl, is called from cvs_src_unpack 100# calls cvs_contorl, is called from cvs_src_unpack
87cvs_fetch() { 101cvs_fetch() {
88 102
89 # fix for sourceforge which doesnt want -z>3 anymore. 103 # fix for sourceforge which doesnt want -z>3 anymore.
160 # switch servers automagically if needed 174 # switch servers automagically if needed
161 if [ "$mode" == "update" ]; then 175 if [ "$mode" == "update" ]; then
162 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME 176 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
163 oldserver="`$run cat CVS/Root`" 177 oldserver="`$run cat CVS/Root`"
164 if [ "$server" != "$oldserver" ]; then 178 if [ "$server" != "$oldserver" ]; then
179
165 einfo "Changing CVS server from $oldserver to $server:" 180 einfo "Changing CVS server from $oldserver to $server:"
166 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:" 181 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:"
167 182
168 einfo "Searching for CVS dirs ..." 183 einfo "Searching for CVS dirs..."
169 cvsdirs="`$run find . -iname CVS -print`" 184 cvsdirs="`$run find . -iname CVS -print`"
170 debug-print "$FUNCNAME: CVS dirs found:" 185 debug-print "$FUNCNAME: CVS dirs found:"
171 debug-print "$cvsdirs" 186 debug-print "$cvsdirs"
172 187
173 einfo "Modifying CVS dirs ..." 188 einfo "Modifying CVS dirs..."
174 for x in $cvsdirs; do 189 for x in $cvsdirs; do
175 debug-print "In $x" 190 debug-print "In $x"
176 $run echo "$server" > "$x/Root" 191 $run echo "$server" > "$x/Root"
177 done 192 done
193
178 fi 194 fi
179 fi 195 fi
180 196
181 # prepare a cvspass file just for this session, we don't want to mess with ~/.cvspass 197 # prepare a cvspass file just for this session, we don't want to mess with ~/.cvspass
182 touch "${T}/cvspass" 198 touch "${T}/cvspass"
190 # ditto without the password, for checkout/update after login, so that 206 # ditto without the password, for checkout/update after login, so that
191 # the CVS/Root files don't contain the password in plaintext 207 # the CVS/Root files don't contain the password in plaintext
192 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 208 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
193 209
194 # commands to run 210 # commands to run
195 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\"" 211 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
196 cmdlogin_opts="login"
197 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\"" 212 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}"
198 cmdupdate_opts="update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}"
199 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\"" 213 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
200 cmdcheckout_opts="checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
201 214
202 cd "${ECVS_TOP_DIR}" 215 cd "${ECVS_TOP_DIR}"
203 if [ "${ECVS_AUTH}" == "pserver" ]; then 216 if [ "${ECVS_AUTH}" == "pserver" ]; then
204 debug-print "$FUNCNAME: logging into cvs ${cmdlogin} ${cmdlogin_opts}"
205 einfo "Logging in: ${cmdlogin}" 217 einfo "Running $cmdlogin"
206 eval ${cmdlogin} ${cmdlogin_opts} >/dev/null || die "cvs login command failed" 218 eval $cmdlogin || die "cvs login command failed"
207 if [ "${mode}" == "update" ]; then 219 if [ "${mode}" == "update" ]; then
208 debug-print "$FUNCNAME: updating cvs tree ${cmdupdate} ${cmdupdate_opts}" 220 einfo "Running $cmdupdate"
209 einfo "Updating existing source tree: ${cmdupdate_opts}" 221 eval $cmdupdate || die "cvs update command failed"
210 eval ${cmdupdate} ${cmdupdate_opts} || die "cvs update command failed"
211 elif [ "${mode}" == "checkout" ]; then 222 elif [ "${mode}" == "checkout" ]; then
212 debug-print "$FUNCNAME: checking out from cvs tree ${cmdcheckout} ${cmdcheckout_opts}" 223 einfo "Running $cmdcheckout"
213 einfo "Checking out source tree (${cmdcheckout_opts})" 224 eval $cmdcheckout|| die "cvs checkout command failed"
214 eval ${cmdcheckout} ${cmdcheckout_opts} || die "cvs checkout command failed"
215 fi 225 fi
216# elif [ "${ECVS_AUTH}" == "ext" ]; then 226 elif [ "${ECVS_AUTH}" == "ext" ]; then
217# # for ext there's also a possible ssh prompt, code not yet written 227 #no login needed for ext
218# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct"
219# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct"
220# if [ "$mode" == "update" ]; then 228 if [ "${mode}" == "update" ]; then
221# expect "$cvsout" "$instruct" | $cmdupdate > "$cvsout" 229 einfo "Running $cmdupdate"
230 eval $cmdupdate || die "cvs update command failed"
222# elif [ "$mode" == "checkout" ]; then 231 elif [ "${mode}" == "checkout" ]; then
223# expect "$cvsout" "$instruct" | $cmdcheckout > "$cvsout" 232 einfo "Running $cmdcheckout"
233 eval $cmdcheckout|| die "cvs checkout command failed"
224# fi 234 fi
225 fi 235 fi
226 236
227 # restore ownership. not sure why this is needed, but someone added it in the orig ECVS_RUNAS stuff. 237 # restore ownership. not sure why this is needed, but someone added it in the orig ECVS_RUNAS stuff.
228 if [ -n "$ECVS_RUNAS" ]; then 238 if [ -n "$ECVS_RUNAS" ]; then
229 chown `whoami` "${T}/cvspass" 239 chown `whoami` "${T}/cvspass"
230 fi 240 fi
241
231} 242}
232 243
233 244
234cvs_src_unpack() { 245cvs_src_unpack() {
246
235 debug-print-function $FUNCNAME $* 247 debug-print-function $FUNCNAME $*
236 248
237 debug-print "$FUNCNAME: init: 249 debug-print "$FUNCNAME: init:
238ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 250 ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
239ECVS_UP_OPTS=$ECVS_UP_OPTS 251 ECVS_UP_OPTS=$ECVS_UP_OPTS
240ECVS_CO_OPTS=$ECVS_CO_OPTS 252 ECVS_CO_OPTS=$ECVS_CO_OPTS
241ECVS_TOP_DIR=$ECVS_TOP_DIR 253 ECVS_TOP_DIR=$ECVS_TOP_DIR
242ECVS_SERVER=$ECVS_SERVER 254 ECVS_SERVER=$ECVS_SERVER
243ECVS_USER=$ECVS_USER 255 ECVS_USER=$ECVS_USER
244ECVS_PASS=$ECVS_PASS 256 ECVS_PASS=$ECVS_PASS
245ECVS_MODULE=$ECVS_MODULE 257 ECVS_MODULE=$ECVS_MODULE
246ECVS_LOCAL=$ECVS_LOCAL 258 ECVS_LOCAL=$ECVS_LOCAL
247ECVS_RUNAS=$ECVS_RUNAS 259 ECVS_RUNAS=$ECVS_RUNAS
248ECVS_LOCALNAME=$ECVS_LOCALNAME" 260 ECVS_LOCALNAME=$ECVS_LOCALNAME"
249 261
250 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 262 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
251 263
252 # merely setting this default value makes things fail when cvs_src_unpack is called 264 # merely setting this default value makes things fail when cvs_src_unpack is called
253 # more than once per ebuild (eg kdenonbeta submodules); so if we set a default value, 265 # more than once per ebuild (eg kdenonbeta submodules); so if we set a default value,
254 # we disable it again at the function's end. 266 # we disable it again at the function's end.
255 # of course, we could instead always reference it with the bash syntax for 'take default 267 # of course, we could instead always reference it with the bash syntax for 'take default
256 # value from this other variable if undefined', but i'm lazy. 268 # value from this other variable if undefined', but i'm lazy.
257 if [ -z "$ECVS_LOCALNAME" ]; then 269 if [ -z "$ECVS_LOCALNAME" ]; then
258 ECVS_LOCALNAME="$ECVS_MODULE" 270 ECVS_LOCALNAME="$ECVS_MODULE"
259 ECVS_LOCALNAME_SETDEFAULT=true 271 ECVS_LOCALNAME_SETDEFAULT=true
260 fi 272 fi
273
261 274
262 if [ "$ECVS_SERVER" == "offline" ]; then 275 if [ "$ECVS_SERVER" == "offline" ]; then
263 # we're not required to fetch anything, the module already exists and shouldn't be updated 276 # we're not required to fetch anything, the module already exists and shouldn't be updated
264 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then 277 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
265 debug-print "$FUNCNAME: offline mode" 278 debug-print "$FUNCNAME: offline mode"
266 else 279 else
267 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error" 280 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
268 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting." 281 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
269 fi 282 fi
270 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 283 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
271 einfo "Fetching module '$ECVS_MODULE' and saving in $ECVS_TOP_DIR ..." 284 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..."
272 cvs_fetch 285 cvs_fetch
273 else # ECVS_SERVER not set 286 else # ECVS_SERVER not set
274 die "ERROR: CVS server not set, cannot continue." 287 die "ERROR: CVS server not set, cannot continue."
275 fi 288 fi
276 289
277 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR ..." 290 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..."
278 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR ..." 291 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
279 292
280 # probably redundant, but best to make sure 293 # probably redundant, but best to make sure
281 mkdir -p "$WORKDIR/$ECVS_LOCALNAME" 294 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
282 295
283 if [ -n "$ECVS_LOCAL" ]; then 296 if [ -n "$ECVS_LOCAL" ]; then
311 if [ -n "$ECVS_LOCALNAME_SETDEFAULT" ]; then 324 if [ -n "$ECVS_LOCALNAME_SETDEFAULT" ]; then
312 unset ECVS_LOCALNAME 325 unset ECVS_LOCALNAME
313 unset ECVS_LOCALNAME_SETDEFAULT 326 unset ECVS_LOCALNAME_SETDEFAULT
314 fi 327 fi
315 328
316 einfo "Module $ECVS_MODULE is now in ${WORKDIR}" 329 einfo "Module ${ECVS_MODULE} is now in ${WORKDIR}"
330
317} 331}
318 332
319EXPORT_FUNCTIONS src_unpack 333EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.20