]> git.saurik.com Git - apt.git/blobdiff - methods/cdrom.cc
More or group patches
[apt.git] / methods / cdrom.cc
index a4446576668b7d2de0280f45ce2b2b8c3af67c12..befd531a657e6529f9a5ac6275d7f2769f0808aa 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdrom.cc,v 1.9 1999/05/23 05:45:13 jgg Exp $
+// $Id: cdrom.cc,v 1.15 1999/10/02 04:14:54 jgg Exp $
 /* ######################################################################
 
    CDROM URI method for APT
@@ -20,8 +20,8 @@
 
 class CDROMMethod : public pkgAcqMethod
 {
-   Configuration Database;
    bool DatabaseLoaded;
+   ::Configuration Database;
    string CurrentID;
    
    virtual bool Fetch(FetchItem *Itm);
@@ -68,13 +68,16 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    URI Get = Itm->Uri;
    string File = Get.Path;
    FetchResult Res;
-   
+
+   bool Debug = _config->FindB("Debug::Acquire::cdrom",false);
+
    /* All IMS queries are returned as a hit, CDROMs are readonly so 
       time stamps never change */
    if (Itm->LastModified != 0)
    {
       Res.LastModified = Itm->LastModified;
       Res.IMSHit = true;
+      Res.Filename = File;
       URIDone(Res);
       return true;
    }
@@ -112,15 +115,28 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    if (CDROM[0] == '.')
       CDROM= SafeGetCWD() + '/' + CDROM;
    string NewID;
-   while (1)
+   while (CurrentID.empty() == true)
    {
-      if (IdentCdrom(CDROM,NewID) == false)
-        return false;
-   
-      // A hit
-      if (Database.Find("CD::" + NewID) == Get.Host)
-        break;
+      bool Hit = false;
+      for (unsigned int Version = 2; Version != 0; Version--)
+      {
+        if (IdentCdrom(CDROM,NewID,Version) == false)
+           return false;
+        
+        if (Debug == true)
+           clog << "ID " << Version << " " << NewID << endl;
+      
+        // A hit
+        if (Database.Find("CD::" + NewID) == Get.Host)
+        {
+           Hit = true;
+           break;
+        }       
+      }
 
+      if (Hit == true)
+        break;
+        
       // I suppose this should prompt somehow?
       if (UnmountCdrom(CDROM) == false)
         return _error->Error("Unable to unmount the CD-ROM in %s, it may still be in use.",
@@ -141,7 +157,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    if (stat(Res.Filename.c_str(),&Buf) != 0)
       return _error->Error("File not found");
    
-   CurrentID = NewID;
+   if (NewID.empty() == false)
+      CurrentID = NewID;
    Res.LastModified = Buf.st_mtime;
    Res.IMSHit = true;
    Res.Size = Buf.st_size;