From 1bb8cd67acb83921ec27a989bcb3c6dd6e0d5786 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Aug 2010 22:41:40 +0200 Subject: * cmdline/apt-get.cc: - remove direct calls of ReadMainList and use the wrapper instead to protect us from useless re-reads and two-times notice display --- cmdline/apt-get.cc | 39 ++++++++++++++++++++------------------- debian/changelog | 8 ++++++-- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9b69e9589..733788353 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1084,13 +1084,13 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return false; // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the package manager and prepare to download SPtr PM= _system->CreatePM(Cache); - if (PM->GetArchives(&Fetcher,&List,&Recs) == false || + if (PM->GetArchives(&Fetcher,List,&Recs) == false || _error->PendingError() == true) return false; @@ -1306,7 +1306,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); - if (PM->GetArchives(&Fetcher,&List,&Recs) == false) + if (PM->GetArchives(&Fetcher,List,&Recs) == false) return false; _system->Lock(); @@ -1542,11 +1542,13 @@ bool DoUpdate(CommandLine &CmdL) { if (CmdL.FileSize() != 1) return _error->Error(_("The update command takes no arguments")); - + + CacheFile Cache; + // Get the source list - pkgSourceList List; - if (List.ReadMainList() == false) + if (Cache.BuildSourceList() == false) return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the progress AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); @@ -1564,7 +1566,7 @@ bool DoUpdate(CommandLine &CmdL) // Populate it with the source selection and get all Indexes // (GetAll=true) - if (List.GetIndexes(&Fetcher,true) == false) + if (List->GetIndexes(&Fetcher,true) == false) return false; pkgAcquire::UriIterator I = Fetcher.UriBegin(); @@ -1575,9 +1577,8 @@ bool DoUpdate(CommandLine &CmdL) } // do the work - CacheFile Cache; if (_config->FindB("APT::Get::Download",true) == true) - ListUpdate(Stat, List); + ListUpdate(Stat, *List); // Rebuild the cache. if (Cache.BuildCaches() == false) @@ -2189,13 +2190,13 @@ bool DoSource(CommandLine &CmdL) return _error->Error(_("Must specify at least one package to fetch source for")); // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers pkgRecords Recs(Cache); - pkgSrcRecords SrcRecs(List); + pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; @@ -2480,13 +2481,13 @@ bool DoBuildDep(CommandLine &CmdL) return _error->Error(_("Must specify at least one package to check builddeps for")); // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers pkgRecords Recs(Cache); - pkgSrcRecords SrcRecs(List); + pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; diff --git a/debian/changelog b/debian/changelog index 41ec1b2a1..5f9384186 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,9 +14,13 @@ apt (0.8.1) UNRELEASED; urgency=low Closes: #594211 [ David Kalnischkies ] - * show in madison command again also source packages (LP: #614589) + * cmdline/apt-cache.cc: + - show in madison command again also source packages (LP: #614589) + * cmdline/apt-get.cc: + - remove direct calls of ReadMainList and use the wrapper instead + to protect us from useless re-reads and two-times notice display - -- David Kalnischkies Wed, 25 Aug 2010 17:46:48 +0200 + -- David Kalnischkies Thu, 26 Aug 2010 22:39:37 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3 From 35db2f353975cba35597592f468d20d9aed8619c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 27 Aug 2010 12:05:55 +0200 Subject: * apt-pkg/depcache.cc: - now that apt-get purge works on 'rc' packages let the MarkDelete pass this purge forward to the non-pseudo package for pseudos --- apt-pkg/depcache.cc | 11 ++++++++++- debian/changelog | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 00bf68af1..018b05e65 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1149,7 +1149,7 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, return; if (DebugMarker == true) - std::clog << OutputInDepth(Depth) << "MarkDelete " << Pkg << " FU=" << FromUser << std::endl; + std::clog << OutputInDepth(Depth) << (rPurge ? "MarkPurge " : "MarkDelete ") << Pkg << " FU=" << FromUser << std::endl; RemoveSizes(Pkg); RemoveStates(Pkg); @@ -1167,6 +1167,15 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, // if we remove the pseudo package, we also need to remove the "real" if (Pkg->CurrentVer != 0 && Pkg.CurrentVer().Pseudo() == true) MarkDelete(Pkg.Group().FindPkg("all"), rPurge, Depth+1, FromUser); + else if (rPurge == true && Pkg->CurrentVer == 0 && + Pkg->CurrentState != pkgCache::State::NotInstalled && + strcmp(Pkg.Arch(), "all") != 0) + { + PkgIterator const allPkg = Pkg.Group().FindPkg("all"); + if (allPkg.end() == false && allPkg->CurrentVer == 0 && + allPkg->CurrentState != pkgCache::State::NotInstalled) + MarkDelete(allPkg, rPurge, Depth+1, FromUser); + } } /*}}}*/ // DepCache::IsDeleteOk - check if it is ok to remove this package /*{{{*/ diff --git a/debian/changelog b/debian/changelog index 5f9384186..1c12b56e3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,8 +19,11 @@ apt (0.8.1) UNRELEASED; urgency=low * cmdline/apt-get.cc: - remove direct calls of ReadMainList and use the wrapper instead to protect us from useless re-reads and two-times notice display + * apt-pkg/depcache.cc: + - now that apt-get purge works on 'rc' packages let the MarkDelete + pass this purge forward to the non-pseudo package for pseudos - -- David Kalnischkies Thu, 26 Aug 2010 22:39:37 +0200 + -- David Kalnischkies Fri, 27 Aug 2010 12:02:15 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3 From 5edc3966e2e1eb4e94b5bd64d59c3a3a78a76ab0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Aug 2010 17:34:06 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - apply SilentlyIgnore also on files without an extension --- apt-pkg/contrib/fileutl.cc | 3 ++- debian/changelog | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 91aecee65..2b73d1424 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -309,7 +309,8 @@ std::vector GetListOfFilesInDir(string const &Dir, std::vector c { if (Debug == true) std::clog << "Bad file: " << Ent->d_name << " → no extension" << std::endl; - _error->Notice("Ignoring file '%s' in directory '%s' as it has no filename extension", Ent->d_name, Dir.c_str()); + if (SilentIgnore.Match(Ent->d_name) == false) + _error->Notice("Ignoring file '%s' in directory '%s' as it has no filename extension", Ent->d_name, Dir.c_str()); continue; } } diff --git a/debian/changelog b/debian/changelog index 1c12b56e3..781b0e6ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,8 +22,10 @@ apt (0.8.1) UNRELEASED; urgency=low * apt-pkg/depcache.cc: - now that apt-get purge works on 'rc' packages let the MarkDelete pass this purge forward to the non-pseudo package for pseudos + * apt-pkg/contrib/fileutl.cc: + - apply SilentlyIgnore also on files without an extension - -- David Kalnischkies Fri, 27 Aug 2010 12:02:15 +0200 + -- David Kalnischkies Sat, 28 Aug 2010 17:33:31 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3 From d6ff64f7068b506d82bbcfde0d9aad527f5951d0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Aug 2010 17:52:55 +0200 Subject: remove death code by removing unused GetInitialize --- cmdline/apt-get.cc | 16 ---------------- debian/changelog | 3 ++- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 733788353..d1c010e49 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2834,22 +2834,6 @@ bool ShowHelp(CommandLine &CmdL) return true; } /*}}}*/ -// GetInitialize - Initialize things for apt-get /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void GetInitialize() -{ - _config->Set("quiet",0); - _config->Set("help",false); - _config->Set("APT::Get::Download-Only",false); - _config->Set("APT::Get::Simulate",false); - _config->Set("APT::Get::Assume-Yes",false); - _config->Set("APT::Get::Fix-Broken",false); - _config->Set("APT::Get::Force-Yes",false); - _config->Set("APT::Get::List-Cleanup",true); - _config->Set("APT::Get::AutomaticRemove",false); -} - /*}}}*/ // SigWinch - Window size change signal handler /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/debian/changelog b/debian/changelog index 781b0e6ac..3c549ab9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,13 +19,14 @@ apt (0.8.1) UNRELEASED; urgency=low * cmdline/apt-get.cc: - remove direct calls of ReadMainList and use the wrapper instead to protect us from useless re-reads and two-times notice display + - remove death code by removing unused GetInitialize * apt-pkg/depcache.cc: - now that apt-get purge works on 'rc' packages let the MarkDelete pass this purge forward to the non-pseudo package for pseudos * apt-pkg/contrib/fileutl.cc: - apply SilentlyIgnore also on files without an extension - -- David Kalnischkies Sat, 28 Aug 2010 17:33:31 +0200 + -- David Kalnischkies Sat, 28 Aug 2010 17:52:36 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3 From e56aac77a45e7a9a5620be12dfae0e2296f1d560 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Aug 2010 17:54:29 +0200 Subject: remove useless GetInitialize method --- cmdline/apt-cache.cc | 11 ----------- debian/changelog | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 74a4f69c2..ba4ad1943 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1781,15 +1781,6 @@ bool ShowHelp(CommandLine &Cmd) return true; } /*}}}*/ -// CacheInitialize - Initialize things for apt-cache /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void CacheInitialize() -{ - _config->Set("quiet",0); - _config->Set("help",false); -} - /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { @@ -1841,8 +1832,6 @@ int main(int argc,const char *argv[]) /*{{{*/ {"madison",&Madison}, {0,0}}; - CacheInitialize(); - // Set up gettext support setlocale(LC_ALL,""); textdomain(PACKAGE); diff --git a/debian/changelog b/debian/changelog index 3c549ab9c..4ec71cbb6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,7 @@ apt (0.8.1) UNRELEASED; urgency=low [ David Kalnischkies ] * cmdline/apt-cache.cc: - show in madison command again also source packages (LP: #614589) + - remove useless GetInitialize method * cmdline/apt-get.cc: - remove direct calls of ReadMainList and use the wrapper instead to protect us from useless re-reads and two-times notice display @@ -26,7 +27,7 @@ apt (0.8.1) UNRELEASED; urgency=low * apt-pkg/contrib/fileutl.cc: - apply SilentlyIgnore also on files without an extension - -- David Kalnischkies Sat, 28 Aug 2010 17:52:36 +0200 + -- David Kalnischkies Sat, 28 Aug 2010 17:53:00 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3 From b093a199056673b55e6467ab9e22e8af15183c43 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Aug 2010 22:26:32 +0200 Subject: * apt-pkg/contrib/configuration.cc: - fix autoremove by using correct config-option name and don't make faulty assumptions in error handling (Closes: #594689) --- apt-pkg/contrib/configuration.cc | 14 +++++++++++--- apt-pkg/contrib/configuration.h | 1 + apt-pkg/depcache.h | 2 +- debian/changelog | 5 ++++- test/integration/test-autoremove | 31 +++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100755 test/integration/test-autoremove diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 81cc87d15..cc7093fe2 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -857,19 +857,27 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config) { regfree(p); delete p; + clearPatterns(); _error->Warning("Regex compilation error for '%s' in configuration option '%s'", s->c_str(), Config); + return; } - } - + } + if (strings.size() == 0) + patterns.push_back(NULL); } /*}}}*/ // MatchAgainstConfig Destructor /*{{{*/ Configuration::MatchAgainstConfig::~MatchAgainstConfig() +{ + clearPatterns(); +} +void Configuration::MatchAgainstConfig::clearPatterns() { for(std::vector::const_iterator p = patterns.begin(); p != patterns.end(); ++p) { + if (*p == NULL) continue; regfree(*p); delete *p; } @@ -880,7 +888,7 @@ bool Configuration::MatchAgainstConfig::Match(char const * str) const { for(std::vector::const_iterator p = patterns.begin(); p != patterns.end(); ++p) - if (regexec(*p, str, 0, 0, 0) == 0) + if (*p != NULL && regexec(*p, str, 0, 0, 0) == 0) return true; return false; diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index cbe18e4e5..175c1bef3 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -109,6 +109,7 @@ class Configuration class MatchAgainstConfig { std::vector patterns; + void clearPatterns(); public: MatchAgainstConfig(char const * Config); diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 45276dc95..08e683558 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -186,7 +186,7 @@ class pkgDepCache : protected pkgCache::Namespace class DefaultRootSetFunc : public InRootSetFunc, public Configuration::MatchAgainstConfig { public: - DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverRemove") {}; + DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverAutoRemove") {}; virtual ~DefaultRootSetFunc() {}; bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); }; diff --git a/debian/changelog b/debian/changelog index 4ec71cbb6..072c00398 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,8 +26,11 @@ apt (0.8.1) UNRELEASED; urgency=low pass this purge forward to the non-pseudo package for pseudos * apt-pkg/contrib/fileutl.cc: - apply SilentlyIgnore also on files without an extension + * apt-pkg/contrib/configuration.cc: + - fix autoremove by using correct config-option name and + don't make faulty assumptions in error handling (Closes: #594689) - -- David Kalnischkies Sat, 28 Aug 2010 17:53:00 +0200 + -- David Kalnischkies Sat, 28 Aug 2010 22:23:20 +0200 apt (0.8.0) unstable; urgency=low diff --git a/test/integration/test-autoremove b/test/integration/test-autoremove new file mode 100755 index 000000000..fb39e979a --- /dev/null +++ b/test/integration/test-autoremove @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +local TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture "i386" + +buildsimplenativepackage "unrelated" "all" "1" "unstable" +buildsimplenativepackage "po-debconf" "all" "1.0.16" "unstable" +buildsimplenativepackage "debhelper" "all" "8.0.0" "unstable" "Depends: po-debconf" +setupaptarchive + +aptget install unrelated debhelper -qq 2>&1 > /dev/null + +testfileequal "rootdir/var/lib/apt/extended_states" "Package: po-debconf +Architecture: i386 +Auto-Installed: 1 +" +aptget remove debhelper -y -qq 2>&1 > /dev/null +aptget autoremove -y -qq 2>&1 > /dev/null + +testfileequal "rootdir/var/lib/apt/extended_states" "" + +sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' +testfileequal "rootdir/var/log/apt/history.log" ' +Install: unrelated:i386 (1), debhelper:i386 (8.0.0), po-debconf:i386 (1.0.16, automatic) + +Remove: debhelper:i386 (8.0.0) + +Remove: po-debconf:i386 (1.0.16)' -- cgit v1.2.3 From ba91b1518a1208fecc1ca076fd9cfbd28344b5b3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 30 Aug 2010 11:39:43 +0200 Subject: * apt-pkg/versionmatch.cc: - let the pin origin actually work as advertised in the manpage which means "" are optional and pinning a local archive does work - even if it is a non-flat archive (Closes: #594435) --- apt-pkg/versionmatch.cc | 9 ++++++--- debian/changelog | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 093180f9b..17a54bc4c 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -118,7 +118,10 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) if (Type == Origin) { - OrSite = Data; + if (Data[0] == '"' && Data.end()[-1] == '"') + OrSite = Data.substr(1, Data.length() - 2); + else + OrSite = Data; return; } } @@ -259,10 +262,10 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File) if (Type == Origin) { if (OrSite.empty() == false) { - if (File->Site == 0 || !ExpressionMatches(OrSite, File.Site())) + if (File->Site == 0) return false; } else // so we are talking about file:// or status file - if (strcmp(File.Site(),"") == 0 && File->Archive != 0) // skip the status file + if (strcmp(File.Site(),"") == 0 && File->Archive != 0 && strcmp(File.Archive(),"now") == 0) // skip the status file return false; return (ExpressionMatches(OrSite, File.Site())); /* both strings match */ } diff --git a/debian/changelog b/debian/changelog index 072c00398..0d566f8b4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,8 +29,12 @@ apt (0.8.1) UNRELEASED; urgency=low * apt-pkg/contrib/configuration.cc: - fix autoremove by using correct config-option name and don't make faulty assumptions in error handling (Closes: #594689) + * apt-pkg/versionmatch.cc: + - let the pin origin actually work as advertised in the manpage + which means "" are optional and pinning a local archive does + work - even if it is a non-flat archive (Closes: #594435) - -- David Kalnischkies Sat, 28 Aug 2010 22:23:20 +0200 + -- David Kalnischkies Mon, 30 Aug 2010 11:38:50 +0200 apt (0.8.0) unstable; urgency=low -- cgit v1.2.3