From 14341a7ee1ca3dbcdcdbe10ad19b947ce23d972d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 12 Oct 2015 15:57:53 +0200 Subject: support .deb files in upgrade operations as well The main part is refactoring through to allow hiding the magic needed to support .deb files in deeper layers of libapt so that frontends have less exposure to Debian specific classes like debDebPkgFileIndex. --- apt-pkg/sourcelist.cc | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'apt-pkg/sourcelist.cc') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 2100b5d3c..56df976e8 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include @@ -536,7 +538,38 @@ std::vector pkgSourceList::GetVolatileFiles() const /*{{{*/ /*}}}*/ void pkgSourceList::AddVolatileFile(pkgIndexFile * const File) /*{{{*/ { - if (File != NULL) + if (File != nullptr) VolatileFiles.push_back(File); } /*}}}*/ +bool pkgSourceList::AddVolatileFile(std::string const &File) /*{{{*/ +{ + if (File.empty() || FileExists(File) == false) + return false; + + if (flExtension(File) == "deb") + AddVolatileFile(new debDebPkgFileIndex(File)); + else + return false; + + return true; +} + /*}}}*/ +void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector * const VolatileCmdL)/*{{{*/ +{ + std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) { + if (I != nullptr && (I[0] == '/' || (I[0] == '.' && I[1] == '/'))) + { + if (AddVolatileFile(I)) + { + if (VolatileCmdL != nullptr) + VolatileCmdL->push_back(I); + } + else + _error->Error(_("Unsupported file %s given on commandline"), I); + return true; + } + return false; + }); +} + /*}}}*/ -- cgit v1.2.3