summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-10-12 15:57:53 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-04 18:04:01 +0100
commit14341a7ee1ca3dbcdcdbe10ad19b947ce23d972d (patch)
treeff8d00ce2347061a0ca8f28fc6ff55173c125abc /apt-pkg
parent64b66a46a7fc9e7070ee6a758013a6059fee691e (diff)
downloadapt-14341a7ee1ca3dbcdcdbe10ad19b947ce23d972d.tar.gz
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.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheset.cc10
-rw-r--r--apt-pkg/sourcelist.cc35
-rw-r--r--apt-pkg/sourcelist.h4
3 files changed, 40 insertions, 9 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index 5e60ef54a..db34c4a20 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -441,14 +441,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
CacheSetHelper::VerSelector const fallback,
CacheSetHelper &helper,
bool const onlyFromName) {
- PackageSet pkgset;
- if(FileExists(pkg)) {
- helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
- if(pkgset.empty() == true)
- return false;
- return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
- }
-
std::string ver;
bool verIsRel = false;
size_t const vertag = pkg.find_last_of("/=");
@@ -457,6 +449,8 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
verIsRel = (pkg[vertag] == '/');
pkg.erase(vertag);
}
+
+ PackageSet pkgset;
if (onlyFromName == false)
helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
else {
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<config.h>
#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
@@ -20,6 +21,7 @@
#include <apt-pkg/tagfile.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/debindexfile.h>
#include <ctype.h>
#include <stddef.h>
@@ -536,7 +538,38 @@ std::vector<pkgIndexFile*> 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 char*> * 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;
+ });
+}
+ /*}}}*/
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 47a562d18..9c2d10a46 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -46,6 +46,7 @@ class pkgTagSection;
class pkgAcquire;
class pkgIndexFile;
class metaIndex;
+class CommandLine;
class pkgSourceList
{
@@ -129,6 +130,9 @@ class pkgSourceList
* @param File is an index file; pointer-ownership is transferred
*/
void AddVolatileFile(pkgIndexFile * const File);
+ bool AddVolatileFile(std::string const &File);
+ void AddVolatileFiles(CommandLine &CmdL, std::vector<const char*> * const VolatileCmdL);
+
/** @return list of files registered with #AddVolatileFile */
std::vector<pkgIndexFile*> GetVolatileFiles() const;