package cfgdiff; BEGIN { die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'}; die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'}; unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan"); } use util; use diffutil; use Text::Diff; sub test_cfg { my ($full_modelcfg,$full_testcfg,$cfg_file) = @_; my $cfg_result = diff $full_modelcfg, $full_testcfg, { STYLE => "OldStyle" }; if($cfg_file eq "build.cfg") { my @temp_array = split (" ",$cfg_result); my @r_array = grep {/\d+/} @temp_array; if ($cfg_result eq "") { return ""; # return "Difference Report: These two collections are identical"; } elsif ($r_array[1] > $r_array[2] && $temp_array[2] eq "builddate" && $temp_array[6] eq "builddate") { return "Difference Report: Using newer collection as model collection"; } elsif ($r_array[1] < $r_array[2] && $temp_array[2] eq "builddate" && $temp_array[6] eq "builddate") { return ""; } else { $cfg_result = &diffutil::GenerateOutput($cfg_result,""); return $cfg_result; } } elsif($cfg_file eq "collect.cfg") { $cfg_result = &diffutil::GenerateOutput($cfg_result,""); if ($cfg_result eq "") { return ""; } else { return "Difference Report:\n$cfg_result"; } } else { die "Error occour in cfgdiff::testcfg!!\n"; } } 1;