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

Diff of /eclass/cvs.eclass

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

Revision 1.42 Revision 1.43
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.42 2003/06/13 09:22:47 torbenh Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.43 2003/06/30 18:17:11 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[ -z "$ECVS_LOCALNAME" ] && ECVS_LOCALNAME="$ECVS_MODULE"
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
95 # 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.
96 # doing it this way we get multiple -rX options - harmless afaik 103 # doing it this way we get multiple -rX options - harmless afaik
97 if [ -n "$ECVS_BRANCH" ]; then 104 if [ -n "$ECVS_BRANCH" ]; then
98 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH" 105 ECVS_UP_OPTS="$ECVS_UP_OPTS -r$ECVS_BRANCH"
99 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"
100 fi 113 fi
101 114
102 # 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
103 # 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`
104 if [ -z "$ECVS_RUNAS" ]; then 117 if [ -z "$ECVS_RUNAS" ]; then
125 # otherwise addwrite() doesn't work. 138 # otherwise addwrite() doesn't work.
126 cd -P "$ECVS_TOP_DIR" > /dev/null 139 cd -P "$ECVS_TOP_DIR" > /dev/null
127 ECVS_TOP_DIR="`/bin/pwd`" 140 ECVS_TOP_DIR="`/bin/pwd`"
128 141
129 # determine checkout or update mode 142 # determine checkout or update mode
130 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then 143 if [ ! -d "$ECVS_TOP_DIR/$ECVS_LOCALNAME/CVS" ]; then
131 mode=checkout 144 mode=checkout
132 else 145 else
133 mode=update 146 mode=update
134 fi 147 fi
135 148
144 # 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
145 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 158 server=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
146 159
147 # switch servers automagically if needed 160 # switch servers automagically if needed
148 if [ "$mode" == "update" ]; then 161 if [ "$mode" == "update" ]; then
149 cd /$ECVS_TOP_DIR/$ECVS_MODULE 162 cd /$ECVS_TOP_DIR/$ECVS_LOCALNAME
150 oldserver="`$run cat CVS/Root`" 163 oldserver="`$run cat CVS/Root`"
151 if [ "$server" != "$oldserver" ]; then 164 if [ "$server" != "$oldserver" ]; then
152 165
153 einfo "Changing CVS server from $oldserver to $server:" 166 einfo "Changing CVS server from $oldserver to $server:"
154 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:" 167 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $server:"
180 # the CVS/Root files don't contain the password in plaintext 193 # the CVS/Root files don't contain the password in plaintext
181 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}" 194 cvsroot_nopass=":${ECVS_AUTH}:${ECVS_USER}@${ECVS_SERVER}"
182 195
183 # commands to run 196 # commands to run
184 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login" 197 cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
185 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}"
186 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}"
187 200
188 cd "${ECVS_TOP_DIR}" 201 cd "${ECVS_TOP_DIR}"
189 if [ "${ECVS_AUTH}" == "pserver" ]; then 202 if [ "${ECVS_AUTH}" == "pserver" ]; then
190 einfo "Running $cmdlogin" 203 einfo "Running $cmdlogin"
227ECVS_SERVER=$ECVS_SERVER 240ECVS_SERVER=$ECVS_SERVER
228ECVS_USER=$ECVS_USER 241ECVS_USER=$ECVS_USER
229ECVS_PASS=$ECVS_PASS 242ECVS_PASS=$ECVS_PASS
230ECS_MODULE=$ECVS_MODULE 243ECS_MODULE=$ECVS_MODULE
231ECVS_LOCAL=$ECVS_LOCAL 244ECVS_LOCAL=$ECVS_LOCAL
232ECVS_RUNAS=$ECVS_RUNAS" 245ECVS_RUNAS=$ECVS_RUNAS
246ECVS_LOCALNAME=$ECVS_LOCALNAME"
233 247
234 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue." 248 [ -z "$ECVS_MODULE" ] && die "ERROR: CVS module not set, cannot continue."
235 249
236 if [ "$ECVS_SERVER" == "offline" ]; then 250 if [ "$ECVS_SERVER" == "offline" ]; then
237 # we're not required to fetch anything, the module already exists and shouldn't be updated 251 # we're not required to fetch anything, the module already exists and shouldn't be updated
238 if [ -d "${ECVS_TOP_DIR}/${ECVS_MODULE}" ]; then 252 if [ -d "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}" ]; then
239 debug-print "$FUNCNAME: offline mode" 253 debug-print "$FUNCNAME: offline mode"
240 else 254 else
241 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_MODULE} not found, exiting with error" 255 debug-print "$FUNCNAME: offline mode specified but directory ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found, exiting with error"
242 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_MODULE} not found. Aborting." 256 die "ERROR: Offline mode specified, but dir ${ECVS_TOP_DIR}/${ECVS_LOCALNAME} not found. Aborting."
243 fi 257 fi
244 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode 258 elif [ -n "$ECVS_SERVER" ]; then # ECVS_SERVER!=offline --> real fetching mode
245 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..." 259 einfo "Fetching cvs module $ECVS_MODULE into $ECVS_TOP_DIR..."
246 cvs_fetch 260 cvs_fetch
247 else # ECVS_SERVER not set 261 else # ECVS_SERVER not set
248 die "ERROR: CVS server not set, cannot continue." 262 die "ERROR: CVS server not set, cannot continue."
249 fi 263 fi
250 264
251 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..." 265 einfo "Copying $ECVS_MODULE from $ECVS_TOP_DIR..."
252 debug-print "Copying module $ECVS_MODULElocal_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..." 266 debug-print "Copying module $ECVS_MODULE local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
253 267
254 # probably redundant, but best to make sure 268 # probably redundant, but best to make sure
255 mkdir -p "$WORKDIR/$ECVS_MODULE" 269 mkdir -p "$WORKDIR/$ECVS_LOCALNAME"
256 270
257 if [ -n "$ECVS_LOCAL" ]; then 271 if [ -n "$ECVS_LOCAL" ]; then
258 mkdir -p "$WORKDIR/$ECVS_MODULE"
259 cp -f "$ECVS_TOP_DIR/$ECVS_MODULE"/* "$WORKDIR/$ECVS_MODULE" 272 cp -f "$ECVS_TOP_DIR/$ECVS_LOCALNAME"/* "$WORKDIR/$ECVS_LOCALNAME"
260 else 273 else
261 cp -Rf "$ECVS_TOP_DIR/$ECVS_MODULE" "$WORKDIR/$ECVS_MODULE/.." 274 cp -Rf "$ECVS_TOP_DIR/$ECVS_LOCALNAME" "$WORKDIR/$ECVS_LOCALNAME/.."
262 fi 275 fi
263 276
264 # if the directory is empty, remove it; empty directories cannot exist in cvs. 277 # if the directory is empty, remove it; empty directories cannot exist in cvs.
265 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist. 278 # this happens when fex. kde-source requests module/doc/subdir which doesn't exist.
266 # still create the empty directory in workdir though. 279 # still create the empty directory in workdir though.
267 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_MODULE}\"`" == "CVS" ]; then 280 if [ "`ls -A \"${ECVS_TOP_DIR}/${ECVS_LOCALNAME}\"`" == "CVS" ]; then
268 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE" 281 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_LOCALNAME"
269 rm -rf "${ECVS_TOP_DIR}/${ECVS_MODULE}" 282 rm -rf "${ECVS_TOP_DIR}/${ECVS_LOCALNAME}"
270 fi 283 fi
271 284
272 # implement some of base_src_unpack's functionality; 285 # implement some of base_src_unpack's functionality;
273 # note however that base.eclass may not have been inherited! 286 # note however that base.eclass may not have been inherited!
274 if [ -n "$PATCHES" ]; then 287 if [ -n "$PATCHES" ]; then

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20