summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc42
-rw-r--r--apt-pkg/deb/debindexfile.h1
-rw-r--r--apt-pkg/deb/deblistparser.cc24
-rw-r--r--apt-pkg/deb/deblistparser.h6
-rw-r--r--apt-pkg/deb/debmetaindex.cc61
-rw-r--r--apt-pkg/deb/debmetaindex.h3
-rw-r--r--apt-pkg/deb/debrecords.cc11
-rw-r--r--apt-pkg/deb/debrecords.h4
-rw-r--r--apt-pkg/deb/debsrcrecords.cc14
-rw-r--r--apt-pkg/deb/debsrcrecords.h4
-rw-r--r--apt-pkg/deb/debsystem.cc17
-rw-r--r--apt-pkg/deb/debsystem.h3
-rw-r--r--apt-pkg/deb/debversion.cc4
-rw-r--r--apt-pkg/deb/dpkgpm.cc19
-rw-r--r--apt-pkg/deb/dpkgpm.h6
15 files changed, 118 insertions, 101 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index c55847305..6aa3af162 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -11,23 +11,23 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debrecords.h>
-#include <apt-pkg/configuration.h>
+#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/srcrecords.h>
-#include <stdio.h>
#include <iostream>
-#include <string>
+#include <memory>
#include <sstream>
+#include <string>
+#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -66,7 +66,7 @@ bool debSourcesIndex::OpenListFile(FileFd &, std::string const &)
}
pkgCacheListParser * debSourcesIndex::CreateListParser(FileFd &)
{
- return NULL;
+ return nullptr;
}
uint8_t debSourcesIndex::GetIndexFlags() const
{
@@ -128,16 +128,10 @@ pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debTranslationsParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// dpkg/status Index /*{{{*/
@@ -162,16 +156,10 @@ pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debStatusListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debStatusListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// DebPkgFile Index - a single .deb file as an index /*{{{*/
@@ -244,16 +232,10 @@ pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
+ std::unique_ptr<pkgCacheListParser> Parser(new debDebFileParser(&Pkg, DebFile));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
uint8_t debDebPkgFileIndex::GetIndexFlags() const
{
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 3652f631c..40a9e4bbc 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -16,7 +16,6 @@
#define PKGLIB_DEBINDEXFILE_H
#include <apt-pkg/indexfile.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/srcrecords.h>
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4e61f0fc2..378988a1c 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -12,26 +12,25 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/deblistparser.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/cachefilter.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/cachefilter.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/crc-16.h>
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/tagfile.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile-keys.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/tagfile.h>
-#include <stddef.h>
-#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
#include <ctype.h>
+#include <stddef.h>
+#include <string.h>
/*}}}*/
using std::string;
@@ -372,6 +371,11 @@ unsigned short debListParser::VersionHash()
string to make that not matter. */
for (; Start != End; ++Start)
{
+ // Strip away 0: epochs from input
+ if (*Start == '0' && Start[1] == ':') {
+ Start++; // Skip the :
+ continue; // Skip the 0
+ }
if (isspace_ascii(*Start) != 0 || *Start == '=')
continue;
Result = AddCRC16Byte(Result, tolower_ascii_unsafe(*Start));
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 39f42915c..8d7efc746 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -11,11 +11,11 @@
#ifndef PKGLIB_DEBLISTPARSER_H
#define PKGLIB_DEBLISTPARSER_H
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/tagfile.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/tagfile.h>
#include <string>
#include <vector>
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index cba00aa8e..a0adf85be 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -1,30 +1,30 @@
#include <config.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/debmetaindex.h>
-#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/debmetaindex.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/gpgv.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/gpgv.h>
-#include <apt-pkg/macros.h>
+#include <algorithm>
#include <map>
+#include <sstream>
#include <string>
#include <utility>
#include <vector>
-#include <algorithm>
-#include <sstream>
-#include <sys/stat.h>
#include <string.h>
+#include <sys/stat.h>
#include <apti18n.h>
@@ -51,6 +51,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/
std::vector<std::string> Architectures;
std::vector<std::string> NoSupportForAll;
+ std::vector<std::string> SupportedComponents;
std::map<std::string, std::string> const ReleaseOptions;
debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), ReleaseOptions(Options) {}
@@ -392,8 +393,12 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
// FIXME: find better tag name
SupportsAcquireByHash = Section.FindB("Acquire-By-Hash", false);
+ SetOrigin(Section.FindS("Origin"));
+ SetLabel(Section.FindS("Label"));
+ SetVersion(Section.FindS("Version"));
Suite = Section.FindS("Suite");
Codename = Section.FindS("Codename");
+ SetReleaseNotes(Section.FindS("Release-Notes"));
{
std::string const archs = Section.FindS("Architectures");
if (archs.empty() == false)
@@ -404,6 +409,29 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
if (targets.empty() == false)
d->NoSupportForAll = VectorizeString(targets, ' ');
}
+ for (auto const &comp: VectorizeString(Section.FindS("Components"), ' '))
+ {
+ if (comp.empty())
+ continue;
+ auto const pos = comp.find_last_of('/');
+ if (pos != std::string::npos) // e.g. security.debian.org uses this style
+ d->SupportedComponents.push_back(comp.substr(pos + 1));
+ d->SupportedComponents.push_back(std::move(comp));
+ }
+ {
+ decltype(pkgCache::ReleaseFile::Flags) flags = 0;
+ Section.FindFlag("NotAutomatic", flags, pkgCache::Flag::NotAutomatic);
+ signed short defaultpin = 500;
+ if ((flags & pkgCache::Flag::NotAutomatic) == pkgCache::Flag::NotAutomatic)
+ {
+ Section.FindFlag("ButAutomaticUpgrades", flags, pkgCache::Flag::ButAutomaticUpgrades);
+ if ((flags & pkgCache::Flag::ButAutomaticUpgrades) == pkgCache::Flag::ButAutomaticUpgrades)
+ defaultpin = 100;
+ else
+ defaultpin = 1;
+ }
+ SetDefaultPin(defaultpin);
+ }
bool FoundHashSum = false;
bool FoundStrongHashSum = false;
@@ -461,7 +489,6 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
if (CheckValidUntil == true)
{
- std::string const Label = Section.FindS("Label");
std::string const StrValidUntil = Section.FindS("Valid-Until");
// if we have a Valid-Until header in the Release file, use it as default
@@ -474,6 +501,7 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
return false;
}
}
+ auto const Label = GetLabel();
// get the user settings for this archive and use what expires earlier
time_t MaxAge = d->ValidUntilMax;
if (MaxAge == 0)
@@ -733,6 +761,13 @@ bool debReleaseIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) c
return std::find(d->NoSupportForAll.begin(), d->NoSupportForAll.end(), target.Option(IndexTarget::CREATED_BY)) == d->NoSupportForAll.end();
}
/*}}}*/
+bool debReleaseIndex::HasSupportForComponent(std::string const &component) const/*{{{*/
+{
+ if (d->SupportedComponents.empty())
+ return true;
+ return std::find(d->SupportedComponents.begin(), d->SupportedComponents.end(), component) != d->SupportedComponents.end();
+}
+ /*}}}*/
std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() /*{{{*/
{
if (Indexes != NULL)
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index f903617f7..5a97cfc78 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -1,8 +1,8 @@
#ifndef PKGLIB_DEBMETAINDEX_H
#define PKGLIB_DEBMETAINDEX_H
-#include <apt-pkg/metaindex.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
#include <map>
#include <string>
@@ -61,6 +61,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex
virtual bool IsTrusted() const APT_OVERRIDE;
bool IsArchitectureSupported(std::string const &arch) const;
bool IsArchitectureAllSupportedFor(IndexTarget const &target) const;
+ bool HasSupportForComponent(std::string const &component) const;
void AddComponent(std::string const &sourcesEntry,
bool const isSrc, std::string const &Name,
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index a132f34a6..bc4a378eb 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -10,22 +10,21 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/debrecords.h>
-#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/debrecords.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/error.h>
-#include <string.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <langinfo.h>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index ae75a2b78..828c2b93b 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -14,10 +14,10 @@
#ifndef PKGLIB_DEBRECORDS_H
#define PKGLIB_DEBRECORDS_H
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/tagfile.h>
#include <string>
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index d664b609e..0368817c2 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -11,22 +11,22 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/hashes.h>
#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/hashes.h>
-#include <apt-pkg/gpgv.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
using std::max;
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index 850040cf5..349e66ba2 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -11,13 +11,13 @@
#ifndef PKGLIB_DEBSRCRECORDS_H
#define PKGLIB_DEBSRCRECORDS_H
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/fileutl.h>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
class pkgIndexFile;
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 899f7328b..3ad25ba05 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -12,30 +12,29 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debindexfile.h>
#include <apt-pkg/debsystem.h>
#include <apt-pkg/debversion.h>
-#include <apt-pkg/debindexfile.h>
#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <algorithm>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
#include <string>
#include <vector>
-#include <unistd.h>
+#include <ctype.h>
#include <dirent.h>
#include <errno.h>
-#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/wait.h>
-#include <fcntl.h>
+#include <unistd.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 5185c92d8..9fdecb42f 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -10,9 +10,8 @@
#ifndef PKGLIB_DEBSYSTEM_H
#define PKGLIB_DEBSYSTEM_H
-#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgsystem.h>
#include <vector>
class Configuration;
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index 48462c6a2..9fe2fd6b3 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -15,9 +15,9 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/pkgcache.h>
-#include <string.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
debVersioningSystem debVS;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 80bee03dd..58599193e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -11,20 +11,20 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/debsystem.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/debsystem.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/install-progress.h>
-#include <apt-pkg/packagemanager.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/statechanges.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/statechanges.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/version.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
@@ -37,9 +37,8 @@
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <sys/wait.h>
#include <sys/types.h>
-#include <dirent.h>
+#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
@@ -49,14 +48,14 @@
#include <cstring>
#include <iostream>
#include <map>
+#include <numeric>
#include <set>
+#include <sstream>
#include <string>
#include <type_traits>
-#include <utility>
#include <unordered_set>
+#include <utility>
#include <vector>
-#include <sstream>
-#include <numeric>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index d1c2bcf41..324551387 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -10,14 +10,14 @@
#ifndef PKGLIB_DPKGPM_H
#define PKGLIB_DPKGPM_H
+#include <apt-pkg/macros.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/macros.h>
-#include <vector>
#include <map>
-#include <stdio.h>
#include <string>
+#include <vector>
+#include <stdio.h>
#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/init.h>