diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-22 18:32:08 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-22 18:32:08 +0200 |
commit | 49cb36fc56225b02b4c39aea43095de15da75217 (patch) | |
tree | 80da1358b64e770e37ce5274bd7cca7c3e9a29f8 /methods/cdrom.cc | |
parent | a6418a4b93376e0e4acf36e88eb1d0ec41e024df (diff) |
methods/cdrom.cc: move the scan into the loop that waits for a CD
Diffstat (limited to 'methods/cdrom.cc')
-rw-r--r-- | methods/cdrom.cc | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/methods/cdrom.cc b/methods/cdrom.cc index cd0d4e512..a677022ad 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -121,6 +121,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm) FetchResult Res; bool Debug = _config->FindB("Debug::Acquire::cdrom",false); + if (Debug) + clog << "CDROMMethod::Fetch " << Itm->Uri << endl; /* All IMS queries are returned as a hit, CDROMs are readonly so time stamps never change */ @@ -156,54 +158,63 @@ bool CDROMMethod::Fetch(FetchItem *Itm) } // We already have a CD inserted, but it is the wrong one - if (CurrentID.empty() == false && Database.Find("CD::" + CurrentID) != Get.Host) + if (CurrentID.empty() == false && + CurrentID != "FAIL" && + Database.Find("CD::" + CurrentID) != Get.Host) { Fail(_("Wrong CD-ROM"),true); return true; } CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/"); + if (Debug) + clog << "Looking for CDROM at " << CDROM << endl; - // auto-detect mode - if (CDROM == "apt-udev-auto/") + if (CDROM[0] == '.') + CDROM= SafeGetCWD() + '/' + CDROM; + string NewID; + pkgUdevCdromDevices udev; + + while (CurrentID.empty() == true) { - pkgUdevCdromDevices udev; - if(udev.Dlopen()) + // hrm, ugly the loop here + if (CDROM == "apt-udev-auto/") { - vector<struct CdromDevice> v = udev.Scan(); - for (unsigned int i=0; i < v.size(); i++) + if(udev.Dlopen()) { - if (!v[i].Mounted) + vector<struct CdromDevice> v = udev.Scan(); + for (unsigned int i=0; i < v.size(); i++) { - if (!FileExists("/media/apt")) - mkdir("/media/apt", 0755); - if(MountCdrom("/media/apt", v[i].DeviceName)) + if (Debug) + clog << "Have cdrom device " << v[i].DeviceName << endl; + if (!v[i].Mounted) { - if (IsCorrectCD(Get, "/media/apt")) + 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)) { - MountedByApt = true; - CDROM = "/media/apt"; + CDROM = v[i].MountPath; break; - } else { - UnmountCdrom("/media/apt"); } } - } else { - if (IsCorrectCD(Get, v[i].MountPath)) - { - CDROM = v[i].MountPath; - break; - } } + } else { + _error->WarningE("udev.Dlopen() failed","foo"); } } - } - if (CDROM[0] == '.') - CDROM= SafeGetCWD() + '/' + CDROM; - string NewID; - while (CurrentID.empty() == true) - { bool Hit = false; if(!IsMounted(CDROM)) MountedByApt = MountCdrom(CDROM); |