#!/usr/bin/perl -w $DescribeFile = $ARGV[0]; $ComponentFile = $ARGV[1]; $LoadCreateFile = ">".$ARGV[2]; # *** Process the data from the input file *** $Pause .= "pause\n"; &Main_Process; # *** Subroutine that does the main processing of program. *** sub Main_Process { $IntFound = 0; $RootFound = 0; &OpenProjectFile; foreach $_ (@DescribeData) { &ProcessGetViewInfo; } close LOADCREATE; } # *** Subroutine that Opens, reads and closes the input file *** sub OpenProjectFile { open DESCRIBE, $DescribeFile or die "Can not find the project describe file!"; while (!eof(DESCRIBE)) { read DESCRIBE, $DescribeDataFromFile, 100; $DescribeData .= $DescribeDataFromFile; } close DESCRIBE; $DescribeData =~ s/\n\n/\n/g; @DescribeData = split("\n", $DescribeData); } # *** Subroutine that gets the required view info from the file *** sub ProcessGetViewInfo { &FindTag; } # *** Subroutine that finds and stores the view tag name for the curent view *** sub FindTag { if (m/project "/) { $ProjectLine = $_; $PrjLeftQuote = index($ProjectLine, "t"); $NameLength = length($ProjectLine) - $PrjLeftQuote - 4; $ProjectName = substr($ProjectLine, $PrjLeftQuote + 3, $NameLength); } if (m/integration stream:/) { $DescribeLine = $_; $LeftQuote = index($DescribeLine, ":"); $RightQuote = index($DescribeLine, "@"); $Intname = $RightQuote - $LeftQuote - 2; $Int = substr($DescribeLine, $LeftQuote + 2 , $Intname); $Int2 = substr($DescribeLine, $LeftQuote + 2 , length($DescribeLine)); $CreateViewCmd .= "cleartool mkview -snapshot -tag ".$Int."_Snapshot -stream ".$Int2." -colocated_server -host idetestcc1 -hpath d:\\ClearCase_Storage\\views\\snapshot\\".$Int."_Snapshot -gpath d:\\ClearCase_Storage\\views\\snapshot\\".$Int."_Snapshot \\\\idetestcc1\\ccstg_d\\views\\snapshot\\".$Int."_Snapshot\n"; $IntFound ++; &OpenComponentFile; foreach $_ (@ComponentData) { &ProcessComponent; } } } # *** Subroutine that Opens, reads and closes the input file *** sub OpenComponentFile { open COMPONENT, $ComponentFile or die "Can not find the component file!"; while (!eof(COMPONENT)) { read COMPONENT, $CompDataFromFile, 100; $ComponentData .= $CompDataFromFile; } close COMPONENT; $ComponentData =~ s/\n\n/\n/g; @ComponentData = split("\n", $ComponentData); } # *** Subroutine that gets the required view info from the file *** sub ProcessComponent { &FindRoot; if ($RootFound == 1) { &CreateLoadFile; } } # *** Subroutine that finds and stores the root name for the current project *** sub FindRoot { if (m/$ProjectName/) { if (m/root directory:/) { $RootLine = $_; $LeftQuoteRoot = index($RootLine, ":"); $RightQuoteRoot = length($RootLine) - $LeftQuoteRoot - 4; $Root = substr($RootLine, $LeftQuoteRoot + 3, $RightQuoteRoot); $LoadViewCmd .= "cleartool update -add_loadrules \.".$Root." \n"; $D .= "d:\n"; $ChangeDirectory .= "cd clearcase_storage\\views\\snapshot\\".$Int."_Snapshot\n"; $RootFound ++; } } } # *** Subroutine that opens and prints the load spec file *** sub CreateLoadFile { open LOADCREATE, $LoadCreateFile or die "Can not find the LoadCreateFile!"; print LOADCREATE $CreateViewCmd; print LOADCREATE $D; print LOADCREATE $ChangeDirectory; print LOADCREATE $LoadViewCmd; print LOADCREATE $Pause; $RootFound = 0; }