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

Diff of /eclass/cvs.eclass

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

Revision 1.5 Revision 1.6
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.5 2002/07/19 09:54:05 danarmak Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/cvs.eclass,v 1.6 2002/08/01 19:16:31 danarmak 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
14# --- begin ebuild-configurable settings 14# --- begin ebuild-configurable settings
15 15
16# cvs command to run. you can set fex. "cvs -t" for extensive debug information 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 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. 18# the ~/.cvsrc config file and to use maximum compression.
19[ -z "$ECVS_CVS_COMMAND" ] && ECVS_CVS_COMMAND="cvs -q -f -z4" 19[ -z "$ECVS_CVS_COMMAND" ] && ECVS_CVS_COMMAND="cvs -f -z4"
20 20
21# Where the cvs modules are stored/accessed 21# Where the cvs modules are stored/accessed
22[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="/usr/src" 22[ -z "$ECVS_TOP_DIR" ] && ECVS_TOP_DIR="/usr/src"
23 23
24# Name of cvs server, set to "" to disable fetching 24# Name of cvs server, set to "" to disable fetching
37 37
38# Module to be fetched, must be set explicitly - 38# Module to be fetched, must be set explicitly -
39# I don't like the former ="$NP" default setting 39# I don't like the former ="$NP" default setting
40[ -z "$ECVS_MODULE" ] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue" 40[ -z "$ECVS_MODULE" ] && die "$ECLASS: error: ECVS_MODULE not set, cannot continue"
41 41
42# Subdirectory in module to be fetched, default is root "/" = whole module (NOT YET IMPLEMENTED) 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!
43[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR="/" 45#[ -z "$ECVS_MODULE_SUBDIR" ] && ECVS_MODULE_SUBDIR=""
44 46
45# --- end ebuild-configurable settings --- 47# --- end ebuild-configurable settings ---
46 48
47debug-print "$ECLASS: init: ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND 49# add cvs to deps
50DEPEND="$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
54cvs_fetch() {
55
56 debug-print-function $FUNCNAME $*
57
58 debug-print "$FUNCNAME: init:
59ECVS_CVS_COMMAND=$ECVS_CVS_COMMAND
48ECVS_TOP_DIR=$ECVS_TOP_DIR 60ECVS_TOP_DIR=$ECVS_TOP_DIR
49ECVS_SERVER=$ECVS_SERVER 61ECVS_SERVER=$ECVS_SERVER
50ECVS_USER=$ECVS_USER 62ECVS_USER=$ECVS_USER
51ECVS_PASS=$ECVS_PASS 63ECVS_PASS=$ECVS_PASS
52ECS_MODULE=$ECVS_MODULE 64ECS_MODULE=$ECVS_MODULE
53ECVS_MODULE_SUBDIR=$ECVS_MODULE_SUBDIR" 65ECVS_MODULE_SUBDIR=$ECVS_SUBDIR
54 66DIR=$DIR"
55# since we now longer have src_fetch as a redefinable ebuild function, 67
56# we are forced to call this function from cvs_src_unpack 68 # a shorthand
57cvs_fetch() { 69 [ -n "$ECVS_SUBDIR" ] && DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}/${ECVS_SUBDIR}" || \
58 70 DIR="${ECVS_TOP_DIR}/${ECVS_MODULE}"
59 debug-print-function $FUNCNAME $* 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
60 85
61 # disable the sandbox for this dir 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
62 if [ ! -d "$ECVS_TOP_DIR" ]; then 91 if [ ! -d "$DIR" ]; then
63 addwrite $ECVS_TOP_DIR/.. 92 debug-print "$FUNCNAME: creating cvs directory $DIR"
64 mkdir -p $ECVS_TOP_DIR 93 einfo "Creating directory $DIR"
65 adddeny $ECVS_TOP_DIR/.. 94 mkdir -p /$DIR
66 fi 95 fi
67 addread ${ECVS_TOP_DIR}
68 addwrite ${ECVS_TOP_DIR}
69 96
70 # prepare a cvspass file just for this session so that cvs thinks we're logged 97 # prepare a cvspass file just for this session so that cvs thinks we're logged
71 # in at the cvs server. we don't want to mess with ~/.cvspass. 98 # in at the cvs server. we don't want to mess with ~/.cvspass.
72 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass 99 echo ":pserver:${ECVS_SERVER} A" > ${T}/cvspass
73 export CVS_PASSFILE="${T}/cvspass" 100 export CVS_PASSFILE="${T}/cvspass"
74 101 #export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
75 cd $ECVS_TOP_DIR 102
76 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
77 if [ -z "$ECVS_SERVER" ]; then 110 if [ -n "$ECVS_SUBDIR" ]; then
78 # we're not required to fetch anything, the module already exists and shouldn't be updated 111 repository="${ECVS_MODULE}/${ECVS_SUBDIR}"
79 if [ -d "$ECVS_MODULE" ]; then 112 else
80 debug-print "$FUNCNAME: offline mode, exiting" 113 repository="${ECVS_MODULE}"
81 return 0 114 fi
82 else 115
83 einfo "ERROR: Offline mode specified, but module not found. Aborting." 116 debug-print "$FUNCNAME: Root<-$newserver, Repository<-$repository"
84 debug-print "$FUNCNAME: offline mode specified but module not found, exiting with error" 117
85 return 1 118 cd $DIR
86 fi 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
87 fi 135 fi
88 136
89 if [ -d "${ECVS_MODULE}" ]; then 137 else
90 #update existing module 138 #update existing module
91 139 debug-print "$FUNCNAME: updating existing module/subdir"
92 cd ${ECVS_MODULE} 140
93
94 # Switch servers if needed 141 # Switch servers if needed
95 # cvs keeps the server info in th CVS/Root file in every checked-out dir; 142 # cvs keeps the server info in the CVS/Root file in every checked-out dir;
96 # we can fix those files to point to the new server 143 # we can fix those files to point to the new server
97 newserver=":pserver:anonymous@${ECVS_SERVER}"
98 oldserver="`cat CVS/Root`" 144 oldserver="`cat CVS/Root`"
99 if [ "$newserver" != "$oldserver" ]; then 145 if [ "$newserver" != "$oldserver" ]; then
100 146
101 einfo "Changing CVS server from $oldserver to $newserver:" 147 einfo "Changing CVS server from $oldserver to $newserver:"
102 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $newserver:" 148 debug-print "$FUNCNAME: Changing CVS server from $oldserver to $newserver:"
112 echo $newserver > $x/Root 158 echo $newserver > $x/Root
113 done 159 done
114 160
115 fi 161 fi
116 162
163 fi
164
165 # finally run the cvs update command
117 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update with $ECVS_SERVER for module $ECVS_MODULE" 166 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND update with $ECVS_SERVER for module $ECVS_MODULE subdir $ECVS_SUBDIR"
118 einfo "Running $ECVS_CVS_COMMAND update with $ECVS_SERVER for module $ECVS_MODULE..." 167 einfo "Running $ECVS_CVS_COMMAND update with $ECVS_SERVER for $ECVS_MODULE/$ECVS_SUBDIR..."
119 $ECVS_CVS_COMMAND update -dP || die "died running cvs update" 168 $ECVS_CVS_COMMAND update -dP || die "died running cvs update"
120
121 else
122 # checkout module
123
124 export CVSROOT=:pserver:${ECVS_USER}@${ECVS_SERVER}
125 debug-print "$FUNCNAME: running $ECVS_CVS_COMMAND checkout -P $ECVS_MODULE with $CVSROOT..."
126 einfo "Running $ECVS_CVS_COMMAND checkout -P $ECVS_MODULE with $CVSROOT..."
127 $ECVS_CVS_COMMAND checkout -P $ECVS_MODULE || die "died running cvs checkout"
128
129 fi
130 169
131} 170}
132 171
133cvs_src_unpack() { 172cvs_src_unpack() {
134 173
138 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 177 einfo "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..."
139 debug-print "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..." 178 debug-print "Copying module $ECVS_MODULE from $ECVS_TOP_DIR..."
140 # the reason this lives here and not in kde-source_src_unpack 179 # the reason this lives here and not in kde-source_src_unpack
141 # is that in the future after copying the sources we might need to 180 # is that in the future after copying the sources we might need to
142 # delete them, so this has to be self-contained 181 # delete them, so this has to be self-contained
182 [ -n "$ECVS_SUBDIR" ] && cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE/$ECVS_SUBDIR $WORKDIR \
143 cp -Rf ${ECVS_TOP_DIR}/${ECVS_MODULE} $WORKDIR 183 || cp -Rf $ECVS_TOP_DIR/$ECVS_MODULE $WORKDIR
144 184
145 # implement some of base_src_unpack's functionality; 185 # implement some of base_src_unpack's functionality;
146 # note however that base.eclass may not have been inherited! 186 # note however that base.eclass may not have been inherited!
147 if [ -n "$PATCHES" ]; then 187 if [ -n "$PATCHES" ]; then
148 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching" 188 debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20