summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/cvs/cvsinit/cvsinit.sh
blob: 49c545190b588c99de6d78faad33cc2b2dc5c8fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#! /bin/sh
:
#
#ident	"@(#)cvs:$Name:  $:$Id: cvsinit.sh,v 1.7 1995/11/14 23:44:18 woods Exp $"
# Copyright (c) 1992, Brian Berliner
#
# You may distribute under the terms of the GNU General Public License as
# specified in the README file that comes with the CVS 1.4 kit.

# This script should be run for each repository you create to help you
# setup your site for CVS.  You may also run it to update existing
# repositories if you install a new version of CVS.

# this line is edited by Makefile when creating cvsinit.inst
CVSLIB="xLIBDIRx"

CVS_VERSION="xVERSIONx"

# All purpose usage message, also suffices for --help and --version.
if test $# -gt 0; then
  echo "cvsinit version $CVS_VERSION"
  echo "usage: $0"
  echo "(set CVSROOT to the repository that you want to initialize)"
  exit 0
fi

# Make sure that the CVSROOT variable is set
if [ "x$CVSROOT" = x ]; then
    echo "The CVSROOT environment variable is not set."
    echo ""
    echo "You should choose a location for your source repository"
    echo "that can be shared by many developers.  It also helps to"
    echo "place the source repository on a file system that has"
    echo "plenty of free space."
    echo ""
    echo "Please enter the full path for your CVSROOT source repository:"
    read CVSROOT junk
    unset junk
    remind_cvsroot=yes
else
    remind_cvsroot=no
fi

# Now, create the $CVSROOT if it is not already there
if [ ! -d $CVSROOT ]; then
    echo "Creating $CVSROOT..."
    path=
    for comp in `echo $CVSROOT | sed -e 's,/, ,g'`; do
	path=$path/$comp
	if [ ! -d $path ]; then
	    mkdir $path
	fi
    done
else
    true
fi

# Next, check for $CVSROOT/CVSROOT
if [ ! -d $CVSROOT/CVSROOT ]; then
    if [ -d $CVSROOT/CVSROOT.adm ]; then
	echo "You have the old $CVSROOT/CVSROOT.adm directory."
	echo "I will rename it to $CVSROOT/CVSROOT for you..."
	mv $CVSROOT/CVSROOT.adm $CVSROOT/CVSROOT
    else
	echo "Creating the $CVSROOT/CVSROOT directory..."
	mkdir $CVSROOT/CVSROOT
    fi
else
    true
fi
if [ ! -d $CVSROOT/CVSROOT ]; then
    echo "Unable to create $CVSROOT/CVSROOT."
    echo "I give up."
    exit 1
fi

# Create the special control files and templates within $CVSROOT/CVSROOT

EXAMPLES="checkoutlist commitinfo cvswrappers editinfo loginfo modules 
rcsinfo rcstemplate taginfo wrap unwrap"

NEWSAMPLE=false
for info in $EXAMPLES; do
    if [ -f $CVSROOT/CVSROOT/${info},v ]; then
	if [ ! -f $CVSROOT/CVSROOT/$info ]; then
	    echo "Checking out $CVSROOT/CVSROOT/$info"
	    echo "  from $CVSROOT/CVSROOT/${info},v..."
	    (cd $CVSROOT/CVSROOT; co -q $info)
	fi
    else
	NEWSAMPLE=true
	if [ -f $CVSROOT/CVSROOT/$info ]; then
	    echo "Checking in $CVSROOT/CVSROOT/${info},v"
	    echo "  from $CVSROOT/CVSROOT/$info..."
	else
	    echo "Creating a sample $CVSROOT/CVSROOT/$info file..."
	    case $info in
	      modules)
		sed -n -e '/END_REQUIRED_CONTENT/q' \
		    -e p $CVSLIB/examples/modules > $CVSROOT/CVSROOT/modules
		;;
	      rcstemplate)
		cp $CVSLIB/examples/$info $CVSROOT/CVSROOT/$info
		;;
	      wrap|unwrap)
		cp $CVSLIB/examples/$info $CVSROOT/CVSROOT/$info
		chmod +x $CVSROOT/CVSROOT/$info
		;;
	      *)
		# comment out everything in all the other examples....
		sed -e 's/^\([^#]\)/#\1/' $CVSLIB/examples/$info > $CVSROOT/CVSROOT/$info
		;;
	    esac
	fi
	(cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m"initial checkin of $info" $info)
    fi
done

if $NEWSAMPLE ; then
    echo "NOTE:  You may wish to check out the CVSROOT module and edit any new"
    echo "configuration files to match your local requirements."
    echo ""
fi

# check to see if there are any references to the old CVSROOT.adm directory
if grep CVSROOT.adm $CVSROOT/CVSROOT/modules >/dev/null 2>&1; then
    echo "Warning: your $CVSROOT/CVSROOT/modules file still"
    echo "	contains references to the old CVSROOT.adm directory"
    echo "	You should really change these to the new CVSROOT directory"
    echo ""
fi

# These files are generated from the contrib files.
# FIXME: Is it really wise to overwrite possible local changes like this?
# Normal folks will keep these up to date by modifying the source in
# their CVS module and re-installing CVS, but is everyone OK with that?
#
#
CONTRIBS="log commit_prep log_accum cln_hist"
#
for contrib in $CONTRIBS; do
    echo "Copying the new version of '${contrib}'"
    echo "  to $CVSROOT/CVSROOT for you..."
    cp $CVSLIB/contrib/$contrib $CVSROOT/CVSROOT/$contrib
done

# XXX - also add a stub for the cvsignore file

# Turn on history logging by default
if [ ! -f $CVSROOT/CVSROOT/history ]; then
    echo "Enabling CVS history logging..."
    touch $CVSROOT/CVSROOT/history
    chmod g+w $CVSROOT/CVSROOT/history
    echo "(Remove $CVSROOT/CVSROOT/history to disable.)"
fi

# finish up by running mkmodules
echo "All done!  Running 'mkmodules' as my final step..."
mkmodules $CVSROOT/CVSROOT

exit 0