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

Diff of /eclass/cvs.eclass

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

Revision 1.14 Revision 1.22
1# Copyright 1999-2000 Gentoo Technologies, Inc. 1# Copyright 1999-2000 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License v2
3# Author Dan Armak <danarmak@gentoo.org> 3# Author Dan Armak <danarmak@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.14 2002/09/08 16:17:15 danarmak Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.22 2002/10/25 19:55:52 vapier Exp $
5# This eclass provides the generic cvs fetching functions. 5# This eclass provides the generic cvs fetching functions.
6 6
7ECLASS=cvs 7ECLASS=cvs
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
9 9
51[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD" 51[ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD"
52 52
53# Subdirectory in module to be fetched, default is not defined = whole module 53# Subdirectory in module to be fetched, default is not defined = whole module
54# DO NOT set default to "", if it's defined at all code will break! 54# DO NOT set default to "", if it's defined at all code will break!
55# don't uncomment following line! 55# don't uncomment following line!
56#[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR="" 56#[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR=""
57 57
58# --- end ebuild-configurable settings --- 58# --- end ebuild-configurable settings ---
59 59
60# add cvs to deps 60# add cvs to deps
61DEPEND="$DEPEND dev-util/cvs" 61DEPEND="$DEPEND dev-util/cvs"
72ECVS_TOP_DIR=$ECVS_TOP_DIR 72ECVS_TOP_DIR=$ECVS_TOP_DIR
73ECVS_SERVER=$ECVS_SERVER 73ECVS_SERVER=$ECVS_SERVER
74ECVS_USER=$ECVS_USER 74ECVS_USER=$ECVS_USER
75ECVS_PASS=$ECVS_PASS 75ECVS_PASS=$ECVS_PASS
76ECS_MODULE=$ECVS_MODULE 76ECS_MODULE=$ECVS_MODULE
77ECVS_MODULE_SUBDIR=$ECVS_SUBDIR 77ECVS_SUBDIR=$ECVS_SUBDIR
78ECVS_LOCAL=$ECVS_LOCAL 78ECVS_LOCAL=$ECVS_LOCAL
79DIR=$DIR" 79DIR=$DIR"
80 80
81 # if ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
82 # otherwise addwrite() doesn't work
83 if [ -n "$ECVS_TOP_DIR" ]; then
84 cd -P $ECVS_TOP_DIR
85 ECVS_TOP_DIR="`pwd`"
86 cd $OLDPWD
87 fi
88
89 # a shorthand 81 # a shorthand
90 [ -n "$ECVS_SUBDIR" ] && DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" || \
91 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}" 82 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
83 debug-print "$FUNCNAME: now DIR=$DIR"
92 84
93 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
94
95 addread $DIR
96
97 if [ "$ECVS_SERVER" == "offline" ]; then 85 if [ "$ECVS_SERVER" == "offline" ]; then
98 # we're not required to fetch anything, the module already exists and shouldn't be updated 86 # we're not required to fetch anything, the module already exists and shouldn't be updated
99 if [ -d "$DIR" ]; then 87 if [ -d "$DIR" ]; then
100 debug-print "$FUNCNAME: offline mode, exiting" 88 debug-print "$FUNCNAME: offline mode, exiting"
101 return 0 89 return 0
102 else 90 else
103 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting." 91 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting."
104 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error" 92 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error"
105 return 1 93 return 1
106 fi
107 fi 94 fi
95 fi
108 96
97 # create target directory as needed
98 if [ ! -d "$DIR" ]; then
99 debug-print "$FUNCNAME: creating cvs directory $DIR"
100 #export SANDBOX_WRITE="$SANDBOX_WRITE:/foobar:/"
101 addwrite /foobar
102 addwrite /
103 mkdir -p /$DIR
104 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foobar:\/}
105 fi
106
107 # in case ECVS_TOP_DIR is a symlink to a dir, get the real dir's path,
108 # otherwise addwrite() doesn't work.
109 cd -P $ECVS_TOP_DIR > /dev/null
110 ECVS_TOP_DIR="`/bin/pwd`"
111 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}"
112 cd $OLDPWD
113
114 debug-print "$FUNCNAME: now DIR=$DIR"
115
109 # disable the sandbox for this dir 116 # disable the sandbox for this dir
110 # not just $DIR because we want to create moduletopdir/CVS too 117 # not just $DIR because we want to create moduletopdir/CVS too
111 addwrite $ECVS_TOP_DIR/$ECVS_MODULE 118 addwrite $ECVS_TOP_DIR/$ECVS_MODULE
112
113 if [ ! -d "$DIR" ]; then
114 debug-print "$FUNCNAME: creating cvs directory $DIR"
115 einfo "Creating directory $DIR"
116 export SANDBOX_WRITE="$SANDBOX_WRITE:/foo:/"
117 mkdir -p /$DIR
118 export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foo:\/}
119 fi
120 119
120 # add option for local (non-recursive) fetching
121 [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l"
122
121 # prepare a cvspass file just for this session so that cvs thinks we're logged 123 # prepare a cvspass file just for this session so that cvs thinks we're logged
122 # in at the cvs server. we don't want to mess with ~/.cvspass. 124 # in at the cvs server. we don't want to mess with ~/.cvspass.
123 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 125 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
124 export CVS_PASSFILE="${T}/cvspass" 126 export CVS_PASSFILE="${T}/cvspass"
125 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} 127 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
126 128
127 # Note: cvs update and checkout commands are unified. 129 # Note: cvs update and checkout commands are unified.
128 # we make sure a CVS/ dir exists in our module subdir with the right 130 # we make sure a CVS/ dir exists in our module subdir with the right
129 # Root and Repository entries in it and cvs update. 131 # Root and Repository entries in it and cvs update.
130 132
131 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" 133 newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}"
136 else 138 else
137 repository="${ECVS_MODULE}" 139 repository="${ECVS_MODULE}"
138 fi 140 fi
139 141
140 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" 142 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
141 143 debug-print "$FUNCNAME: entering directory $DIR"
142 cd $DIR 144 cd /$DIR
145
143 if [ ! -d "$DIR/CVS" ]; then 146 if [ ! -d "CVS" ]; then
144 # create a new CVS/ directory (checkout) 147 # create a new CVS/ directory (checkout)
145 debug-print "$FUNCNAME: creating new cvs directory" 148 debug-print "$FUNCNAME: creating new cvs directory"
146 149
147 mkdir CVS 150 mkdir CVS
148 echo $newserver > CVS/Root 151 echo $newserver > CVS/Root
189 # cvs auto-switches branches, how nice 192 # cvs auto-switches branches, how nice
190 # warning: if we do it this way we get multiple -rX options - harmless i think 193 # warning: if we do it this way we get multiple -rX options - harmless i think
191 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" 194 [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH"
192 195
193 # finally run the cvs update command 196 # finally run the cvs update command
197 debug-print "$FUNCNAME: is in dir `/bin/pwd`"
194 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR" 198 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
195 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..." 199 einfo "Running $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
196 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update" 200 $ECVS_CVS_COMMAND update $ECVS_CVS_OPTIONS || die "died running cvs update"
197 201
198} 202}
199 203
200cvs_src_unpack() { 204cvs_src_unpack() {
201 205
202 debug-print-function $FUNCNAME $* 206 debug-print-function $FUNCNAME $*
203 cvs_fetch || die "died running cvs_fetch" 207 cvs_fetch || die "died running cvs_fetch"
204 208
205 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 209 einfo "Copying $ECVS_MODULE/$ECVS_SUBDIR from $ECVS_TOP_DIR..."
206 debug-print "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 210 debug-print "Copying module $ECVS_MODULE subdir $ECVS_SUBDIR local_mode=$ECVS_LOCAL from $ECVS_TOP_DIR..."
211
212 # probably redundant, but best to make sure
213 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR
207 214
208 if [ -n "$ECVS_SUBDIR" ]; then 215 if [ -n "$ECVS_SUBDIR" ]; then
209 mkdir -p $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR 216 if [ -n "$ECVS_LOCAL" ]; then
210 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/ 217 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR/* $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR
218 else
219 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR/$ECVS_MODULE/$ECVS_SUBDIR/..
220 fi
211 else 221 else
212 if [ -n "$ECVS_LOCAL" ]; then 222 if [ -n "$ECVS_LOCAL" ]; then
213 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE 223 cp -f $ECVS_TOP_DIR/$ECVS_MODULE/* $WORKDIR/$ECVS_MODULE
214 else 224 else
215 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR 225 cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
222 if [ "`ls -A $DIR`" == "CVS" ]; then 232 if [ "`ls -A $DIR`" == "CVS" ]; then
223 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR" 233 debug-print "$FUNCNAME: removing cvs-empty directory $ECVS_MODULE/$ECVS_SUBDIR"
224 rm -rf $DIR 234 rm -rf $DIR
225 fi 235 fi
226 236
227 # implement some of base_src_unpack's functionality; 237 # implement some of base_src_unpack's functionality;
228 # note however that base.eclass may not have been inherited! 238 # note however that base.eclass may not have been inherited!
229 if [ -n "$PATCHES" ]; then 239 if [ -n "$PATCHES" ]; then
230 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 240 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
231 cd $S 241 cd $S
232 for x in $PATCHES; do 242 for x in $PATCHES; do
233 debug-print "patching from $x" 243 debug-print "patching from $x"
234 patch -p0 < $x 244 patch -p0 < $x
235 done 245 done
236 # make sure we don't try to apply patches more than once, since 246 # make sure we don't try to apply patches more than once, since
237 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack 247 # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack
238 export PATCHES="" 248 export PATCHES=""
239 fi 249 fi
240 250
241} 251}
242 252
243EXPORT_FUNCTIONS src_unpack 253EXPORT_FUNCTIONS src_unpack
244
245

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.20