From 33b813ce44c7bafeb2a36b66fd004f8d94a2cbe4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 Feb 2014 17:35:33 +0100 Subject: move isatty() check into InitOutput() --- cmdline/apt-get.cc | 4 ---- cmdline/apt.cc | 2 -- 2 files changed, 6 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6bff6e7de..1019ff325 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1736,10 +1736,6 @@ int main(int argc,const char *argv[]) /*{{{*/ // see if we are in simulate mode CheckSimulateMode(CmdL); - // Deal with stdout not being a tty - if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) - _config->Set("quiet","1"); - // Setup the output streams InitOutput(); diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 6fe25e3f3..6ad470faa 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -156,8 +156,6 @@ int main(int argc, const char *argv[]) /*{{{*/ << std::endl << std::endl; } - if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) - _config->Set("quiet","1"); // See if the help should be shown if (_config->FindB("help") == true || -- cgit v1.2.3 From e209542632e61b9bf07b809c333f1e4b9de7fde9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Feb 2014 18:06:28 +0100 Subject: use VersionSet in download to handle repeats Closes: 738103 --- cmdline/apt-get.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6bff6e7de..2a9964722 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -630,8 +630,8 @@ bool DoDownload(CommandLine &CmdL) return false; APT::CacheSetHelper helper(c0out); - APT::VersionList verset = APT::VersionList::FromCommandLine(Cache, - CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper); + APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache, + CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper); if (verset.empty() == true) return false; @@ -650,7 +650,7 @@ bool DoDownload(CommandLine &CmdL) std::string const cwd = SafeGetCWD(); _config->Set("Dir::Cache::Archives", cwd); int i = 0; - for (APT::VersionList::const_iterator Ver = verset.begin(); + for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver, ++i) { pkgAcquire::Item *I = new pkgAcqArchive(&Fetcher, SrcList, &Recs, *Ver, storefile[i]); -- cgit v1.2.3 From 62dcbf84c4aee8cb01e40c594d4c7f3a23b64836 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Fri, 13 Dec 2013 20:59:31 +0100 Subject: apt-cdrom should succeed if any drive succeeds If there are multiple CD-ROM drives, `apt-cdrom add` will abort with an error if any of the drives do not contain a Debian CD which is against the documentation we have saying "a CD-ROM" and also scripts do not expect it this way. This patch modifies apt-cdrom to return success if any of the drives succeeded. If failures occur, apt-cdrom will still continue trying all the drives and report the last failure (if none of them succeeded). The 'ident' command was also changed to match the new 'add' behavior. Closes: 728153 --- cmdline/apt-cdrom.cc | 76 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 17 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 17a60ddcb..20c6e8892 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -111,10 +111,12 @@ OpProgress* pkgCdromTextStatus::GetOpProgress() }; /*}}}*/ // SetupAutoDetect /*{{{*/ -bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i) +bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted) { bool Debug = _config->FindB("Debug::Acquire::cdrom", false); + automounted = false; + vector v = UdevCdroms.Scan(); if (i >= v.size()) return false; @@ -137,6 +139,8 @@ bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i) mkdir(AptMountPoint.c_str(), 0750); if(MountCdrom(AptMountPoint, v[i].DeviceName) == false) _error->Warning(_("Failed to mount '%s' to '%s'"), v[i].DeviceName.c_str(), AptMountPoint.c_str()); + else + automounted = true; _config->Set("Acquire::cdrom::mount", AptMountPoint); _config->Set("APT::CDROM::NoMount", true); } @@ -160,17 +164,35 @@ bool DoAdd(CommandLine &) bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); unsigned int count = 0; + string AptMountPoint = _config->FindDir("Dir::Media::MountPath"); + bool automounted = false; if (AutoDetect && UdevCdroms.Dlopen()) - while (AutoDetectCdrom(UdevCdroms, count)) - res &= cdrom.Add(&log); - if (count == 0) { - res = cdrom.Add(&log); - if (res == false) { - _error->Error("%s", _(W_NO_CDROM_FOUND)); + while (AutoDetectCdrom(UdevCdroms, count, automounted)) { + if (count == 1) { + // begin loop with res false to detect any success using OR + res = false; + } + + // dump any warnings/errors from autodetect + if (_error->empty() == false) + _error->DumpErrors(); + + res |= cdrom.Add(&log); + + if (automounted) + UnmountCdrom(AptMountPoint); + + // dump any warnings/errors from add/unmount + if (_error->empty() == false) + _error->DumpErrors(); } - } - if(res) + if (count == 0) + res = cdrom.Add(&log); + + if (res == false) + _error->Error("%s", _(W_NO_CDROM_FOUND)); + else cout << _("Repeat this process for the rest of the CDs in your set.") << endl; return res; @@ -187,18 +209,38 @@ bool DoIdent(CommandLine &) pkgCdrom cdrom; bool res = true; - bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect"); + bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); unsigned int count = 0; + string AptMountPoint = _config->FindDir("Dir::Media::MountPath"); + bool automounted = false; if (AutoDetect && UdevCdroms.Dlopen()) - while (AutoDetectCdrom(UdevCdroms, count)) - res &= cdrom.Ident(ident, &log); - if (count == 0) { - res = cdrom.Ident(ident, &log); - if (res == false) { - _error->Error("%s", _(W_NO_CDROM_FOUND)); + while (AutoDetectCdrom(UdevCdroms, count, automounted)) { + if (count == 1) { + // begin loop with res false to detect any success using OR + res = false; + } + + // dump any warnings/errors from autodetect + if (_error->empty() == false) + _error->DumpErrors(); + + res |= cdrom.Ident(ident, &log); + + if (automounted) + UnmountCdrom(AptMountPoint); + + // dump any warnings/errors from add/unmount + if (_error->empty() == false) + _error->DumpErrors(); } - } + + if (count == 0) + res = cdrom.Ident(ident, &log); + + if (res == false) + _error->Error("%s", _(W_NO_CDROM_FOUND)); + return res; } /*}}}*/ -- cgit v1.2.3 From 8f3594c3487800edc2a97af1f3290049776dc556 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Feb 2014 07:59:07 +0100 Subject: Use a APT::VersionSet instead of a VersionList Use a APT::VersionSet instead of a APT::VersionList in DoDownload() to ensure that there is only one version in the set even if the user passes multiple identical name/versions on the commandline (Bug#738103) --- cmdline/apt-get.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1019ff325..4d609104c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -630,8 +630,8 @@ bool DoDownload(CommandLine &CmdL) return false; APT::CacheSetHelper helper(c0out); - APT::VersionList verset = APT::VersionList::FromCommandLine(Cache, - CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper); + APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache, + CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper); if (verset.empty() == true) return false; @@ -650,7 +650,7 @@ bool DoDownload(CommandLine &CmdL) std::string const cwd = SafeGetCWD(); _config->Set("Dir::Cache::Archives", cwd); int i = 0; - for (APT::VersionList::const_iterator Ver = verset.begin(); + for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver, ++i) { pkgAcquire::Item *I = new pkgAcqArchive(&Fetcher, SrcList, &Recs, *Ver, storefile[i]); -- cgit v1.2.3