#!/usr/local/bin/perl # # ToolName: Change CVS/Root # Usage: chcvsroot newcvsroot [targetdir] # Lisence: GNU Public Lisence # Author: Mika Ohtsuki (mika@mikamama.com) # Version: $Id: chcvsroot.txt,v 1.1 2001/11/09 10:49:46 misty Exp $ # Comment: Let's play with CVS! # # Argument1: newcvsroot if ($ARGV[0]) { $newcvsroot = $ARGV[0]; } else { print "Usage: chcvsroot newcvsroot [targetdir]\n"; exit (0); } # Argument 2: target $target = '.'; if ($ARGV[1]) { $target = $ARGV[1]; } chcvsroot($target); # Dir check method. sub chcvsroot { my $dirname = $_[0]; my @dirs = (); print "Openning $dirname..."; opendir(DIR, $dirname) or die "Could not open $dirname: $!\n"; print "done.\n"; while ($filename = readdir(DIR)) { $path = $dirname.'/'.$filename; if ( -d $path ) { if ($filename eq 'CVS') { $root = $path.'/Root'; open (ROOT, ">$root") or die "Could not open $root: $!\n"; #$oldcvsroot = ; #chomp($oldcvsroot); print "...writing $newcvsroot.."; print ROOT "$newcvsroot\n"; print "done\n"; close(ROOT); } elsif ($filename ne '.' && $filename ne '..') { print "DIR: $path\n"; push(@dirs, $path); } } } closedir(DIR); # Recursion (fun!) foreach $dir (@dirs) { chcvsroot($dir); } }