386BSD 0.1 development
[unix-history] / usr / othersrc / public / cvs-1.3 / cvsinit
CommitLineData
754dd213
WJ
1:
2#
3# Copyright (c) 1992, Brian Berliner
4#
5# You may distribute under the terms of the GNU General Public License as
6# specified in the README file that comes with the CVS 1.3 kit.
7#
8# @(#)cvsinit 1.1 92/03/31
9#
10# This script should be run once to help you setup your site for CVS.
11
12# Make sure that the CVSROOT variable is set
13if [ "x$CVSROOT" = x ]; then
14 echo "The CVSROOT environment variable is not set."
15 echo ""
16 echo "You should choose a location for your source repository"
17 echo "that can be shared by many developers. It also helps to"
18 echo "place the source repository on a file system that has"
19 echo "plenty of free space."
20 echo ""
21 echo "Please enter the full path for your CVSROOT source repository:"
22 read CVSROOT
23 remind_cvsroot=yes
24else
25 echo "Using $CVSROOT as the source repository."
26 remind_cvsroot=no
27fi
28echo ""
29
30# Now, create the $CVSROOT if it is not already there
31if [ ! -d $CVSROOT ]; then
32 echo "Hmmm... $CVSROOT does not exist; trying to make it..."
33 path=
34 for comp in `echo $CVSROOT | sed -e 's,/, ,g'`; do
35 path=$path/$comp
36 if [ ! -d $path ]; then
37 mkdir $path
38 fi
39 done
40else
41 echo "Good... $CVSROOT already exists."
42fi
43
44# Next, check for $CVSROOT/CVSROOT
45if [ ! -d $CVSROOT/CVSROOT ]; then
46 if [ -d $CVSROOT/CVSROOT.adm ]; then
47 echo "You have the old $CVSROOT/CVSROOT.adm directory."
48 echo "I will rename it to $CVSROOT/CVSROOT for you..."
49 mv $CVSROOT/CVSROOT.adm $CVSROOT/CVSROOT
50 else
51 echo "Making the $CVSROOT/CVSROOT directory..."
52 mkdir $CVSROOT/CVSROOT
53 fi
54else
55 echo "Wow!... so does $CVSROOT/CVSROOT."
56fi
57echo ""
58if [ ! -d $CVSROOT/CVSROOT ]; then
59 echo "You still don't have a $CVSROOT/CVSROOT directory."
60 echo "I give up."
61 exit 1
62fi
63
64# Create the special *info files within $CVSROOT/CVSROOT
65
66# Trump up a simple modules file, if one doesn't exist
67if [ -f $CVSROOT/CVSROOT/modules,v ]; then
68 if [ ! -f $CVSROOT/CVSROOT/modules ]; then
69 echo "You have a $CVSROOT/CVSROOT/modules,v file,"
70 echo "But no $CVSROOT/CVSROOT/modules file. This is OK."
71 echo "I'll checkout a fresh copy..."
72 (cd $CVSROOT/CVSROOT; co -q modules)
73 echo ""
74 fi
75else
76 if [ -f $CVSROOT/CVSROOT/modules ]; then
77 echo "You have a $CVSROOT/CVSROOT/modules file,"
78 echo "But no $CVSROOT/CVSROOT/modules,v file."
79 echo "I'll create one for you, but otherwise leave it alone..."
80 else
81 echo "The $CVSROOT/CVSROOT/modules file does not exist."
82 echo "Making a simple one for you..."
83 cat > $CVSROOT/CVSROOT/modules <<"HERE"
84#
85# The CVS modules file
86#
87# Three different line formats are valid:
88# key -a aliases...
89# key [options] directory
90# key [options] directory files...
91#
92# Where "options" are composed of:
93# -i prog Run "prog" on "cvs commit" from top-level of module.
94# -o prog Run "prog" on "cvs checkout" of module.
95# -t prog Run "prog" on "cvs rtag" of module.
96# -u prog Run "prog" on "cvs update" of module.
97# -d dir Place module in directory "dir" instead of module name.
98# -l Top-level directory only -- do not recurse.
99#
100# And "directory" is a path to a directory relative to $CVSROOT.
101#
102# The "-a" option specifies an alias. An alias is interpreted as if
103# everything on the right of the "-a" had been typed on the command line.
104#
105# You can encode a module within a module by using the special '&'
106# character to interpose another module into the current module. This
107# can be useful for creating a module that consists of many directories
108# spread out over the entire source repository.
109#
110
111# Convenient aliases
112world -a .
113
114# CVSROOT support; run mkmodules whenever anything changes.
115CVSROOT -i mkmodules CVSROOT
116modules -i mkmodules CVSROOT modules
117loginfo -i mkmodules CVSROOT loginfo
118commitinfo -i mkmodules CVSROOT commitinfo
119rcsinfo -i mkmodules CVSROOT rcsinfo
120editinfo -i mkmodules CVSROOT editinfo
121
122# Add other modules here...
123HERE
124 fi
125 (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m'initial checkin of modules' modules)
126 echo ""
127fi
128
129# check to see if there are any references to the old CVSROOT.adm directory
130if grep CVSROOT.adm $CVSROOT/CVSROOT/modules >/dev/null 2>&1; then
131 echo "Warning: your $CVSROOT/CVSROOT/modules file still"
132 echo " contains references to the old CVSROOT.adm directory"
133 echo " You should really change these to the new CVSROOT directory"
134 echo ""
135fi
136
137# loginfo, like modules, is special-cased
138if [ -f $CVSROOT/CVSROOT/loginfo,v ]; then
139 if [ ! -f $CVSROOT/CVSROOT/loginfo ]; then
140 echo "You have a $CVSROOT/CVSROOT/loginfo,v file,"
141 echo "But no $CVSROOT/CVSROOT/loginfo file. This is OK."
142 echo "I'll checkout a fresh copy..."
143 (cd $CVSROOT/CVSROOT; co -q loginfo)
144 echo ""
145 fi
146else
147 if [ -f $CVSROOT/CVSROOT/loginfo ]; then
148 echo "You have a $CVSROOT/CVSROOT/loginfo file,"
149 echo "But no $CVSROOT/CVSROOT/loginfo,v file."
150 echo "I'll create one for you, but otherwise leave it alone..."
151 else
152 echo "The $CVSROOT/CVSROOT/loginfo file does not exist."
153 echo "Making a simple one for you..."
154 # try to find perl; use fancy log script if we can
155 for perlpath in `echo $PATH | sed -e 's/:/ /g'` x; do
156 if [ -f $perlpath/perl ]; then
157 echo "#!$perlpath/perl" > $CVSROOT/CVSROOT/log.pl
158 cat contrib/log.pl >> $CVSROOT/CVSROOT/log.pl
159 chmod 755 $CVSROOT/CVSROOT/log.pl
160 cp examples/loginfo $CVSROOT/CVSROOT/loginfo
161 break
162 fi
163 done
164 if [ $perlpath = x ]; then
165 # we did not find perl anywhere, so make a simple loginfo file
166 cat > $CVSROOT/CVSROOT/loginfo <<"HERE"
167#
168# The "loginfo" file is used to control where "cvs commit" log information
169# is sent. The first entry on a line is a regular expression which is tested
170# against the directory that the change is being made to, relative to the
171# $CVSROOT. If a match is found, then the remainder of the line is a filter
172# program that should expect log information on its standard input.
173#
174# The filter program may use one and only one % modifier (ala printf). If
175# %s is specified in the filter program, a brief title is included (enclosed
176# in single quotes) showing the modified file names.
177#
178# If the repository name does not match any of the regular expressions in this
179# file, the "DEFAULT" line is used, if it is specified.
180#
181# If the name ALL appears as a regular expression it is always used
182# in addition to the first matching regex or DEFAULT.
183#
184DEFAULT (echo ""; echo $USER; date; cat) >> $CVSROOT/CVSROOT/commitlog
185HERE
186 fi
187 fi
188 (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m'initial checkin of loginfo' loginfo)
189 echo ""
190fi
191
192# The remaining files are generated from the examples files.
193for info in commitinfo rcsinfo editinfo; do
194 if [ -f $CVSROOT/CVSROOT/${info},v ]; then
195 if [ ! -f $CVSROOT/CVSROOT/$info ]; then
196 echo "You have a $CVSROOT/CVSROOT/${info},v file,"
197 echo "But no $CVSROOT/CVSROOT/$info file. This is OK."
198 echo "I'll checkout a fresh copy..."
199 (cd $CVSROOT/CVSROOT; co -q $info)
200 echo ""
201 fi
202 else
203 if [ -f $CVSROOT/CVSROOT/$info ]; then
204 echo "You have a $CVSROOT/CVSROOT/$info file,"
205 echo "But no $CVSROOT/CVSROOT/${info},v file."
206 echo "I'll create one for you, but otherwise leave it alone..."
207 else
208 echo "The $CVSROOT/CVSROOT/$info file does not exist."
209 echo "Making a simple one for you..."
210 sed -e 's/^\([^#]\)/#\1/' examples/$info > $CVSROOT/CVSROOT/$info
211 fi
212 (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m"initial checkin of $info" $info)
213 echo ""
214 fi
215done
216
217# Turn on history logging by default
218if [ ! -f $CVSROOT/CVSROOT/history ]; then
219 echo "Enabling CVS history logging..."
220 touch $CVSROOT/CVSROOT/history
221 echo ""
222fi
223
224# finish up by running mkmodules
225echo "All done! Running 'mkmodules' as my final step..."
226mkmodules $CVSROOT/CVSROOT
227
228# and, if necessary, remind them about setting CVSROOT
229if [ $remind_cvsroot = yes ]; then
230 echo "Remember to set the CVSROOT environment variable in your login script"
231fi
232
233exit 0