#!/usr/bin/perl # # File: ccimport.pl # # Description: This script will import an in-place view-private # directory structure and files into ClearCase. # # The script accomplishes this by moving the entire directory # structure aside, creating the directory elements, copying # the files, and creating the file elements. # # At the conclusion of running the script, all contents of the # directory will be checked-in. A view-private copy of the # contents of the directory will exist in dir-name.copy.pid. # This can be removed once you are satisfied that it has been # checked-into ClearCase successfully. # # Windows USERS: # This script will work on Windows, but there are some prerequisites. # You must have installed and in your path the following utilities: # find # mv # mkdir # cp # Note that there is a find executable in WINNT\System32 that does # not work. The path to the correct version of find executable must # appear before WINNT\System32 in your path statement. # $usage = "\nUsage: ccimport.pl [-h] directory\n\n"; while ($_ = shift(@ARGV)) { if (/^-h/) { print("$usage"); exit 0; } $top_dir = $_; } unless ("$top_dir") { print("\nError: directory not spcified.\n$usage"); exit 1; } if ($top_dir =~ m/\/$/){ chop($top_dir); } $OS = (eval{Win32::IsWinNT();},$@) ? "UNIX" : "NT"; if ($OS eq "NT") { $CT = "c:\\atria\\bin\\cleartool"; $FIND = "find"; $MV = "mv"; $MKDIR = "mkdir"; $CP = "cp"; } else { $CT = "/usr/atria/bin/cleartool"; $FIND = "/usr/bin/find"; $MV = "/usr/bin/mv"; $MKDIR = "/usr/bin/mkdir"; $CP = "/usr/bin/cp"; } # find all the directory names and file names @dirlist = `$FIND "$top_dir" -type d -print`; chomp(@dirlist); @filelist = `$FIND "$top_dir" -type f -print`; chomp(@filelist); # move the top level directory to dir.copy `$MKDIR "${top_dir}.copy.$$"`; `$MV "$top_dir" "${top_dir}.copy.$$"`; # checkout the parent directory `$CT checkout -nc .`; # for each directory, make the directory in ClearCase foreach $dir (@dirlist) { `$CT mkdir -c "Import" "${dir}"`; } # for each file, make the file in ClearCase foreach $file (@filelist) { `$CP "${top_dir}.copy.$$/$file" "$file"`; `$CT mkelem -ci -c "Import" "$file"`; } # for each directory, check in the directory foreach $dir (@dirlist) { `$CT checkin -c "Import" "${dir}"`; } # checkin the parent directory `$CT checkin -c "Import" .`;