summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc76
1 files changed, 58 insertions, 18 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index b9bdfd20f..034fce79c 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -18,7 +18,6 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/netrc.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/policy.h>
#include <apt-pkg/strutl.h>
@@ -85,7 +84,6 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : VerPins(nullptr),
/* */
bool pkgPolicy::InitDefaults()
{
- std::vector<std::unique_ptr<FileFd>> authconfs;
// Initialize the priorities based on the status of the package file
for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I != Cache->FileEnd(); ++I)
{
@@ -96,8 +94,6 @@ bool pkgPolicy::InitDefaults()
PFPriority[I->ID] = 100;
else if (I.Flagged(pkgCache::Flag::NotAutomatic))
PFPriority[I->ID] = 1;
- if (I.Flagged(pkgCache::Flag::PackagesRequireAuthorization) && !IsAuthorized(I, authconfs))
- PFPriority[I->ID] = NEVER_PIN;
}
// Apply the defaults..
@@ -175,6 +171,11 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
return;
}
+ bool IsSourcePin = APT::String::Startswith(Name, "src:");
+ if (IsSourcePin) {
+ Name = Name.substr(sizeof("src:") - 1);
+ }
+
size_t found = Name.rfind(':');
string Arch;
if (found != string::npos) {
@@ -190,10 +191,11 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() != true; ++G)
if (Name != G.Name() && match.ExpressionMatches(Name, G.Name()))
{
+ auto NameToPinFor = IsSourcePin ? string("src:").append(G.Name()) : string(G.Name());
if (Arch.empty() == false)
- CreatePin(Type, string(G.Name()).append(":").append(Arch), Data, Priority);
+ CreatePin(Type, NameToPinFor.append(":").append(Arch), Data, Priority);
else
- CreatePin(Type, G.Name(), Data, Priority);
+ CreatePin(Type, NameToPinFor, Data, Priority);
}
return;
}
@@ -209,20 +211,19 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
else
MatchingArch = Arch;
APT::CacheFilter::PackageArchitectureMatchesSpecification pams(MatchingArch);
- for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
- {
- if (pams(Pkg.Arch()) == false)
- continue;
-
- PkgPin P(Pkg.FullName());
- P.Type = Type;
- P.Priority = Priority;
- P.Data = Data;
- // Find matching version(s) and copy the pin into it
- pkgVersionMatch Match(P.Data,P.Type);
- for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
+ if (IsSourcePin) {
+ for (pkgCache::VerIterator Ver = Grp.VersionsInSource(); not Ver.end(); Ver = Ver.NextInSource())
{
+ if (pams(Ver.ParentPkg().Arch()) == false)
+ continue;
+
+ PkgPin P(Ver.ParentPkg().FullName());
+ P.Type = Type;
+ P.Priority = Priority;
+ P.Data = Data;
+ // Find matching version(s) and copy the pin into it
+ pkgVersionMatch Match(P.Data,P.Type);
if (Match.VersionMatches(Ver)) {
Pin *VP = VerPins + Ver->ID;
if (VP->Type == pkgVersionMatch::None) {
@@ -231,6 +232,30 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
}
}
}
+ } else {
+ for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
+ {
+ if (pams(Pkg.Arch()) == false)
+ continue;
+
+ PkgPin P(Pkg.FullName());
+ P.Type = Type;
+ P.Priority = Priority;
+ P.Data = Data;
+
+ // Find matching version(s) and copy the pin into it
+ pkgVersionMatch Match(P.Data,P.Type);
+ for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
+ {
+ if (Match.VersionMatches(Ver)) {
+ Pin *VP = VerPins + Ver->ID;
+ if (VP->Type == pkgVersionMatch::None) {
+ *VP = P;
+ matched = true;
+ }
+ }
+ }
+ }
}
}
@@ -285,6 +310,21 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &Fi
return PFPriority[File->ID];
}
/*}}}*/
+// SetPriority - Directly set priority /*{{{*/
+// ---------------------------------------------------------------------
+void pkgPolicy::SetPriority(pkgCache::VerIterator const &Ver, signed short Priority)
+{
+ Pin pin;
+ pin.Data = "pkgPolicy::SetPriority";
+ pin.Priority = Priority;
+ VerPins[Ver->ID] = pin;
+}
+void pkgPolicy::SetPriority(pkgCache::PkgFileIterator const &File, signed short Priority)
+{
+ PFPriority[File->ID] = Priority;
+}
+
+ /*}}}*/
// ReadPinDir - Load the pin files from this dir into a Policy /*{{{*/
// ---------------------------------------------------------------------
/* This will load each pin file in the given dir into a Policy. If the