| 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 or later |
| 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.10 2002/08/03 15:31:09 danarmak Exp $ |
4 | # $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.18 2002/09/15 14:15:54 danarmak Exp $ |
| 5 | # This eclass provides the generic cvs fetching functions. |
5 | # This eclass provides the generic cvs fetching functions. |
| 6 | |
6 | |
| 7 | ECLASS=cvs |
7 | ECLASS=cvs |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
| 9 | |
9 | |
| … | |
… | |
| 24 | |
24 | |
| 25 | # set this for the module/subdir to be fetched non-recursively |
25 | # set this for the module/subdir to be fetched non-recursively |
| 26 | #[ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" |
26 | #[ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" |
| 27 | |
27 | |
| 28 | # Where the cvs modules are stored/accessed |
28 | # Where the cvs modules are stored/accessed |
| 29 | [ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="/usr/src" |
29 | [ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="${DISTDIR}/cvs-src" |
| 30 | |
30 | |
| 31 | # Name of cvs server, set to "offline" to disable fetching |
31 | # Name of cvs server, set to "offline" to disable fetching |
| 32 | # (i.e. to assume module is checked out already and don't update it). |
32 | # (i.e. to assume module is checked out already and don't update it). |
| 33 | # Format is server:/dir e.g. "anoncvs.kde.org:/home/kde". remove the other |
33 | # Format is server:/dir e.g. "anoncvs.kde.org:/home/kde". remove the other |
| 34 | # parts of the full CVSROOT (which looks like |
34 | # parts of the full CVSROOT (which looks like |
| … | |
… | |
| 41 | |
41 | |
| 42 | # Password to use (NOT (YET) SUPPORTED, because cvs doesn't store passwords in plaintext in .cvspass) |
42 | # Password to use (NOT (YET) SUPPORTED, because cvs doesn't store passwords in plaintext in .cvspass) |
| 43 | [ -z "$ECVS_PASS" ] && ECVS_PASS="" |
43 | [ -z "$ECVS_PASS" ] && ECVS_PASS="" |
| 44 | |
44 | |
| 45 | # Module to be fetched, must be set explicitly - |
45 | # Module to be fetched, must be set explicitly - |
| 46 | # I don't like the former ="$NP" default setting |
46 | # I don't like the former ="$PN" default setting |
| 47 | [ -z "$ECVS_MODULE" ] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue" |
47 | [ -z "$ECVS_MODULE" ] && debug-print "$ECLASS: error: ECVS_MODULE not set, cannot continue" |
|
|
48 | |
|
|
49 | # Branch/tag to use, default is HEAD |
|
|
50 | # uncomment the following line to enable the reset-branch-to-HEAD behaviour |
|
|
51 | [ -z "$ECVS_BRANCH" ] && ECVS_BRANCH="HEAD" |
| 48 | |
52 | |
| 49 | # 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 |
| 50 | # 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! |
| 51 | # don't uncomment following line! |
55 | # don't uncomment following line! |
| 52 | #[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR="" |
56 | #[ -z "$ECVS_SUBDIR" ] && ECVS_SUBDIR="" |
| 53 | |
57 | |
| 54 | # --- end ebuild-configurable settings --- |
58 | # --- end ebuild-configurable settings --- |
| 55 | |
59 | |
| 56 | # add cvs to deps |
60 | # add cvs to deps |
| 57 | DEPEND="$DEPEND dev-util/cvs" |
61 | DEPEND="$DEPEND dev-util/cvs" |
| … | |
… | |
| 68 | ECVS_TOP_DIR=$ECVS_TOP_DIR |
72 | ECVS_TOP_DIR=$ECVS_TOP_DIR |
| 69 | ECVS_SERVER=$ECVS_SERVER |
73 | ECVS_SERVER=$ECVS_SERVER |
| 70 | ECVS_USER=$ECVS_USER |
74 | ECVS_USER=$ECVS_USER |
| 71 | ECVS_PASS=$ECVS_PASS |
75 | ECVS_PASS=$ECVS_PASS |
| 72 | ECS_MODULE=$ECVS_MODULE |
76 | ECS_MODULE=$ECVS_MODULE |
| 73 | ECVS_MODULE_SUBDIR=$ECVS_SUBDIR |
77 | ECVS_SUBDIR=$ECVS_SUBDIR |
| 74 | ECVS_LOCAL=$ECVS_LOCAL |
78 | ECVS_LOCAL=$ECVS_LOCAL |
| 75 | DIR=$DIR" |
79 | DIR=$DIR" |
| 76 | |
80 | |
| 77 | # a shorthand |
81 | # a shorthand |
| 78 | [ -n "$ECVS_SUBDIR" ] && DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" || \ |
|
|
| 79 | DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}" |
82 | DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" |
|
|
83 | debug-print "$FUNCNAME: now DIR=$DIR" |
| 80 | |
84 | |
| 81 | [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" |
|
|
| 82 | |
|
|
| 83 | addread $DIR |
|
|
| 84 | |
|
|
| 85 | if [ "$ECVS_SERVER" == "offline" ]; then |
85 | if [ "$ECVS_SERVER" == "offline" ]; then |
| 86 | # 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 |
| 87 | if [ -d "$DIR" ]; then |
87 | if [ -d "$DIR" ]; then |
| 88 | debug-print "$FUNCNAME: offline mode, exiting" |
88 | debug-print "$FUNCNAME: offline mode, exiting" |
| 89 | return 0 |
89 | return 0 |
| … | |
… | |
| 92 | 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" |
| 93 | return 1 |
93 | return 1 |
| 94 | fi |
94 | fi |
| 95 | fi |
95 | fi |
| 96 | |
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 | |
| 97 | # disable the sandbox for this dir |
116 | # disable the sandbox for this dir |
| 98 | |
|
|
| 99 | # not just $DIR because we want to create moduletopdir/CVS too |
117 | # not just $DIR because we want to create moduletopdir/CVS too |
| 100 | addwrite $ECVS_TOP_DIR/$ECVS_MODULE |
118 | addwrite $ECVS_TOP_DIR/$ECVS_MODULE |
| 101 | |
|
|
| 102 | if [ ! -d "$DIR" ]; then |
|
|
| 103 | debug-print "$FUNCNAME: creating cvs directory $DIR" |
|
|
| 104 | einfo "Creating directory $DIR" |
|
|
| 105 | export SANDBOX_WRITE="$SANDBOX_WRITE:/foo:/" |
|
|
| 106 | mkdir -p /$DIR |
|
|
| 107 | export SANDBOX_WRITE=${SANDBOX_WRITE//:\/foo:\/} |
|
|
| 108 | fi |
|
|
| 109 | |
119 | |
|
|
120 | # add option for local (non-recursive) fetching |
|
|
121 | [ -n "$ECVS_LOCAL" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -l" |
|
|
122 | |
| 110 | # 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 |
| 111 | # 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. |
| 112 | echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass |
125 | echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass |
| 113 | export CVS_PASSFILE="${T}/cvspass" |
126 | export CVS_PASSFILE="${T}/cvspass" |
| 114 | #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} |
127 | #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER} |
| 115 | |
128 | |
| 116 | # Note: cvs update and checkout commands are unified. |
129 | # Note: cvs update and checkout commands are unified. |
| 117 | # 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 |
| 118 | # Root and Repository entries in it and cvs update. |
131 | # Root and Repository entries in it and cvs update. |
| 119 | |
132 | |
| 120 | newserver=":pserver:anonymous@${ECVS_SERVER}" |
133 | newserver=":pserver:${ECVS_USER}@${ECVS_SERVER}" |
| 121 | |
134 | |
| 122 | # CVS/Repository files can't (I think) contain two concatenated slashes |
135 | # CVS/Repository files can't (I think) contain two concatenated slashes |
| 123 | if [ -n "$ECVS_SUBDIR" ]; then |
136 | if [ -n "$ECVS_SUBDIR" ]; then |
| 124 | repository="${ECVS_MODULE}/${ECVS_SUBDIR}" |
137 | repository="${ECVS_MODULE}/${ECVS_SUBDIR}" |
| 125 | else |
138 | else |
| 126 | repository="${ECVS_MODULE}" |
139 | repository="${ECVS_MODULE}" |
| 127 | fi |
140 | fi |
| 128 | |
141 | |
| 129 | debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" |
142 | debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository" |
| 130 | |
143 | debug-print "$FUNCNAME: entering directory $DIR" |
| 131 | cd $DIR |
144 | cd /$DIR |
|
|
145 | |
| 132 | if [ ! -d "$DIR/CVS" ]; then |
146 | if [ ! -d "CVS" ]; then |
| 133 | # create a new CVS/ directory (checkout) |
147 | # create a new CVS/ directory (checkout) |
| 134 | debug-print "$FUNCNAME: creating new cvs directory" |
148 | debug-print "$FUNCNAME: creating new cvs directory" |
| 135 | |
149 | |
| 136 | mkdir CVS |
150 | mkdir CVS |
| 137 | echo $newserver > CVS/Root |
151 | echo $newserver > CVS/Root |
| … | |
… | |
| 173 | |
187 | |
| 174 | fi |
188 | fi |
| 175 | |
189 | |
| 176 | fi |
190 | fi |
| 177 | |
191 | |
|
|
192 | # cvs auto-switches branches, how nice |
|
|
193 | # warning: if we do it this way we get multiple -rX options - harmless i think |
|
|
194 | [ -n "$ECVS_BRANCH" ] && ECVS_CVS_OPTIONS="$ECVS_CVS_OPTIONS -r$ECVS_BRANCH" |
|
|
195 | |
| 178 | # finally run the cvs update command |
196 | # finally run the cvs update command |
|
|
197 | debug-print "$FUNCNAME: is in dir `/bin/pwd`" |
| 179 | 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" |
| 180 | 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..." |
| 181 | $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" |
| 182 | |
201 | |
| 183 | } |
202 | } |
| … | |
… | |
| 216 | cd $S |
235 | cd $S |
| 217 | for x in $PATCHES; do |
236 | for x in $PATCHES; do |
| 218 | debug-print "patching from $x" |
237 | debug-print "patching from $x" |
| 219 | patch -p0 < $x |
238 | patch -p0 < $x |
| 220 | done |
239 | done |
|
|
240 | # make sure we don't try to apply patches more than once, since |
|
|
241 | # cvs_src_unpack is usually called several times from e.g. kde-source_src_unpack |
|
|
242 | export PATCHES="" |
| 221 | fi |
243 | fi |
| 222 | |
244 | |
| 223 | } |
245 | } |
| 224 | |
246 | |
| 225 | EXPORT_FUNCTIONS src_unpack |
247 | EXPORT_FUNCTIONS src_unpack |