apt-key del: Ignore case when checking if a keyid exists in a keyring.
[ntk/apt.git] / methods / cdrom.cc
index b0f1a15..74e2ecc 100644 (file)
@@ -8,17 +8,20 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/cdrom.h>
 #include <apt-pkg/cdromutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
 #include <apt-pkg/hashes.h>
 
+#include <string>
+#include <vector>
 #include <sys/stat.h>
-#include <unistd.h>
-#include <dlfcn.h>
 
 #include <iostream>
 #include <apti18n.h>
@@ -54,11 +57,12 @@ class CDROMMethod : public pkgAcqMethod
 CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
                                          SendConfig | NeedsCleanup |
                                          Removable), 
-                                          DatabaseLoaded(false), 
+                                          DatabaseLoaded(false),
+                                         Debug(false),
                                           MountedByApt(false)
 {
    UdevCdroms.Dlopen();
-};
+}
                                                                        /*}}}*/
 // CDROMMethod::Exit - Unmount the disc if necessary                   /*{{{*/
 // ---------------------------------------------------------------------
@@ -116,23 +120,24 @@ bool CDROMMethod::AutoDetectAndMount(const URI Get, string &NewID)
       return false;
 
    // check if we have the mount point
-   if (!FileExists("/media/apt"))
-      mkdir("/media/apt", 0755);
+   string AptMountPoint = _config->FindDir("Dir::Media::MountPath");
+   if (!FileExists(AptMountPoint))
+      mkdir(AptMountPoint.c_str(), 0750);
 
    // now try mounting
    for (unsigned int i=0; i < v.size(); i++)
    {
       if (!v[i].Mounted)
       {
-        if(MountCdrom("/media/apt", v[i].DeviceName)) 
+        if(MountCdrom(AptMountPoint, v[i].DeviceName)) 
         {
-           if (IsCorrectCD(Get, "/media/apt", NewID))
+           if (IsCorrectCD(Get, AptMountPoint, NewID))
            {
               MountedByApt = true;
-              CDROM = "/media/apt";
+              CDROM = AptMountPoint;
               return true;
            } else {
-              UnmountCdrom("/media/apt");
+              UnmountCdrom(AptMountPoint);
            }
         }
       }
@@ -218,7 +223,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
       return true;
    }
 
-   CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true);
+   CDROM = _config->FindDir("Acquire::cdrom::mount");
    if (Debug)
       clog << "Looking for CDROM at " << CDROM << endl;
 
@@ -228,7 +234,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    string NewID;
    while (CurrentID.empty() == true)
    {
-      if (CDROM == "apt-udev-auto/") 
+      if (AutoDetect)
         AutoDetectAndMount(Get, NewID);
 
       if(!IsMounted(CDROM))
@@ -262,7 +268,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
 
    Hashes Hash;
    FileFd Fd(Res.Filename, FileFd::ReadOnly);
-   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Hash.AddFD(Fd);
    Res.TakeHashes(Hash);
 
    URIDone(Res);