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

Diff of /eclass/cvs.eclass

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

Revision 1.23 Revision 1.31
1# Copyright 1999-2000 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.31 2003/02/16 04:26:21 vapier Exp $
4#
3# Author Dan Armak <danarmak@gentoo.org> 5# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.23 2002/11/01 10:54:42 danarmak Exp $ 6#
5# This eclass provides the generic cvs fetching functions. 7# This eclass provides the generic cvs fetching functions.
6 8
7ECLASS=cvs 9ECLASS=cvs
8INHERITED="$INHERITED $ECLASS" 10INHERITED="$INHERITED $ECLASS"
9 11
37[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline" 39[ -z "$ECVS_SERVER" ] && ECVS_SERVER="offline"
38 40
39# Anonymous cvs login? 41# Anonymous cvs login?
40# if 'yes' uses :pserver: with empty password, if 'no' uses :ext: with $ECVS_PASS, other values not allowed 42# if 'yes' uses :pserver: with empty password, if 'no' uses :ext: with $ECVS_PASS, other values not allowed
41[ -z "$ECVS_ANON" ] && ECVS_ANON="yes" 43[ -z "$ECVS_ANON" ] && ECVS_ANON="yes"
44
45# Authentication method to use on ECVS_ANON="no" - possible values are "pserver" and "ext"
46[ -z "$ECVS_AUTH" ] && ECVS_AUTH="ext"
47
48# Use su to run cvs as user
49[ -z "$ECVS_RUNAS" ] && ECVS_RUNAS="`whoami`"
42 50
43# Username to use 51# Username to use
44[ -z "$ECVS_USER" ] && ECVS_USER="anonymous" 52[ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
45 53
46# Password to use if anonymous login is off 54# Password to use if anonymous login is off
103 if [ ! -d "$DIR" ]; then 111 if [ ! -d "$DIR" ]; then
104 debug-print "$FUNCNAME: creating cvs directory $DIR" 112 debug-print "$FUNCNAME: creating cvs directory $DIR"
105 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/" 113 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/"
106 addwrite /foobar 114 addwrite /foobar
107 addwrite / 115 addwrite /
108 mkdir -p /$DIR 116 mkdir -p "/$DIR"
109 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foobar:\/} 117 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
110 fi 118 fi
111 119
112 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path, 120 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
113 # otherwise addwrite() doesn't work. 121 # otherwise addwrite() doesn't work.
114 cd -P $ECVS_TOP_DIR > /dev/null 122 cd -P "$ECVS_TOP_DIR" > /dev/null
115 ECVS_TOP_DIR="`/bin/pwd`" 123 ECVS_TOP_DIR="`/bin/pwd`"
116 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" 124 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
117 cd $OLDPWD 125 cd "$OLDPWD"
118 126
119 debug-print "$FUNCNAME: now DIR=$DIR" 127 debug-print "$FUNCNAME: now DIR=$DIR"
120 128
121 # disable the sandbox for this dir 129 # disable the sandbox for this dir
122 # not just $DIR because we want to create moduletopdir/CVS too 130 # not just $DIR because we want to create moduletopdir/CVS too
123 addwrite $ECVS_TOP_DIR/$ECVS_MODULE 131 addwrite "$ECVS_TOP_DIR/$ECVS_MODULE"
124 132
125 # add option for local (non-recursive) fetching 133 # add option for local (non-recursive) fetching
126 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" 134 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
127 135
128 # prepare a cvspass file just for this session so that cvs thinks we're logged 136 # prepare a cvspass file just for this session so that cvs thinks we're logged
129 # in at the cvs server. we don't want to mess with ~/.cvspass. 137 # in at the cvs server. we don't want to mess with ~/.cvspass.
130 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 138 echo ":pserver:${ECVS_SERVER} A" > "${T}/cvspass"
131 export CVS_PASSFILE="${T}/cvspass" 139 export CVS_PASSFILE="${T}/cvspass"
140 chown $ECVS_RUNAS "${T}/cvspass"
132 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 141 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
133 142
134 # Note: cvs update and checkout commands are unified. 143 # Note: cvs update and checkout commands are unified.
135 # we make sure a CVS/ dir exists in our module subdir with the right 144 # we make sure a CVS/ dir exists in our module subdir with the right
136 # Root and Repository entries in it and cvs update. 145 # Root and Repository entries in it and cvs update.
137 146
138 [ "${ECVS_ANON}" == "yes" ] && \ 147 [ "${ECVS_ANON}" == "yes" ] && \
139 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \ 148 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" || \
140 newserver=":ext:${ECVS_USER}@${ECVS_SERVER}" 149 newserver=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
141 150
142 151
143 # CVS/Repository files can't (I think) contain two concatenated slashes 152 # CVS/Repository files can't (I think) contain two concatenated slashes
144 if [ -n "$ECVS_SUBDIR" ]; then 153 if [ -n "$ECVS_SUBDIR" ]; then
145 repository="${ECVS_MODULE}/${ECVS_SUBDIR}" 154 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
147 repository="${ECVS_MODULE}" 156 repository="${ECVS_MODULE}"
148 fi 157 fi
149 158
150 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" 159 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
151 debug-print "$FUNCNAME: entering directory $DIR" 160 debug-print "$FUNCNAME: entering directory $DIR"
152 cd /$DIR 161 cd "/$DIR"
153 162
154 if [ ! -d "CVS" ]; then 163 if [ ! -d "CVS" ]; then
155 # create a new CVS/ directory (checkout) 164 # create a new CVS/ directory (checkout)
156 debug-print "$FUNCNAME: creating new cvs directory" 165 debug-print "$FUNCNAME: creating new cvs directory"
157 166
163 # if we're checking out a subdirectory only, create a CVS/ dir 172 # if we're checking out a subdirectory only, create a CVS/ dir
164 # in the module's top dir so that the user (and we) can cvs update 173 # in the module's top dir so that the user (and we) can cvs update
165 # from there to get the full module. 174 # from there to get the full module.
166 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then 175 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then
167 debug-print "$FUNCNAME: Copying CVS/ directory to module top-level dir" 176 debug-print "$FUNCNAME: Copying CVS/ directory to module top-level dir"
168 cp -r CVS $ECVS_TOP_DIR/$ECVS_MODULE/ 177 cp -r CVS "$ECVS_TOP_DIR/$ECVS_MODULE/"
169 echo $ECVS_MODULE > $ECVS_TOP_DIR/$ECVS_MODULE/CVS/Repository 178 echo $ECVS_MODULE > "$ECVS_TOP_DIR/$ECVS_MODULE/CVS/Repository"
170 fi 179 fi
171 180
172 else 181 else
173 #update existing module 182 #update existing module
174 debug-print "$FUNCNAME: updating existing module/subdir" 183 debug-print "$FUNCNAME: updating existing module/subdir"
188 debug-print "$cvsdirs" 197 debug-print "$cvsdirs"
189 198
190 einfo "Modifying CVS dirs..." 199 einfo "Modifying CVS dirs..."
191 for x in $cvsdirs; do 200 for x in $cvsdirs; do
192 debug-print "In $x" 201 debug-print "In $x"
193 echo $newserver > $x/Root 202 echo $newserver > "$x/Root"
194 done 203 done
195 204
196 fi 205 fi
197 206
198 fi 207 fi
199 208
200 # cvs auto-switches branches, how nice 209 # cvs auto-switches branches, how nice
201 # warning: if we do it this way we get multiple -rX options - harmless i think 210 # warning: if we do it this way we get multiple -rX options - harmless i think
202 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 211 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
212
213 # Chowning the directory
214 if [ "${ECVS_RUNAS}" != "`whoami`" ]; then
215 chown -R "$ECVS_RUNAS" "/$DIR"
216 fi
203 217
204 # finally run the cvs update command 218 # finally run the cvs update command
205 debug-print "$FUNCNAME: is in dir `/bin/pwd`" 219 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
206 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR" 220 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
207 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..." 221 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
218/usr/bin/env python << EndOfFile 232/usr/bin/env python << EndOfFile
219 233
220import pexpect,os 234import pexpect,os
221 235
222mypasswd = "${ECVS_PASS}" 236mypasswd = "${ECVS_PASS}"
237myauth = "${ECVS_AUTH}"
223mytimeout = 10 238mytimeout = 10
224 239
240if "${ECVS_RUNAS}" == "`whoami`":
225mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}" 241 mycommand = "${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}"
226child = pexpect.spawn(mycommand)
227
228index = child.expect(['continue connecting','word:'], mytimeout)
229if index == 0:
230 child.sendline('yes')
231 ## Added server to ~/.ssh/known_hosts
232 child.expect('word:', mytimeout)
233else: 242else:
243 mycommand = "su ${ECVS_RUNAS} -c \"${ECVS_CVS_COMMAND} update ${ECVS_CVS_OPTIONS}\""
244
245if myauth == "ext":
246 child = pexpect.spawn(mycommand)
247
248 index = child.expect(['continue connecting','word:'], mytimeout)
249 if index == 0:
250 child.sendline('yes')
251 ## Added server to ~/.ssh/known_hosts
252 child.expect('word:', mytimeout)
253 else:
234 ## Server already is in ~/.ssh/known_hosts 254 ## Server already is in ~/.ssh/known_hosts
235 pass 255 pass
236 256
237child.sendline(mypasswd) 257 child.sendline(mypasswd)
258 child.expect(pexpect.EOF)
259
260elif myauth == "pserver":
261 if "${ECVS_RUNAS}" == "`whoami`":
262 mycommand2 = "cvs login"
263 else:
264 mycommand2 = "su ${ECVS_RUNAS} -c \"cvs login\""
265 child = pexpect.spawn(mycommand2)
266 child.expect("CVS password:",mytimeout)
267 child.sendline(mypasswd)
238child.expect(pexpect.EOF) 268 child.expect(pexpect.EOF)
239 269
270 # Logged in - checking out
271 os.system(mycommand)
272
240EndOfFile 273EndOfFile
241########################### End of inline-python ################################## 274########################### End of inline-python ##################################
242 else 275 else
243 debug-print "$FUNCNAME: using anonymous cvs login" 276 debug-print "$FUNCNAME: using anonymous cvs login"
244 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update" 277 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update"
245 fi 278 fi
246 279
247 280 # log out and restore ownership
248 281 if [ "$ECVS_RUNAS" == "`whoami`" ]; then
282 cvs logout &> /dev/null
283 else
284 su $ECVS_RUNAS -c "cvs logout" &> /dev/null
285 fi
286 chown `whoami` "${T}/cvspass"
249} 287}
250 288
251cvs_src_unpack() { 289cvs_src_unpack() {
252 290
253 debug-print-function $FUNCNAME $* 291 debug-print-function $FUNCNAME $*
255 293
256 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..." 294 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
257 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 295 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
258 296
259 # probably redundant, but best to make sure 297 # probably redundant, but best to make sure
260 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 298 mkdir -p "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR"
261 299
262 if [ -n "$ECVS_SUBDIR" ]; then 300 if [ -n "$ECVS_SUBDIR" ]; then
263 if [ -n "$ECVS_LOCAL" ]; then 301 if [ -n "$ECVS_LOCAL" ]; then
264 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 302 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR"/* "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR"
265 else 303 else
266 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/.. 304 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR" "$WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/.."
267 fi 305 fi
268 else 306 else
269 if [ -n "$ECVS_LOCAL" ]; then 307 if [ -n "$ECVS_LOCAL" ]; then
270 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 308 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* $WORKDIR/$ECVS_MODULE
271 else 309 else
272 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 310 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR"
273 fi 311 fi
274 fi 312 fi
275 313
276 # if the directory is empty, remove it; empty directories cannot exist in cvs. 314 # if the directory is empty, remove it; empty directories cannot exist in cvs.
277 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist. 315 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist.
278 # still create the empty directory in workdir though. 316 # still create the empty directory in workdir though.
279 if [ "`ls -A $DIR`" == "CVS" ]; then 317 if [ "`ls -A \"$DIR\"`" == "CVS" ]; then
280 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 318 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
281 rm -rf $DIR 319 rm -rf "$DIR"
282 fi 320 fi
283 321
284 # implement some of base_src_unpack's functionality; 322 # implement some of base_src_unpack's functionality;
285 # note however that base.eclass may not have been inherited! 323 # note however that base.eclass may not have been inherited!
286 if [ -n "$PATCHES" ]; then 324 if [ -n "$PATCHES" ]; then
287 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 325 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
288 cd $S 326 cd "$S"
289 for x in $PATCHES; do 327 for x in $PATCHES; do
290 debug-print "patching from $x" 328 debug-print "patching from $x"
291 patch -p0 < $x 329 patch -p0 < "$x"
292 done 330 done
293 # make sure we don't try to apply patches more than once, since 331 # make sure we don't try to apply patches more than once, since
294 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack 332 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
295 export PATCHES="" 333 export PATCHES=""
296 fi 334 fi

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20