summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/deb/dpkgpm.cc26
-rw-r--r--apt-pkg/depcache.cc1
-rw-r--r--apt-pkg/init.cc3
-rw-r--r--apt-pkg/init.h2
-rw-r--r--apt-pkg/pkgcache.cc14
-rw-r--r--apt-pkg/pkgcache.h6
-rw-r--r--apt-pkg/pkgcachegen.cc5
8 files changed, 43 insertions, 16 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 14ee09e0d..ca602d4bf 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -337,7 +337,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
char* arch = strtok(buf, " ");
while (arch != NULL) {
for (; isspace(*arch) != 0; ++arch);
- if (arch != '\0') {
+ if (arch[0] != '\0') {
char const* archend = arch;
for (; isspace(*archend) == 0 && *archend != '\0'; ++archend);
archs.push_back(string(arch, (archend - arch)));
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 01808be24..e957ce5fd 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1289,7 +1289,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
string::size_type pos;
FILE *report;
- if (_config->FindB("Dpkg::ApportFailureReport", false) == false)
+ if (_config->FindB("Dpkg::ApportFailureReport", true) == false)
{
std::clog << "configured to not write apport reports" << std::endl;
return;
@@ -1316,16 +1316,28 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
}
// do not report out-of-memory failures
- if(strstr(errormsg, strerror(ENOMEM)) != NULL) {
+ if(strstr(errormsg, strerror(ENOMEM)) != NULL ||
+ strstr(errormsg, "Cannot allocate memory") != NULL) {
std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl;
return;
}
- // do not report dpkg I/O errors
- // XXX - this message is localized, but this only matches the English version. This is better than nothing.
- if(strstr(errormsg, "short read in buffer_copy (")) {
- std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
- return;
+ // do not report dpkg I/O errors, this is a format string, so we compare
+ // the prefix and the suffix of the error with the dpkg error message
+ const char *short_read_error = dgettext("dpkg", "short read in buffer_copy %s");
+ vector<string> list = VectorizeString(short_read_error, '%');
+ if (list.size() > 1)
+ {
+ // we need to split %s, VectorizeString only allows char so we need
+ // to kill the "s" manually
+ if (list[1].size() > 1) {
+ list[1].erase(0, 1);
+ if(strstr(errormsg, list[0].c_str()) &&
+ strstr(errormsg, list[1].c_str())) {
+ std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
+ return;
+ }
+ }
}
// get the pkgname and reportfile
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 07803d7bf..8cf322464 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -927,6 +927,7 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
if (FromUser == false && Pkg->CurrentVer == 0)
{
StateCache &P = PkgState[Pkg->ID];
+ // Status == 2 means this applies for new installs only
if (P.InstallVer != 0 && P.Status == 2 && (P.Flags & Flag::Auto) != Flag::Auto)
{
if (DebugMarker == true)
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index a30f27844..0354e6e4d 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -84,6 +84,9 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$");
+ // ubuntu specific
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.distUpgrade$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$");
// Translation
Cnf.Set("APT::Acquire::Translation", "environment");
diff --git a/apt-pkg/init.h b/apt-pkg/init.h
index 15a1165b9..6d3ef953c 100644
--- a/apt-pkg/init.h
+++ b/apt-pkg/init.h
@@ -21,7 +21,7 @@
// reverse-dependencies of libapt-pkg against the new SONAME.
// Non-ABI-Breaks should only increase RELEASE number.
// See also buildlib/libversion.mak
-#define APT_PKG_MAJOR 4
+#define APT_PKG_MAJOR 4
#define APT_PKG_MINOR 10
#define APT_PKG_RELEASE 1
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index c6326abf1..b63900adb 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -217,6 +217,9 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
if (found == string::npos)
return FindPkg(Name, "native");
string const Arch = Name.substr(found+1);
+ /* Beware: This is specialcased to handle pkg:any in dependencies as
+ these are linked to virtual pkg:any named packages with all archs.
+ If you want any arch from a given pkg, use FindPkg(pkg,arch) */
if (Arch == "any")
return FindPkg(Name, "any");
return FindPkg(Name.substr(0, found), Arch);
@@ -228,7 +231,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
if (MultiArchCache() == false) {
if (Arch == "native" || Arch == "all" || Arch == "any" ||
- Arch == _config->Find("APT::Architecture"))
+ Arch == NativeArch())
return SingleArchFindPkg(Name);
else
return PkgIterator(*this,0);
@@ -322,15 +325,15 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
if (Arch == "any")
return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
- static string const myArch = _config->Find("APT::Architecture");
+ char const* const myArch = Owner->NativeArch();
/* Most of the time the package for our native architecture is
the one we add at first to the cache, but this would be the
last one we check, so we do it now. */
if (Arch == "native" || Arch == myArch || Arch == "all") {
- Arch = myArch;
pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
- if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0)
+ if (strcasecmp(myArch, Owner->StrP + Pkg->Arch) == 0)
return PkgIterator(*Owner, Pkg);
+ Arch = myArch;
}
/* Iterate over the list to find the matching arch
@@ -503,7 +506,8 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
{
string fullname = Name();
if (Pretty == false ||
- (strcmp(Arch(), "all") != 0 && _config->Find("APT::Architecture") != Arch()))
+ (strcmp(Arch(), "all") != 0 &&
+ strcmp(Owner->NativeArch(), Arch()) != 0))
return fullname.append(":").append(Arch());
return fullname;
}
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index d654a2976..1b1743724 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -215,6 +215,7 @@ class pkgCache /*{{{*/
private:
bool MultiArchEnabled;
PkgIterator SingleArchFindPkg(const string &Name);
+ inline char const * const NativeArch() const;
};
/*}}}*/
// Header structure /*{{{*/
@@ -649,6 +650,11 @@ struct pkgCache::StringItem
map_ptrloc NextItem; // StringItem
};
/*}}}*/
+
+
+inline char const * const pkgCache::NativeArch() const
+ { return StrP + HeaderP->Architecture; };
+
#include <apt-pkg/cacheiterators.h>
inline pkgCache::GrpIterator pkgCache::GrpBegin()
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index b0ee04554..9820fde81 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -479,7 +479,8 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
// Set the name, arch and the ID
Pkg->Name = Grp->Name;
Pkg->Group = Grp.Index();
- map_ptrloc const idxArch = WriteUniqString((Arch == "all") ? _config->Find("APT::Architecture") : Arch.c_str());
+ // all is mapped to the native architecture
+ map_ptrloc const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : WriteUniqString(Arch.c_str());
if (unlikely(idxArch == 0))
return false;
Pkg->Arch = idxArch;
@@ -783,7 +784,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
// We do not add self referencing provides
if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
- (PkgArch == "all" && _config->Find("APT::Architecture") == Ver.ParentPkg().Arch())))
+ (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)))
return true;
// Get a structure