summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/debmetaindex.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 0f05cb21a..3bc7f78de 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -17,6 +17,7 @@
#include <apt-pkg/tagfile.h>
#include <algorithm>
+#include <cassert>
#include <map>
#include <optional>
#include <sstream>
@@ -1299,7 +1300,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
std::string const &Dist, std::string const &Section,
bool const &IsSrc, std::map<std::string, std::string> Options) const
{
- auto Snapshot = GetSnapshotOption(Options, "snapshot");
+ std::string SnapshotAptConf = _config->Find("APT::Snapshot");
+ std::string Snapshot = GetSnapshotOption(Options, "snapshot", SnapshotAptConf.empty() ? "" : SnapshotAptConf + "?");
if (not Snapshot.empty()) {
std::map<std::string, std::string> SnapshotOptions = Options;
@@ -1339,15 +1341,28 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
}
if (Server.empty() || Server == "no")
{
+ if (APT::String::Endswith(Snapshot, "?"))
+ {
+ Options.erase("SHADOWED");
+ goto nosnapshot;
+ }
if (Server != "no" && filename.empty())
return _error->Error("Cannot identify snapshot server for %s %s - run update without snapshot id first", URI.c_str(), Dist.c_str());
return _error->Error("Snapshots not supported for %s %s", URI.c_str(), Dist.c_str());
}
+ // We have found a server by now, so we enable snapshots for this source.
+ if (APT::String::Endswith(Snapshot, "?"))
+ {
+ Snapshot.pop_back();
+ }
+
+ assert(not Snapshot.empty());
auto SnapshotURI = SubstVar(SubstVar(Server, "@SNAPSHOTID@", Snapshot), "@PATH@", ArchiveURI.Path);
if (not CreateItemInternalOne(List, SnapshotURI, Dist, Section, IsSrc, SnapshotOptions))
return false;
}
+ nosnapshot:
if (not CreateItemInternalOne(List, URI, Dist, Section, IsSrc, Options))
return false;