From 25252738d5ad6042b356f2d6bec2ca52ef08a1e2 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 4 Sep 2013 17:06:11 +0200 Subject: EDSP: bump protocol version to 0.5 --- apt-pkg/edsp.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index ee42267bc..a44d4a4a9 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -231,7 +231,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade, continue; req->append(" ").append(Pkg.FullName()); } - fprintf(output, "Request: EDSP 0.4\n"); + fprintf(output, "Request: EDSP 0.5\n"); if (del.empty() == false) fprintf(output, "Remove: %s\n", del.c_str()+1); if (inst.empty() == false) -- cgit v1.2.3 From caa3279367401965cbdd5e3a41c47945f3e263bd Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 4 Sep 2013 17:13:49 +0200 Subject: EDSP: add Architecture(s) multi-arch fields to the Request stanza --- apt-pkg/edsp.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index a44d4a4a9..33478dfa6 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -232,6 +232,15 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade, req->append(" ").append(Pkg.FullName()); } fprintf(output, "Request: EDSP 0.5\n"); + + const char *arch = _config->Find("APT::Architecture").c_str(); + std::vector archs = APT::Configuration::getArchitectures(); + fprintf(output, "Architecture: %s\n", arch); + fprintf(output, "Architectures:"); + for (std::vector::const_iterator a = archs.begin(); a != archs.end(); ++a) + fprintf(output, " %s", a->c_str()); + fprintf(output, "\n"); + if (del.empty() == false) fprintf(output, "Remove: %s\n", del.c_str()+1); if (inst.empty() == false) -- cgit v1.2.3 From f63c067e686b59ce9fa7c52bb39b7440e0770671 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 5 Sep 2013 16:36:44 +0200 Subject: EDSP: add Source field to Package stanzas --- apt-pkg/edsp.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 33478dfa6..178791dae 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -87,7 +88,12 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output, void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver) { + pkgRecords Recs(Cache); + pkgRecords::Parser &rec = Recs.Lookup(Ver.FileList()); + string srcpkg = rec.SourcePkg().empty() ? Pkg.Name() : rec.SourcePkg(); + fprintf(output, "Package: %s\n", Pkg.Name()); + fprintf(output, "Source: %s\n", srcpkg.c_str()); fprintf(output, "Architecture: %s\n", Ver.Arch()); fprintf(output, "Version: %s\n", Ver.VerStr()); if (Pkg.CurrentVer() == Ver) -- cgit v1.2.3 From b5ea5d4a5b8f82afb7bbe4c3eee07ae36f2fba9c Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 5 Sep 2013 10:54:12 +0200 Subject: EDSP: add APT-Release field to Package stanzas --- apt-pkg/edsp.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 178791dae..88ad27681 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -113,10 +113,22 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI else if ((Ver->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same) fprintf(output, "Multi-Arch: same\n"); signed short Pin = std::numeric_limits::min(); - for (pkgCache::VerFileIterator File = Ver.FileList(); File.end() == false; ++File) { - signed short const p = Cache.GetPolicy().GetPriority(File.File()); + std::set Releases; + for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; ++I) { + pkgCache::PkgFileIterator File = I.File(); + signed short const p = Cache.GetPolicy().GetPriority(File); if (Pin < p) Pin = p; + if ((File->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource) { + string Release = File.RelStr(); + if (!Release.empty()) + Releases.insert(Release); + } + } + if (!Releases.empty()) { + fprintf(output, "APT-Release:\n"); + for (std::set::iterator R = Releases.begin(); R != Releases.end(); ++R) + fprintf(output, " %s\n", R->c_str()); } fprintf(output, "APT-Pin: %d\n", Pin); if (Cache.GetCandidateVer(Pkg) == Ver) -- cgit v1.2.3 From 21ea1dbb50176a89e7f456f9b31220ff3097fdf2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 16:25:43 +0200 Subject: use free() instead of delete() when realloc is used ContentsExtract::~ContentsExtract() needs to use free() because Data got allocated via realloc() Reported-By: clang -fsanitize=address -fno-omit-frame-pointer --- apt-pkg/contrib/fileutl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index b77c7ff7f..bfd958183 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1241,7 +1241,8 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C if (d->lzma == NULL) d->lzma = new FileFdPrivate::LZMAFILE; d->lzma->file = (FILE*) compress_struct; - d->lzma->stream = LZMA_STREAM_INIT; + lzma_stream tmp_stream = LZMA_STREAM_INIT; + d->lzma->stream = tmp_stream; if ((Mode & ReadWrite) == ReadWrite) return FileFdError("ReadWrite mode is not supported for file %s", FileName.c_str()); -- cgit v1.2.3 From de6221c9d5f99a276628bcf45fb28537e46e7660 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 17:49:53 +0200 Subject: Do not try to cast a pkgDepCache::Policy to a pkgCache Fix incorrect cast in pkgDepCache::Policy::GetCandidateVer() Reported-By: clang -fsanitize=address -fno-omit-frame-pointer --- apt-pkg/depcache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 19a6e0d7e..aa96ac58f 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1678,7 +1678,7 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk { /* Not source/not automatic versions cannot be a candidate version unless they are already installed */ - VerIterator Last(*(pkgCache *)this,0); + VerIterator Last; for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I) { -- cgit v1.2.3 From 7f48c4dfbb1f27c51044edde0692d7446ee74438 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 23:42:10 +0200 Subject: use free() instead of delete[] in debSrcRecordParser::~debSrcRecordParser The Buffer was allocated using strndup() so we need to free it using free() instead of delete[] --- apt-pkg/deb/debsrcrecords.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index b09588dd3..a444cbe4d 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -186,6 +186,7 @@ bool debSrcRecordParser::Files(std::vector &List) /* */ debSrcRecordParser::~debSrcRecordParser() { - delete[] Buffer; + // was allocated via strndup() + free(Buffer); } /*}}}*/ -- cgit v1.2.3 From b29599105ed9a5bb38b55cb066ef81256d66be41 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 May 2014 10:00:52 +0200 Subject: Fix warning about uninitialized variable Reported-By: clang++ -Werror --- apt-pkg/deb/dpkgpm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e410594df..613a4de9f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1438,7 +1438,8 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) if (_config->FindB("DPkg::FlushSTDIN",true) == true && isatty(STDIN_FILENO)) { - int Flags,dummy; + int Flags; + int dummy = 0; if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0) _exit(100); -- cgit v1.2.3 From 5681b3fc2a8e35a12cd7c8e94013611211188459 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 May 2014 15:58:30 +0200 Subject: check exit status of external solvers Solvers are supposed to exit successfully even if they haven't found a solution, but a solver which fails drastically (like e.g. segfaults) should be detected and dealt with accordingly instead of ignored. --- apt-pkg/edsp.cc | 29 ++++++++++++++++++++++------- apt-pkg/edsp.h | 6 +++--- 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 88ad27681..52556c1ed 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -535,7 +535,7 @@ bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* } /*}}}*/ // EDSP::ExecuteSolver - fork requested solver and setup ipc pipes {{{*/ -bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_out) { +pid_t EDSP::ExecuteSolver(const char* const solver, int * const solver_in, int * const solver_out, bool) { std::vector const solverDirs = _config->FindVector("Dir::Bin::Solvers"); std::string file; for (std::vector::const_iterator dir = solverDirs.begin(); @@ -547,10 +547,16 @@ bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_o } if (file.empty() == true) - return _error->Error("Can't call external solver '%s' as it is not in a configured directory!", solver); + { + _error->Error("Can't call external solver '%s' as it is not in a configured directory!", solver); + return 0; + } int external[4] = {-1, -1, -1, -1}; if (pipe(external) != 0 || pipe(external + 2) != 0) - return _error->Errno("Resolve", "Can't create needed IPC pipes for EDSP"); + { + _error->Errno("Resolve", "Can't create needed IPC pipes for EDSP"); + return 0; + } for (int i = 0; i < 4; ++i) SetCloseExec(external[i], true); @@ -567,11 +573,19 @@ bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_o close(external[3]); if (WaitFd(external[1], true, 5) == false) - return _error->Errno("Resolve", "Timed out while Waiting on availability of solver stdin"); + { + _error->Errno("Resolve", "Timed out while Waiting on availability of solver stdin"); + return 0; + } *solver_in = external[1]; *solver_out = external[2]; - return true; + return Solver; +} +bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_out) { + if (ExecuteSolver(solver, solver_in, solver_out, true) == 0) + return false; + return true; } /*}}}*/ // EDSP::ResolveExternal - resolve problems by asking external for help {{{*/ @@ -579,7 +593,8 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, bool const upgrade, bool const distUpgrade, bool const autoRemove, OpProgress *Progress) { int solver_in, solver_out; - if (EDSP::ExecuteSolver(solver, &solver_in, &solver_out) == false) + pid_t const solver_pid = EDSP::ExecuteSolver(solver, &solver_in, &solver_out, true); + if (solver_pid == 0) return false; FILE* output = fdopen(solver_in, "w"); @@ -599,6 +614,6 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, if (EDSP::ReadResponse(solver_out, Cache, Progress) == false) return false; - return true; + return ExecWait(solver_pid, solver); } /*}}}*/ diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index f3092d3c6..9e833556a 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -205,10 +205,10 @@ public: * \param[out] solver_in will be the stdin of the solver * \param[out] solver_out will be the stdout of the solver * - * \return true if the solver could be started and the pipes - * are set up correctly, otherwise false and the pipes are invalid + * \return PID of the started solver or 0 if failure occurred */ - bool static ExecuteSolver(const char* const solver, int *solver_in, int *solver_out); + pid_t static ExecuteSolver(const char* const solver, int * const solver_in, int * const solver_out, bool /*overload*/); + APT_DEPRECATED bool static ExecuteSolver(const char* const solver, int *solver_in, int *solver_out); /** \brief call an external resolver to handle the request * -- cgit v1.2.3 From 003c40d373b8d3b8c6ddd9cc4e0f92dc493b4a60 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 May 2014 17:14:13 +0200 Subject: without a filename we can't stat pipes EDSP code uses pipes opened via an FD as sources and later for those files modification times and filesize are read - but never really used again. The result we get from FileFd is probably wrong, but as we don't use it anyway, we just don't fallback if we have nothing to fallback to Git-Dch: Ignore --- apt-pkg/contrib/fileutl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index bfd958183..1ba4674e5 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1798,7 +1798,8 @@ static bool StatFileFd(char const * const msg, int const iFd, std::string const // higher-level code will generate more meaningful messages, // even translated this would be meaningless for users return _error->Errno("fstat", "Unable to determine %s for fd %i", msg, iFd); - ispipe = S_ISFIFO(Buf.st_mode); + if (FileName.empty() == false) + ispipe = S_ISFIFO(Buf.st_mode); } // for compressor pipes st_size is undefined and at 'best' zero -- cgit v1.2.3 From 1f6cf9e79742ea8e328ef2225b2f5217a9440216 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 May 2014 18:01:47 +0200 Subject: support parsing EDSP requests Architecture{,s} stanza Adds also a small testcase for EDSP Git-Dch: Ignore --- apt-pkg/edsp.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 52556c1ed..6d1b68c23 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -438,6 +438,13 @@ bool EDSP::ReadRequest(int const input, std::list &install, distUpgrade = EDSP::StringToBool(line.c_str() + 14, false); else if (line.compare(0, 11, "Autoremove:") == 0) autoRemove = EDSP::StringToBool(line.c_str() + 12, false); + else if (line.compare(0, 13, "Architecture:") == 0) + _config->Set("APT::Architecture", line.c_str() + 14); + else if (line.compare(0, 14, "Architectures:") == 0) + { + std::string const archs = line.c_str() + 15; + _config->Set("APT::Architectures", SubstVar(archs, " ", ",")); + } else _error->Warning("Unknown line in EDSP Request stanza: %s", line.c_str()); -- cgit v1.2.3 From e41d3d7e25754f858b6dfe4dd841f4749f7f3ab1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 7 Jun 2014 22:46:37 +0200 Subject: do not revert candidate for protected packages In commit 21b3eac8 I promoted the check for installable dependencies to a pre-install check, which also reverts to a known good candidate (the installed version) if it fails. This revert was done even for user requested candidate switches which disabled our Broken detection so that install requests which are impossible to satisfy do not fail anymore, but print an (incomplete) solution proposal and then exit successfully. Closes: 745046 --- apt-pkg/depcache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index aa96ac58f..c25672d1c 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1374,7 +1374,7 @@ bool pkgDepCache::IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator con // 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) + if (Pkg->CurrentVer != 0 && (PkgState[Pkg->ID].iFlags & Protected) != Protected) SetCandidateVersion(Pkg.CurrentVer()); return false; } -- cgit v1.2.3 From 462557017a0d8be321ca7d3eb96072f4db6a92ec Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 9 Jun 2014 09:06:07 +0200 Subject: add pkgSrcRecords::Next() to step through all the pkgSrcRecords --- apt-pkg/srcrecords.cc | 37 ++++++++++++++++++++++++------------- apt-pkg/srcrecords.h | 9 +++++++-- 2 files changed, 31 insertions(+), 15 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 775cf2e5f..f4d034b85 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -81,6 +81,27 @@ bool pkgSrcRecords::Restart() return true; } /*}}}*/ +// SrcRecords::Next - Step to the next Source Record /*{{{*/ +// --------------------------------------------------------------------- +/* Step to the next source package record */ +const pkgSrcRecords::Parser* pkgSrcRecords::Next() +{ + if (Current == Files.end()) + return 0; + + // Step to the next record, possibly switching files + while ((*Current)->Step() == false) + { + if (_error->PendingError() == true) + return 0; + ++Current; + if (Current == Files.end()) + return 0; + } + + return *Current; +} + /*}}}*/ // SrcRecords::Find - Find the first source package with the given name /*{{{*/ // --------------------------------------------------------------------- /* This searches on both source package names and output binary names and @@ -88,21 +109,11 @@ bool pkgSrcRecords::Restart() function to be called multiple times to get successive entries */ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOnly) { - if (Current == Files.end()) - return 0; - while (true) { - // Step to the next record, possibly switching files - while ((*Current)->Step() == false) - { - if (_error->PendingError() == true) - return 0; - ++Current; - if (Current == Files.end()) - return 0; - } - + if(Next() == 0) + return 0; + // IO error somehow if (_error->PendingError() == true) return 0; diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index 9915debfe..82460d70f 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -95,8 +95,13 @@ class pkgSrcRecords // Reset the search bool Restart(); - // Locate a package by name - Parser *Find(const char *Package,bool const &SrcOnly = false); + // Step to the next SourcePackage and return pointer to the + // next SourceRecord. The pointer is owned by libapt. + const Parser* Next(); + + // Locate a package by name and return pointer to the Parser. + // The pointer is owned by libapt. + Parser* Find(const char *Package,bool const &SrcOnly = false); pkgSrcRecords(pkgSourceList &List); virtual ~pkgSrcRecords(); -- cgit v1.2.3 From 401e5db12dd71ed84e8d17a559ff5932c1b98367 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 10 Jun 2014 15:07:15 +0200 Subject: use pkgSrcRecords::Step() instead of Next() --- apt-pkg/srcrecords.cc | 6 +++--- apt-pkg/srcrecords.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index f4d034b85..81b1c545d 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -81,10 +81,10 @@ bool pkgSrcRecords::Restart() return true; } /*}}}*/ -// SrcRecords::Next - Step to the next Source Record /*{{{*/ +// SrcRecords::Step - Step to the next Source Record /*{{{*/ // --------------------------------------------------------------------- /* Step to the next source package record */ -const pkgSrcRecords::Parser* pkgSrcRecords::Next() +const pkgSrcRecords::Parser* pkgSrcRecords::Step() { if (Current == Files.end()) return 0; @@ -111,7 +111,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn { while (true) { - if(Next() == 0) + if(Step() == 0) return 0; // IO error somehow diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index 82460d70f..e000e176a 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -97,7 +97,7 @@ class pkgSrcRecords // Step to the next SourcePackage and return pointer to the // next SourceRecord. The pointer is owned by libapt. - const Parser* Next(); + const Parser* Step(); // Locate a package by name and return pointer to the Parser. // The pointer is owned by libapt. -- cgit v1.2.3