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

Diff of /eclass/cvs.eclass

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

Revision 1.37 Revision 1.44
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.37 2003/04/22 09:17:17 danarmak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.44 2003/07/04 13:21:02 danarmak Exp $
4# 4#
5# Author Dan Armak <danarmak@gentoo.org> 5# Author Dan Armak <danarmak@gentoo.org>
6# 6#
7# This eclass provides the generic cvs fetching functions. 7# 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. 8# to use from an ebuild, set the 'ebuild-configurable settings' below in your ebuild before inheriting.
27# don't remove -dP from update or things won't work 27# don't remove -dP from update or things won't work
28[ -z "$ECVS_UP_OPTS" ] && ECVS_UP_OPTS="-dP" 28[ -z "$ECVS_UP_OPTS" ] && ECVS_UP_OPTS="-dP"
29[ -z "$ECVS_CO_OPTS" ] && ECVS_CO_OPTS="" 29[ -z "$ECVS_CO_OPTS" ] && ECVS_CO_OPTS=""
30 30
31# set this to some value for the module/subdir to be fetched non-recursively: ECVS_LOCAL 31# set this to some value for the module/subdir to be fetched non-recursively: ECVS_LOCAL
32
33# local name of module. useful if the module on the server is called
34# something common like 'driver' or is nested deep in a tree, and you don't
35# like useless empty directories.
36# WARNING: to be set only from within ebuilds! if set in your shell or some such,
37# things wil break because the ebuild won't expect it and have e.g. a wrong $S setting.
38# ECVS_LOCALNAME
32 39
33# Where the cvs modules are stored/accessed 40# Where the cvs modules are stored/accessed
34[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" 41[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src"
35 42
36# Name of cvs server, set to "offline" to disable fetching 43# Name of cvs server, set to "offline" to disable fetching
77#[ "$ECVS_AUTH" == "ext" ] && DEPEND="$DEPEND net-misc/openssh" 84#[ "$ECVS_AUTH" == "ext" ] && DEPEND="$DEPEND net-misc/openssh"
78 85
79# calls cvs_contorl, is called from cvs_src_unpack 86# calls cvs_contorl, is called from cvs_src_unpack
80cvs_fetch() { 87cvs_fetch() {
81 88
89 # fix for sourceforge which doesnt want -z>3 anymore.
90
91 (echo $ECVS_SERVER | grep sourceforge) && [ "$ECVS_CVS_COMMAND" == "cvs -q -f -z4" ] && ECVS_CVS_COMMAND="cvs -q -f -z3"
92
82 debug-print-function $FUNCNAME $* 93 debug-print-function $FUNCNAME $*
83 94
84 # parameters modifying other parameters that should be effective every time cvs_fetch is called, 95 # parameters modifying other parameters that should be effective every time cvs_fetch is called,
85 # and not just every time cvs.eclas is inherited 96 # and not just every time cvs.eclas is inherited
86 # 1. parameter for local (non-recursive) fetching 97 # 1. parameter for local (non-recursive) fetching
91 # 2. cvs auto-switches branches, we just have to pass the correct -rBRANCH option to it when updating. 102 # 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 103 # doing it this way we get multiple -rX options - harmless afaik
93 if [ -n "$ECVS_BRANCH" ]; then 104 if [ -n "$ECVS_BRANCH" ]; then
94 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 105 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
95 ECVS_CO_OPTS="$ECVS_CO_OPTS -r$ECVS_BRANCH" 106 ECVS_CO_OPTS="$ECVS_CO_OPTS -r$ECVS_BRANCH"
107 fi
108
109 if [ "$ECVS_LOCALNAME" != "$ECVS_MODULE" ]; then
110 # the option to cvs on which this is based. note this isn't the same as the
111 # global -d option to cvs, which specifies the cvs server. ugh @ cvs syntax.
112 ECVS_CO_OPTS="$ECVS_CO_OPTS -d $ECVS_LOCALNAME"
96 fi 113 fi
97 114
98 # it's easiest to always be in "run-as mode", logic-wise 115 # 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` 116 # or would be if sudo didn't ask for a password even when sudo'ing to `whoami`
100 if [ -z "$ECVS_RUNAS" ]; then 117 if [ -z "$ECVS_RUNAS" ]; then
121 # otherwise addwrite() doesn't work. 138 # otherwise addwrite() doesn't work.
122 cd -P "$ECVS_TOP_DIR" > /dev/null 139 cd -P "$ECVS_TOP_DIR" > /dev/null
123 ECVS_TOP_DIR="`/bin/pwd`" 140 ECVS_TOP_DIR="`/bin/pwd`"
124 141
125 # determine checkout or update mode 142 # determine checkout or update mode
126 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then 143 if [ ! -d "$ECVS_TOP_DIR/$ECVS_LOCALNAME/CVS" ]; then
127 mode=checkout 144 mode=checkout
128 else 145 else
129 mode=update 146 mode=update
130 fi 147 fi
131 148
140 # our server string (aka CVSROOT), without the password so it can be put in Root 157 # our server string (aka CVSROOT), without the password so it can be put in Root
141 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 158 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
142 159
143 # switch servers automagically if needed 160 # switch servers automagically if needed
144 if [ "$mode" == "update" ]; then 161 if [ "$mode" == "update" ]; then
145 cd /$ECVS_TOP_DIR/$ECVS_MODULE 162 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
146 oldserver="`$run cat CVS/Root`" 163 oldserver="`$run cat CVS/Root`"
147 if [ "$server" != "$oldserver" ]; then 164 if [ "$server" != "$oldserver" ]; then
148 165
149 einfo "Changing CVS server from $oldserver to $server:" 166 einfo "Changing CVS server from $oldserver to $server:"
150 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:" 167 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:"
161 done 178 done
162 179
163 fi 180 fi
164 fi 181 fi
165 182
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 183 # prepare a cvspass file just for this session, we don't want to mess with ~/.cvspass
176 touch "${T}/cvspass" 184 touch "${T}/cvspass"
177 export CVS_PASSFILE="${T}/cvspass" 185 export CVS_PASSFILE="${T}/cvspass"
178 if [ -n "$ECVS_RUNAS" ]; then 186 if [ -n "$ECVS_RUNAS" ]; then
179 chown "$ECVS_RUNAS" "${T}/cvspass" 187 chown "$ECVS_RUNAS" "${T}/cvspass"
180 fi 188 fi
181 189
190 # the server string with the password in it, for login
191 cvsroot_pass=":${ECVS_AUTH}:${ECVS_USER}:${ECVS_PASS}@${ECVS_SERVER}"
192 # ditto without the password, for checkout/update after login, so that
193 # the CVS/Root files don't contain the password in plaintext
194 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
195
182 # commands to run 196 # commands to run
197 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
183 cmdupdate="${run} ${ECVS_CVS_COMMAND} update ${ECVS_UP_OPTS} ${ECVS_MODULE}" 198 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}" 199 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
185 200
186 cd "${ECVS_TOP_DIR}" 201 cd "${ECVS_TOP_DIR}"
187 if [ "${ECVS_AUTH}" == "pserver" ]; then 202 if [ "${ECVS_AUTH}" == "pserver" ]; then
203 einfo "Running $cmdlogin"
204 eval $cmdlogin || die "cvs login command failed"
188 if [ "${mode}" == "update" ]; then 205 if [ "${mode}" == "update" ]; then
189 $cmdupdate 206 einfo "Running $cmdupdate"
207 eval $cmdupdate || die "cvs update command failed"
190 elif [ "${mode}" == "checkout" ]; then 208 elif [ "${mode}" == "checkout" ]; then
191 $cmdcheckout 209 einfo "Running $cmdcheckout"
210 eval $cmdcheckout|| die "cvs checkout command failed"
192 fi 211 fi
193# elif [ "${ECVS_AUTH}" == "ext" ]; then 212# elif [ "${ECVS_AUTH}" == "ext" ]; then
194# # for ext there's also a possible ssh prompt, code not yet written 213# # for ext there's also a possible ssh prompt, code not yet written
195# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct" 214# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct"
196# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct" 215# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct"
219ECVS_CO_OPTS=$ECVS_CO_OPTS 238ECVS_CO_OPTS=$ECVS_CO_OPTS
220ECVS_TOP_DIR=$ECVS_TOP_DIR 239ECVS_TOP_DIR=$ECVS_TOP_DIR
221ECVS_SERVER=$ECVS_SERVER 240ECVS_SERVER=$ECVS_SERVER
222ECVS_USER=$ECVS_USER 241ECVS_USER=$ECVS_USER
223ECVS_PASS=$ECVS_PASS 242ECVS_PASS=$ECVS_PASS
224ECS_MODULE=$ECVS_MODULE 243ECVS_MODULE=$ECVS_MODULE
225ECVS_LOCAL=$ECVS_LOCAL 244ECVS_LOCAL=$ECVS_LOCAL
226ECVS_RUNAS=$ECVS_RUNAS" 245ECVS_RUNAS=$ECVS_RUNAS
246ECVS_LOCALNAME=$ECVS_LOCALNAME"
227 247
228 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 248 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
249
250 # merely setting this default value makes things fail when cvs_src_unpack is called
251 # more than once per ebuild (eg kdenonbeta submodules); so if we set a default value,
252 # we disable it again at the function's end.
253 # of course, we could instead always reference it with the bash syntax for 'take default
254 # value from this other variable if undefined', but i'm lazy.
255 if [ -z "$ECVS_LOCALNAME" ]; then
256 ECVS_LOCALNAME="$ECVS_MODULE"
257 ECVS_LOCALNAME_SETDEFAULT=true
258 fi
259
229 260
230 if [ "$ECVS_SERVER" == "offline" ]; then 261 if [ "$ECVS_SERVER" == "offline" ]; then
231 # we're not required to fetch anything, the module already exists and shouldn't be updated 262 # 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 263 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
233 debug-print "$FUNCNAME: offline mode, exiting" 264 debug-print "$FUNCNAME: offline mode"
234 return 0
235 else 265 else
236 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error" 266 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." 267 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
238 fi 268 fi
239 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 269 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
240 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..." 270 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..."
241 cvs_fetch 271 cvs_fetch
242 else # ECVS_SERVER not set 272 else # ECVS_SERVER not set
243 die "ERROR: CVS server not set, cannot continue." 273 die "ERROR: CVS server not set, cannot continue."
244 fi 274 fi
245 275
246 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." 276 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..."
247 debug-print "Copying module $ECVS_MODULElocal_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 277 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
248 278
249 # probably redundant, but best to make sure 279 # probably redundant, but best to make sure
250 mkdir -p "$WORKDIR/$ECVS_MODULE" 280 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
251 281
252 if [ -n "$ECVS_LOCAL" ]; then 282 if [ -n "$ECVS_LOCAL" ]; then
253 mkdir -p "$WORKDIR/$ECVS_MODULE"
254 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* "$WORKDIR/$ECVS_MODULE" 283 cp -f "$ECVS_TOP_DIR/$ECVS_LOCALNAME"/* "$WORKDIR/$ECVS_LOCALNAME"
255 else 284 else
256 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR/$ECVS_MODULE/.." 285 cp -Rf "$ECVS_TOP_DIR/$ECVS_LOCALNAME" "$WORKDIR/$ECVS_LOCALNAME/.."
257 fi 286 fi
258 287
259 # if the directory is empty, remove it; empty directories cannot exist in cvs. 288 # 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. 289 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist.
261 # still create the empty directory in workdir though. 290 # still create the empty directory in workdir though.
262 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_MODULE}\"`" == "CVS" ]; then 291 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_LOCALNAME}\"`" == "CVS" ]; then
263 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE" 292 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_LOCALNAME"
264 rm -rf "${ECVS_TOP_DIR}/${ECVS_MODULE}" 293 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
265 fi 294 fi
266 295
267 # implement some of base_src_unpack's functionality; 296 # implement some of base_src_unpack's functionality;
268 # note however that base.eclass may not have been inherited! 297 # note however that base.eclass may not have been inherited!
269 if [ -n "$PATCHES" ]; then 298 if [ -n "$PATCHES" ]; then
275 done 304 done
276 # make sure we don't try to apply patches more than once, since 305 # 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 306 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
278 export PATCHES="" 307 export PATCHES=""
279 fi 308 fi
309
310 if [ -n "$ECVS_LOCALNAME_SETDEFAULT" ]; then
311 unset ECVS_LOCALNAME
312 unset ECVS_LOCALNAME_SETDEFAULT
313 fi
280 314
281} 315}
282 316
283EXPORT_FUNCTIONS src_unpack 317EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.44

  ViewVC Help
Powered by ViewVC 1.1.20