summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1995-03-12 10:18:55 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1995-03-12 10:18:55 +0000
commit36d59faf6ae859f0f94c7917ffb5c2ecd6168031 (patch)
treee21730dd2b733c679c5fd54b57543302211480ba
parentdb4427d33494e4695dbc1f5d90e612dbd28a045a (diff)
downloadsrc-test2-36d59faf6ae859f0f94c7917ffb5c2ecd6168031.tar.gz
src-test2-36d59faf6ae859f0f94c7917ffb5c2ecd6168031.zip
This commit was manufactured by cvs2svn to create branch 'VENDOR-cvs'.
Notes
Notes: svn path=/vendor/cvs/dist/; revision=7021
-rw-r--r--gnu/usr.bin/cvs/contrib/easy-import.perl324
-rw-r--r--gnu/usr.bin/cvs/cvsinit/cvsinit.sh233
2 files changed, 557 insertions, 0 deletions
diff --git a/gnu/usr.bin/cvs/contrib/easy-import.perl b/gnu/usr.bin/cvs/contrib/easy-import.perl
new file mode 100644
index 000000000000..d7716b5a804a
--- /dev/null
+++ b/gnu/usr.bin/cvs/contrib/easy-import.perl
@@ -0,0 +1,324 @@
+#!/usr/bin/perl
+#
+# Support for importing a source collection into CVS.
+# Trys to prevent the user from the most common pitfalls (like creating
+# new top-level repositories or second-level areas accidentally), and
+# cares to do some of the `dirty' work like maintaining the modules
+# database accordingly.
+#
+# Written by Jörg Wunsch, 95/03/07, and placed in the public domain.
+#
+
+require "complete.pl";
+
+
+sub lsdir
+{
+ # find all subdirectories under @_
+ # ignore all CVS entries, dot entries, and non-directories
+
+ local($base) = @_;
+ local(@ls, @rv, $fname);
+
+ opendir(DIR, $base) || die "Cannot find dir $base.\n";
+
+ @ls = readdir(DIR);
+ closedir(DIR);
+
+ @rv = ();
+
+ foreach $fname (@ls) {
+ next if $fname =~ /^CVS/ || $fname eq "Attic"
+ || $fname =~ /^\./ || ! -d "$base/$fname";
+ @rv = (@rv, $fname);
+ }
+
+ return sort(@rv);
+}
+
+
+sub contains
+{
+ # look if the first parameter is contained in the list following it
+ local($item, @list) = @_;
+ local($found, $i);
+
+ $found = 0;
+ foreach $i (@list) {
+ return 1 if $i eq $item;
+ }
+ return 0;
+}
+
+
+
+sub term_init
+{
+ # first, get some terminal attributes
+
+ # try bold mode first
+ $so = `tput md`; $se = `tput me`;
+
+ # if no bold mode available, use standout mode
+ if ($so eq "") {
+ $so = `tput so`; $se = `tput se`;
+ }
+
+ # try if we can underscore
+ $us = `tput us`; $ue = `tput ue`;
+ # if we don't have it available, or same as bold/standout, disable it
+ if ($us eq "" || $us eq $so) {
+ $us = $ue = "";
+ }
+
+ # look how many columns we've got
+ if($ENV{'COLUMNS'} ne "") {
+ $columns = $ENV{'COLUMNS'};
+ } elsif(-t STDIN) { # if we operate on a terminal...
+ local($word, $tmp);
+
+ open(STTY, "stty -a|");
+ $_ = <STTY>; # try getting the tty win structure value
+ close(STTY);
+ chop;
+ $columns = 0;
+ foreach $word (split) {
+ $columns = $tmp if $word eq "columns;"; # the number preceding
+ $tmp = $word;
+ }
+ } else {
+ $columns = 80;
+ }
+ # sanity
+ $columns = 80 unless $columns >= 5;
+}
+
+
+sub list
+{
+ # pretty-print a list
+ # imports: global variable $columns
+ local(@items) = @_;
+ local($longest,$i,$item,$cols,$width);
+
+ # find the longest item
+ $longest = 0;
+ foreach $item (@items) {
+ $i = length($item);
+ $longest = $i if $longest < $i;
+ }
+ $width = $longest + 1;
+ $cols = int($columns / $width);
+
+ $i = 0;
+ foreach $item (@items) {
+ print $item;
+ if(++$i == $cols) {
+ $i = 0; print "\n";
+ } else {
+ print ' ' x ($width - length($item));
+ }
+ }
+ print "\n" unless $i == 0;
+}
+
+sub cvs_init
+{
+ # get the CVS repository(s)
+
+ die "You need to have the \$CVSROOT variable set.\n"
+ unless $ENV{'CVSROOT'} ne "";
+
+ # get the list of available repositories
+ $cvsroot = $ENV{'CVSROOT'};
+ @reps = &lsdir($cvsroot);
+}
+
+
+sub lsmodules
+{
+ # list all known CVS modules
+ local(@rv, $mname, $_);
+
+ @rv = ();
+
+ open(CVS, "cvs co -c|");
+ while($_ = <CVS>) {
+ chop;
+ ($mname) = split;
+ next if $mname eq "";
+ @rv = (@rv, $mname);
+ }
+ close(CVS);
+
+ return @rv;
+}
+
+
+sub checktag
+{
+ # check a given string for tag rules
+ local($s) = @_;
+ return 0 if($s !~ /^[A-Za-z][A-Za-z0-9_]*$/);
+
+ return 1;
+}
+
+
+&term_init;
+&cvs_init;
+
+print "${so}Available repositories:${se}\n";
+&list(@reps);
+
+$selected =
+ &Complete("Enter repository (<TAB>=complete, ^D=show): ",
+ @reps);
+
+die "\aYou cannot create new repositories with this script.\n"
+ unless &contains($selected, @reps);
+
+$rep = $selected;
+
+print "\n${so}Selected repository:${se} ${us}$rep${ue}\n";
+
+
+@areas = &lsdir("$cvsroot/$rep");
+
+print "${so}Existent areas in this repository:${se}\n";
+&list(@areas);
+
+# the following kludge prevents the Complete package from starting
+# over with the string just selected; Complete should better provide
+# some reinitialize method
+$Complete'return = ""; $Complete'r = 0;
+
+$selected =
+ &Complete("Enter area name (<TAB>=complete, ^D=show): ",
+ @areas);
+
+print "\a${us}Warning: this will create a new area.${ue}\n"
+ unless &contains($selected, @areas);
+
+$area = "$rep/$selected";
+
+print "\n${so}[Working on:${se} ${us}$area${ue}${so}]${se}\n";
+
+for(;;) {
+ $| = 1;
+ print "${so}Enter the module path:${se} $area/";
+ $| = 0;
+ $modpath = <>;
+ chop $modpath;
+ if ($modpath eq "") {
+ print "\a${us}You cannot use an empty module path.${ue}\n";
+ next;
+ }
+ last if ! -d "$cvsroot/$area/$modpath";
+ print "\a${us}This module path does already exist; " .
+ "choose another one.${ue}\n";
+}
+
+
+@newdirs = ();
+$dir1 = "$cvsroot/$area";
+$dir2 = "$area";
+
+@newdirs = (@newdirs, "$dir2") if ! -d $dir1;
+
+foreach $ele (split(/\//, $modpath)) {
+ $dir1 = "$dir1/$ele";
+ $dir2 = "$dir2/$ele";
+ @newdirs = (@newdirs, "$dir2") if ! -d $dir1;
+}
+
+print "${so}You're going to create the following new directories:${se}\n";
+
+&list(@newdirs);
+
+@cvsmods = &lsmodules();
+
+for(;;) {
+ $| = 1;
+ print "${so}Gimme the module name:${se} ";
+ $| = 0;
+ $modname = <>;
+ chop $modname;
+ if ($modname eq "") {
+ print "\a${us}You cannot use an empty module name.${ue}\n";
+ next;
+ }
+ last if !&contains($modname, @cvsmods);
+ print "\a${us}This module name does already exist; " .
+ "choose another one.${ue}\n";
+}
+
+
+for(;;) {
+ $| = 1;
+ print "${so}Enter a \`vendor\' tag (e. g. the authors ID):${se} ";
+ $| = 0;
+ $vtag = <>;
+ chop $vtag;
+ last if &checktag($vtag);
+ print "\a${us}Valid tags must match the regexp " .
+ "^[A-Za-z][A-Za-z0-9_]*\$.${ue}\n";
+}
+
+for(;;) {
+ $| = 1;
+ print "${so}Enter a \`release\' tag (e. g. the version #):${se} ";
+ $| = 0;
+ $rtag = <>;
+ chop $rtag;
+ last if &checktag($rtag);
+ print "\a${us}Valid tags must match the regexp " .
+ "^[A-Za-z][A-Za-z0-9_]*\$.${ue}\n";
+}
+
+
+$| = 1;
+print "${so}This is your last chance to interrupt, " .
+ "hit <return> to go on:${se} ";
+$| = 0;
+<>;
+
+$mod = "";
+foreach $tmp (@cvsmods) {
+ if($tmp gt $modname) {
+ $mod = $tmp;
+ last;
+ }
+}
+
+if($mod eq "") {
+ # we are going to append our module
+ $cmd = "\$\na\n";
+} else {
+ # we can insert it
+ $cmd = "/^${mod}[ \t]/\ni\n";
+}
+
+print "${so}Checking out the modules database...${se}\n";
+system("cvs co modules") && die "${us}failed.\n${ue}";
+
+print "${so}Inserting new module...${se}\n";
+open(ED, "|ed modules/modules") || die "${us}Cannot start ed${ue}\n";
+print(ED "${cmd}${modname}" . ' ' x (32 - length($modname)) .
+ "$area/${modpath}\n.\nw\nq\n");
+close(ED);
+
+print "${so}Commiting new modules database...${se}\n";
+system("cvs commit -m \" ${modname} --> $area/${modpath}\" modules")
+ && die "Commit failed\n";
+
+system("cvs release -dQ modules");
+
+print "${so}Importing source. Enter a commit message in the editor.${se}\n";
+
+system("cvs import $area/$modpath $vtag $rtag");
+
+print "${so}You are done now. Go to a different directory, perform a${se}\n".
+ "${us}cvs co ${modname}${ue} ${so}command, and see if your new module" .
+ " builds ok.${se}\n";
+
diff --git a/gnu/usr.bin/cvs/cvsinit/cvsinit.sh b/gnu/usr.bin/cvs/cvsinit/cvsinit.sh
new file mode 100644
index 000000000000..58e4332bd480
--- /dev/null
+++ b/gnu/usr.bin/cvs/cvsinit/cvsinit.sh
@@ -0,0 +1,233 @@
+:
+#
+# 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.3 kit.
+#
+# @(#)cvsinit 1.1 92/03/31
+#
+# This script should be run once to help you setup your site for CVS.
+
+# 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
+ remind_cvsroot=yes
+else
+ echo "Using $CVSROOT as the source repository."
+ remind_cvsroot=no
+fi
+echo ""
+
+# Now, create the $CVSROOT if it is not already there
+if [ ! -d $CVSROOT ]; then
+ echo "Hmmm... $CVSROOT does not exist; trying to make it..."
+ path=
+ for comp in `echo $CVSROOT | sed -e 's,/, ,g'`; do
+ path=$path/$comp
+ if [ ! -d $path ]; then
+ mkdir $path
+ fi
+ done
+else
+ echo "Good... $CVSROOT already exists."
+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 "Making the $CVSROOT/CVSROOT directory..."
+ mkdir $CVSROOT/CVSROOT
+ fi
+else
+ echo "Wow!... so does $CVSROOT/CVSROOT."
+fi
+echo ""
+if [ ! -d $CVSROOT/CVSROOT ]; then
+ echo "You still don't have a $CVSROOT/CVSROOT directory."
+ echo "I give up."
+ exit 1
+fi
+
+# Create the special *info files within $CVSROOT/CVSROOT
+
+# Trump up a simple modules file, if one doesn't exist
+if [ -f $CVSROOT/CVSROOT/modules,v ]; then
+ if [ ! -f $CVSROOT/CVSROOT/modules ]; then
+ echo "You have a $CVSROOT/CVSROOT/modules,v file,"
+ echo "But no $CVSROOT/CVSROOT/modules file. This is OK."
+ echo "I'll checkout a fresh copy..."
+ (cd $CVSROOT/CVSROOT; co -q modules)
+ echo ""
+ fi
+else
+ if [ -f $CVSROOT/CVSROOT/modules ]; then
+ echo "You have a $CVSROOT/CVSROOT/modules file,"
+ echo "But no $CVSROOT/CVSROOT/modules,v file."
+ echo "I'll create one for you, but otherwise leave it alone..."
+ else
+ echo "The $CVSROOT/CVSROOT/modules file does not exist."
+ echo "Making a simple one for you..."
+ cat > $CVSROOT/CVSROOT/modules <<"HERE"
+#
+# The CVS modules file
+#
+# Three different line formats are valid:
+# key -a aliases...
+# key [options] directory
+# key [options] directory files...
+#
+# Where "options" are composed of:
+# -i prog Run "prog" on "cvs commit" from top-level of module.
+# -o prog Run "prog" on "cvs checkout" of module.
+# -t prog Run "prog" on "cvs rtag" of module.
+# -u prog Run "prog" on "cvs update" of module.
+# -d dir Place module in directory "dir" instead of module name.
+# -l Top-level directory only -- do not recurse.
+#
+# And "directory" is a path to a directory relative to $CVSROOT.
+#
+# The "-a" option specifies an alias. An alias is interpreted as if
+# everything on the right of the "-a" had been typed on the command line.
+#
+# You can encode a module within a module by using the special '&'
+# character to interpose another module into the current module. This
+# can be useful for creating a module that consists of many directories
+# spread out over the entire source repository.
+#
+
+# Convenient aliases
+world -a .
+
+# CVSROOT support; run mkmodules whenever anything changes.
+CVSROOT -i mkmodules CVSROOT
+modules -i mkmodules CVSROOT modules
+loginfo -i mkmodules CVSROOT loginfo
+commitinfo -i mkmodules CVSROOT commitinfo
+rcsinfo -i mkmodules CVSROOT rcsinfo
+editinfo -i mkmodules CVSROOT editinfo
+
+# Add other modules here...
+HERE
+ fi
+ (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m'initial checkin of modules' modules)
+ 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
+
+# loginfo, like modules, is special-cased
+if [ -f $CVSROOT/CVSROOT/loginfo,v ]; then
+ if [ ! -f $CVSROOT/CVSROOT/loginfo ]; then
+ echo "You have a $CVSROOT/CVSROOT/loginfo,v file,"
+ echo "But no $CVSROOT/CVSROOT/loginfo file. This is OK."
+ echo "I'll checkout a fresh copy..."
+ (cd $CVSROOT/CVSROOT; co -q loginfo)
+ echo ""
+ fi
+else
+ if [ -f $CVSROOT/CVSROOT/loginfo ]; then
+ echo "You have a $CVSROOT/CVSROOT/loginfo file,"
+ echo "But no $CVSROOT/CVSROOT/loginfo,v file."
+ echo "I'll create one for you, but otherwise leave it alone..."
+ else
+ echo "The $CVSROOT/CVSROOT/loginfo file does not exist."
+ echo "Making a simple one for you..."
+ # try to find perl; use fancy log script if we can
+ for perlpath in `echo $PATH | sed -e 's/:/ /g'` x; do
+ if [ -f $perlpath/perl ]; then
+ echo "#!$perlpath/perl" > $CVSROOT/CVSROOT/log.pl
+ cat contrib/log.pl >> $CVSROOT/CVSROOT/log.pl
+ chmod 755 $CVSROOT/CVSROOT/log.pl
+ cp examples/loginfo $CVSROOT/CVSROOT/loginfo
+ break
+ fi
+ done
+ if [ $perlpath = x ]; then
+ # we did not find perl anywhere, so make a simple loginfo file
+ cat > $CVSROOT/CVSROOT/loginfo <<"HERE"
+#
+# The "loginfo" file is used to control where "cvs commit" log information
+# is sent. The first entry on a line is a regular expression which is tested
+# against the directory that the change is being made to, relative to the
+# $CVSROOT. If a match is found, then the remainder of the line is a filter
+# program that should expect log information on its standard input.
+#
+# The filter program may use one and only one % modifier (ala printf). If
+# %s is specified in the filter program, a brief title is included (enclosed
+# in single quotes) showing the modified file names.
+#
+# If the repository name does not match any of the regular expressions in this
+# file, the "DEFAULT" line is used, if it is specified.
+#
+# If the name ALL appears as a regular expression it is always used
+# in addition to the first matching regex or DEFAULT.
+#
+DEFAULT (echo ""; echo $USER; date; cat) >> $CVSROOT/CVSROOT/commitlog
+HERE
+ fi
+ fi
+ (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m'initial checkin of loginfo' loginfo)
+ echo ""
+fi
+
+# The remaining files are generated from the examples files.
+for info in commitinfo rcsinfo editinfo; do
+ if [ -f $CVSROOT/CVSROOT/${info},v ]; then
+ if [ ! -f $CVSROOT/CVSROOT/$info ]; then
+ echo "You have a $CVSROOT/CVSROOT/${info},v file,"
+ echo "But no $CVSROOT/CVSROOT/$info file. This is OK."
+ echo "I'll checkout a fresh copy..."
+ (cd $CVSROOT/CVSROOT; co -q $info)
+ echo ""
+ fi
+ else
+ if [ -f $CVSROOT/CVSROOT/$info ]; then
+ echo "You have a $CVSROOT/CVSROOT/$info file,"
+ echo "But no $CVSROOT/CVSROOT/${info},v file."
+ echo "I'll create one for you, but otherwise leave it alone..."
+ else
+ echo "The $CVSROOT/CVSROOT/$info file does not exist."
+ echo "Making a simple one for you..."
+ sed -e 's/^\([^#]\)/#\1/' examples/$info > $CVSROOT/CVSROOT/$info
+ fi
+ (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m"initial checkin of $info" $info)
+ echo ""
+ fi
+done
+
+# Turn on history logging by default
+if [ ! -f $CVSROOT/CVSROOT/history ]; then
+ echo "Enabling CVS history logging..."
+ touch $CVSROOT/CVSROOT/history
+ echo ""
+fi
+
+# finish up by running mkmodules
+echo "All done! Running 'mkmodules' as my final step..."
+mkmodules $CVSROOT/CVSROOT
+
+# and, if necessary, remind them about setting CVSROOT
+if [ $remind_cvsroot = yes ]; then
+ echo "Remember to set the CVSROOT environment variable in your login script"
+fi
+
+exit 0