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

Diff of /eclass/cvs.eclass

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

Revision 1.36 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.36 2003/04/19 11:52:50 danarmak 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.
11 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?)
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
16# will take care of that. If you want to set the global KDE cvs ebuilds' settings, 23# will take care of that. If you want to set the global KDE cvs ebuilds' settings,
27# don't remove -dP from update or things won't work 34# don't remove -dP from update or things won't work
28[ -z "$ECVS_UP_OPTS" ] && ECVS_UP_OPTS="-dP" 35[ -z "$ECVS_UP_OPTS" ] && ECVS_UP_OPTS="-dP"
29[ -z "$ECVS_CO_OPTS" ] && ECVS_CO_OPTS="" 36[ -z "$ECVS_CO_OPTS" ] && ECVS_CO_OPTS=""
30 37
31# set this to some value for the module/subdir to be fetched non-recursively: ECVS_LOCAL 38# set this to some value for the module/subdir to be fetched non-recursively: ECVS_LOCAL
39
40# local name of module. useful if the module on the server is called
41# something common like 'driver' or is nested deep in a tree, and you don't
42# like useless empty directories.
43# WARNING: to be set only from within ebuilds! if set in your shell or some such,
44# things wil break because the ebuild won't expect it and have e.g. a wrong $S setting.
45# ECVS_LOCALNAME
32 46
33# Where the cvs modules are stored/accessed 47# Where the cvs modules are stored/accessed
34[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 48[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src"
35 49
36# Name of cvs server, set to "offline" to disable fetching 50# Name of cvs server, set to "offline" to disable fetching
43[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 57[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline"
44 58
45# Authentication method to use - possible values are "pserver" and "ext" 59# Authentication method to use - possible values are "pserver" and "ext"
46# 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)
47[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver" 61[ -z "$ECVS_AUTH" ] && ECVS_AUTH="pserver"
48[ "$ECVS_AUTH" == ext ] && die "ERROR: ext auth not supported. If you want it, please contact danarmak@gentoo.org."
49 62
50# Use su to run cvs as user 63# Use su to run cvs as user
51# 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
52# [ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`" 65# [ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
53 66
72 85
73# add cvs to deps 86# add cvs to deps
74# ssh is used for ext auth 87# ssh is used for ext auth
75# sudo is used to run as a specified user 88# sudo is used to run as a specified user
76DEPEND="$DEPEND dev-util/cvs app-admin/sudo" 89DEPEND="$DEPEND dev-util/cvs app-admin/sudo"
77#[ "$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
78 99
79# calls cvs_contorl, is called from cvs_src_unpack 100# calls cvs_contorl, is called from cvs_src_unpack
80cvs_fetch() { 101cvs_fetch() {
81 102
103 # fix for sourceforge which doesnt want -z>3 anymore.
104
105 (echo $ECVS_SERVER | grep sourceforge) && [ "$ECVS_CVS_COMMAND" == "cvs -q -f -z4" ] && ECVS_CVS_COMMAND="cvs -q -f -z3"
106
82 debug-print-function $FUNCNAME $* 107 debug-print-function $FUNCNAME $*
83 108
84 # parameters modifying other parameters that should be effective every time cvs_prep is called, and not 109 # parameters modifying other parameters that should be effective every time cvs_fetch is called,
85 # just every time cvs.eclas is inherited 110 # and not just every time cvs.eclas is inherited
86 # 1. parameter for local (non-recursive) fetching 111 # 1. parameter for local (non-recursive) fetching
87 if [ -n "$ECVS_LOCAL" ]; then 112 if [ -n "$ECVS_LOCAL" ]; then
88 ECVS_UP_OPTS="$ECVS_UP_OPTS -l" 113 ECVS_UP_OPTS="$ECVS_UP_OPTS -l"
89 ECVS_CO_OPTS="$ECVS_CO_OPTS -l" 114 ECVS_CO_OPTS="$ECVS_CO_OPTS -l"
90 fi 115 fi
91 # 2. cvs auto-switches branches, we just have to pass the correct -rBRANCH option to it when updating. 116 # 2. cvs auto-switches branches, we just have to pass the correct -rBRANCH option to it when updating.
92 # doing it this way we get multiple -rX options - harmless afaik 117 # doing it this way we get multiple -rX options - harmless afaik
93 if [ -n "$ECVS_BRANCH" ]; then 118 if [ -n "$ECVS_BRANCH" ]; then
94 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 119 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
95 ECVS_CO_OPTS="$ECVS_CO_OPTS -r$ECVS_BRANCH" 120 ECVS_CO_OPTS="$ECVS_CO_OPTS -r$ECVS_BRANCH"
121 fi
122
123 if [ "$ECVS_LOCALNAME" != "$ECVS_MODULE" ]; then
124 # the option to cvs on which this is based. note this isn't the same as the
125 # global -d option to cvs, which specifies the cvs server. ugh @ cvs syntax.
126 ECVS_CO_OPTS="$ECVS_CO_OPTS -d $ECVS_LOCALNAME"
96 fi 127 fi
97 128
98 # it's easiest to always be in "run-as mode", logic-wise 129 # it's easiest to always be in "run-as mode", logic-wise
99 # or would be if sudo didn't ask for a password even when sudo'ing to `whoami` 130 # or would be if sudo didn't ask for a password even when sudo'ing to `whoami`
100 if [ -z "$ECVS_RUNAS" ]; then 131 if [ -z "$ECVS_RUNAS" ]; then
121 # otherwise addwrite() doesn't work. 152 # otherwise addwrite() doesn't work.
122 cd -P "$ECVS_TOP_DIR" > /dev/null 153 cd -P "$ECVS_TOP_DIR" > /dev/null
123 ECVS_TOP_DIR="`/bin/pwd`" 154 ECVS_TOP_DIR="`/bin/pwd`"
124 155
125 # determine checkout or update mode 156 # determine checkout or update mode
126 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then 157 if [ ! -d "$ECVS_TOP_DIR/$ECVS_LOCALNAME/CVS" ]; then
127 mode=checkout 158 mode=checkout
128 else 159 else
129 mode=update 160 mode=update
130 fi 161 fi
131 162
135 # chowning the directory and all contents 166 # chowning the directory and all contents
136 if [ -n "$ECVS_RUNAS" ]; then 167 if [ -n "$ECVS_RUNAS" ]; then
137 $run chown -R "$ECVS_RUNAS" "/$ECVS_TOP_DIR" 168 $run chown -R "$ECVS_RUNAS" "/$ECVS_TOP_DIR"
138 fi 169 fi
139 170
140 # our server string (aka CVSHOST), without the password so it can be put in Root 171 # our server string (aka CVSROOT), without the password so it can be put in Root
141 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 172 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
142 173
143 # switch servers automagically if needed 174 # switch servers automagically if needed
144 if [ "$mode" == "update" ]; then 175 if [ "$mode" == "update" ]; then
145 cd /$ECVS_TOP_DIR/$ECVS_MODULE 176 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
146 oldserver="`$run cat CVS/Root`" 177 oldserver="`$run cat CVS/Root`"
147 if [ "$server" != "$oldserver" ]; then 178 if [ "$server" != "$oldserver" ]; then
148 179
149 einfo "Changing CVS server from $oldserver to $server:" 180 einfo "Changing CVS server from $oldserver to $server:"
150 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:" 181 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:"
161 done 192 done
162 193
163 fi 194 fi
164 fi 195 fi
165 196
166 # the server string with the password in it
167 # needed for mode=update too as we may not be inside ECVS_MODULE but only inside ECVS_TOP_DIR
168 # however putting the password in in update mode can break (?)
169 if [ "$mode" == "checkout" ]; then
170 export CVSROOT=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
171 else
172 export CVSROOT=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
173 fi
174
175 # 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
176 touch "${T}/cvspass" 198 touch "${T}/cvspass"
177 export CVS_PASSFILE="${T}/cvspass" 199 export CVS_PASSFILE="${T}/cvspass"
178 if [ -n "$ECVS_RUNAS" ]; then 200 if [ -n "$ECVS_RUNAS" ]; then
179 chown "$ECVS_RUNAS" "${T}/cvspass" 201 chown "$ECVS_RUNAS" "${T}/cvspass"
180 fi 202 fi
181 203
204 # the server string with the password in it, for login
205 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
206 # ditto without the password, for checkout/update after login, so that
207 # the CVS/Root files don't contain the password in plaintext
208 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
209
182 # commands to run 210 # commands to run
211 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
183 cmdupdate="${run} ${ECVS_CVS_COMMAND} update ${ECVS_UP_OPTS} ${ECVS_MODULE}" 212 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}"
184 cmdcheckout="${run} ${ECVS_CVS_COMMAND} checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}" 213 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
185 214
186 cd "${ECVS_TOP_DIR}" 215 cd "${ECVS_TOP_DIR}"
187 if [ "${ECVS_AUTH}" == "pserver" ]; then 216 if [ "${ECVS_AUTH}" == "pserver" ]; then
217 einfo "Running $cmdlogin"
218 eval $cmdlogin || die "cvs login command failed"
188 if [ "${mode}" == "update" ]; then 219 if [ "${mode}" == "update" ]; then
189 $cmdupdate 220 einfo "Running $cmdupdate"
221 eval $cmdupdate || die "cvs update command failed"
190 elif [ "${mode}" == "checkout" ]; then 222 elif [ "${mode}" == "checkout" ]; then
191 $cmdcheckout 223 einfo "Running $cmdcheckout"
224 eval $cmdcheckout|| die "cvs checkout command failed"
192 fi 225 fi
193# elif [ "${ECVS_AUTH}" == "ext" ]; then 226 elif [ "${ECVS_AUTH}" == "ext" ]; then
194# # for ext there's also a possible ssh prompt, code not yet written 227 #no login needed for ext
195# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct"
196# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct"
197# if [ "$mode" == "update" ]; then 228 if [ "${mode}" == "update" ]; then
198# expect "$cvsout" "$instruct" | $cmdupdate > "$cvsout" 229 einfo "Running $cmdupdate"
230 eval $cmdupdate || die "cvs update command failed"
199# elif [ "$mode" == "checkout" ]; then 231 elif [ "${mode}" == "checkout" ]; then
200# expect "$cvsout" "$instruct" | $cmdcheckout > "$cvsout" 232 einfo "Running $cmdcheckout"
233 eval $cmdcheckout|| die "cvs checkout command failed"
201# fi 234 fi
202 fi 235 fi
203 236
204 # 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.
205 if [ -n "$ECVS_RUNAS" ]; then 238 if [ -n "$ECVS_RUNAS" ]; then
206 chown `whoami` "${T}/cvspass" 239 chown `whoami` "${T}/cvspass"
212cvs_src_unpack() { 245cvs_src_unpack() {
213 246
214 debug-print-function $FUNCNAME $* 247 debug-print-function $FUNCNAME $*
215 248
216 debug-print "$FUNCNAME: init: 249 debug-print "$FUNCNAME: init:
217ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 250 ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
218ECVS_UP_OPTS=$ECVS_UP_OPTS 251 ECVS_UP_OPTS=$ECVS_UP_OPTS
219ECVS_CO_OPTS=$ECVS_CO_OPTS 252 ECVS_CO_OPTS=$ECVS_CO_OPTS
220ECVS_TOP_DIR=$ECVS_TOP_DIR 253 ECVS_TOP_DIR=$ECVS_TOP_DIR
221ECVS_SERVER=$ECVS_SERVER 254 ECVS_SERVER=$ECVS_SERVER
222ECVS_USER=$ECVS_USER 255 ECVS_USER=$ECVS_USER
223ECVS_PASS=$ECVS_PASS 256 ECVS_PASS=$ECVS_PASS
224ECS_MODULE=$ECVS_MODULE 257 ECVS_MODULE=$ECVS_MODULE
225ECVS_LOCAL=$ECVS_LOCAL 258 ECVS_LOCAL=$ECVS_LOCAL
226ECVS_RUNAS=$ECVS_RUNAS" 259 ECVS_RUNAS=$ECVS_RUNAS
260 ECVS_LOCALNAME=$ECVS_LOCALNAME"
227 261
228 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 262 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
263
264 # merely setting this default value makes things fail when cvs_src_unpack is called
265 # more than once per ebuild (eg kdenonbeta submodules); so if we set a default value,
266 # we disable it again at the function's end.
267 # of course, we could instead always reference it with the bash syntax for 'take default
268 # value from this other variable if undefined', but i'm lazy.
269 if [ -z "$ECVS_LOCALNAME" ]; then
270 ECVS_LOCALNAME="$ECVS_MODULE"
271 ECVS_LOCALNAME_SETDEFAULT=true
272 fi
273
229 274
230 if [ "$ECVS_SERVER" == "offline" ]; then 275 if [ "$ECVS_SERVER" == "offline" ]; then
231 # 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
232 if [ -d "${ECVS_TOP_DIR}/${ECVS_MODULE}" ]; then 277 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
233 debug-print "$FUNCNAME: offline mode, exiting" 278 debug-print "$FUNCNAME: offline mode"
234 return 0
235 else 279 else
236 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error" 280 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
237 die "ERROR: Offline mode specified, but module/subdir checkout not found. Aborting." 281 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
238 fi 282 fi
239 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 283 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
240 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..." 284 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..."
241 cvs_fetch 285 cvs_fetch
242 else # ECVS_SERVER not set 286 else # ECVS_SERVER not set
243 die "ERROR: CVS server not set, cannot continue." 287 die "ERROR: CVS server not set, cannot continue."
244 fi 288 fi
245 289
246 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." 290 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..."
247 debug-print "Copying module $ECVS_MODULElocal_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 291 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
248 292
249 # probably redundant, but best to make sure 293 # probably redundant, but best to make sure
250 mkdir -p "$WORKDIR/$ECVS_MODULE" 294 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
251 295
252 if [ -n "$ECVS_LOCAL" ]; then 296 if [ -n "$ECVS_LOCAL" ]; then
253 mkdir -p "$WORKDIR/$ECVS_MODULE"
254 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* "$WORKDIR/$ECVS_MODULE" 297 cp -f "$ECVS_TOP_DIR/$ECVS_LOCALNAME"/* "$WORKDIR/$ECVS_LOCALNAME"
255 else 298 else
256 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR/$ECVS_MODULE/.." 299 cp -Rf "$ECVS_TOP_DIR/$ECVS_LOCALNAME" "$WORKDIR/$ECVS_LOCALNAME/.."
257 fi 300 fi
258 301
259 # if the directory is empty, remove it; empty directories cannot exist in cvs. 302 # if the directory is empty, remove it; empty directories cannot exist in cvs.
260 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist. 303 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist.
261 # still create the empty directory in workdir though. 304 # still create the empty directory in workdir though.
262 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_MODULE}\"`" == "CVS" ]; then 305 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_LOCALNAME}\"`" == "CVS" ]; then
263 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE" 306 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_LOCALNAME"
264 rm -rf "${ECVS_TOP_DIR}/${ECVS_MODULE}" 307 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
265 fi 308 fi
266 309
267 # implement some of base_src_unpack's functionality; 310 # implement some of base_src_unpack's functionality;
268 # note however that base.eclass may not have been inherited! 311 # note however that base.eclass may not have been inherited!
269 if [ -n "$PATCHES" ]; then 312 if [ -n "$PATCHES" ]; then
275 done 318 done
276 # make sure we don't try to apply patches more than once, since 319 # make sure we don't try to apply patches more than once, since
277 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack 320 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
278 export PATCHES="" 321 export PATCHES=""
279 fi 322 fi
323
324 if [ -n "$ECVS_LOCALNAME_SETDEFAULT" ]; then
325 unset ECVS_LOCALNAME
326 unset ECVS_LOCALNAME_SETDEFAULT
327 fi
328
329 einfo "Module ${ECVS_MODULE} is now in ${WORKDIR}"
280 330
281} 331}
282 332
283EXPORT_FUNCTIONS src_unpack 333EXPORT_FUNCTIONS src_unpack

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

  ViewVC Help
Powered by ViewVC 1.1.20