From 8d1277b777045f45ffae210edea608c27587d7a2 Mon Sep 17 00:00:00 2001 From: CoolStar Date: Thu, 20 Dec 2018 15:11:31 -0800 Subject: APT 1.7.0-sileo --- apt-pkg/acquire-item.cc | 10 +-- apt-pkg/acquire.cc | 2 +- apt-pkg/algorithms.cc | 155 ++++++++++++++++++++++++++++++++++---------- apt-pkg/contrib/fileutl.cc | 8 +-- apt-pkg/contrib/progress.cc | 2 +- apt-pkg/deb/debmetaindex.cc | 4 ++ apt-pkg/edsp.cc | 9 +++ apt-pkg/indexfile.cc | 4 ++ 8 files changed, 147 insertions(+), 47 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 09b8954b6..fb47bc676 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1725,11 +1725,11 @@ void pkgAcqMetaClearSig::QueueIndexes(bool const verify) /*{{{*/ else { - if (Target.IsOptional) - { - new CleanupItem(Owner, TransactionManager, Target); - continue; - } + if (Target.IsOptional){ + new CleanupItem(Owner, TransactionManager, Target); + continue; + } + // if we have no file to patch, no point in trying trypdiff &= (GetExistingFilename(GetFinalFileNameFromURI(Target.URI)).empty() == false); } diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 541785b03..8bedc9d71 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1262,7 +1262,7 @@ static struct timeval GetTimevalFromSteadyClock() auto const Time = std::chrono::steady_clock::now().time_since_epoch(); auto const Time_sec = std::chrono::duration_cast(Time); auto const Time_usec = std::chrono::duration_cast(Time - Time_sec); - return { Time_sec.count(), Time_usec.count() }; + return { Time_sec.count(), static_cast<__darwin_suseconds_t>(Time_usec.count()) }; } bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) { diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index bb0e2f873..4c34e5989 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -73,6 +73,32 @@ pkgSimulate::~pkgSimulate() Parameter Candidate == true displays the candidate package version */ void pkgSimulate::Describe(PkgIterator Pkg,ostream &out,bool Current,bool Candidate) { + bool forSileo = _config->FindB("APT::Format::for-sileo", false); + if (forSileo){ + VerIterator Ver(Sim); + + out << "\"Package\":\"" << Pkg.FullName(true) << "\""; + + if (Current == true) + { + Ver = Pkg.CurrentVer(); + if (Ver.end() == false) + out << ",\"Version\":\"" << Ver.VerStr() << '"'; + } + + if (Candidate == true) + { + Ver = Sim[Pkg].CandidateVerIter(Sim); + if (Ver.end() == true) + return; + + out << ",\"Version\":\"" << Ver.VerStr() << '"'; + out << ",\"Release\":\"" << Ver.RelStr() << '"'; + } + out << "}"; + return; + } + VerIterator Ver(Sim); out << Pkg.FullName(true); @@ -106,6 +132,47 @@ bool pkgSimulate::Install(PkgIterator iPkg,string File) } bool pkgSimulate::RealInstall(PkgIterator iPkg,string /*File*/) { + bool forSileo = _config->FindB("APT::Format::for-sileo", false); + if (forSileo){ + // Adapt the iterator + PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch()); + Flags[Pkg->ID] = 1; + + cout << "{\"Type\":\"Inst\","; + Describe(Pkg,cout,true,true); + Sim.MarkInstall(Pkg,false); + + // Look for broken conflicts+predepends. + for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I) + { + if (Sim[I].InstallVer == 0) + continue; + + for (DepIterator D = Sim[I].InstVerIter(Sim).DependsList(); D.end() == false;) + { + DepIterator Start; + DepIterator End; + D.GlobOr(Start,End); + if (Start.IsNegative() == true || + End->Type == pkgCache::Dep::PreDepends) + { + if ((Sim[End] & pkgDepCache::DepGInstall) == 0) + { + cout << " [" << I.FullName(false) << " on " << Start.TargetPkg().FullName(false) << ']'; + if (Start->Type == pkgCache::Dep::Conflicts) + _error->Error("Fatal, conflicts violated %s",I.FullName(false).c_str()); + } + } + } + } + + if (Sim.BrokenCount() != 0) + ShortBreaks(); + else + cout << endl; + return true; + } + // Adapt the iterator PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch()); Flags[Pkg->ID] = 1; @@ -159,46 +226,49 @@ bool pkgSimulate::Configure(PkgIterator iPkg) } bool pkgSimulate::RealConfigure(PkgIterator iPkg) { + bool forSileo = _config->FindB("APT::Format::for-sileo", false); // Adapt the iterator PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch()); Flags[Pkg->ID] = 2; - if (Sim[Pkg].InstBroken() == true) - { - cout << "Conf " << Pkg.FullName(false) << " broken" << endl; - - Sim.Update(); - - // Print out each package and the failed dependencies - for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D) + if (!forSileo){ + if (Sim[Pkg].InstBroken() == true) { - if (Sim.IsImportantDep(D) == false || - (Sim[D] & pkgDepCache::DepInstall) != 0) - continue; - - if (D->Type == pkgCache::Dep::Obsoletes) - cout << " Obsoletes:" << D.TargetPkg().FullName(false); - else if (D->Type == pkgCache::Dep::Conflicts) - cout << " Conflicts:" << D.TargetPkg().FullName(false); - else if (D->Type == pkgCache::Dep::DpkgBreaks) - cout << " Breaks:" << D.TargetPkg().FullName(false); - else - cout << " Depends:" << D.TargetPkg().FullName(false); - } - cout << endl; + cout << "Conf " << Pkg.FullName(false) << " broken" << endl; - _error->Error("Conf Broken %s",Pkg.FullName(false).c_str()); - } - else - { - cout << "Conf "; - Describe(Pkg,cout,false,true); + Sim.Update(); + + // Print out each package and the failed dependencies + for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D) + { + if (Sim.IsImportantDep(D) == false || + (Sim[D] & pkgDepCache::DepInstall) != 0) + continue; + + if (D->Type == pkgCache::Dep::Obsoletes) + cout << " Obsoletes:" << D.TargetPkg().FullName(false); + else if (D->Type == pkgCache::Dep::Conflicts) + cout << " Conflicts:" << D.TargetPkg().FullName(false); + else if (D->Type == pkgCache::Dep::DpkgBreaks) + cout << " Breaks:" << D.TargetPkg().FullName(false); + else + cout << " Depends:" << D.TargetPkg().FullName(false); + } + cout << endl; + + _error->Error("Conf Broken %s",Pkg.FullName(false).c_str()); + } + else + { + cout << "Conf "; + Describe(Pkg,cout,false,true); + } } if (Sim.BrokenCount() != 0) ShortBreaks(); - else + else if (!forSileo) cout << endl; return true; @@ -216,6 +286,8 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge) } bool pkgSimulate::RealRemove(PkgIterator iPkg,bool Purge) { + bool forSileo = _config->FindB("APT::Format::for-sileo", false); + // Adapt the iterator PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch()); if (Pkg.end() == true) @@ -227,16 +299,27 @@ bool pkgSimulate::RealRemove(PkgIterator iPkg,bool Purge) Flags[Pkg->ID] = 3; Sim.MarkDelete(Pkg); - if (Purge == true) - cout << "Purg "; - else - cout << "Remv "; + if (forSileo){ + if (Purge == true) + cout << "{\"Type\":\"Purg\","; + else + cout << "{\"Type\":\"Remv\","; + } else { + if (Purge == true) + cout << "Purg "; + else + cout << "Remv "; + } Describe(Pkg,cout,true,false); - if (Sim.BrokenCount() != 0) - ShortBreaks(); - else + if (!forSileo){ + if (Sim.BrokenCount() != 0) + ShortBreaks(); + else + cout << endl; + } else { cout << endl; + } return true; } diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index f7c8107b4..2ef1075a1 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -186,8 +186,8 @@ static char *searchpath(const char *binaryname){ strcpy(foundpath, binaryname); return foundpath; } else { - return NULL; - } + return NULL; + } } char *pathvar = getenv("PATH"); @@ -274,7 +274,7 @@ static char *fixedCmd(const char *cmdStr){ strcat(rawCommand, " "); strcat(rawCommand, args); } - rawCommand[(commandSize)+1] = '\0'; + rawCommand[(commandSize)+1] = '\0'; free(interpreter); free(abs_path); @@ -295,7 +295,7 @@ static char *fixedCmd(const char *cmdStr){ strcat(rawCommand, " "); strcat(rawCommand, args); } - rawCommand[(commandSize)+1] = '\0'; + rawCommand[(commandSize)+1] = '\0'; free(abs_path); free(cmdCpy); diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 806bd47f8..cab3ebce7 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -119,7 +119,7 @@ bool OpProgress::CheckChange(float Interval) auto const Now = std::chrono::steady_clock::now().time_since_epoch(); auto const Now_sec = std::chrono::duration_cast(Now); auto const Now_usec = std::chrono::duration_cast(Now - Now_sec); - struct timeval NowTime = { Now_sec.count(), Now_usec.count() }; + struct timeval NowTime = { Now_sec.count(), static_cast<__darwin_suseconds_t>(Now_usec.count()) }; std::chrono::duration Delta = std::chrono::seconds(NowTime.tv_sec - LastTime.tv_sec) + diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index cd794c7a7..2039f8308 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -566,6 +566,10 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro if (CheckValidUntil == true) { + + if (Date == 0) + strprintf(*ErrorText, _("Invalid '%s' entry in Release file %s"), "Date", Filename.c_str()); + std::string const StrValidUntil = Section.FindS("Valid-Until"); // if we have a Valid-Until header in the Release file, use it as default diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 2e39be377..9879fd8b3 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -661,6 +661,15 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres _error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str()); if (Progress != nullptr) Progress->Done(); + + bool forSileo = _config->FindB("APT::Format::for-sileo", false); + if (forSileo){ + std::cerr << "SOLVERR: " << section.FindS("Error") << std::endl; + std::cerr << "SOLVINFO:" << std::endl; + std::cerr << msg << std::endl << std::endl; + return false; + } + std::cerr << "The solver encountered an error of type: " << section.FindS("Error") << std::endl; std::cerr << "The following information might help you to understand what is wrong:" << std::endl; std::cerr << msg << std::endl << std::endl; diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 85d0e87cd..515208525 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -203,6 +203,10 @@ pkgDebianIndexTargetFile::pkgDebianIndexTargetFile(IndexTarget const &Target, bo /*}}}*/ std::string pkgDebianIndexTargetFile::ArchiveURI(std::string const &File) const/*{{{*/ { + std::string httpprefix = "http://"; + std::string httpsprefix = "https://"; + if (File.substr(0, httpprefix.size()) == httpprefix || File.substr(0, httpsprefix.size()) == httpsprefix) + return File; return Target.Option(IndexTarget::REPO_URI) + File; } /*}}}*/ -- cgit v1.2.3