bintools/evalid/EvalidCompare.pm.bak
changeset 676 b5e6747818a9
parent 655 3f65fd25dfd4
--- a/bintools/evalid/EvalidCompare.pm.bak	Tue Nov 02 09:31:04 2010 +0800
+++ b/bintools/evalid/EvalidCompare.pm.bak	Wed Nov 10 14:19:09 2010 +0800
@@ -62,7 +62,8 @@
       'Unknown library' => 'identical',
       'chm file' => 'chm_file',
 	  'Header file' => 'header',
-	  'Distribution Policy' => 'distpol'
+	  'Distribution Policy' => 'distpol',
+	  'Rofs image' => 'img'
      );
 
 
@@ -83,7 +84,8 @@
       ignore => {filter => \&FilterAll},
       chm_file => {expandor => 'hh -decompile %TEMPDIR% %FILE%', rawretry => 1},
 	  header => {filter => \&FilterCVSTags},
-	  distpol => {filter => \&DistributionPolicyFilter}
+	  distpol => {filter => \&DistributionPolicyFilter},
+      img => {expandor => 'readimage -z %TEMPDIR% %FILE%', rawretry => 1}
      );
 
 
@@ -93,6 +95,7 @@
 
 my $log;
 my $verbose;
+my $keepgoing;
 my $toRoot;
 my $dumpDir;
 
@@ -108,6 +111,8 @@
   my $file2 = shift;
   $verbose = defined($_[0]) ? shift : 0;
   $log = defined($_[0]) ? shift : *STDOUT;
+  $keepgoing = defined($_[0]) ? shift : 0;
+  
   # Try binary compare first (to keep semantics the same as evalid)...
   if (DoCompareFiles($file1, $file2, 'unknown format')) {
     return 1,'identical';
@@ -240,7 +245,7 @@
     open (FILE, $file) or die "Error: Couldn't open \"$file\" for reading: $!\n";
     binmode (FILE);
     
-    while ($typeBuf =~ /^.{48}([0-9 ]{9})\x60\x0A(......)/s) {
+    while ($typeBuf =~ /^.{48}([0-9 ]{9}).\x60\x0A(......)/s) {
       # $1 is the size of the archive member, $2 is first 6 bytes of the file
       # There may be several different sorts of file in the archive, and we
       # need to scan through until we find a type we recognize:
@@ -354,6 +359,11 @@
     return "chm file";
   }
 
+  if ($typeBuf =~/^(ROFS|ROFx)/) {
+    # img file
+    return "Rofs image";
+  }
+
   if ($file =~ m/\.(iby|h|hby|hrh|oby|rsg|cpp)$/i) {
     return "Header file";
   }
@@ -811,34 +821,62 @@
           }, $tempdir2;
   
   #Work out the if the two file lists are different
+  my @tmpfiles;
   foreach my $file (sort keys %iFileList1)
   {
     if (! defined $iFileList2{$file})
     {
       # If the filename does not exist in the second filelist the compressed files cannot be the same.
       print ($log "Did not find $file in $file2\n") if ($verbose);
-      return 0;
+      if(!$keepgoing){
+      	return 0;
+      }else{
+      	push @tmpfiles, $file;
+      }
     } else {
       delete $iFileList2{$file}
     }
   }
+  foreach my $file (@tmpfiles)
+  {
+   	delete $iFileList1{$file};
+  }
   
   # There are extra files in the second compressed file therefore the compressed files cannot be the same.
   if (scalar(keys %iFileList2) > 0)
   {
     print ($log "$file2 contained more files than $file1\n") if ($verbose);
-    return 0;
+    if (!$keepgoing){
+	    return 0;
+	  }else{
+	  	foreach my $file (sort keys %iFileList2){
+	  		print ($log "Dig not find $file in $file1\n") if ($verbose);
+	  	}
+	  }
   }
   
   print($log "Comparing content\n") if ($verbose);
   #filelist1 and filelist2 contain all the same filenames, now compare the contents of each file
-  my $same = -1; # Variable to store collated result of comparison, assume an error
+  my $same = 1; # Variable to store collated result of comparison, assume an error
   foreach my $file (keys %iFileList1)
   {
-    my $type; 
-    ($same, $type) = CompareFiles($tempdir1.$file,$tempdir2.$file, $verbose, $log);
-    print ($log "Comparing $tempdir1.$file against $tempdir2.$file\n") if ($verbose);
-    last if ($same == 0); # do not bother comparing more files if one of the expanded files is different.
+  	my $tmpsame;
+  	my $type;
+    ($tmpsame, $type) = CompareFiles($tempdir1.$file,$tempdir2.$file, $verbose, $log, $keepgoing);
+    print ($log "Comparing $tempdir1.$file against $tempdir2.$file, $tmpsame, $keepgoing\n") if ($verbose);
+    if (!$keepgoing){
+	    if ($tmpsame == 0){ # do not bother comparing more files if one of the expanded files is different.
+	    	$same = 0;
+	    	last;
+	    }
+	  }else{
+	  	if ($tmpsame == 0){
+	  		print ($log "Failed\n\n") if ($verbose);
+	  		$same = 0;
+	  	}else{
+	  		print ($log "OK\n\n") if ($verbose);
+	  	}
+	  }
   }
   
   #Cleanup the temporary directories