diff options
author | will <will@FreeBSD.org> | 2002-10-14 16:47:42 +0800 |
---|---|---|
committer | will <will@FreeBSD.org> | 2002-10-14 16:47:42 +0800 |
commit | 1c2ed7c1128e5b872c066c8fa884e7c6a969584b (patch) | |
tree | 9a082bf6a6f44e9cbb9757f73a3d9d359a53d7e0 | |
parent | 923c44f2234d6132775438bc8f2535eee4e92d66 (diff) | |
download | freebsd-ports-gnome-1c2ed7c1128e5b872c066c8fa884e7c6a969584b.tar.gz freebsd-ports-gnome-1c2ed7c1128e5b872c066c8fa884e7c6a969584b.tar.zst freebsd-ports-gnome-1c2ed7c1128e5b872c066c8fa884e7c6a969584b.zip |
I never thought I'd change this code, but a change was required to make
sure cvs -R is enforced for freefall !=n cvs. And it's a Bad Thing(TM)
that a piece of code addport depended on wasn't in the CVS tree anyway.
-rwxr-xr-x | Tools/scripts/modulesupdate | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Tools/scripts/modulesupdate b/Tools/scripts/modulesupdate new file mode 100755 index 000000000000..f204e11fd684 --- /dev/null +++ b/Tools/scripts/modulesupdate @@ -0,0 +1,107 @@ +#! /usr/bin/perl +# +# This code mostly stolen from easy-import written by J^vrg Wunsch +# +# $Id: modulesupdate,v 1.8 2000/04/02 05:42:12 mharo Exp $ +# $FreeBSD$ + +use strict; + +my $tmpdir; + +if ($ENV{CVSROOT} eq "") { + $ENV{CVSROOT}="/home/ncvs"; +} + +sub goodbye +{ + my ($exitstatus)=@_; + chdir "/tmp"; + print `rm -rf $tmpdir`; + exit $exitstatus; +} + +sub contains +{ + # look if the first parameter is contained in the list following it + my($item, @list) = @_; + + foreach my $i (@list) { + return 1 if $i eq $item; + } + return 0; +} + +sub lsmodules +{ + # list all known CVS modules + my(%rv, $mname, $mpath); + + %rv = (); + + open(CVS, "cvs -R co -c|") || die "cvs: $!"; + while(<CVS>) { + chomp; + chomp; + ($mname,$mpath) = split; + next if $mname eq ""; + $rv{$mname} = $mpath; + } + close(CVS); + + return %rv; +} + +my %cvsmods = &lsmodules; +my $modulename = shift; +my $modulepath = shift; +my $dont_do_it = ""; + +$tmpdir=`mktemp -d -t mu`; +chomp $tmpdir; +chdir $tmpdir or die "$tmpdir: $!"; + +if ($modulepath eq "") { + print "Error: Must specify both modulename and modulepath\n"; + &goodbye(1); +} + +if (&contains($modulename, keys(%cvsmods))) { + print "Error: $modulename already exists in modules\n"; + &goodbye(1); +} + +my $mod = ""; +foreach my $tmp (sort(keys(%cvsmods))) { + if ($tmp gt $modulename) { + $mod = $tmp; + last; + } +} + +my $cmd; +if ($mod eq "") { + # we are going to append our module + $cmd = "\$\na\n"; +} else { + # we can insert it + $cmd = "/^" . $mod . "[ \t]/\ni\n"; +} + +print "Checking out the modules database...\n"; +system("cvs -R co modules") && die "failed.\n"; + +my $len = length($modulename); +print "Inserting new module...\n"; +open(ED, "|ed modules/modules") || die "Cannot start ed\n"; +print ED "$cmd$modulename" . "\t" x ($len < 8 ? 2 : 1) . + "$modulepath\n.\nw\nq\n"; +close(ED); + +print "Commiting new modules database...\n"; +system("cvs -R $dont_do_it commit -m \" " . + "$modulename --> $modulepath\" modules") + && die "Commit failed\n"; + +# cleanup +&goodbye; |