diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2024-02-12 14:48:48 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-02-13 14:27:27 +0100 |
commit | a8352c2859a6f84b36fa5cd0af89231cb656b1ce (patch) | |
tree | 69ba18aec6b6a49efd85ef746feb752afc90a780 /apt-pkg/pkgcache.cc | |
parent | 26e0e9b76fb06afe5250eeb8e5b3d069d4793432 (diff) |
Add public phased update API
This moves the functions of the PhasedUpgrader class into
various other classes so they can be publicly exposed.
This introduces three new functions:
pkgDepCache::PhasingApplied() tells you whether phasing should
be applied to the package.
pkgProblemResolver::KeepPhasedUpdates() keeps back updates that
have phasing applied.
pkgCache::VerIterator::IsSecurityUpdate() determines whether this
version contains security fixes.
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r-- | apt-pkg/pkgcache.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 76336b9b3..06689aa33 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -1017,5 +1017,30 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const } /*}}}*/ +// VerIterator::IsSecurity - check if it is a security update /*{{{*/ +// See if this version is a security update. This also checks, for installed packages, +// if any of the previous versions is a security update +bool pkgCache::VerIterator::IsSecurityUpdate() const +{ + auto Pkg = ParentPkg(); + auto Installed = Pkg.CurrentVer(); + + auto OtherVer = Pkg.VersionList(); + + // Advance to first version < our version + while (OtherVer->ID != S->ID) + ++OtherVer; + + // Iterate over all versions < our version + for (; !OtherVer.end() && (Installed.end() || OtherVer->ID != Installed->ID); OtherVer++) + { + for (auto PF = OtherVer.FileList(); !PF.end(); PF++) + if (PF.File() && PF.File().Archive() != nullptr && APT::String::Endswith(PF.File().Archive(), "-security")) + return true; + } + return false; +} + + /*}}}*/ pkgCache::~pkgCache() {} |