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

Diff of /eclass/cvs.eclass

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

Revision 1.40 Revision 1.45
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.40 2003/04/27 19:35:00 danarmak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.45 2003/07/20 05:23:17 vapier 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:"
176 # the CVS/Root files don't contain the password in plaintext 193 # the CVS/Root files don't contain the password in plaintext
177 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 194 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
178 195
179 # commands to run 196 # commands to run
180 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" 197 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
181 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_MODULE}" 198 cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}"
182 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}" 199 cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE}"
183 200
184 cd "${ECVS_TOP_DIR}" 201 cd "${ECVS_TOP_DIR}"
185 if [ "${ECVS_AUTH}" == "pserver" ]; then 202 if [ "${ECVS_AUTH}" == "pserver" ]; then
186 einfo "Running $cmdlogin" 203 einfo "Running $cmdlogin"
187 eval $cmdlogin 204 eval $cmdlogin || die "cvs login command failed"
188 if [ "${mode}" == "update" ]; then 205 if [ "${mode}" == "update" ]; then
189 einfo "Running $cmdupdate" 206 einfo "Running $cmdupdate"
190 eval $cmdupdate 207 eval $cmdupdate || die "cvs update command failed"
191 elif [ "${mode}" == "checkout" ]; then 208 elif [ "${mode}" == "checkout" ]; then
192 einfo "Running $cmdcheckout" 209 einfo "Running $cmdcheckout"
193 eval $cmdcheckout 210 eval $cmdcheckout|| die "cvs checkout command failed"
194 fi 211 fi
195# elif [ "${ECVS_AUTH}" == "ext" ]; then 212# elif [ "${ECVS_AUTH}" == "ext" ]; then
196# # 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
197# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct" 214# echo "${ECVS_DELAY} continue connecting&yes" >> "$instruct"
198# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct" 215# echo "${ECVS_DELAY} CVS password:&${ECVS_PASS}" >> "$instruct"
221ECVS_CO_OPTS=$ECVS_CO_OPTS 238ECVS_CO_OPTS=$ECVS_CO_OPTS
222ECVS_TOP_DIR=$ECVS_TOP_DIR 239ECVS_TOP_DIR=$ECVS_TOP_DIR
223ECVS_SERVER=$ECVS_SERVER 240ECVS_SERVER=$ECVS_SERVER
224ECVS_USER=$ECVS_USER 241ECVS_USER=$ECVS_USER
225ECVS_PASS=$ECVS_PASS 242ECVS_PASS=$ECVS_PASS
226ECS_MODULE=$ECVS_MODULE 243ECVS_MODULE=$ECVS_MODULE
227ECVS_LOCAL=$ECVS_LOCAL 244ECVS_LOCAL=$ECVS_LOCAL
228ECVS_RUNAS=$ECVS_RUNAS" 245ECVS_RUNAS=$ECVS_RUNAS
246ECVS_LOCALNAME=$ECVS_LOCALNAME"
229 247
230 [ -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
231 260
232 if [ "$ECVS_SERVER" == "offline" ]; then 261 if [ "$ECVS_SERVER" == "offline" ]; then
233 # 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
234 if [ -d "${ECVS_TOP_DIR}/${ECVS_MODULE}" ]; then 263 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
235 debug-print "$FUNCNAME: offline mode" 264 debug-print "$FUNCNAME: offline mode"
236 else 265 else
237 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_MODULE} not found, exiting with error" 266 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
238 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_MODULE} not found. Aborting." 267 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
239 fi 268 fi
240 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 269 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
241 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..." 270 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..."
242 cvs_fetch 271 cvs_fetch
243 else # ECVS_SERVER not set 272 else # ECVS_SERVER not set
244 die "ERROR: CVS server not set, cannot continue." 273 die "ERROR: CVS server not set, cannot continue."
245 fi 274 fi
246 275
247 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." 276 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..."
248 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..."
249 278
250 # probably redundant, but best to make sure 279 # probably redundant, but best to make sure
251 mkdir -p "$WORKDIR/$ECVS_MODULE" 280 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
252 281
253 if [ -n "$ECVS_LOCAL" ]; then 282 if [ -n "$ECVS_LOCAL" ]; then
254 mkdir -p "$WORKDIR/$ECVS_MODULE"
255 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* "$WORKDIR/$ECVS_MODULE" 283 cp -f "$ECVS_TOP_DIR/$ECVS_LOCALNAME"/* "$WORKDIR/$ECVS_LOCALNAME"
256 else 284 else
257 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR/$ECVS_MODULE/.." 285 cp -Rf "$ECVS_TOP_DIR/$ECVS_LOCALNAME" "$WORKDIR/$ECVS_LOCALNAME/.."
258 fi 286 fi
259 287
260 # 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.
261 # 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.
262 # still create the empty directory in workdir though. 290 # still create the empty directory in workdir though.
263 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_MODULE}\"`" == "CVS" ]; then 291 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_LOCALNAME}\"`" == "CVS" ]; then
264 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE" 292 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_LOCALNAME"
265 rm -rf "${ECVS_TOP_DIR}/${ECVS_MODULE}" 293 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
266 fi 294 fi
267 295
268 # implement some of base_src_unpack's functionality; 296 # implement some of base_src_unpack's functionality;
269 # note however that base.eclass may not have been inherited! 297 # note however that base.eclass may not have been inherited!
270 if [ -n "$PATCHES" ]; then 298 if [ -n "$PATCHES" ]; then
276 done 304 done
277 # 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
278 # 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
279 export PATCHES="" 307 export PATCHES=""
280 fi 308 fi
309
310 if [ -n "$ECVS_LOCALNAME_SETDEFAULT" ]; then
311 unset ECVS_LOCALNAME
312 unset ECVS_LOCALNAME_SETDEFAULT
313 fi
281 314
315 einfo "Source now in ${WORKDIR}"
282} 316}
283 317
284EXPORT_FUNCTIONS src_unpack 318EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20