]> git.saurik.com Git - apt.git/commitdiff
install: Set a local deb as the candidate for that package
authorJulian Andres Klode <jak@debian.org>
Wed, 26 Aug 2015 22:28:47 +0000 (00:28 +0200)
committerJulian Andres Klode <jak@debian.org>
Thu, 27 Aug 2015 11:27:44 +0000 (13:27 +0200)
This ensures that we can install .deb files that are not the
candidate for a given package.

apt-private/private-install.cc
test/integration/test-apt-get-install-deb

index 844fcbc7e0c52d32e0959f8c7e0a5a0fb7d74b32..3647ca99d17aef1639c3bbd8aa2dbd1423d6dc5c 100644 (file)
@@ -675,6 +675,18 @@ bool DoInstall(CommandLine &CmdL)
    
    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))
       return false;
 
index bd720bedec688cccb13acc04f90d4126a0d5b07e..65951cede4bead7c8d382097294ee55ed319a096 100755 (executable)
@@ -60,3 +60,21 @@ The following NEW packages will be installed:
 Remv foo:i386 [1.0]
 Inst foo (1.0 local-deb [amd64])
 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s -q=0
+
+# Check that installing the local deb works if it is not the candidate
+echo "Package: foo
+Pin: version 1.0
+Pin-Priority: -1" > rootdir/etc/apt/preferences
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Reading state information...
+Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
+The following packages will be REMOVED:
+  foo:i386
+The following NEW packages will be installed:
+  foo
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv foo:i386 [1.0]
+Inst foo (1.0 local-deb [amd64])
+Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s -q=0