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

Contents of /eclass/cvs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Thu Aug 1 19:16:31 2002 UTC (12 years, 1 month ago) by danarmak
Branch: MAIN
Changes since 1.5: +88 -48 lines
a big rewrite. fixes some bugs (hopefully the sandbox issues too); adds support for module subdirs to be fetched - used in fetching kde-common/admin and will soon provide the base for the kdenonbeta- and kdeextragear-derivative ebuilds.

1 # Copyright 1999-2000 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License, v2 or later
3 # Author Dan Armak <danarmak@gentoo.org>
4 # $Header: /home/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.5 2002/07/19 09:54:05 danarmak Exp $
5 # This eclass provides the generic cvs fetching functions.
6
7 ECLASS=cvs
8 INHERITED="$INHERITED $ECLASS"
9
10 # You shouldn't change these settings yourself! The ebuild/eclass inheriting this eclass
11 # will take care of that. If you want to set the global KDE cvs ebuilds' settings,
12 # see the comments in kde-source.eclass.
13
14 # --- begin ebuild-configurable settings
15
16 # cvs command to run. you can set fex. "cvs -t" for extensive debug information
17 # on the cvs onnection. the default of "cvs -q -f -z4" means to be quiet, to disregard
18 # the ~/.cvsrc config file and to use maximum compression.
19 [ -z "$ECVS_CVS_COMMAND" ] && ECVS_CVS_COMMAND="cvs -f -z4"
20
21 # Where the cvs modules are stored/accessed
22 [ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="/usr/src"
23
24 # Name of cvs server, set to "" to disable fetching
25 # (i.e. to assume module is checked out already and don't update it).
26 # Format is server:/dir e.g. "anoncvs.kde.org:/home/kde". remove the other
27 # parts of the full CVSROOT (which looks like
28 # ":pserver:anonymous@anoncvs.kde.org:/home/kde"); these are added from
29 # other settings
30 [ -z "$ECVS_SERVER" ] && ECVS_SERVER=""
31
32 # Username to use
33 [ -z "$ECVS_USER" ] && ECVS_USER="anonymous"
34
35 # Password to use (NOT (YET) SUPPORTED, because cvs doesn't store passwords in plaintext in .cvspass)
36 [ -z "$ECVS_PASS" ] && ECVS_PASS=""
37
38 # Module to be fetched, must be set explicitly -
39 # I don't like the former ="$NP" default setting
40 [ -z "$ECVS_MODULE" ] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue"
41
42 # Subdirectory in module to be fetched, default is not defined = whole module
43 # DO NOT set default to "", if it's defined at all code will break!
44 # don't uncomment following line!
45 #[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR=""
46
47 # --- end ebuild-configurable settings ---
48
49 # add cvs to deps
50 DEPEND="$DEPEND dev-util/cvs"
51
52 # since we now longer have src_fetch as a redefinable ebuild function,
53 # we are forced to call this function from cvs_src_unpack
54 cvs_fetch() {
55
56 debug-print-function $FUNCNAME $*
57
58 debug-print "$FUNCNAME: init:
59 ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
60 ECVS_TOP_DIR=$ECVS_TOP_DIR
61 ECVS_SERVER=$ECVS_SERVER
62 ECVS_USER=$ECVS_USER
63 ECVS_PASS=$ECVS_PASS
64 ECS_MODULE=$ECVS_MODULE
65 ECVS_MODULE_SUBDIR=$ECVS_SUBDIR
66 DIR=$DIR"
67
68 # a shorthand
69 [ -n "$ECVS_SUBDIR" ] && DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" || \
70 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}"
71
72 addread $DIR
73
74 if [ -z "$ECVS_SERVER" ]; then
75 # we're not required to fetch anything, the module already exists and shouldn't be updated
76 if [ -d "$DIR" ]; then
77 debug-print "$FUNCNAME: offline mode, exiting"
78 return 0
79 else
80 einfo "ERROR: Offline mode specified, but module/subdir not found. Aborting."
81 debug-print "$FUNCNAME: offline mode specified but module/subdir not found, exiting with error"
82 return 1
83 fi
84 fi
85
86 # disable the sandbox for this dir
87
88 # not just $DIR because we want to create moduletopdir/CVS too
89 addwrite $ECVS_TOP_DIR/$ECVS_MODULE
90
91 if [ ! -d "$DIR" ]; then
92 debug-print "$FUNCNAME: creating cvs directory $DIR"
93 einfo "Creating directory $DIR"
94 mkdir -p /$DIR
95 fi
96
97 # prepare a cvspass file just for this session so that cvs thinks we're logged
98 # in at the cvs server. we don't want to mess with ~/.cvspass.
99 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
100 export CVS_PASSFILE="${T}/cvspass"
101 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
102
103 # Note: cvs update and checkout commands are unified.
104 # we make sure a CVS/ dir exists in our module subdir with the right
105 # Root and Repository entries in it and cvs update.
106
107 newserver=":pserver:anonymous@${ECVS_SERVER}"
108
109 # CVS/Repository files can't (I think) contain two concatenated slashes
110 if [ -n "$ECVS_SUBDIR" ]; then
111 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
112 else
113 repository="${ECVS_MODULE}"
114 fi
115
116 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
117
118 cd $DIR
119 if [ ! -d "$DIR/CVS" ]; then
120 # create a new CVS/ directory (checkout)
121 debug-print "$FUNCNAME: creating new cvs directory"
122
123 mkdir CVS
124 echo $newserver > CVS/Root
125 echo $repository > CVS/Repository
126 touch CVS/Entries
127
128 # if we're checking out a subdirectory only, create a CVS/ dir
129 # in the module's top dir so that the user (and we) can cvs update
130 # from there to get the full module.
131 if [ ! -d "$ECVS_TOP_DIR/$ECVS_MODULE/CVS" ]; then
132 debug-print "$FUNCNAME: Copying CVS/ directory to module top-level dir"
133 cp -r CVS $ECVS_TOP_DIR/$ECVS_MODULE/
134 echo $ECVS_MODULE > $ECVS_TOP_DIR/$ECVS_MODULE/CVS/Repository
135 fi
136
137 else
138 #update existing module
139 debug-print "$FUNCNAME: updating existing module/subdir"
140
141 # Switch servers if needed
142 # cvs keeps the server info in the CVS/Root file in every checked-out dir;
143 # we can fix those files to point to the new server
144 oldserver="`cat CVS/Root`"
145 if [ "$newserver" != "$oldserver" ]; then
146
147 einfo "Changing CVS server from $oldserver to $newserver:"
148 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $newserver:"
149
150 einfo "Searching for CVS dirs..."
151 cvsdirs="`find . -iname CVS -print`"
152 debug-print "$FUNCNAME: CVS dirs found:"
153 debug-print "$cvsdirs"
154
155 einfo "Modifying CVS dirs..."
156 for x in $cvsdirs; do
157 debug-print "In $x"
158 echo $newserver > $x/Root
159 done
160
161 fi
162
163 fi
164
165 # finally run the cvs update command
166 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
167 einfo "Running $ECVS_CVS_COMMAND update with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
168 $ECVS_CVS_COMMAND update -dP || die "died running cvs update"
169
170 }
171
172 cvs_src_unpack() {
173
174 debug-print-function $FUNCNAME $*
175 cvs_fetch || die "died running cvs_fetch"
176
177 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..."
178 debug-print "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..."
179 # the reason this lives here and not in kde-source_src_unpack
180 # is that in the future after copying the sources we might need to
181 # delete them, so this has to be self-contained
182 [ -n "$ECVS_SUBDIR" ] && cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR \
183 || cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
184
185 # implement some of base_src_unpack's functionality;
186 # note however that base.eclass may not have been inherited!
187 if [ -n "$PATCHES" ]; then
188 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
189 cd $S
190 for x in $PATCHES; do
191 debug-print "patching from $x"
192 patch -p0 < $x
193 done
194 fi
195
196 }
197
198 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20