summaryrefslogtreecommitdiff
path: root/apt-private
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-private
parent64b66a46a7fc9e7070ee6a758013a6059fee691e (diff)
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-private')
-rw-r--r--apt-private/private-install.cc49
-rw-r--r--apt-private/private-install.h3
-rw-r--r--apt-private/private-upgrade.cc5
3 files changed, 31 insertions, 26 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 28b8d9a7b..a9d93a92a 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -21,7 +21,6 @@
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/upgrade.h>
#include <apt-pkg/install-progress.h>
-#include <apt-pkg/debindexfile.h>
#include <stdlib.h>
#include <string.h>
@@ -496,10 +495,15 @@ static const unsigned short MOD_INSTALL = 2;
bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode)
{
+ std::vector<const char*> VolatileCmdL;
+ return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeMode);
+}
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<const char*> &VolatileCmdL, CacheFile &Cache, int UpgradeMode)
+{
std::map<unsigned short, APT::VersionSet> verset;
- return DoCacheManipulationFromCommandLine(CmdL, Cache, verset, UpgradeMode);
+ return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, UpgradeMode);
}
-bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<const char*> &VolatileCmdL, CacheFile &Cache,
std::map<unsigned short, APT::VersionSet> &verset, int UpgradeMode)
{
// Enter the special broken fixing mode if the user specified arguments
@@ -535,6 +539,20 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
verset = APT::VersionSet::GroupedFromCommandLine(Cache,
CmdL.FileList + 1, mods, fallback, helper);
+ for (auto const &I: VolatileCmdL)
+ {
+ pkgCache::PkgIterator const P = Cache->FindPkg(I);
+ if (P.end())
+ continue;
+
+ // Set any version providing the .deb as the candidate.
+ for (auto Prv = P.ProvidesList(); Prv.end() == false; Prv++)
+ Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer());
+
+ // via cacheset to have our usual virtual handling
+ APT::VersionContainerInterface::FromPackage(&(verset[MOD_INSTALL]), Cache, P, APT::CacheSetHelper::CANDIDATE, helper);
+ }
+
if (_error->PendingError() == true)
{
helper.showVirtualPackageErrors(Cache);
@@ -656,33 +674,16 @@ struct PkgIsExtraInstalled {
bool DoInstall(CommandLine &CmdL)
{
CacheFile Cache;
- // first check for local pkgs and add them to the cache
- for (const char **I = CmdL.FileList; *I != 0; I++)
- {
- if(FileExists(*I) && flExtension(*I) == "deb")
- Cache.GetSourceList()->AddVolatileFile(new debDebPkgFileIndex(*I));
- }
+ std::vector<char const *> VolatileCmdL;
+ Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL);
// then open the cache
if (Cache.OpenForInstall() == false ||
Cache.CheckDeps(CmdL.FileSize() != 1) == false)
return false;
-
- std::map<unsigned short, APT::VersionSet> verset;
-
- for (const char **I = CmdL.FileList; *I != 0; I++) {
- // Check for local pkgs like in the loop above.
- if(!FileExists(*I) || flExtension(*I) != "deb")
- continue;
-
- pkgCache::PkgIterator pkg = Cache->FindPkg(*I);
- // Set any version providing the .deb as the candidate.
- for (auto Prv = pkg.ProvidesList(); Prv.end() == false; Prv++)
- Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer());
- }
-
- if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset, 0))
+ std::map<unsigned short, APT::VersionSet> verset;
+ if(!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, 0))
return false;
/* Print out a list of packages that are going to be installed extra
diff --git a/apt-private/private-install.h b/apt-private/private-install.h
index 62276fbff..551787c38 100644
--- a/apt-private/private-install.h
+++ b/apt-private/private-install.h
@@ -18,8 +18,9 @@ class pkgProblemResolver;
APT_PUBLIC bool DoInstall(CommandLine &Cmd);
-bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<const char*> &VolatileCmdL, CacheFile &Cache,
std::map<unsigned short, APT::VersionSet> &verset, int UpgradeMode);
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<const char*> &VolatileCmdL, CacheFile &Cache, int UpgradeMode);
bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode);
APT_PUBLIC bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index d13a6af49..4e0197a3f 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -19,10 +19,13 @@
static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
{
CacheFile Cache;
+ std::vector<char const *> VolatileCmdL;
+ Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL);
+
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
- if(!DoCacheManipulationFromCommandLine(CmdL, Cache, UpgradeFlags))
+ if(!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeFlags))
return false;
return InstallPackages(Cache,true);