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