diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-method.h | 4 | ||||
-rw-r--r-- | apt-pkg/cdrom.h | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 15 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 6 | ||||
-rw-r--r-- | apt-pkg/contrib/macros.h | 4 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 3 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 24 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 90 | ||||
-rw-r--r-- | apt-pkg/depcache.h | 2 | ||||
-rw-r--r-- | apt-pkg/edsp.h | 11 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.h | 18 | ||||
-rw-r--r-- | apt-pkg/tagfile.h | 8 |
12 files changed, 124 insertions, 65 deletions
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index f0f2a537a..221ccf273 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -20,6 +20,8 @@ #ifndef PKGLIB_ACQUIRE_METHOD_H #define PKGLIB_ACQUIRE_METHOD_H +#include <apt-pkg/macros.h> + #include <stdarg.h> #include <time.h> @@ -107,7 +109,7 @@ class pkgAcqMethod virtual ~pkgAcqMethod() {}; private: - void Dequeue(); + APT_HIDDEN void Dequeue(); }; /** @} */ diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 0ed4a6a73..0f2c2cd02 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -1,6 +1,8 @@ #ifndef PKGLIB_CDROM_H #define PKGLIB_CDROM_H +#include <apt-pkg/macros.h> + #include<string> #include<vector> @@ -73,7 +75,7 @@ class pkgCdrom /*{{{*/ bool Add(pkgCdromStatus *log); private: - bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, + APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive); }; /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 1eabf37f4..69406a9bf 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1191,7 +1191,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C d->openmode = Mode; d->compressor = compressor; #if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA - if (AutoClose == false && compress_open != NULL) + if ((Flags & AutoClose) != AutoClose && compress_open != NULL) { // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well int const internFd = dup(iFd); @@ -1430,7 +1430,15 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) errno = 0; } else + { Res = Size - d->lzma->stream.avail_out; + if (Res == 0) + { + // lzma run was okay, but produced no output… + Res = -1; + errno = EINTR; + } + } } #endif else @@ -1439,7 +1447,12 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) if (Res < 0) { if (errno == EINTR) + { + // trick the while-loop into running again + Res = 1; + errno = 0; continue; + } if (false) /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 278a25742..f25ed3622 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -150,11 +150,11 @@ class FileFd private: FileFdPrivate* d; - bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); + APT_HIDDEN bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); // private helpers to set Fail flag and call _error->Error - bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; - bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; + APT_HIDDEN bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; + APT_HIDDEN bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; }; bool RunScripts(const char *Cnf); diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index d97053553..2d6448e5e 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -94,8 +94,12 @@ #if APT_GCC_VERSION >= 0x0400 #define APT_SENTINEL __attribute__((sentinel)) + #define APT_PUBLIC __attribute__ ((visibility ("default"))) + #define APT_HIDDEN __attribute__ ((visibility ("hidden"))) #else #define APT_SENTINEL + #define APT_PUBLIC + #define APT_HIDDEN #endif // cold functions are unlikely() to be called diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 286244cc9..baace79fe 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -15,6 +15,7 @@ #include <apt-pkg/tagfile.h> #include <apt-pkg/md5.h> #include <apt-pkg/pkgcache.h> +#include <apt-pkg/macros.h> #include <string> #include <vector> @@ -102,7 +103,7 @@ class debListParser : public pkgCacheGenerator::ListParser virtual ~debListParser() {}; private: - unsigned char ParseMultiArch(bool const showErrors); + APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors); }; #endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 9fee7c923..5a5fff13b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1530,28 +1530,18 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) // here but keep the loop going and just report it as a error // for later bool const stopOnError = _config->FindB("Dpkg::StopOnError",true); - - if(stopOnError) - RunScripts("DPkg::Post-Invoke"); - if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) + if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) strprintf(d->dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]); else if (WIFEXITED(Status) != 0) strprintf(d->dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status)); - else + else strprintf(d->dpkg_error, "Sub-process %s exited unexpectedly",Args[0]); + _error->Error("%s", d->dpkg_error.c_str()); - if(d->dpkg_error.size() > 0) - _error->Error("%s", d->dpkg_error.c_str()); - - if(stopOnError) - { - CloseLog(); - StopPtyMagic(); - d->progress->Stop(); - return false; - } - } + if(stopOnError) + break; + } } // dpkg is done at this point d->progress->Stop(); @@ -1582,7 +1572,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) } Cache.writeStateFile(NULL); - return true; + return d->dpkg_error.empty(); } void SigINT(int /*sig*/) { diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index e2c412757..19a6e0d7e 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1059,10 +1059,9 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, return true; } - // check if we are allowed to install the package (if we haven't already) - if (P.Mode != ModeInstall || P.InstallVer != P.CandidateVer) - if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false) - return false; + // check if we are allowed to install the package + if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false) + return false; ActionGroup group(*this); P.iFlags &= ~AutoKept; @@ -1123,32 +1122,22 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, continue; /* Check if this dep should be consider for install. If it is a user - defined important dep and we are installed a new package then + defined important dep and we are installed a new package then it will be installed. Otherwise we only check for important - deps that have changed from the installed version - */ + deps that have changed from the installed version */ if (IsImportantDep(Start) == false) continue; - /* If we are in an or group locate the first or that can - succeed. We have already cached this.. */ + /* If we are in an or group locate the first or that can + succeed. We have already cached this… */ for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors) ++Start; + + /* unsatisfiable dependency: IsInstallOkDependenciesSatisfiableByCandidates + would have prevented us to get here if not overridden, so just skip + over the problem here as the frontend will know what it is doing */ if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer && Start.IsNegative() == false) - { - if(DebugAutoInstall == true) - std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl; - if (Start.IsCritical() == false) - continue; - // if the dependency was critical, we have absolutely no chance to install it, - // so if it wasn't installed remove it again. If it was, discard the candidate - // as the problemresolver will trip over it otherwise trying to install it (#735967) - if (Pkg->CurrentVer == 0) - MarkDelete(Pkg,false,Depth + 1, false); - else - SetCandidateVersion(Pkg.CurrentVer()); - return false; - } + continue; /* Check if any ImportantDep() (but not Critical) were added * since we installed the package. Also check for deps that @@ -1300,7 +1289,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst, unsigned long Depth, bool FromUser) { - return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser); + return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser) && + IsInstallOkDependenciesSatisfiableByCandidates(Pkg,AutoInst, Depth, FromUser); } bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, bool const /*AutoInst*/, unsigned long const Depth, bool const FromUser) @@ -1308,6 +1298,11 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, if (FromUser == true) // as always: user is always right return true; + // if we have checked before and it was okay, it will still be okay + if (PkgState[Pkg->ID].Mode == ModeInstall && + PkgState[Pkg->ID].InstallVer == PkgState[Pkg->ID].CandidateVer) + return true; + // ignore packages with none-M-A:same candidates VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this); if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer() || @@ -1340,6 +1335,53 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, return true; } +bool pkgDepCache::IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg, + bool const AutoInst, unsigned long const Depth, bool const /*FromUser*/) +{ + if (AutoInst == false) + return true; + + VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this); + if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer()) + return true; + + for (DepIterator Dep = CandVer.DependsList(); Dep.end() != true;) + { + // Grok or groups + DepIterator Start = Dep; + bool Result = true; + unsigned Ors = 0; + for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors) + { + LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or; + + if ((DepState[Dep->ID] & DepInstall) == DepInstall) + Result = false; + } + + if (Start.IsCritical() == false || Start.IsNegative() == true || Result == false) + continue; + + /* If we are in an or group locate the first or that can succeed. + We have already cached this… */ + for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors) + ++Start; + + if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer) + { + if (DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl; + + // the dependency is critical, but can't be installed, so discard the candidate + // as the problemresolver will trip over it otherwise trying to install it (#735967) + if (Pkg->CurrentVer != 0) + SetCandidateVersion(Pkg.CurrentVer()); + return false; + } + } + + return true; +} /*}}}*/ // DepCache::SetReInstall - Set the reinstallation flag /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index bde648c65..bec651279 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -506,6 +506,8 @@ class pkgDepCache : protected pkgCache::Namespace // methods call by IsInstallOk bool IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, bool const AutoInst, unsigned long const Depth, bool const FromUser); + bool IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg, + bool const AutoInst, unsigned long const Depth, bool const FromUser); // methods call by IsDeleteOk bool IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg, diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index ae20ed7db..f3092d3c6 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -12,6 +12,7 @@ #include <apt-pkg/cacheset.h> #include <apt-pkg/pkgcache.h> #include <apt-pkg/cacheiterators.h> +#include <apt-pkg/macros.h> #include <stdio.h> @@ -32,15 +33,15 @@ class EDSP /*{{{*/ static const char * const PrioMap[]; static const char * const DepMap[]; - bool static ReadLine(int const input, std::string &line); - bool static StringToBool(char const *answer, bool const defValue); + APT_HIDDEN bool static ReadLine(int const input, std::string &line); + APT_HIDDEN bool static StringToBool(char const *answer, bool const defValue); - void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, + APT_HIDDEN void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver); - void static WriteScenarioDependency(FILE* output, + APT_HIDDEN void static WriteScenarioDependency(FILE* output, pkgCache::VerIterator const &Ver); - void static WriteScenarioLimitedDependency(FILE* output, + APT_HIDDEN void static WriteScenarioLimitedDependency(FILE* output, pkgCache::VerIterator const &Ver, APT::PackageSet const &pkgset); public: diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 5994dab9f..1e1a71026 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -38,10 +38,10 @@ class pkgCacheGenerator /*{{{*/ private: pkgCache::StringItem *UniqHash[26]; - map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); }; - map_ptrloc WriteStringInMap(const char *String); - map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len); - map_ptrloc AllocateInMap(const unsigned long &size); + APT_HIDDEN map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); }; + APT_HIDDEN map_ptrloc WriteStringInMap(const char *String); + APT_HIDDEN map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len); + APT_HIDDEN map_ptrloc AllocateInMap(const unsigned long &size); public: @@ -117,14 +117,14 @@ class pkgCacheGenerator /*{{{*/ ~pkgCacheGenerator(); private: - bool MergeListGroup(ListParser &List, std::string const &GrpName); - bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); - bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, + APT_HIDDEN bool MergeListGroup(ListParser &List, std::string const &GrpName); + APT_HIDDEN bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); + APT_HIDDEN bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, std::string const &Version, pkgCache::VerIterator* &OutVer); - bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P, + APT_HIDDEN bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P, pkgCache::VerIterator &V); - bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D); + APT_HIDDEN bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D); }; /*}}}*/ // This is the abstract package list parser class. /*{{{*/ diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 2f600d397..d5b62e76d 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -20,6 +20,8 @@ #ifndef PKGLIB_TAGFILE_H #define PKGLIB_TAGFILE_H +#include <apt-pkg/macros.h> + #include <stdio.h> #include <string> @@ -93,9 +95,9 @@ class pkgTagFile { pkgTagFilePrivate *d; - bool Fill(); - bool Resize(); - bool Resize(unsigned long long const newSize); + APT_HIDDEN bool Fill(); + APT_HIDDEN bool Resize(); + APT_HIDDEN bool Resize(unsigned long long const newSize); public: |