]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cdrom.cc
apt-pkg/depcache.cc: Really release action groups only once (Closes: #622744)
[apt.git] / apt-pkg / cdrom.cc
index e3e0027fcadfad9004388322b613643d93ccde13..36a1d7f12c3be7af2b0d63b7c36d04de8ca9a435 100644 (file)
@@ -198,7 +198,7 @@ int pkgCdrom::Score(string Path)
    // a symlink gets a big penalty
    struct stat Buf;
    string statPath = flNotFile(Path);
-   string cdromPath = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   string cdromPath = _config->FindDir("Acquire::cdrom::mount");
    while(statPath != cdromPath && statPath != "./") {
       statPath.resize(statPath.size()-1);  // remove the trailing '/'
       if (lstat(statPath.c_str(),&Buf) == 0) {
@@ -229,7 +229,7 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
       // Between Start and End is the architecture
       Start += 8;
       if ((End = strstr(Start,"/")) != 0 && Start != End &&
-          APT::Configuration::checkArchitecture(string(Start, --End)) == true)
+          APT::Configuration::checkArchitecture(string(Start, End)) == true)
         continue; // okay, architecture is accepted
 
       // not accepted -> Erase it
@@ -509,7 +509,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)            /*{{{*/
    stringstream msg;
 
    // Startup
-   string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   string CDROM = _config->FindDir("Acquire::cdrom::mount");
    if (CDROM[0] == '.')
       CDROM= SafeGetCWD() + '/' + CDROM;
 
@@ -568,7 +568,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)                                     /*{{{*/
    stringstream msg;
 
    // Startup
-   string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   string CDROM = _config->FindDir("Acquire::cdrom::mount");
    if (CDROM[0] == '.')
       CDROM= SafeGetCWD() + '/' + CDROM;
    
@@ -854,6 +854,9 @@ pkgUdevCdromDevices::Dlopen()                                       /*{{{*/
    libudev_handle = h;
    udev_new = (udev* (*)(void)) dlsym(h, "udev_new");
    udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property");
+#if 0 // FIXME: uncomment on next ABI break
+   udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_sysattr");
+#endif
    udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices");
    udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry");
    udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath");
@@ -867,8 +870,20 @@ pkgUdevCdromDevices::Dlopen()                                      /*{{{*/
    return true;
 }
                                                                        /*}}}*/
+
+                                                                        /*{{{*/
+// compatiblity only with the old API/ABI, can be removed on the next
+// ABI break
+vector<CdromDevice>
+pkgUdevCdromDevices::Scan()
+{ 
+   bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true);
+   return ScanForRemovable(CdromOnly); 
+};
+                                                                       /*}}}*/
+                                                                        /*{{{*/
 vector<CdromDevice>
-pkgUdevCdromDevices::Scan()                                             /*{{{*/
+pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
 {
    vector<CdromDevice> cdrom_devices;
    struct udev_enumerate *enumerate;
@@ -880,7 +895,15 @@ pkgUdevCdromDevices::Scan()                                             /*{{{*/
 
    udev_ctx = udev_new();
    enumerate = udev_enumerate_new (udev_ctx);
-   udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
+   if (CdromOnly)
+      udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
+   else {
+#if 1 // FIXME: remove the next two lines on the next ABI break
+      int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
+      udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(libudev_handle, "udev_enumerate_add_match_sysattr");
+#endif
+      udev_enumerate_add_match_sysattr(enumerate, "removable", "1");
+   }
 
    udev_enumerate_scan_devices (enumerate);
    devices = udev_enumerate_get_list_entry (enumerate);
@@ -892,11 +915,18 @@ pkgUdevCdromDevices::Scan()                                             /*{{{*/
       if (udevice == NULL)
         continue;
       const char* devnode = udev_device_get_devnode(udevice);
-      const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR");
+
+      // try fstab_dir first
+      string mountpath;
+      const char* mp = udev_device_get_property_value(udevice, "FSTAB_DIR");
+      if (mp)
+         mountpath = string(mp);
+      else
+         mountpath = FindMountPointForDevice(devnode);
 
       // fill in the struct
       cdrom.DeviceName = string(devnode);
-      if (mountpath) {
+      if (mountpath != "") {
         cdrom.MountPath = mountpath;
         string s = string(mountpath);
         cdrom.Mounted = IsMounted(s);