]> git.saurik.com Git - apt.git/commitdiff
check build-dep candidate if install is forbidden
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 10 Jun 2012 22:16:51 +0000 (00:16 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 10 Jun 2012 22:16:51 +0000 (00:16 +0200)
cmdline/apt-get.cc
debian/changelog
test/integration/framework
test/integration/test-bug-632221-cross-dependency-satisfaction

index a4fd3cfb98f72501d1331ce19a5e0c6332000f97..870c77280957dd85075844d49194b4dc312f95d2 100644 (file)
@@ -2889,33 +2889,42 @@ bool DoBuildDep(CommandLine &CmdL)
               else
                  Pkg = Cache->FindPkg(D->Package);
 
-              // We need to decide if host or build arch, so find a version we can look at
-              pkgCache::VerIterator Ver;
-
               // a bad version either is invalid or doesn't satify dependency
-              #define BADVER(Ver) Ver.end() == true || \
-                                  (Ver.end() == false && D->Version.empty() == false && \
-                                   Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false)
+              #define BADVER(Ver) (Ver.end() == true || \
+                                   (D->Version.empty() == false && \
+                                    Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false))
 
+              APT::VersionList verlist;
               if (Pkg.end() == false)
               {
-                 Ver = (*Cache)[Pkg].InstVerIter(*Cache);
-                 if (BADVER(Ver))
-                    Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
+                 pkgCache::VerIterator Ver = (*Cache)[Pkg].InstVerIter(*Cache);
+                 if (BADVER(Ver) == false)
+                    verlist.insert(Ver);
+                 Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
+                 if (BADVER(Ver) == false)
+                    verlist.insert(Ver);
               }
-              if (BADVER(Ver))
+              if (verlist.empty() == true)
               {
                  pkgCache::PkgIterator HostPkg = Cache->FindPkg(D->Package, hostArch);
                  if (HostPkg.end() == false)
                  {
-                    Ver = (*Cache)[HostPkg].InstVerIter(*Cache);
-                    if (BADVER(Ver))
-                       Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache);
+                    pkgCache::VerIterator Ver = (*Cache)[HostPkg].InstVerIter(*Cache);
+                    if (BADVER(Ver) == false)
+                       verlist.insert(Ver);
+                    Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache);
+                    if (BADVER(Ver) == false)
+                       verlist.insert(Ver);
                  }
               }
-              if ((BADVER(Ver)) == false)
+              #undef BADVER
+
+              string forbidden;
+              // We need to decide if host or build arch, so find a version we can look at
+              APT::VersionList::const_iterator Ver = verlist.begin();
+              for (; Ver != verlist.end(); ++Ver)
               {
-                 string forbidden;
+                 forbidden.clear();
                  if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All)
                  {
                     if (colon == string::npos)
@@ -2953,10 +2962,24 @@ bool DoBuildDep(CommandLine &CmdL)
                     }
                     // native gets buildArch
                  }
+
                  if (forbidden.empty() == false)
                  {
                     if (_config->FindB("Debug::BuildDeps",false) == true)
-                       cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << endl;
+                       cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << " (" << Ver.VerStr() << ")" << endl;
+                    continue;
+                 }
+
+                 //we found a good version
+                 break;
+              }
+              if (Ver == verlist.end())
+              {
+                 if (_config->FindB("Debug::BuildDeps",false) == true)
+                    cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
+
+                 if (forbidden.empty() == false)
+                 {
                     if (hasAlternatives)
                        continue;
                     return _error->Error(_("%s dependency for %s can't be satisfied "
@@ -2965,9 +2988,6 @@ bool DoBuildDep(CommandLine &CmdL)
                                          D->Package.c_str(), forbidden.c_str());
                  }
               }
-              else if (_config->FindB("Debug::BuildDeps",false) == true)
-                 cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
-              #undef BADVER
            }
            else
               Pkg = Cache->FindPkg(D->Package);
index 720b072738357a53db2c1f431ef7fe0d0a1ad8bc..ee108b059cfdbdf5dcf39e3fdabdb5380d6b39b9 100644 (file)
@@ -11,6 +11,7 @@ apt (0.9.5.2) UNRELEASED; urgency=low
     - print URIs for all changelogs in case of --print-uris,
       thanks to Daniel Hartwig for the patch! (Closes: #674897)
     - show 'bzr branch' as 'bzr get' is deprecated (LP: #1011032)
+    - check build-dep candidate if install is forbidden
   * debian/apt-utils.links:
     - the internal resolver 'apt' is now directly installed in
       /usr/lib/apt/solvers, so don't instruct dh to create a broken link
index 5a0e1070f82c3bc6067cf835c6b8886e97d9c28e..dba8c016236f542c04820658bfa92b3a94164e5a 100644 (file)
@@ -508,7 +508,8 @@ Architecture: $ARCH" >> $FILE
        test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
        echo "Files:
  d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
- d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz
+" >> $FILE
 }
 
 insertinstalledpackage() {
index a128366c5fb9c1272409f34d54e2a72601824a55..93cc153e66e9f6001b9cbe62a791a149903755e4 100755 (executable)
@@ -23,8 +23,22 @@ insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0'
 
 insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-arm] | linux-stuff [ linux-any]'
 
+insertsource 'unstable' 'forbidden-none' 'any' '1' 'Build-Depends: amdboot:any'
+insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any'
+insertsource 'unstable' 'forbidden-foreign' 'any' '1' 'Build-Depends: doxygen:any'
+
 setupaptarchive
 
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-none can't be satisfied because amdboot:any is not allowed on 'Multi-Arch: none' packages" aptget build-dep forbidden-none -s -a armel
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-same can't be satisfied because libc6:any is not allowed on 'Multi-Arch: same' packages" aptget build-dep forbidden-same -s -a armel
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-foreign can't be satisfied because doxygen:any is not allowed on 'Multi-Arch: foreign' packages" aptget build-dep forbidden-foreign -s -a armel
+
 testequal 'Reading package lists...
 Building dependency tree...
 The following NEW packages will be installed: