summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2008-10-07 20:24:10 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2008-10-07 20:24:10 +0200
commitc4ed75769f32eee57bd56350709b24b2bb7222aa (patch)
tree4f76b20d2a4c04685132e58437893deb4844f6bc /apt-pkg
parentc5fdf360513f8d2e5858711ff46c744cddcdeb6f (diff)
parent5634f31af3ddd58171b660e48af18d9cb0939275 (diff)
merged from the debain-sid branch
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc3
-rw-r--r--apt-pkg/algorithms.h1
-rw-r--r--apt-pkg/deb/dpkgpm.cc78
-rw-r--r--apt-pkg/depcache.cc5
-rw-r--r--apt-pkg/packagemanager.cc4
-rw-r--r--apt-pkg/pkgcache.cc3
-rw-r--r--apt-pkg/pkgcachegen.cc20
7 files changed, 100 insertions, 14 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index eaab4c0ea..59f994cd7 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -37,7 +37,8 @@ pkgProblemResolver *pkgProblemResolver::This = 0;
this is not necessary since the pkgCaches are fully shared now. */
pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache),
iPolicy(Cache),
- Sim(&Cache->GetCache(),&iPolicy)
+ Sim(&Cache->GetCache(),&iPolicy),
+ group(Sim)
{
Sim.Init(0);
Flags = new unsigned char[Cache->Head().PackageCount];
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index defaed57d..d183cd213 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -60,6 +60,7 @@ class pkgSimulate : public pkgPackageManager
Policy iPolicy;
pkgDepCache Sim;
+ pkgDepCache::ActionGroup group;
// The Actuall installation implementation
virtual bool Install(PkgIterator Pkg,string File);
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index bc15b8819..4fad0fd52 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -25,6 +25,8 @@
#include <signal.h>
#include <errno.h>
#include <stdio.h>
+#include <string.h>
+#include <algorithm>
#include <sstream>
#include <map>
@@ -39,7 +41,38 @@
using namespace std;
-
+namespace
+{
+ // Maps the dpkg "processing" info to human readable names. Entry 0
+ // of each array is the key, entry 1 is the value.
+ const std::pair<const char *, const char *> PackageProcessingOps[] = {
+ std::make_pair("install", N_("Installing %s")),
+ std::make_pair("configure", N_("Configuring %s")),
+ std::make_pair("remove", N_("Removing %s")),
+ std::make_pair("trigproc", N_("Running post-installation trigger %s"))
+ };
+
+ const std::pair<const char *, const char *> * const PackageProcessingOpsBegin = PackageProcessingOps;
+ const std::pair<const char *, const char *> * const PackageProcessingOpsEnd = PackageProcessingOps + sizeof(PackageProcessingOps) / sizeof(PackageProcessingOps[0]);
+
+ // Predicate to test whether an entry in the PackageProcessingOps
+ // array matches a string.
+ class MatchProcessingOp
+ {
+ const char *target;
+
+ public:
+ MatchProcessingOp(const char *the_target)
+ : target(the_target)
+ {
+ }
+
+ bool operator()(const std::pair<const char *, const char *> &pair) const
+ {
+ return strcmp(pair.first, target) == 0;
+ }
+ };
+}
// DPkgPM::pkgDPkgPM - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -333,6 +366,12 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
'status: /var/cache/apt/archives/krecipes_0.8.1-0ubuntu1_i386.deb : error : trying to overwrite `/usr/share/doc/kde/HTML/en/krecipes/krectip.png', which is also in package krecipes-data
and conffile-prompt like this
'status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited
+
+ Newer versions of dpkg sent also:
+ 'processing: install: pkg'
+ 'processing: configure: pkg'
+ 'processing: remove: pkg'
+ 'processing: trigproc: trigger'
*/
char* list[5];
@@ -351,6 +390,36 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
char *pkg = list[1];
char *action = _strstrip(list[2]);
+ // 'processing' from dpkg looks like
+ // 'processing: action: pkg'
+ if(strncmp(list[0], "processing", strlen("processing")) == 0)
+ {
+ char s[200];
+ char *pkg_or_trigger = _strstrip(list[2]);
+ action =_strstrip( list[1]);
+ const std::pair<const char *, const char *> * const iter =
+ std::find_if(PackageProcessingOpsBegin,
+ PackageProcessingOpsEnd,
+ MatchProcessingOp(action));
+ if(iter == PackageProcessingOpsEnd)
+ {
+ if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+ std::clog << "ignoring unknwon action: " << action << std::endl;
+ return;
+ }
+ snprintf(s, sizeof(s), _(iter->second), pkg_or_trigger);
+
+ status << "pmstatus:" << pkg_or_trigger
+ << ":" << (PackagesDone/float(PackagesTotal)*100.0)
+ << ":" << s
+ << endl;
+ if(OutStatusFd > 0)
+ write(OutStatusFd, status.str().c_str(), status.str().size());
+ if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+ std::clog << "send: '" << status.str() << "'" << endl;
+ return;
+ }
+
if(strncmp(action,"error",strlen("error")) == 0)
{
status << "pmerror:" << list[1]
@@ -520,13 +589,14 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024);
unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024);
+ bool NoTriggers = _config->FindB("DPkg::NoTriggers",false);
if (RunScripts("DPkg::Pre-Invoke") == false)
return false;
if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false)
return false;
-
+
// map the dpkg states to the operations that are performed
// (this is sorted in the same way as Item::Ops)
static const struct DpkgState DpkgStatesOpMap[][7] = {
@@ -649,6 +719,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
case Item::Configure:
Args[n++] = "--configure";
+ if (NoTriggers)
+ Args[n++] = "--no-triggers";
Size += strlen(Args[n-1]);
break;
@@ -884,6 +956,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
if (RunScripts("DPkg::Post-Invoke") == false)
return false;
+
+ Cache.writeStateFile(NULL);
return true;
}
/*}}}*/
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index d1bea4cf6..d8b4dc6d2 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -914,8 +914,9 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
{
//FIXME: deal better with or-groups(?)
DepIterator LocalStart = D;
-
- if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg())
+
+ if(IsImportantDep(D) && !D.IsCritical() &&
+ Start.TargetPkg() == D.TargetPkg())
{
if(!isPreviouslySatisfiedImportantDep)
{
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index c391a6036..304d1c653 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -666,10 +666,6 @@ pkgPackageManager::DoInstallPostFork(int statusFd)
if(goResult == false)
return Failed;
- // if all was fine update the state file
- if(Res == Completed) {
- Cache.writeStateFile(NULL);
- }
return Res;
};
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 133899a27..8eb62089a 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -622,7 +622,8 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
for (; Desc.end() == false; Desc++)
if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
break;
- if (Desc.end() == true) Desc = DescDefault;
+ if (Desc.end() == true)
+ Desc = DescDefault;
return Desc;
};
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index d00cd4e64..f71547f39 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -139,10 +139,21 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
{
pkgCache::DescIterator Desc = Ver.DescriptionList();
map_ptrloc *LastDesc = &Ver->DescriptionList;
-
- for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
+ bool duplicate=false;
+
+ // don't add a new description if we have one for the given
+ // md5 && language
+ for ( ; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
+ if (MD5SumValue(Desc.md5()) == CurMd5 &&
+ Desc.LanguageCode() == List.DescriptionLanguage())
+ duplicate=true;
+ if(duplicate)
+ continue;
+
+ for (Desc = Ver.DescriptionList();
+ Desc.end() == false;
+ LastDesc = &Desc->NextDesc, Desc++)
{
-
if (MD5SumValue(Desc.md5()) == CurMd5)
{
// Add new description
@@ -434,7 +445,8 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
// ---------------------------------------------------------------------
/* This puts a description structure in the linked list */
map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
- const string &Lang, const MD5SumValue &md5sum,
+ const string &Lang,
+ const MD5SumValue &md5sum,
map_ptrloc Next)
{
// Get a structure