summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc23
-rw-r--r--apt-pkg/contrib/error.cc164
-rw-r--r--apt-pkg/contrib/error.h5
-rw-r--r--apt-pkg/contrib/fileutl.cc14
-rw-r--r--apt-pkg/contrib/mmap.cc4
-rw-r--r--apt-pkg/contrib/mmap.h2
-rw-r--r--apt-pkg/deb/dpkgpm.cc26
-rw-r--r--apt-pkg/depcache.cc13
-rw-r--r--apt-pkg/init.cc3
-rw-r--r--apt-pkg/init.h2
-rw-r--r--apt-pkg/pkgcachegen.cc18
11 files changed, 170 insertions, 104 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index fc520d744..66c182b23 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -162,7 +162,28 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
}
}
-// Sim.MarkInstall(Pkg,false);
+ if (Sim[Pkg].InstBroken() == true)
+ {
+ /* We don't call Configure for Pseudo packages and if the 'all' is already installed
+ the simulation will think the pseudo package is not installed, so if something is
+ broken we walk over the dependencies and search for not installed pseudo packages */
+ for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++)
+ {
+ if (Sim.IsImportantDep(D) == false ||
+ (Sim[D] & pkgDepCache::DepInstall) != 0)
+ continue;
+ pkgCache::PkgIterator T = D.TargetPkg();
+ if (T.end() == true || T->CurrentVer != 0 || Flags[T->ID] != 0)
+ continue;
+ pkgCache::PkgIterator A = T.Group().FindPkg("all");
+ if (A.end() == true || A->VersionList == 0 || A->CurrentVer == 0 ||
+ Cache.VS().CheckDep(A.CurVersion(), pkgCache::Dep::Equals, T.CandVersion()) == false)
+ continue;
+ Sim.MarkInstall(T, false);
+ Flags[T->ID] = 2;
+ }
+ }
+
if (Sim[Pkg].InstBroken() == true)
{
cout << "Conf " << Pkg.FullName(false) << " broken" << endl;
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index e2e8d6e57..fe50e606b 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -18,6 +18,7 @@
#include <iostream>
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <string>
@@ -57,108 +58,110 @@
// GlobalError::GlobalError - Constructor /*{{{*/
GlobalError::GlobalError() : PendingFlag(false) {}
/*}}}*/
-// GlobalError::FatalE - Get part of the error string from errno /*{{{*/
-bool GlobalError::FatalE(const char *Function,const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return InsertErrno(FATAL, Function, Description, args);
-}
- /*}}}*/
-// GlobalError::Errno - Get part of the error string from errno /*{{{*/
-bool GlobalError::Errno(const char *Function,const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return InsertErrno(ERROR, Function, Description, args);
-}
- /*}}}*/
-// GlobalError::WarningE - Get part of the warning string from errno /*{{{*/
-bool GlobalError::WarningE(const char *Function,const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return InsertErrno(WARNING, Function, Description, args);
-}
- /*}}}*/
-// GlobalError::NoticeE - Get part of the notice string from errno /*{{{*/
-bool GlobalError::NoticeE(const char *Function,const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return InsertErrno(NOTICE, Function, Description, args);
-}
- /*}}}*/
-// GlobalError::DebugE - Get part of the debug string from errno /*{{{*/
-bool GlobalError::DebugE(const char *Function,const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return InsertErrno(DEBUG, Function, Description, args);
+// GlobalError::FatalE, Errno, WarningE, NoticeE and DebugE - Add to the list/*{{{*/
+#define GEMessage(NAME, TYPE) \
+bool GlobalError::NAME (const char *Function, const char *Description,...) { \
+ va_list args; \
+ size_t msgSize = 400; \
+ int const errsv = errno; \
+ while (true) { \
+ va_start(args,Description); \
+ if (InsertErrno(TYPE, Function, Description, args, errsv, msgSize) == false) \
+ break; \
+ va_end(args); \
+ } \
+ return false; \
}
+GEMessage(FatalE, FATAL)
+GEMessage(Errno, ERROR)
+GEMessage(WarningE, WARNING)
+GEMessage(NoticeE, NOTICE)
+GEMessage(DebugE, DEBUG)
+#undef GEMessage
/*}}}*/
// GlobalError::InsertErrno - Get part of the errortype string from errno/*{{{*/
bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
const char *Description,...) {
va_list args;
- va_start(args,Description);
- return InsertErrno(type, Function, Description, args);
+ size_t msgSize = 400;
+ int const errsv = errno;
+ while (true) {
+ va_start(args,Description);
+ if (InsertErrno(type, Function, Description, args, errsv, msgSize) == false)
+ break;
+ va_end(args);
+ }
+ return false;
}
/*}}}*/
// GlobalError::InsertErrno - formats an error message with the errno /*{{{*/
bool GlobalError::InsertErrno(MsgType type, const char* Function,
- const char* Description, va_list &args) {
- char S[400];
- snprintf(S, sizeof(S), "%s - %s (%i: %s)", Description,
- Function, errno, strerror(errno));
- return Insert(type, S, args);
-}
- /*}}}*/
-// GlobalError::Fatal - Add a fatal error to the list /*{{{*/
-bool GlobalError::Fatal(const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return Insert(FATAL, Description, args);
-}
- /*}}}*/
-// GlobalError::Error - Add an error to the list /*{{{*/
-bool GlobalError::Error(const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return Insert(ERROR, Description, args);
-}
- /*}}}*/
-// GlobalError::Warning - Add a warning to the list /*{{{*/
-bool GlobalError::Warning(const char *Description,...) {
- va_list args;
- va_start(args,Description);
- return Insert(WARNING, Description, args);
-}
- /*}}}*/
-// GlobalError::Notice - Add a notice to the list /*{{{*/
-bool GlobalError::Notice(const char *Description,...)
-{
- va_list args;
- va_start(args,Description);
- return Insert(NOTICE, Description, args);
+ const char* Description, va_list &args,
+ int const errsv, size_t &msgSize) {
+ char* S = (char*) malloc(msgSize);
+ int const n = snprintf(S, msgSize, "%s - %s (%i: %s)", Description,
+ Function, errsv, strerror(errsv));
+ if (n > -1 && ((unsigned int) n) < msgSize);
+ else {
+ if (n > -1)
+ msgSize = n + 1;
+ else
+ msgSize *= 2;
+ return true;
+ }
+
+ bool const geins = Insert(type, S, args, msgSize);
+ free(S);
+ return geins;
}
/*}}}*/
-// GlobalError::Debug - Add a debug to the list /*{{{*/
-bool GlobalError::Debug(const char *Description,...)
-{
- va_list args;
- va_start(args,Description);
- return Insert(DEBUG, Description, args);
+// GlobalError::Fatal, Error, Warning, Notice and Debug - Add to the list/*{{{*/
+#define GEMessage(NAME, TYPE) \
+bool GlobalError::NAME (const char *Description,...) { \
+ va_list args; \
+ size_t msgSize = 400; \
+ while (true) { \
+ va_start(args,Description); \
+ if (Insert(TYPE, Description, args, msgSize) == false) \
+ break; \
+ va_end(args); \
+ } \
+ return false; \
}
+GEMessage(Fatal, FATAL)
+GEMessage(Error, ERROR)
+GEMessage(Warning, WARNING)
+GEMessage(Notice, NOTICE)
+GEMessage(Debug, DEBUG)
+#undef GEMessage
/*}}}*/
// GlobalError::Insert - Add a errotype message to the list /*{{{*/
bool GlobalError::Insert(MsgType const &type, const char *Description,...)
{
va_list args;
- va_start(args,Description);
- return Insert(type, Description, args);
+ size_t msgSize = 400;
+ while (true) {
+ va_start(args,Description);
+ if (Insert(type, Description, args, msgSize) == false)
+ break;
+ va_end(args);
+ }
+ return false;
}
/*}}}*/
// GlobalError::Insert - Insert a new item at the end /*{{{*/
bool GlobalError::Insert(MsgType type, const char* Description,
- va_list &args) {
- char S[400];
- vsnprintf(S,sizeof(S),Description,args);
+ va_list &args, size_t &msgSize) {
+ char* S = (char*) malloc(msgSize);
+ int const n = vsnprintf(S, msgSize, Description, args);
+ if (n > -1 && ((unsigned int) n) < msgSize);
+ else {
+ if (n > -1)
+ msgSize = n + 1;
+ else
+ msgSize *= 2;
+ return true;
+ }
Item const m(S, type);
Messages.push_back(m);
@@ -169,6 +172,7 @@ bool GlobalError::Insert(MsgType type, const char* Description,
if (type == FATAL || type == DEBUG)
std::clog << m << std::endl;
+ free(S);
return false;
}
/*}}}*/
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index ae756dbc4..21c51c1be 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -307,9 +307,10 @@ private: /*{{{*/
std::list<MsgStack> Stacks;
bool InsertErrno(MsgType type, const char* Function,
- const char* Description, va_list &args);
+ const char* Description, va_list &args,
+ int const errsv, size_t &msgSize);
bool Insert(MsgType type, const char* Description,
- va_list &args);
+ va_list &args, size_t &msgSize);
/*}}}*/
};
/*}}}*/
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 935c4bebf..50019872e 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -42,6 +42,11 @@
#include <errno.h>
#include <set>
#include <algorithm>
+
+#include <config.h>
+#ifdef WORDS_BIGENDIAN
+#include <inttypes.h>
+#endif
/*}}}*/
using namespace std;
@@ -971,9 +976,16 @@ unsigned long FileFd::Size()
off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
if (lseek(iFd, -4, SEEK_END) < 0)
return _error->Errno("lseek","Unable to seek to end of gzipped file");
+ size = 0L;
if (read(iFd, &size, 4) != 4)
return _error->Errno("read","Unable to read original size of gzipped file");
- size &= 0xFFFFFFFF;
+
+#ifdef WORDS_BIGENDIAN
+ uint32_t tmp_size = size;
+ uint8_t const * const p = (uint8_t const * const) &tmp_size;
+ tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+ size = tmp_size;
+#endif
if (lseek(iFd, orig_pos, SEEK_SET) < 0)
return _error->Errno("lseek","Unable to seek in gzipped file");
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 69fb61fca..9945b1606 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -106,7 +106,7 @@ bool MMap::Map(FileFd &Fd)
/* */
bool MMap::Close(bool DoSync)
{
- if ((Flags & UnMapped) == UnMapped || Base == 0 || iSize == 0)
+ if ((Flags & UnMapped) == UnMapped || validData() == false || iSize == 0)
return true;
if (DoSync == true)
@@ -266,6 +266,8 @@ DynamicMMap::~DynamicMMap()
{
if (Fd == 0)
{
+ if (validData() == false)
+ return;
#ifdef _POSIX_MAPPED_FILES
munmap(Base, WorkSpace);
#else
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 5ca951204..2bf2c1540 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -61,6 +61,8 @@ class MMap
inline operator void *() {return Base;};
inline void *Data() {return Base;};
inline unsigned long Size() {return iSize;};
+ inline void AddSize(unsigned long const size) {iSize += size;};
+ inline bool validData() const { return Base != (void *)-1 && Base != 0; };
// File manipulators
bool Sync();
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 5747f1164..eeb57f715 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1270,7 +1270,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;
@@ -1297,16 +1297,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 5f59b6d49..cb1264b04 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -339,7 +339,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
/* Check simple depends. A depends -should- never self match but
we allow it anyhow because dpkg does. Technically it is a packaging
bug. Conflicts may never self match */
- if (Dep.TargetPkg()->Group != Dep.ParentPkg()->Group ||
+ if (Dep.TargetPkg() != Dep.ParentPkg() ||
(Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes))
{
PkgIterator Pkg = Dep.TargetPkg();
@@ -1193,9 +1193,13 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
std::clog << OutputInDepth(Depth) << "Hold prevents MarkDelete of " << Pkg << " FU=" << FromUser << std::endl;
return false;
}
+ // if the removal is not explictely requested by the user, protect
+ // explicit new-install package from accidental removal by the
+ // problemresolver
else 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)
@@ -1257,9 +1261,10 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
if(FromUser)
{
- // Set it to manual if it's a new install or cancelling the
- // removal of a garbage package.
- if(P.Status == 2 || (!Pkg.CurrentVer().end() && !P.Marked))
+ // Set it to manual if it's a new install or already installed,
+ // but only if its not marked by the autoremover (aptitude depend on this behavior)
+ // or if we do automatic installation (aptitude never does it)
+ if(P.Status == 2 || (Pkg->CurrentVer != 0 && (AutoInst == true || P.Marked == false)))
P.Flags &= ~Flag::Auto;
}
else
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/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index ed35174bb..5b943cca1 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -638,21 +638,19 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
Dynamic<pkgCache::PkgIterator> DynP(P);
for (; P.end() != true; P = G.NextPkg(P))
{
- if (strcmp(P.Arch(),"all") == 0)
- continue;
pkgCache::PkgIterator allPkg;
Dynamic<pkgCache::PkgIterator> DynallPkg(allPkg);
pkgCache::VerIterator V = P.VersionList();
Dynamic<pkgCache::VerIterator> DynV(V);
for (; V.end() != true; V++)
{
- string const Arch = V.Arch(true);
+ char const * const Arch = P.Arch();
map_ptrloc *OldDepLast = NULL;
/* MultiArch handling introduces a lot of implicit Dependencies:
- MultiArch: same → Co-Installable if they have the same version
- Architecture: all → Need to be Co-Installable for internal reasons
- All others conflict with all other group members */
- bool const coInstall = (V->MultiArch == pkgCache::Version::All ||
+ bool const coInstall = ((V->MultiArch == pkgCache::Version::All && strcmp(Arch, "all") != 0) ||
V->MultiArch == pkgCache::Version::Same);
if (V->MultiArch == pkgCache::Version::All && allPkg.end() == true)
allPkg = G.FindPkg("all");
@@ -686,9 +684,15 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
}
} else {
// Conflicts: ${self}:other
- NewDepends(D, V, "",
- pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
- OldDepLast);
+ if (strcmp(Arch, "all") == 0) {
+ NewDepends(D, V, V.VerStr(),
+ pkgCache::Dep::NotEquals, pkgCache::Dep::Conflicts,
+ OldDepLast);
+ } else {
+ NewDepends(D, V, "",
+ pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
+ OldDepLast);
+ }
}
}
}