diff -ur apt-0.5.4.orig/apt-pkg/contrib/cdromutl.cc apt-0.5.4/apt-pkg/contrib/cdromutl.cc
--- apt-0.5.4.orig/apt-pkg/contrib/cdromutl.cc	Tue Feb 20 09:03:17 2001
+++ apt-0.5.4/apt-pkg/contrib/cdromutl.cc	Sun Oct 27 03:36:35 2002
@@ -29,6 +29,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <iostream>
+#include <fstream>
 									/*}}}*/
 
 // IsMounted - Returns true if the mount point is mounted		/*{{{*/
@@ -142,45 +144,77 @@
    from effecting the outcome. */
 bool IdentCdrom(string CD,string &Res,unsigned int Version)
 {
+   using std::ifstream;
+   using std::ios;
+   
    MD5Summation Hash;
+   char S[4096];
 
-   string StartDir = SafeGetCWD();
-   if (chdir(CD.c_str()) != 0)
-      return _error->Errno("chdir",_("Unable to change to %s"),CD.c_str());
-   
-   DIR *D = opendir(".");
-   if (D == 0)
-      return _error->Errno("opendir",_("Unable to read %s"),CD.c_str());
-      
-   /* Run over the directory, we assume that the reader order will never
-      change as the media is read-only. In theory if the kernel did
-      some sort of wacked caching this might not be true.. */
-   char S[300];
-   for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
+   if (CD[CD.length() - 1] != '/')
+      CD += '/';
+
+   const string InfoFile = CD + ".disk/info";
+
+   if (FileExists(InfoFile))
    {
-      // Skip some files..
-      if (strcmp(Dir->d_name,".") == 0 ||
-	  strcmp(Dir->d_name,"..") == 0)
-	 continue;
+      /* Calculate CDROM ID as info file md5 sum */
 
-      if (Version <= 1)
-      {
-	 sprintf(S,"%lu",(unsigned long)Dir->d_ino);
-      }
-      else
-      {
-	 struct stat Buf;
-	 if (stat(Dir->d_name,&Buf) != 0)
-	    continue;
-	 sprintf(S,"%lu",(unsigned long)Buf.st_mtime);
+      // Open the file in binary mode
+      ifstream F(InfoFile.c_str(),ios::in | ios::binary);
+      if (F.is_open() == false)
+         return _error->Errno("ifstream::ifstream",_("Opening %s"),
+	    InfoFile.c_str());
+
+      // Read file and calculate its checksum
+      while (F.eof() == false)
+      {
+	 F.read(S,4096);
+	 const unsigned long BytesRead = F.gcount();
+	 Hash.Add((const unsigned char *)S,BytesRead);
       }
+   }
+   else
+   {
+      /* Calculate CDROM ID using old method - by considering
+         CDROM root dir entries names and their modification times */
+	 
+      string StartDir = SafeGetCWD();
+      if (chdir(CD.c_str()) != 0)
+         return _error->Errno("chdir",_("Unable to change to %s"),CD.c_str());
+   
+      DIR *D = opendir(".");
+      if (D == 0)
+         return _error->Errno("opendir",_("Unable to read %s"),CD.c_str());
       
-      Hash.Add(S);
-      Hash.Add(Dir->d_name);
-   };
+      /* Run over the directory, we assume that the reader order will never
+         change as the media is read-only. In theory if the kernel did
+         some sort of wacked caching this might not be true.. */
+      for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
+      {
+         // Skip some files..
+         if (strcmp(Dir->d_name,".") == 0 ||
+             strcmp(Dir->d_name,"..") == 0)
+            continue;
+
+         if (Version <= 1)
+         {
+            sprintf(S,"%lu",(unsigned long)Dir->d_ino);
+         }
+         else
+         {
+            struct stat Buf;
+	    if (stat(Dir->d_name,&Buf) != 0)
+               continue;
+            sprintf(S,"%lu",(unsigned long)Buf.st_mtime);
+         }
+
+         Hash.Add(S);
+         Hash.Add(Dir->d_name);
+      };
    
-   chdir(StartDir.c_str());
-   closedir(D);
+      chdir(StartDir.c_str());
+      closedir(D);
+   }
    
    // Some stats from the fsys
    if (_config->FindB("Debug::identcdrom",false) == false)
