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/deb') 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/deb') 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 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'apt-pkg/deb') 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); -- 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/deb') 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/deb') 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/deb') 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/deb') 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