From a0e96b87e1f9e2b924dd473b7a29272f88c461bb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Dec 2008 23:16:14 +0100 Subject: cmdline/apt-get.cc: remove --build-dep-automatic line again --- cmdline/apt-get.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 43f8ec8b8..a7221d47d 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2732,7 +2732,6 @@ int main(int argc,const char *argv[]) {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, {0,"auto-remove","APT::Get::AutomaticRemove",0}, - {0,"build-dep-automatic","APT::Get::Build-Dep-Automatic",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean}, {0,"fix-policy","APT::Get::Fix-Policy-Broken",0}, -- cgit v1.2.3 From 09fab2442c2ab9a503841d3dcd56b3c0c3efb502 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 9 Apr 2009 04:36:34 +0200 Subject: * apt-pkg/contrib/strutl.cc: - fix TimeToStr i18n (LP: #289807) * [ABI break] merge support for http redirects, thanks to Jeff Licquia and Anthony Towns * [ABI break] use int for the package IDs (thanks to Steve Cotton) * apt-pkg/pkgcache.cc: - do not run "dpkg --configure pkg" if pkg is in trigger-awaited state (LP: #322955) * methods/https.cc: - add Acquire::https::AllowRedirect support * Clarify the --help for 'purge' (LP: #243948) * cmdline/apt-get.cc - fix "apt-get source pkg" if there is a binary package and a source package of the same name but from different packages (LP: #330103) * cmdline/acqprogress.cc: - Call pkgAcquireStatus::Pulse even if quiet, so that we still get dlstatus messages on the status-fd (LP: #290234). --- cmdline/acqprogress.cc | 4 ++-- cmdline/apt-get.cc | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'cmdline') diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index a5fee1db5..b3ded4142 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -145,11 +145,11 @@ void AcqTextStatus::Stop() bandwidth and ETA indicator. */ bool AcqTextStatus::Pulse(pkgAcquire *Owner) { + pkgAcquireStatus::Pulse(Owner); + if (Quiet > 0) return true; - pkgAcquireStatus::Pulse(Owner); - enum {Long = 0,Medium,Short} Mode = Long; char Buffer[sizeof(BlankLine)]; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index a7221d47d..ccf53ed25 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1272,16 +1272,23 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, } } } - - // No source package name.. - if (Src.empty() == true) - Src = TmpSrc; - + // The best hit pkgSrcRecords::Parser *Last = 0; unsigned long Offset = 0; string Version; bool IsMatch = false; + bool MatchSrcOnly = false; + + // No source package name.. + if (Src.empty() == true) + Src = TmpSrc; + else + // if we have a source pkg name, make sure to only search + // for srcpkg names, otherwise apt gets confused if there + // is a binary package "pkg1" and a source package "pkg1" + // with the same name but that comes from different packages + MatchSrcOnly = true; // If we are matching by version then we need exact matches to be happy if (VerTag.empty() == false) @@ -1291,13 +1298,11 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, binary packages in the search */ pkgSrcRecords::Parser *Parse; SrcRecs.Restart(); - while ((Parse = SrcRecs.Find(Src.c_str(),false)) != 0) + while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) { string Ver = Parse->Version(); - // Skip name mismatches - if (IsMatch == true && Parse->Package() != Src) - continue; + ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str()); if (VerTag.empty() == false) { @@ -2632,7 +2637,7 @@ bool ShowHelp(CommandLine &CmdL) " install - Install new packages (pkg is libc6 not libc6.deb)\n" " remove - Remove packages\n" " autoremove - Remove automatically all unused packages\n" - " purge - Remove and purge packages\n" + " purge - Remove packages and config files\n" " source - Download source archives\n" " build-dep - Configure build-dependencies for source packages\n" " dist-upgrade - Distribution upgrade, see apt-get(8)\n" -- cgit v1.2.3 From f0bb64930676131f8df667e064ed8b1d1b14145b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 14 Apr 2009 14:17:40 +0200 Subject: build fixes, change version 0.7.21 --- cmdline/apt-get.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ccf53ed25..028f371b5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1301,7 +1301,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) { string Ver = Parse->Version(); - + + // show name mismatches + if (IsMatch == true && Parse->Package() != Src) ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str()); if (VerTag.empty() == false) -- cgit v1.2.3 From 55a5a46c235a30bf024fb2301066553953701cc5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Jun 2009 16:55:49 +0200 Subject: support running "--simulate" as user --- cmdline/apt-get.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 028f371b5..faad2ed6b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2788,7 +2788,18 @@ int main(int argc,const char *argv[]) ShowHelp(CmdL); return 0; } - + + // simulate user-friendly if apt-get has no root privileges + if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true) + { + cout << _("NOTE: This is only a simulation!\n" + " apt-get needs root privileges for real execution.\n" + " Keep also in mind that locking is deactivated,\n" + " so don't depend on the relevance to the real current situation!" + ) << std::endl; + _config->Set("Debug::NoLocking",true); + } + // Deal with stdout not being a tty if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1) _config->Set("quiet","1"); -- cgit v1.2.3 From 9964a721855b74b4f6008d30ebc637198776ca04 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Jun 2009 18:13:23 +0200 Subject: do not write state file in simulate mode (closes: #433007) --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index faad2ed6b..93b3a83dc 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1870,7 +1870,8 @@ bool DoInstall(CommandLine &CmdL) // cache.commit() if (AutoMarkChanged > 0 && Cache->DelCount() == 0 && Cache->InstCount() == 0 && - Cache->BadCount() == 0) + Cache->BadCount() == 0 && + _config->FindB("APT::Get::Simulate",false) == false) Cache->writeStateFile(NULL); // See if we need to prompt -- cgit v1.2.3 From 7a9f09bd66d51b92bb68f07e7fbc111df6206c93 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 30 Jun 2009 14:11:31 +0200 Subject: merged r1811..1815 from lp:~donkult/apt/experimental --- cmdline/apt-get.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 93b3a83dc..f5642c04d 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -111,6 +111,9 @@ class CacheFile : public pkgCacheFile return Open(true); } CacheFile() : List(0) {}; + ~CacheFile() { + delete[] List; + } }; /*}}}*/ -- cgit v1.2.3 From 92fcbfc16396d9a2fbde0edb0902d4ebe7ff0090 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 30 Jun 2009 21:37:30 +0200 Subject: add the various foldmarkers in apt-pkg & cmdline (no code change) --- cmdline/apt-cache.cc | 19 +++++++------------ cmdline/apt-cdrom.cc | 10 +++------- cmdline/apt-config.cc | 4 ++-- cmdline/apt-extracttemplates.cc | 4 ++-- cmdline/apt-get.cc | 18 ++++++++---------- cmdline/apt-sortpkgs.cc | 8 ++++---- 6 files changed, 26 insertions(+), 37 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 4431fd4f9..93558fa88 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -622,7 +622,7 @@ bool Depends(CommandLine &CmdL) return true; } - + /*}}}*/ // RDepends - Print out a reverse dependency tree - mbc /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -710,10 +710,7 @@ bool RDepends(CommandLine &CmdL) return true; } - /*}}}*/ - - // xvcg - Generate a graph for xvcg /*{{{*/ // --------------------------------------------------------------------- // Code contributed from Junichi Uekawa on 20 June 2002. @@ -933,8 +930,6 @@ bool XVcg(CommandLine &CmdL) return true; } /*}}}*/ - - // Dotty - Generate a graph for Dotty /*{{{*/ // --------------------------------------------------------------------- /* Dotty is the graphvis program for generating graphs. It is a fairly @@ -1270,15 +1265,16 @@ bool DisplayRecord(pkgCache::VerIterator V) return true; } /*}}}*/ -// Search - Perform a search /*{{{*/ -// --------------------------------------------------------------------- -/* This searches the package names and package descriptions for a pattern */ + struct ExDescFile { pkgCache::DescFile *Df; bool NameMatch; }; +// Search - Perform a search /*{{{*/ +// --------------------------------------------------------------------- +/* This searches the package names and package descriptions for a pattern */ bool Search(CommandLine &CmdL) { pkgCache &Cache = *GCache; @@ -1691,7 +1687,6 @@ bool Madison(CommandLine &CmdL) return true; } - /*}}}*/ // GenCaches - Call the main cache generator /*{{{*/ // --------------------------------------------------------------------- @@ -1765,8 +1760,7 @@ void CacheInitialize() _config->Set("help",false); } /*}}}*/ - -int main(int argc,const char *argv[]) +int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -1873,3 +1867,4 @@ int main(int argc,const char *argv[]) return 0; } + /*}}}*/ diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 379a433ea..342b6314a 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -40,8 +40,7 @@ using namespace std; - /*{{{*/ -class pkgCdromTextStatus : public pkgCdromStatus +class pkgCdromTextStatus : public pkgCdromStatus /*{{{*/ { protected: OpTextProgress Progress; @@ -98,9 +97,7 @@ OpProgress* pkgCdromTextStatus::GetOpProgress() { return &Progress; }; - /*}}}*/ - // DoAdd - Add a new CDROM /*{{{*/ // --------------------------------------------------------------------- /* This does the main add bit.. We show some status and things. The @@ -129,7 +126,6 @@ bool DoIdent(CommandLine &) return cdrom.Ident(ident, &log); } /*}}}*/ - // ShowHelp - Show the help screen /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -164,8 +160,7 @@ int ShowHelp() return 0; } /*}}}*/ - -int main(int argc,const char *argv[]) +int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -222,3 +217,4 @@ int main(int argc,const char *argv[]) return 0; } + /*}}}*/ diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 63fa0867c..9919a9c94 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -88,8 +88,7 @@ int ShowHelp() return 0; } /*}}}*/ - -int main(int argc,const char *argv[]) +int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -133,3 +132,4 @@ int main(int argc,const char *argv[]) return 0; } + /*}}}*/ diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index de22386b9..21ef1a050 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -348,8 +348,7 @@ bool Go(CommandLine &CmdL) return !_error->PendingError(); } /*}}}*/ - -int main(int argc, const char **argv) +int main(int argc, const char **argv) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -391,3 +390,4 @@ int main(int argc, const char **argv) return 0; } + /*}}}*/ diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index f5642c04d..97c83c9b0 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -597,7 +597,6 @@ void Stats(ostream &out,pkgDepCache &Dep) Dep.BadCount()); } /*}}}*/ - // CacheFile::NameComp - QSort compare by name /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -690,7 +689,10 @@ bool CacheFile::CheckDeps(bool AllowBroken) return true; } - + /*}}}*/ +// CheckAuth - check if each download comes form a trusted source /*{{{*/ +// --------------------------------------------------------------------- +/* */ static bool CheckAuth(pkgAcquire& Fetcher) { string UntrustedList; @@ -731,10 +733,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) return _error->Error(_("There are problems and -y was used without --force-yes")); } - - /*}}}*/ - // InstallPackages - Actually download and install the packages /*{{{*/ // --------------------------------------------------------------------- /* This displays the informative messages describing what is going to @@ -1338,7 +1337,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, return Last; } /*}}}*/ - // DoUpdate - Update the package lists /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -1460,7 +1458,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } return true; } - + /*}}}*/ // DoUpgrade - Upgrade all packages /*{{{*/ // --------------------------------------------------------------------- /* Upgrade all packages without installing new packages or erasing old @@ -1535,7 +1533,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, regfree(&Pattern); return res; } - + /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -2702,8 +2700,7 @@ void SigWinch(int) #endif } /*}}}*/ - -int main(int argc,const char *argv[]) +int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -2835,3 +2832,4 @@ int main(int argc,const char *argv[]) return 0; } + /*}}}*/ diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 7b2a74aed..171b0ba13 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -31,7 +31,7 @@ using namespace std; -struct PkgName +struct PkgName /*{{{*/ { string Name; string Ver; @@ -55,7 +55,7 @@ struct PkgName bool operator >(const PkgName &x) const {return Compare3(x) > 0;}; bool operator ==(const PkgName &x) const {return Compare3(x) == 0;}; }; - + /*}}}*/ // DoIt - Sort a single file /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -161,8 +161,7 @@ int ShowHelp() return 0; } /*}}}*/ - -int main(int argc,const char *argv[]) +int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -206,3 +205,4 @@ int main(int argc,const char *argv[]) return 0; } + /*}}}*/ -- cgit v1.2.3 From e68ca100711326895126dc1fca86a2124a8e8d63 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 6 Jul 2009 15:46:54 +0200 Subject: Support /etc/apt/preferences.d (Closes: #535512) --- cmdline/apt-cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 4431fd4f9..acef8dc5e 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -401,7 +401,7 @@ bool DumpAvail(CommandLine &Cmd) pkgCache &Cache = *GCache; pkgPolicy Plcy(&Cache); - if (ReadPinFile(Plcy) == false) + if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false) return false; unsigned long Count = Cache.HeaderP->PackageCount+1; @@ -1515,7 +1515,7 @@ bool Policy(CommandLine &CmdL) pkgCache &Cache = *GCache; pkgPolicy Plcy(&Cache); - if (ReadPinFile(Plcy) == false) + if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false) return false; // Print out all of the package files -- cgit v1.2.3 From ecf59bfcf3ca573aa15a44086a7852d1308ff1ad Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 7 Jul 2009 19:23:04 +0200 Subject: [apt-get] add possibility to hide the user simulation note --- cmdline/apt-get.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 97c83c9b0..2ca0855b6 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2793,11 +2793,12 @@ int main(int argc,const char *argv[]) /*{{{*/ // simulate user-friendly if apt-get has no root privileges if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true) { - cout << _("NOTE: This is only a simulation!\n" - " apt-get needs root privileges for real execution.\n" - " Keep also in mind that locking is deactivated,\n" - " so don't depend on the relevance to the real current situation!" - ) << std::endl; + if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true) + cout << _("NOTE: This is only a simulation!\n" + " apt-get needs root privileges for real execution.\n" + " Keep also in mind that locking is deactivated,\n" + " so don't depend on the relevance to the real current situation!" + ) << std::endl; _config->Set("Debug::NoLocking",true); } -- cgit v1.2.3 From 8dfb8a0ab2c2a06e319678701c144e5156d7e869 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Jul 2009 15:28:21 +0200 Subject: * cmdline/apt-get.cc: - honor APT::Get::Only-Source properly in FindSrc() (thanks to Martin Pitt for reporting the problem) --- cmdline/apt-get.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 27e16d3f3..2693bd968 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1260,7 +1260,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, /* Lookup the version of the package we would install if we were to install a version and determine the source package name, then look in the archive for a source package of the same name. */ - if (_config->FindB("APT::Get::Only-Source") == false) + bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source"); + if (MatchSrcOnly == false) { if (Pkg.end() == false) { @@ -1278,7 +1279,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, unsigned long Offset = 0; string Version; bool IsMatch = false; - bool MatchSrcOnly = false; // No source package name.. if (Src.empty() == true) -- cgit v1.2.3 From 03dbbc98ba48eeb7c360c7fb02f21cdc9cd86465 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 31 Jul 2009 18:52:16 +0200 Subject: [cmdline/apt-get.cc] add APT::Get::HideAutoRemove=small to display only a short line instead of the full package list. (Closes: #537450) --- cmdline/apt-get.cc | 58 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ab6dca388..d3972ad81 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1400,20 +1400,29 @@ bool DoAutomaticRemove(CacheFile &Cache) bool Debug = _config->FindI("Debug::pkgAutoRemove",false); bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false); bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove"); - pkgDepCache::ActionGroup group(*Cache); + pkgDepCache::ActionGroup group(*Cache); if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; - if (_config->FindB("APT::Get::Remove",true) == false && - doAutoRemove == true) + // we don't want to autoremove and we don't want to see it, so why calculating? + if (doAutoRemove == false && hideAutoRemove == true) + return true; + + if (doAutoRemove == true && + _config->FindB("APT::Get::Remove",true) == false) { c1out << _("We are not supposed to delete stuff, can't start " "AutoRemover") << std::endl; - doAutoRemove = false; + return false; } + bool purgePkgs = _config->FindB("APT::Get::Purge", false); + bool smallList = (hideAutoRemove == false && + strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0); + string autoremovelist, autoremoveversions; + unsigned long autoRemoveCount = 0; // look over the cache to see what can be removed for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { @@ -1422,30 +1431,43 @@ bool DoAutomaticRemove(CacheFile &Cache) if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) if(Debug) std::cout << "We could delete %s" << Pkg.Name() << std::endl; - - // only show stuff in the list that is not yet marked for removal - if(Cache[Pkg].Delete() == false) - { - autoremovelist += string(Pkg.Name()) + " "; - autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; - } + if (doAutoRemove) { if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) - Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false)); + Cache->MarkDelete(Pkg, purgePkgs); else Cache->MarkKeep(Pkg, false, false); } + else + { + // only show stuff in the list that is not yet marked for removal + if(Cache[Pkg].Delete() == false) + { + // we don't need to fill the strings if we don't need them + if (smallList == true) + ++autoRemoveCount; + else + { + autoremovelist += string(Pkg.Name()) + " "; + autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; + } + } + } } } - if (!hideAutoRemove) - ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); - if (!doAutoRemove && !hideAutoRemove && autoremovelist.size() > 0) + // if we don't remove them, we should show them! + if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0)) + { + if (smallList == false) + ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + else + ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount); c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; - - // Now see if we destroyed anything - if (Cache->BrokenCount() != 0) + } + // Now see if we had destroyed anything (if we had done anything) + else if (Cache->BrokenCount() != 0) { c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n" "shouldn't happen. Please file a bug report against apt.") << endl; -- cgit v1.2.3 From 0dae8ac5f8a3092057a80d932ae4e55c1e7d3ca5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 31 Jul 2009 20:29:50 +0200 Subject: [cmdline/apt-get.cc] ShowBroken() in build-dep (Closes: #145916) Patch from Mike O'Connor, thanks! --- cmdline/apt-get.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d3972ad81..ebb634b4f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2572,7 +2572,10 @@ bool DoBuildDep(CommandLine &CmdL) // Now we check the state of the packages, if (Cache->BrokenCount() != 0) - return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I); + { + ShowBroken(cout, Cache, false); + return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I); + } } if (InstallPackages(Cache, false, true) == false) -- cgit v1.2.3 From 034960416c99c4737f99536c55b77cc9a27b8d66 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 8 Aug 2009 12:40:00 +0200 Subject: [cmdline/apt-cache.cc] fix a memory leak in the xvcg method Patch from George Danchev, thanks (Closes: #511557) --- cmdline/apt-cache.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 0e950310b..7d7f58a62 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -929,7 +929,11 @@ bool XVcg(CommandLine &CmdL) Shapes[ShapeMap[Pkg->ID]]); } - + + delete[] Show; + delete[] Flags; + delete[] ShapeMap; + printf("}\n"); return true; } -- cgit v1.2.3 From f64196e879103151f3b90ba423dc74ef61ea8c76 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Aug 2009 10:21:00 +0200 Subject: [cmdline/apt-get.cc] check for availability ofstatfs.f_type Patch from Robert Millan, thanks! (Closes: #509313) --- cmdline/apt-get.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ebb634b4f..384953a6b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -868,8 +868,11 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) { struct statfs Stat; - if (statfs(OutputDir.c_str(),&Stat) != 0 || - unsigned(Stat.f_type) != RAMFS_MAGIC) + if (statfs(OutputDir.c_str(),&Stat) != 0 +#if HAVE_STRUCT_STATFS_F_TYPE + || unsigned(Stat.f_type) != RAMFS_MAGIC +#endif + ) return _error->Error(_("You don't have enough free space in %s."), OutputDir.c_str()); } @@ -2201,8 +2204,11 @@ bool DoSource(CommandLine &CmdL) if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) { struct statfs Stat; - if (statfs(OutputDir.c_str(),&Stat) != 0 || - unsigned(Stat.f_type) != RAMFS_MAGIC) + if (statfs(OutputDir.c_str(),&Stat) != 0 +#if HAVE_STRUCT_STATFS_F_TYPE + || unsigned(Stat.f_type) != RAMFS_MAGIC +#endif + ) return _error->Error(_("You don't have enough free space in %s"), OutputDir.c_str()); } -- cgit v1.2.3 From 717ec7d41a232a1571f98e1efe2ff3c71d94968f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Aug 2009 13:43:21 +0200 Subject: [cmdline/apt-get.cc] correct the order of picked package binary vs source in the source command in the msg "No source package x picking y instead" --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 384953a6b..34ffaf11a 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1309,7 +1309,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // show name mismatches if (IsMatch == true && Parse->Package() != Src) - ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str()); + ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Src.c_str(), Parse->Package().c_str()); if (VerTag.empty() == false) { -- cgit v1.2.3 From 619596fcd20e3fda2ab352103cfeb9437015dfbc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Aug 2009 13:17:36 +0200 Subject: [cmdline/apt-get.cc] - use SourceVersion instead of the BinaryVersion to get the source Patch by Matt Kraai, thanks! (Closes: #382826) --- cmdline/apt-get.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 34ffaf11a..71566fd55 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1255,7 +1255,10 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, //std::cout << VF.File().Archive() << std::endl; if(VF.File().Archive() && (VF.File().Archive() == DefRel)) { - VerTag = Ver.VerStr(); + pkgRecords::Parser &Parse = Recs.Lookup(VF); + VerTag = Parse.SourceVer(); + if (VerTag.empty()) + VerTag = Ver.VerStr(); break; } } -- cgit v1.2.3 From ebf6c42d9db4766c315ea15f25c4a7a9a799660b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Aug 2009 14:52:43 +0200 Subject: Add the pkg/release syntax to the source command in apt-get and also add the understanding for codenames instead of archives here [cmdline/apt-get.cc] - add pkg/archive and codename in source (Closes: #414105, #441178) --- cmdline/apt-get.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 71566fd55..1582fff85 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1220,17 +1220,25 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { // We want to pull the version off the package specification.. string VerTag; + string DefRel; string TmpSrc = Name; - string::size_type Slash = TmpSrc.rfind('='); + const size_t found = TmpSrc.find_last_of("/="); // honor default release - string DefRel = _config->Find("APT::Default-Release"); + if (found != string::npos && TmpSrc[found] == '/') + { + DefRel = TmpSrc.substr(found+1); + TmpSrc = TmpSrc.substr(0,found); + } + else + DefRel = _config->Find("APT::Default-Release"); + pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc); - if (Slash != string::npos) + if (found != string::npos && TmpSrc[found] == '=') { - VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end()); - TmpSrc = string(TmpSrc.begin(),TmpSrc.begin() + Slash); + VerTag = TmpSrc.substr(found+1); + TmpSrc = TmpSrc.substr(0,found); } else if(!Pkg.end() && DefRel.empty() == false) { @@ -1252,8 +1260,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) continue; - //std::cout << VF.File().Archive() << std::endl; - if(VF.File().Archive() && (VF.File().Archive() == DefRel)) + if((VF.File().Archive() != 0 && VF.File().Archive() == DefRel) || + (VF.File().Codename() != 0 && VF.File().Codename() == DefRel)) { pkgRecords::Parser &Parse = Recs.Lookup(VF); VerTag = Parse.SourceVer(); -- cgit v1.2.3 From 364af2ef2aba2911b12379ec8b6e55874e4b0a31 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 24 Sep 2009 11:55:46 +0200 Subject: * cmdline/apt-key: - Emit a warning if removed keys keyring is missing and skip associated checks (LP: #218971) --- cmdline/apt-key | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index 7bb30240e..5f4e02fdf 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -93,13 +93,17 @@ update() { # add any security. we *need* this check on net-update though $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import - # remove no-longer supported/used keys - keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5` - for key in $keys; do - if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then - $GPG --quiet --batch --delete-key --yes ${key} - fi - done + if [ -r "$REMOVED_KEYS" ]; then + # remove no-longer supported/used keys + keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5` + for key in $keys; do + if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then + $GPG --quiet --batch --delete-key --yes ${key} + fi + done + else + echo "Warning: removed keys keyring $REMOVED_KEYS missing or not readable" >&2 + fi } -- cgit v1.2.3 From 5e62aac041d57ecbfd07c7e1ec7822d5fbbba522 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 24 Sep 2009 12:58:38 +0200 Subject: When selecting a real package instead of a virtual one, ignore versions for the same package that are not candidates. This allows us to survive repositories that contain more than one version of a package. Bugreport #547788 and patch by Marius Vollmer, thanks! --- cmdline/apt-get.cc | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1582fff85..c32d67226 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1049,17 +1049,42 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, unsigned int &ExpectedInst,bool AllowFail = true) { - /* This is a pure virtual package and there is a single available - provides */ - if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 && - Pkg.ProvidesList()->NextProvides == 0) + /* This is a pure virtual package and there is a single available + candidate providing it. */ + if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0) { - pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg(); - ioprintf(c1out,_("Note, selecting %s instead of %s\n"), - Tmp.Name(),Pkg.Name()); - Pkg = Tmp; + pkgCache::PkgIterator Prov; + bool found_one = false; + + for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; P++) + { + pkgCache::VerIterator const PVer = P.OwnerVer(); + pkgCache::PkgIterator const PPkg = PVer.ParentPkg(); + + /* Ignore versions that are not a candidate. */ + if (Cache[PPkg].CandidateVer != PVer) + continue; + + if (found_one == false) + { + Prov = PPkg; + found_one = true; + } + else if (PPkg != Prov) + { + found_one = false; // we found at least two + break; + } + } + + if (found_one == true) + { + ioprintf(c1out,_("Note, selecting %s instead of %s\n"), + Prov.Name(),Pkg.Name()); + Pkg = Prov; + } } - + // Handle the no-upgrade case if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0) -- cgit v1.2.3 From cdd5a135d9232123dc3650ed1c1cb31d1e24de0b Mon Sep 17 00:00:00 2001 From: "bubulle@debian.org" <> Date: Sat, 26 Sep 2009 19:45:15 +0200 Subject: Fix some typos from #479997 --- cmdline/apt-cdrom.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 342b6314a..d804c55e5 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -74,7 +74,7 @@ string pkgCdromTextStatus::PromptLine(const char *Text) bool pkgCdromTextStatus::AskCdromName(string &name) { - cout << _("Please provide a name for this Disc, such as 'Debian 2.1r1 Disk 1'") << flush; + cout << _("Please provide a name for this Disc, such as 'Debian 5.0.3 Disk 1'") << flush; name = PromptLine(""); return true; -- cgit v1.2.3 From 9c876fe428588d155533b40f95265beaee03fc88 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Oct 2009 21:10:09 +0200 Subject: rewrite FindSrc() in cmdline/apt-get.cc to fix some bugs, including: * cmdline/apt-get.cc: - source should displays his final pkg pick (Closes: #249383, #550952) - source doesn't need the complete version for match (Closes: #245250) - source ignores versions/releases if not available (Closes: #377424) --- cmdline/apt-get.cc | 256 ++++++++++++++++++++++++++--------------------------- 1 file changed, 125 insertions(+), 131 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c32d67226..ca14f4c2b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1243,137 +1243,131 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, pkgSrcRecords &SrcRecs,string &Src, pkgDepCache &Cache) { - // We want to pull the version off the package specification.. - string VerTag; - string DefRel; - string TmpSrc = Name; - const size_t found = TmpSrc.find_last_of("/="); - - // honor default release - if (found != string::npos && TmpSrc[found] == '/') - { - DefRel = TmpSrc.substr(found+1); - TmpSrc = TmpSrc.substr(0,found); - } - else - DefRel = _config->Find("APT::Default-Release"); - - pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc); - - if (found != string::npos && TmpSrc[found] == '=') - { - VerTag = TmpSrc.substr(found+1); - TmpSrc = TmpSrc.substr(0,found); - } - else if(!Pkg.end() && DefRel.empty() == false) - { - // we have a default release, try to locate the pkg. we do it like - // this because GetCandidateVer() will not "downgrade", that means - // "apt-get source -t stable apt" won't work on a unstable system - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; - Ver++) - { - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; - VF++) - { - /* If this is the status file, and the current version is not the - version in the status file (ie it is not installed, or somesuch) - then it is not a candidate for installation, ever. This weeds - out bogus entries that may be due to config-file states, or - other. */ - if ((VF.File()->Flags & pkgCache::Flag::NotSource) == - pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) - continue; - - if((VF.File().Archive() != 0 && VF.File().Archive() == DefRel) || - (VF.File().Codename() != 0 && VF.File().Codename() == DefRel)) - { - pkgRecords::Parser &Parse = Recs.Lookup(VF); - VerTag = Parse.SourceVer(); - if (VerTag.empty()) - VerTag = Ver.VerStr(); - break; - } - } - } - } - - /* Lookup the version of the package we would install if we were to - install a version and determine the source package name, then look - in the archive for a source package of the same name. */ - bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source"); - if (MatchSrcOnly == false) - { - if (Pkg.end() == false) - { - pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg); - if (Ver.end() == false) - { - pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList()); - Src = Parse.SourcePkg(); - } - } - } - - // The best hit - pkgSrcRecords::Parser *Last = 0; - unsigned long Offset = 0; - string Version; - bool IsMatch = false; - - // No source package name.. - if (Src.empty() == true) - Src = TmpSrc; - else - // if we have a source pkg name, make sure to only search - // for srcpkg names, otherwise apt gets confused if there - // is a binary package "pkg1" and a source package "pkg1" - // with the same name but that comes from different packages - MatchSrcOnly = true; - - // If we are matching by version then we need exact matches to be happy - if (VerTag.empty() == false) - IsMatch = true; - - /* Iterate over all of the hits, which includes the resulting - binary packages in the search */ - pkgSrcRecords::Parser *Parse; - SrcRecs.Restart(); - while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) - { - string Ver = Parse->Version(); - - // show name mismatches - if (IsMatch == true && Parse->Package() != Src) - ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Src.c_str(), Parse->Package().c_str()); - - if (VerTag.empty() == false) - { - /* Don't want to fall through because we are doing exact version - matching. */ - if (Cache.VS().CmpVersion(VerTag,Ver) != 0) - continue; - - Last = Parse; - Offset = Parse->Offset(); - break; - } - - // Newer version or an exact match - if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0 || - (Parse->Package() == Src && IsMatch == false)) - { - IsMatch = Parse->Package() == Src; - Last = Parse; - Offset = Parse->Offset(); - Version = Ver; - } - } - - if (Last == 0 || Last->Jump(Offset) == false) - return 0; - - return Last; + string VerTag; + string DefRel = _config->Find("APT::Default-Release"); + string TmpSrc = Name; + const size_t found = TmpSrc.find_last_of("/="); + + // extract the version/release from the pkgname + if (found != string::npos) { + if (TmpSrc[found] == '/') + DefRel = TmpSrc.substr(found+1); + else + VerTag = TmpSrc.substr(found+1); + TmpSrc = TmpSrc.substr(0,found); + } + + /* Lookup the version of the package we would install if we were to + install a version and determine the source package name, then look + in the archive for a source package of the same name. */ + bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source"); + const pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc); + if (MatchSrcOnly == false && Pkg.end() == false) { + if(VerTag.empty() == false || DefRel.empty() == false) { + // we have a default release, try to locate the pkg. we do it like + // this because GetCandidateVer() will not "downgrade", that means + // "apt-get source -t stable apt" won't work on a unstable system + for (pkgCache::VerIterator Ver = Pkg.VersionList(); + Ver.end() == false; Ver++) { + for (pkgCache::VerFileIterator VF = Ver.FileList(); + VF.end() == false; VF++) { + /* If this is the status file, and the current version is not the + version in the status file (ie it is not installed, or somesuch) + then it is not a candidate for installation, ever. This weeds + out bogus entries that may be due to config-file states, or + other. */ + if ((VF.File()->Flags & pkgCache::Flag::NotSource) == + pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) + continue; + + // We match against a concrete version (or a part of this version) + if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0) + continue; + + // or we match against a release + if(VerTag.empty() == false || + (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) || + (VF.File().Codename() != 0 && VF.File().Codename() == DefRel)) { + pkgRecords::Parser &Parse = Recs.Lookup(VF); + Src = Parse.SourcePkg(); + if (VerTag.empty() == true) + VerTag = Parse.SourceVer(); + 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 + _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 we don't have a version or default release, use the CandidateVer to find the Source + pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg); + if (Ver.end() == false) { + pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList()); + Src = Parse.SourcePkg(); + VerTag = Parse.SourceVer(); + } + } + } + + if (Src.empty() == true) + Src = TmpSrc; + else { + /* if we have a source pkg name, make sure to only search + for srcpkg names, otherwise apt gets confused if there + is a binary package "pkg1" and a source package "pkg1" + with the same name but that comes from different packages */ + MatchSrcOnly = true; + if (Src != TmpSrc) { + ioprintf(c1out, _("Picking '%s' as source package instead of '%s'\n"), Src.c_str(), TmpSrc.c_str()); + } + } + + // The best hit + pkgSrcRecords::Parser *Last = 0; + unsigned long Offset = 0; + string Version; + + /* Iterate over all of the hits, which includes the resulting + binary packages in the search */ + pkgSrcRecords::Parser *Parse; + while (true) { + SrcRecs.Restart(); + while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) { + const string Ver = Parse->Version(); + + // Ignore all versions which doesn't fit + if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0) + continue; + + // Newer version or an exact match? Save the hit + if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0) { + Last = Parse; + Offset = Parse->Offset(); + Version = Ver; + } + + // was the version check above an exact match? If so, we don't need to look further + if (VerTag.empty() == false && VerTag.size() == Ver.size()) + break; + } + if (Last != 0 || VerTag.empty() == true) + break; + //if (VerTag.empty() == false && Last == 0) + _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str()); + VerTag.clear(); + } + + if (Last == 0 || Last->Jump(Offset) == false) + return 0; + + return Last; } /*}}}*/ // DoUpdate - Update the package lists /*{{{*/ -- cgit v1.2.3 From c1ce032acd71b8414ee8d9a1f20899f8e53388a0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Oct 2009 08:30:21 +0200 Subject: only warn if (free) space can't be determined as it overflows the struct as this prevents e.g. download operations on large RAIDs (Closes: #522238) --- cmdline/apt-get.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ca14f4c2b..49fde7466 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -862,10 +862,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, { struct statvfs Buf; string OutputDir = _config->FindDir("Dir::Cache::Archives"); - if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs",_("Couldn't determine free space in %s"), - OutputDir.c_str()); - if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) + if (statvfs(OutputDir.c_str(),&Buf) != 0) { + if (errno == EOVERFLOW) + return _error->WarningE("statvfs",_("Couldn't determine free space in %s"), + OutputDir.c_str()); + else + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), + OutputDir.c_str()); + } else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) { struct statfs Stat; if (statfs(OutputDir.c_str(),&Stat) != 0 @@ -2228,10 +2232,14 @@ bool DoSource(CommandLine &CmdL) // Check for enough free space struct statvfs Buf; string OutputDir = "."; - if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs",_("Couldn't determine free space in %s"), - OutputDir.c_str()); - if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) + if (statvfs(OutputDir.c_str(),&Buf) != 0) { + if (errno == EOVERFLOW) + return _error->WarningE("statvfs",_("Couldn't determine free space in %s"), + OutputDir.c_str()); + else + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), + OutputDir.c_str()); + } else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) { struct statfs Stat; if (statfs(OutputDir.c_str(),&Stat) != 0 -- cgit v1.2.3 From 8b8fdb116138b3adea3ce3c1fd51b3016902c8a5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Dec 2009 21:43:34 +0100 Subject: merged -r 1914..1915 from lp:~donkult/apt/sid --- cmdline/apt-mark | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-mark b/cmdline/apt-mark index 226d2079b..c44ce7038 100755 --- a/cmdline/apt-mark +++ b/cmdline/apt-mark @@ -31,8 +31,12 @@ def mark_unmark_automatic(filename, action, pkgs): " mark or unmark automatic flag" # open the statefile if os.path.exists(STATE_FILE): - tagfile = apt_pkg.ParseTagFile(open(STATE_FILE)) - outfile = open(STATE_FILE+".tmp","w") + try: + tagfile = apt_pkg.ParseTagFile(open(STATE_FILE)) + outfile = open(STATE_FILE+".tmp","w") + except IOError, msg: + print "%s, are you root?" % (msg) + sys.exit(1) while tagfile.Step(): pkgname = tagfile.Section.get("Package") autoInst = tagfile.Section.get("Auto-Installed") -- cgit v1.2.3 From 3f35be50ee4cb425b08139d4ccf5b54d527fe700 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Dec 2009 21:45:31 +0100 Subject: merged -r 1918..1919 from lp:~donkult/apt/sid --- cmdline/apt-mark | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-mark b/cmdline/apt-mark index c44ce7038..3a818a3db 100755 --- a/cmdline/apt-mark +++ b/cmdline/apt-mark @@ -2,13 +2,14 @@ from optparse import OptionParser +import sys +import os.path + try: import apt_pkg except ImportError: print "Error importing apt_pkg, is python-apt installed?" - -import sys -import os.path + sys.exit(1) actions = { "markauto" : 1, "unmarkauto": 0 -- cgit v1.2.3 From a0895a74fe95997a5d75e5b54c95afb9594554f6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Dec 2009 21:59:49 +0100 Subject: merged -r 1923..1926 from lp:~donkult/apt/sid --- cmdline/apt-get.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 52e90fc64..f84c82d28 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2811,6 +2811,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {0,"force-yes","APT::Get::force-yes",0}, {0,"print-uris","APT::Get::Print-URIs",0}, {0,"diff-only","APT::Get::Diff-Only",0}, + {0,"debian-only","APT::Get::Diff-Only",0}, {0,"tar-only","APT::Get::Tar-Only",0}, {0,"dsc-only","APT::Get::Dsc-Only",0}, {0,"purge","APT::Get::Purge",0}, -- cgit v1.2.3 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 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'cmdline') 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(); } } } -- cgit v1.2.3