]> git.saurik.com Git - apt.git/blobdiff - methods/cdrom.cc
* apt-pkg/acquire-item.cc:
[apt.git] / methods / cdrom.cc
index 41eb8a0ee7be3a02263dd9dfff4c8d42f1637477..601bc11c9039037fe94b3c78fb54d67d94d2c63d 100644 (file)
@@ -30,7 +30,7 @@ class CDROMMethod : public pkgAcqMethod
    ::Configuration Database;
    string CurrentID;
    string CDROM;
-   bool Mounted;
+   bool MountedByApt;
    
    virtual bool Fetch(FetchItem *Itm);
    string GetID(string Name);
@@ -48,7 +48,7 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
                                          SendConfig | NeedsCleanup |
                                          Removable), 
                                           DatabaseLoaded(false), 
-                                          Mounted(false)
+                                          MountedByApt(false)
 {
 };
                                                                        /*}}}*/
@@ -57,7 +57,7 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
 /* */
 void CDROMMethod::Exit()
 {
-   if (Mounted == true)
+   if (MountedByApt == true)
       UnmountCdrom(CDROM);
 }
                                                                        /*}}}*/
@@ -139,7 +139,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    while (CurrentID.empty() == true)
    {
       bool Hit = false;
-      Mounted = MountCdrom(CDROM);
+      if(!IsMounted(CDROM))
+        MountedByApt = MountCdrom(CDROM);
       for (unsigned int Version = 2; Version != 0; Version--)
       {
         if (IdentCdrom(CDROM,NewID,Version) == false)
@@ -160,14 +161,14 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
         break;
         
       // I suppose this should prompt somehow?
-      if (UnmountCdrom(CDROM) == false)
+      if (_config->FindB("APT::CDROM::NoMount",false) == false &&
+         UnmountCdrom(CDROM) == false)
         return _error->Error(_("Unable to unmount the CD-ROM in %s, it may still be in use."),
                              CDROM.c_str());
       if (MediaFail(Get.Host,CDROM) == false)
       {
         CurrentID = "FAIL";
-        Fail(_("Wrong CD-ROM"),true);
-        return true;
+        return _error->Error(_("Disk not found."));
       }
    }