From 470a5c38519989313514ebaec6920aafee53d798 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 May 2011 15:15:13 +0200 Subject: rename I to J to avoid redefining a variable (clang warning) --- apt-pkg/deb/deblistparser.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b59ae8896..4a9e94c85 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -284,18 +284,18 @@ unsigned short debListParser::VersionHash() /* Strip out any spaces from the text, this undoes dpkgs reformatting of certain fields. dpkg also has the rather interesting notion of reformatting depends operators < -> <= */ - char *I = S; + char *J = S; for (; Start != End; Start++) { if (isspace(*Start) == 0) - *I++ = tolower_ascii(*Start); + *J++ = tolower_ascii(*Start); if (*Start == '<' && Start[1] != '<' && Start[1] != '=') - *I++ = '='; + *J++ = '='; if (*Start == '>' && Start[1] != '>' && Start[1] != '=') - *I++ = '='; + *J++ = '='; } - Result = AddCRC16(Result,S,I - S); + Result = AddCRC16(Result,S,J - S); } return Result; -- cgit v1.2.3 From 388f2962666a265709ad7c6e18902d49726b1f2c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 19 May 2011 14:16:43 +0200 Subject: remove invalid pkgcache.bin and rebuild it if possible The next invocation of APT tried to load an outdated big (and possible io-cold) file just to end up rebuilding it (possibly only as non-root in memory again and again), so we remove it here and if we have a srcpkgcache we are going to rebuild, too. --- apt-pkg/deb/dpkgpm.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index b37980b7e..a9d23ea67 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include @@ -1269,6 +1269,23 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (RunScripts("DPkg::Post-Invoke") == false) return false; + if (_config->FindB("Debug::pkgDPkgPM",false) == false) + { + std::string const oldpkgcache = _config->FindFile("Dir::cache::pkgcache"); + if (oldpkgcache.empty() == false && RealFileExists(oldpkgcache) == true && + unlink(oldpkgcache.c_str()) == 0) + { + std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); + if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) + { + _error->PushToStack(); + pkgCacheFile CacheFile; + CacheFile.BuildCaches(NULL, true); + _error->RevertToStack(); + } + } + } + Cache.writeStateFile(NULL); return true; } -- cgit v1.2.3 From 97be52d4372d1ca6b8d276060b434348876ca322 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 23 May 2011 18:10:48 +0200 Subject: log reinstall commands in history.log --- apt-pkg/deb/dpkgpm.cc | 47 +++++++++++++++++++++++++++++------------------ apt-pkg/depcache.h | 2 ++ 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index a9d23ea67..5ddcd47e9 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -681,31 +681,42 @@ bool pkgDPkgPM::OpenLog() return _error->WarningE("OpenLog", _("Could not open file '%s'"), history_name.c_str()); chmod(history_name.c_str(), 0644); fprintf(history_out, "\nStart-Date: %s\n", timestr); - string remove, purge, install, upgrade, downgrade; + string remove, purge, install, reinstall, upgrade, downgrade; for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { - if (Cache[I].NewInstall()) - { - install += I.FullName(false) + string(" (") + Cache[I].CandVersion; - if (Cache[I].Flags & pkgCache::Flag::Auto) - install+= ", automatic"; - install += string("), "); - } - else if (Cache[I].Upgrade()) - upgrade += I.FullName(false) + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), "); - else if (Cache[I].Downgrade()) - downgrade += I.FullName(false) + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), "); - else if (Cache[I].Delete()) - { - if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge) - purge += I.FullName(false) + string(" (") + Cache[I].CurVersion + string("), "); - else - remove += I.FullName(false) + string(" (") + Cache[I].CurVersion + string("), "); + enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring; + string *line = NULL; + #define HISTORYINFO(X, Y) { line = &X; infostring = Y; } + if (Cache[I].NewInstall() == true) + HISTORYINFO(install, CANDIDATE_AUTO) + else if (Cache[I].ReInstall() == true) + HISTORYINFO(reinstall, CANDIDATE) + else if (Cache[I].Upgrade() == true) + HISTORYINFO(upgrade, CURRENT_CANDIDATE) + else if (Cache[I].Downgrade() == true) + HISTORYINFO(downgrade, CURRENT_CANDIDATE) + else if (Cache[I].Delete() == true) + HISTORYINFO((Cache[I].Purge() ? purge : remove), CURRENT) + else + continue; + #undef HISTORYINFO + line->append(I.FullName(false)).append(" ("); + switch (infostring) { + case CANDIDATE: line->append(Cache[I].CandVersion); break; + case CANDIDATE_AUTO: + line->append(Cache[I].CandVersion); + if ((Cache[I].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) + line->append(", automatic"); + break; + case CURRENT_CANDIDATE: line->append(Cache[I].CurVersion).append(", ").append(Cache[I].CandVersion); break; + case CURRENT: line->append(Cache[I].CurVersion); break; } + line->append("), "); } if (_config->Exists("Commandline::AsString") == true) WriteHistoryTag("Commandline", _config->Find("Commandline::AsString")); WriteHistoryTag("Install", install); + WriteHistoryTag("Reinstall", reinstall); WriteHistoryTag("Upgrade", upgrade); WriteHistoryTag("Downgrade",downgrade); WriteHistoryTag("Remove",remove); diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 750da3d6f..9efe110f5 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -231,6 +231,7 @@ class pkgDepCache : protected pkgCache::Namespace // Various test members for the current status of the package inline bool NewInstall() const {return Status == 2 && Mode == ModeInstall;}; inline bool Delete() const {return Mode == ModeDelete;}; + inline bool Purge() const {return Delete() == true && (iFlags & pkgDepCache::Purge) == pkgDepCache::Purge; }; inline bool Keep() const {return Mode == ModeKeep;}; inline bool Upgrade() const {return Status > 0 && Mode == ModeInstall;}; inline bool Upgradable() const {return Status >= 1;}; @@ -241,6 +242,7 @@ class pkgDepCache : protected pkgCache::Namespace inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;}; inline bool InstPolicyBroken() const {return (DepState & DepInstPolicy) != DepInstPolicy;}; inline bool Install() const {return Mode == ModeInstall;}; + inline bool ReInstall() const {return Delete() == false && (iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall;}; inline VerIterator InstVerIter(pkgCache &Cache) {return VerIterator(Cache,InstallVer);}; inline VerIterator CandidateVerIter(pkgCache &Cache) -- cgit v1.2.3 From da833832ee0748f72674677a0c28ad0762159438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Sat, 28 May 2011 10:14:43 +0200 Subject: use the correct option name in comment for Acquire::Languages --- apt-pkg/aptconfiguration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index ca602d4bf..e8c8e73d0 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -224,7 +224,7 @@ std::vector const Configuration::getLanguages(bool const &All, environment.push_back("en"); } - // Support settings like Acquire::Translation=none on the command line to + // Support settings like Acquire::Languages=none on the command line to // override the configuration settings vector of languages. string const forceLang = _config->Find("Acquire::Languages",""); if (forceLang.empty() == false) { -- cgit v1.2.3 From a5ca55e452d48bb59b4a5151816042ed722c4983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Sat, 28 May 2011 10:54:10 +0200 Subject: =?UTF-8?q?*=20apt-pkg/init.cc:=20=20=20-=20don't=20set=20deprecat?= =?UTF-8?q?ed=20APT::Acquire::Translation,=20thanks=20J=C3=B6rg=20Sommer!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt-pkg/init.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index a30f27844..31b2d9ccd 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -85,9 +85,6 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$"); Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$"); - // Translation - Cnf.Set("APT::Acquire::Translation", "environment"); - // Default cdrom mount point Cnf.Set("Acquire::cdrom::mount", "/media/cdrom/"); -- cgit v1.2.3 From 85c26e8c9a04e98d1b5dc330d18429f628f230d4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 9 Jun 2011 11:51:45 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - include all known languages when building the apt cache (LP: #794907) --- apt-pkg/deb/deblistparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b59ae8896..ff6de2d9f 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -201,7 +201,7 @@ string debListParser::DescriptionLanguage() if (Section.FindS("Description").empty() == false) return ""; - std::vector const lang = APT::Configuration::getLanguages(); + std::vector const lang = APT::Configuration::getLanguages(true); for (std::vector::const_iterator l = lang.begin(); l != lang.end(); l++) if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false) -- cgit v1.2.3 From 64c2bdc9cfa77d05143aec6d744a3b65b4bb6cd7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 9 Jun 2011 13:24:36 +0200 Subject: apt-pkg/deb/debindexfile.cc: remove tests for TranslationsAvailable() as this will break adding translations to the cache if the current environment does not include the language (e.g. LANG=C but german translations). testing for existance of the file is the better approach --- apt-pkg/deb/debindexfile.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 1e8c04033..1d828c144 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -468,9 +468,6 @@ string debTranslationsIndex::Info(const char *Type) const /*}}}*/ bool debTranslationsIndex::HasPackages() const /*{{{*/ { - if(!TranslationsAvailable()) - return false; - return FileExists(IndexFile(Language)); } /*}}}*/ @@ -510,7 +507,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const { // Check the translation file, if in use string TranslationFile = IndexFile(Language); - if (TranslationsAvailable() && FileExists(TranslationFile)) + if (FileExists(TranslationFile)) { FileFd Trans(TranslationFile,FileFd::ReadOnlyGzip); debListParser TransParser(&Trans); -- cgit v1.2.3 From e4d30d3fdc11a5af7fb04b5f6bb65e5f47f76810 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 9 Jun 2011 13:30:08 +0200 Subject: apt-pkg/deb/debindexfile.cc: kill off another TranslationsAvailable() usage that is not needed --- apt-pkg/deb/debindexfile.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 1d828c144..c9e7f1176 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -423,12 +423,10 @@ string debTranslationsIndex::IndexURI(const char *Type) const /* */ bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const { - if (TranslationsAvailable()) { - string const TranslationFile = string("Translation-").append(Language); - new pkgAcqIndexTrans(Owner, IndexURI(Language), - Info(TranslationFile.c_str()), - TranslationFile); - } + string const TranslationFile = string("Translation-").append(Language); + new pkgAcqIndexTrans(Owner, IndexURI(Language), + Info(TranslationFile.c_str()), + TranslationFile); return true; } -- cgit v1.2.3 From 9c76a88155c346666325339c5581a528d70b1f69 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 27 Jun 2011 10:46:41 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - set permissions of term.log to root.adm and 644 (LP: #404724) --- apt-pkg/deb/dpkgpm.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index b37980b7e..ca544e778 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -667,7 +669,13 @@ bool pkgDPkgPM::OpenLog() return _error->WarningE("OpenLog", _("Could not open file '%s'"), logfile_name.c_str()); setvbuf(term_out, NULL, _IONBF, 0); SetCloseExec(fileno(term_out), true); - chmod(logfile_name.c_str(), 0600); + struct passwd *pw; + struct group *gr; + pw = getpwnam("root"); + gr = getgrnam("adm"); + if (pw != NULL && gr != NULL) + chown(logfile_name.c_str(), pw->pw_uid, gr->gr_gid); + chmod(logfile_name.c_str(), 0644); fprintf(term_out, "\nLog started: %s\n", timestr); } -- cgit v1.2.3 From 15657fcc72462aed8e5b361fe52450484229ec5d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 28 Jun 2011 15:45:59 +0100 Subject: cherry pick from donkult --- apt-pkg/orderlist.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index ba43bc757..19661fc2d 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -1073,6 +1073,12 @@ bool pkgOrderList::CheckDep(DepIterator D) just needs one */ if (D.IsNegative() == false) { + // ignore provides by older versions of this package + if (((D.Reverse() == false && Pkg == D.ParentPkg()) || + (D.Reverse() == true && Pkg == D.TargetPkg())) && + Cache[Pkg].InstallVer != *I) + continue; + /* Try to find something that does not have the after flag set if at all possible */ if (IsFlag(Pkg,After) == true) -- cgit v1.2.3 From 00c6e1a3eb3d7c8890ca8861c07663f54e0900e0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Jun 2011 08:33:19 +0100 Subject: * doc/makefile: - create doxygen directory to avoid depending on magic (Closes: #628799) * cmdline/apt-key: - explicitly state that net-update is not supported if no url is set - require to be root for add, rm, update and net-update - clarify update vs. net-update in different distros (Closes: #632043) * debian/apt.symbols: - forgot 'mips' in the list for all architecture dependent symbols - comment out gcc-4.5 specific symbols as gcc-4.6 is now default - the symbol for PrintStatus() is architecture dependent * apt-pkg/policy.cc: - do not segfault in pinning if a package with this name doesn't exist. Thanks to Ferdinand Thommes for the report! - Defaults is a vector of Pin not of PkgPin - ensure that only the first specific stanza for a package is used - save all stanzas which had no effect in Unmatched - allow package:architecure in Package: --- apt-pkg/policy.cc | 64 ++++++++++++++++++++++++++++++++++++++----------------- apt-pkg/policy.h | 1 + 2 files changed, 45 insertions(+), 20 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 2cc2e5e39..bd213e0ce 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -210,13 +210,20 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name, { if (Name.empty() == true) { - Pin *P = &*Defaults.insert(Defaults.end(),PkgPin()); + Pin *P = &*Defaults.insert(Defaults.end(),Pin()); P->Type = Type; P->Priority = Priority; P->Data = Data; return; } - + + size_t found = Name.rfind(':'); + string Arch; + if (found != string::npos) { + Arch = Name.substr(found+1); + Name.erase(found); + } + // Allow pinning by wildcards // TODO: Maybe we should always prefer specific pins over non- // specific ones. @@ -225,32 +232,49 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name, pkgVersionMatch match(Data, Type); for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() != true; ++G) if (match.ExpressionMatches(Name, G.Name())) - CreatePin(Type, G.Name(), Data, Priority); + { + if (Arch.empty() == false) + CreatePin(Type, string(G.Name()).append(":").append(Arch), Data, Priority); + else + CreatePin(Type, G.Name(), Data, Priority); + } return; } - // Get a spot to put the pin - pkgCache::GrpIterator Grp = Cache->FindGrp(Name); - for (pkgCache::PkgIterator Pkg = Grp.PackageList(); - Pkg.end() != true; Pkg = Grp.NextPkg(Pkg)) + // find the package (group) this pin applies to + pkgCache::GrpIterator Grp; + pkgCache::PkgIterator Pkg; + if (Arch.empty() == false) + Pkg = Cache->FindPkg(Name, Arch); + else { + Grp = Cache->FindGrp(Name); + if (Grp.end() == false) + Pkg = Grp.PackageList(); + } + + if (Pkg.end() == true) { - Pin *P = 0; - if (Pkg.end() == false) - P = Pins + Pkg->ID; - else - { - // Check the unmatched table - for (vector::iterator I = Unmatched.begin(); - I != Unmatched.end() && P == 0; I++) - if (I->Pkg == Name) - P = &*I; + PkgPin *P = &*Unmatched.insert(Unmatched.end(),PkgPin(Name)); + if (Arch.empty() == false) + P->Pkg.append(":").append(Arch); + P->Type = Type; + P->Priority = Priority; + P->Data = Data; + return; + } - if (P == 0) - P = &*Unmatched.insert(Unmatched.end(),PkgPin()); - } + for (; Pkg.end() != true; Pkg = Grp.NextPkg(Pkg)) + { + Pin *P = Pins + Pkg->ID; + // the first specific stanza for a package is the ruler, + // all others need to be ignored + if (P->Type != pkgVersionMatch::None) + P = &*Unmatched.insert(Unmatched.end(),PkgPin(Pkg.FullName())); P->Type = Type; P->Priority = Priority; P->Data = Data; + if (Grp.end() == true) + break; } } /*}}}*/ diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h index f8b2678de..a5e6c6048 100644 --- a/apt-pkg/policy.h +++ b/apt-pkg/policy.h @@ -55,6 +55,7 @@ class pkgPolicy : public pkgDepCache::Policy struct PkgPin : Pin { string Pkg; + PkgPin(string const &Pkg) : Pin(), Pkg(Pkg) {}; }; Pin *Pins; -- cgit v1.2.3