+
+ CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+
+ // auto-detect mode
+ if (CDROM == "apt-udev-auto/")
+ {
+ pkgUdevCdromDevices udev;
+ if(udev.Dlopen())
+ {
+ vector<struct CdromDevice> v = udev.Scan();
+ for (unsigned int i=0; i < v.size(); i++)
+ {
+ if (!v[i].Mounted)
+ {
+ if (!FileExists("/media/apt"))
+ mkdir("/media/apt", 0755);
+ if(MountCdrom("/media/apt", v[i].DeviceName))
+ {
+ if (IsCorrectCD(Get, "/media/apt"))
+ {
+ MountedByApt = true;
+ CDROM = "/media/apt";
+ break;
+ } else {
+ UnmountCdrom("/media/apt");
+ }
+ }
+ } else {
+ if (IsCorrectCD(Get, v[i].MountPath))
+ {
+ CDROM = v[i].MountPath;
+ break;
+ }
+ }
+ }
+ }
+ }
+