From bf07dd586e9d3c5c3640511636662196357291ba Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 23 Dec 2009 14:11:59 +0100 Subject: * cmdline/apt-get.cc: - fix apt-get source pkg=version regression (closes: #561971) --- cmdline/apt-get.cc | 24 +++++++++++++++++------- debian/changelog | 2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index f84c82d28..dede0137e 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1299,31 +1299,41 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { pkgRecords::Parser &Parse = Recs.Lookup(VF); Src = Parse.SourcePkg(); + // no SourcePkg name, so it is the "binary" name + if (Src.empty() == true) + Src = TmpSrc; + // no Version, so we try the Version of the SourcePkg - + // and after that the version of the binary package if (VerTag.empty() == true) VerTag = Parse.SourceVer(); + if (VerTag.empty() == true) + VerTag = Ver.VerStr(); break; } } + if (Src.empty() == false) + break; } if (Src.empty() == true) { - if (VerTag.empty() == false) - _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str()); - else + // Sources files have no codename information + if (VerTag.empty() == true && DefRel.empty() == false) _error->Warning(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str()); - VerTag.clear(); DefRel.clear(); } } - if (VerTag.empty() == true && DefRel.empty() == true) + if (Src.empty() == true) { - // if we don't have a version or default release, use the CandidateVer to find the Source + // if we don't have found a fitting package yet so we will + // choose a good candidate and proceed with that. + // Maybe we will find a source later on with the right VerTag pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg); if (Ver.end() == false) { pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList()); Src = Parse.SourcePkg(); - VerTag = Parse.SourceVer(); + if (VerTag.empty() == true) + VerTag = Parse.SourceVer(); } } } diff --git a/debian/changelog b/debian/changelog index eb50b4c78..03a467cfa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ apt (0.7.25.1) UNRELEASED; urgency=low * merged lp:~mvo/apt/history - this writes a /var/log/apt/history tagfile that contains details from the transaction (complements term.log) + * cmdline/apt-get.cc: + - fix apt-get source pkg=version regression (closes: #561971) -- Michael Vogt Fri, 18 Dec 2009 16:54:18 +0100 -- cgit v1.2.3 From 5ae004ce7a925426808635b92ec1cbaa5443bb4e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Jan 2010 20:05:11 +0100 Subject: * apt-pkg/contrib/cdromutl.cc: - fix UnmountCdrom() fails, give it a bit more time and try the umount again --- apt-pkg/contrib/cdromutl.cc | 51 ++++++++++++++++++++++++++------------------- debian/changelog | 3 +++ 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 0cf9697ac..6dce82fe1 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -64,35 +64,44 @@ bool UnmountCdrom(string Path) { if (IsMounted(Path) == false) return true; - - int Child = ExecFork(); - // The child - if (Child == 0) + for (int i=0;i<3;i++) { - // Make all the fds /dev/null - for (int I = 0; I != 3; I++) - dup2(open("/dev/null",O_RDWR),I); + + int Child = ExecFork(); - if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true) + // The child + if (Child == 0) { - if (system(_config->Find("Acquire::cdrom::"+Path+"::UMount").c_str()) != 0) + // Make all the fds /dev/null + for (int I = 0; I != 3; I++) + dup2(open("/dev/null",O_RDWR),I); + + if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true) + { + if (system(_config->Find("Acquire::cdrom::"+Path+"::UMount").c_str()) != 0) + _exit(100); + _exit(0); + } + else + { + const char *Args[10]; + Args[0] = "umount"; + Args[1] = Path.c_str(); + Args[2] = 0; + execvp(Args[0],(char **)Args); _exit(100); - _exit(0); + } } - else - { - const char *Args[10]; - Args[0] = "umount"; - Args[1] = Path.c_str(); - Args[2] = 0; - execvp(Args[0],(char **)Args); - _exit(100); - } + + // if it can not be umounted, give it a bit more time + // this can happen when auto-mount magic or fs/cdrom prober attack + if (ExecWait(Child,"umount",true) == true) + return true; + sleep(1); } - // Wait for mount - return ExecWait(Child,"umount",true); + return false; } /*}}}*/ // MountCdrom - Mount a cdrom /*{{{*/ diff --git a/debian/changelog b/debian/changelog index 03a467cfa..5bb90cc1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,9 @@ apt (0.7.25.1) UNRELEASED; urgency=low from the transaction (complements term.log) * cmdline/apt-get.cc: - fix apt-get source pkg=version regression (closes: #561971) + * apt-pkg/contrib/cdromutl.cc: + - fix UnmountCdrom() fails, give it a bit more time and try + the umount again -- Michael Vogt Fri, 18 Dec 2009 16:54:18 +0100 -- cgit v1.2.3 From bf783d9044cb5c9e851fbf10c9bb7e6192b13afd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Jan 2010 21:21:30 +0100 Subject: * methods/cdrom.cc: - fixes in multi cdrom setup code --- debian/changelog | 2 ++ methods/cdrom.cc | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5bb90cc1d..b499d7298 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ apt (0.7.25.1) UNRELEASED; urgency=low * apt-pkg/contrib/cdromutl.cc: - fix UnmountCdrom() fails, give it a bit more time and try the umount again + * methods/cdrom.cc: + - fixes in multi cdrom setup code -- Michael Vogt Fri, 18 Dec 2009 16:54:18 +0100 diff --git a/methods/cdrom.cc b/methods/cdrom.cc index 9802eb46c..763547013 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -37,8 +37,8 @@ class CDROMMethod : public pkgAcqMethod bool MountedByApt; pkgUdevCdromDevices UdevCdroms; - bool IsCorrectCD(URI want, string MountPath); - bool AutoDetectAndMount(URI); + bool IsCorrectCD(URI want, string MountPath, string& NewID); + bool AutoDetectAndMount(URI, string &NewID); virtual bool Fetch(FetchItem *Itm); string GetID(string Name); virtual void Exit(); @@ -92,7 +92,7 @@ string CDROMMethod::GetID(string Name) // CDROMMethod::AutoDetectAndMount /*{{{*/ // --------------------------------------------------------------------- /* Modifies class varaiable CDROM to the mountpoint */ -bool CDROMMethod::AutoDetectAndMount(URI Get) +bool CDROMMethod::AutoDetectAndMount(URI Get, string NewID) { vector v = UdevCdroms.Scan(); @@ -103,7 +103,7 @@ bool CDROMMethod::AutoDetectAndMount(URI Get) { if (Debug) clog << "Checking mounted cdrom device " << v[i].DeviceName << endl; - if (IsCorrectCD(Get, v[i].MountPath)) + if (IsCorrectCD(Get, v[i].MountPath, NewID)) { CDROM = v[i].MountPath; return true; @@ -126,7 +126,7 @@ bool CDROMMethod::AutoDetectAndMount(URI Get) { if(MountCdrom("/media/apt", v[i].DeviceName)) { - if (IsCorrectCD(Get, "/media/apt")) + if (IsCorrectCD(Get, "/media/apt", NewID)) { MountedByApt = true; CDROM = "/media/apt"; @@ -144,10 +144,8 @@ bool CDROMMethod::AutoDetectAndMount(URI Get) // CDROMMethod::IsCorrectCD /*{{{*/ // --------------------------------------------------------------------- /* */ -bool CDROMMethod::IsCorrectCD(URI want, string MountPath) +bool CDROMMethod::IsCorrectCD(URI want, string MountPath, string& NewID) { - string NewID; - for (unsigned int Version = 2; Version != 0; Version--) { if (IdentCdrom(MountPath,NewID,Version) == false) @@ -226,17 +224,17 @@ bool CDROMMethod::Fetch(FetchItem *Itm) if (CDROM[0] == '.') CDROM= SafeGetCWD() + '/' + CDROM; - string NewID; + string NewID; while (CurrentID.empty() == true) { if (CDROM == "apt-udev-auto/") - AutoDetectAndMount(Get); + AutoDetectAndMount(Get, NewID); if(!IsMounted(CDROM)) MountedByApt = MountCdrom(CDROM); - if (IsCorrectCD(Get, CDROM)) + if (IsCorrectCD(Get, CDROM, NewID)) break; // I suppose this should prompt somehow? -- cgit v1.2.3 From ff1e4b0626d8ce567492ccadbd30dfc32d4c15f1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jan 2010 11:27:58 +0100 Subject: add new "Acquire::cdrom::AutoDetect" variable that enables/disables the dlopen of libudev for automatic cdrom detection --- debian/changelog | 2 ++ doc/examples/configure-index | 4 ++++ methods/cdrom.cc | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b499d7298..7e38cda99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ apt (0.7.25.1) UNRELEASED; urgency=low the umount again * methods/cdrom.cc: - fixes in multi cdrom setup code + - add new "Acquire::cdrom::AutoDetect" variable that enables/disables + the dlopen of libudev for automatic cdrom detection -- Michael Vogt Fri, 18 Dec 2009 16:54:18 +0100 diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 1e9946e1b..317acddf6 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -250,6 +250,10 @@ Acquire cdrom { + // do auto detection of the cdrom mountpoint + AutoDetect "true"; + + // cdrom mountpoint (needs to be defined in fstab if AutoDetect is not used) mount "/cdrom"; // You need the trailing slash! diff --git a/methods/cdrom.cc b/methods/cdrom.cc index 763547013..87794b052 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -218,6 +218,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm) return true; } + bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/"); if (Debug) clog << "Looking for CDROM at " << CDROM << endl; @@ -228,7 +229,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)) -- cgit v1.2.3