summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cacheset.cc10
-rw-r--r--apt-pkg/sourcelist.cc35
-rw-r--r--apt-pkg/sourcelist.h4
-rw-r--r--apt-private/private-install.cc49
-rw-r--r--apt-private/private-install.h3
-rw-r--r--apt-private/private-upgrade.cc5
-rwxr-xr-xtest/integration/test-apt-get-install-deb14
7 files changed, 76 insertions, 44 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;
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);
diff --git a/test/integration/test-apt-get-install-deb b/test/integration/test-apt-get-install-deb
index 89b7f7299..5af6c5bf7 100755
--- a/test/integration/test-apt-get-install-deb
+++ b/test/integration/test-apt-get-install-deb
@@ -8,25 +8,21 @@ setupenvironment
configarchitecture 'amd64' 'i386'
# regression test for #754904
-testfailureequal 'E: Unable to locate package /dev/null' aptget install -qq /dev/null
+testfailureequal 'E: Unsupported file /dev/null given on commandline' aptget install -qq /dev/null
# only consider .deb files
cat > foo.rpm <<EOF
I'm not a deb, I'm a teapot.
EOF
-testfailureequal "E: Unable to locate package ./foo.rpm
-E: Couldn't find any package by glob './foo.rpm'
-E: Couldn't find any package by regex './foo.rpm'" aptget install -qq ./foo.rpm
+testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' aptget install -qq ./foo.rpm
# and ensure we fail for invalid debs
mv foo.rpm foo.deb
-testfailure aptget install ./foo.deb
-testsuccess grep '^E: Sub-process Popen returned an error code' rootdir/tmp/testfailure.output
-testequal "E: Encountered a section with no Package: header
+testfailuremsg "E: Sub-process Popen returned an error code (2)
+E: Encountered a section with no Package: header
E: Problem with MergeList ${TMPWORKINGDIRECTORY}/foo.deb
-E: The package lists or status file could not be parsed or opened." tail -n 3 rootdir/tmp/testfailure.output
+E: The package lists or status file could not be parsed or opened." aptget install ./foo.deb
-# fakeroot is currently not found, framwork needs updating
buildsimplenativepackage 'foo' 'i386,amd64' '1.0'
testfailureequal "Reading package lists...