#!/usr/bin/perl # 2003 Alex Fritze # # cvsintegrate v1.0 sub usage { print <) { if (/^\/(.*)\/(.*)\/(.*)\/(.*)\/(.*)/) { my $filename = $1; $file{$filename} = 1; if ($4 =~ /-kb/) { $binary{$filename} = 1; } } elsif (/^D\/([^\/]*)\//) { $subdir{$1} = 1; } } close(ENTRIES); open(LOG, $dir . "/CVS/Entries.Log"); # fail silently; file is optional while () { if (/^A D\/([^\/]*)\//) { $subdir{$1} = 1; } elsif (/^R D\/([^\/]*)\//) { delete($subdir{$1}); } elsif (/^[AR]/) { die "unknown entry in Entries.Log!" } } close(LOG); # build the import statement for this directory: my $import_cmd = "cd $dir; cvs -d $target_repository -z3 import"; $import_cmd .= " -b $branch" if ($branch); $import_cmd .= " -m \"$comment\""; # ignore all subdirectories (will process ourselves) and all files # not listed in %file my @ignore; opendir(DIR, $dir) or die "Can't opendir $dir: $!"; while (defined($dir_entry = readdir(DIR))) { next if $dir_entry =~ /^\.\.?$/; # skip . and .. push @ignore, $dir_entry unless $file{$dir_entry}; } closedir(DIR); $import_cmd .= " -I \"@ignore\"" if (@ignore); foreach $key (keys %binary) { $import_cmd .= " -W \"$key -k 'b'\"" } my $import_dir = $target_directory . "/" . $dir; $import_dir =~ s!/\.!!; $import_cmd .= " $import_dir"; $import_cmd .= " $vendor_tag $release_tag"; if ($pretend) { print "* DIRECTORY $dir\n"; print "files for import: @{[keys %file]} \n"; print "binaries: @{[keys %binary]}\n"; print "subdirs:\n@{[keys %subdir]}\n"; print "import statement: $import_cmd\n\n"; } else { if ($verbose) { print "* DIRECTORY $dir\n"; print "$import_cmd\n"; } print `$import_cmd`; die "cvs failure" if $?; } # now process subdirs: foreach $key (keys %subdir) { process_dir($dir . "/" . $key); } } # ---------------------------------------------------------------------- # main # parse options: while ($_ = $ARGV[0], /^-/) { shift; if (/^-d(.*)/) { $target_repository = $1; $target_repository = shift unless $1; } elsif (/^-m(.*)/) { $comment = $1; $comment = shift unless $1; } elsif (/^-b(.*)/) { $branch = $1; $branch = shift unless $1; } elsif (/^-p/) { $pretend = 1; } elsif (/^-v/) { $verbose = 1; } } if (!$target_repository or !$comment) { usage; } # parse other parameters: $target_directory = shift || usage; $vendor_tag = shift || usage; $release_tag = shift || usage; # walk the CVS directories: process_dir(".");