summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-05-10 14:51:30 +0200
committerJulian Andres Klode <jak@debian.org>2016-05-10 20:53:37 +0200
commita39467f5d9fc51c9bf32d0f0e42e36041ece6bd5 (patch)
treebd6b01d5a371cc366ba3c7009cedcfd8d6f5256e
parent910accc32542b5e99bdf146e55afdc0c48d17a6e (diff)
don't sent uninstallable rc-only versions via EDSP
Versions which are only available in dpkg/status aren't installable and apt doesn't pick them as candidate for this reason – for the same reason such packages shouldn't be sent to an external solver via EDSP. The packages are pinned to -1, but if the solver has strict pinning disabled it could end up picking this version anyhow – which is a request apt can not satisfy. Reported-By: Maximiliano Curia <maxy@debian.org> on IRC (cherry picked from commit 33190fe3d3c200dcd417cd336f9db11f5f4408d5)
-rw-r--r--apt-pkg/edsp.cc22
-rwxr-xr-xtest/integration/test-ubuntu-bug-761175-remove-purge73
2 files changed, 72 insertions, 23 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 59e8e7ab4..38ac36831 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -180,6 +180,24 @@ static void WriteScenarioLimitedDependency(FILE* output,
fprintf(output, "Provides: %s\n", provides.c_str()+2);
}
/*}}}*/
+static bool SkipUnavailableVersions(pkgDepCache &Cache, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)/*{{{*/
+{
+ /* versions which aren't current and aren't available in
+ any "online" source file are bad, expect if they are the choosen
+ candidate: The exception is for build-dep implementation as it creates
+ such pseudo (package) versions and removes them later on again.
+ We filter out versions at all so packages in 'rc' state only available
+ in dpkg/status aren't passed to solvers as they can't be installed. */
+ if (Pkg->CurrentVer != 0)
+ return false;
+ if (Cache.GetCandidateVersion(Pkg) == Ver)
+ return false;
+ for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; ++I)
+ if (I.File().Flagged(pkgCache::Flag::NotSource) == false)
+ return false;
+ return true;
+}
+ /*}}}*/
// EDSP::WriteScenario - to the given file descriptor /*{{{*/
bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress)
{
@@ -194,6 +212,8 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress)
continue;
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p)
{
+ if (SkipUnavailableVersions(Cache, Pkg, Ver))
+ continue;
WriteScenarioVersion(Cache, output, Pkg, Ver);
WriteScenarioDependency(output, Ver);
fprintf(output, "\n");
@@ -215,6 +235,8 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg, ++p)
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
+ if (SkipUnavailableVersions(Cache, Pkg, Ver))
+ continue;
WriteScenarioVersion(Cache, output, Pkg, Ver);
WriteScenarioLimitedDependency(output, Ver, pkgset);
fprintf(output, "\n");
diff --git a/test/integration/test-ubuntu-bug-761175-remove-purge b/test/integration/test-ubuntu-bug-761175-remove-purge
index 00f289b53..aae394ad8 100755
--- a/test/integration/test-ubuntu-bug-761175-remove-purge
+++ b/test/integration/test-ubuntu-bug-761175-remove-purge
@@ -23,35 +23,62 @@ buildcompizpkg 'all' 'all' '2.0' 'unstable'
setupaptarchive
runtests() {
- testdpkgnotinstalled compiz-core-$1
- testsuccess aptget install compiz-core-$1 -t "${2:-unstable}"
- testdpkginstalled compiz-core-$1
+ local PKG="$1"
+ local RELEASE="${2}"
+ shift 2
+ testdpkgnotinstalled compiz-core-${PKG}
+ testsuccess aptget install compiz-core-${PKG} -t "${RELEASE}" "$@"
+ testdpkginstalled compiz-core-${PKG}
- testsuccess aptget remove compiz-core-$1 -y
- testdpkgnotinstalled compiz-core-$1
- testdpkgstatus 'rc' '1' "compiz-core-$1"
+ testsuccess aptget remove compiz-core-${PKG} -y "$@"
+ testdpkgnotinstalled compiz-core-${PKG}
+ testdpkgstatus 'rc' '1' "compiz-core-${PKG}"
- testsuccessequal "Reading package lists...
+ if [ -z "$1" ]; then
+ testsuccessequal "Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
- compiz-core-$1*
+ compiz-core-${PKG}*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
-Purg compiz-core-$1" aptget purge compiz-core-$1 -s
- testsuccess aptget purge compiz-core-$1 -y
+Purg compiz-core-${PKG}" aptget purge compiz-core-${PKG} -s "$@"
+ else
+ # check that the rc-version isn't passed to the external resolver if its only in dpkg/status
+ export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/dump-${PKG}.edsp"
+ testfailure aptget purge compiz-core-${PKG} -y "$@" -s --solver dump
+ testsuccessequal '2' grep -c "^Package: compiz-core-${PKG}\$" "$APT_EDSP_DUMP_FILENAME"
+ mv rootdir/etc/apt/sources.list.d/apt-test-stable-deb.list rootdir/etc/apt/sources.list.d/apt-test-stable-deb.disabled
+ testfailure aptget purge compiz-core-${PKG} -y "$@" -s --solver dump
+ testsuccessequal '1' grep -c "^Package: compiz-core-${PKG}\$" "$APT_EDSP_DUMP_FILENAME"
+ mv rootdir/etc/apt/sources.list.d/apt-test-stable-deb.disabled rootdir/etc/apt/sources.list.d/apt-test-stable-deb.list
+
+ testsuccessequal "Reading package lists...
+Building dependency tree...
+Reading state information...
+Execute external solver...
+The following packages will be REMOVED:
+ compiz-core-${PKG}*
+0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
+Purg compiz-core-${PKG}" aptget purge compiz-core-${PKG} -s "$@"
+ fi
+ testsuccess aptget purge compiz-core-${PKG} -y "$@"
echo -n '' > rootdir/var/lib/dpkg/available # dpkg -l < 1.16.2 reads the available file by default, where the package can be found
- testequalor2 "dpkg-query: no packages found matching compiz-core-$1" "No packages found matching compiz-core-$1." dpkg -l compiz-core-$1
+ testequalor2 "dpkg-query: no packages found matching compiz-core-${PKG}" "No packages found matching compiz-core-${PKG}." dpkg -l compiz-core-${PKG}
+}
+runtestround() {
+ runtests 'native' 'unstable' "$@"
+ runtests 'all' 'unstable' "$@"
+ runtests 'native' 'stable' "$@"
+ runtests 'all' 'stable' "$@"
}
+testround() {
+ msgmsg 'Test in multi arch environment' "$@"
+ configarchitecture 'amd64' 'i386'
+ runtestround "$@"
-msgmsg 'Test in multi arch environment'
-runtests 'native'
-runtests 'all'
-runtests 'native' 'stable'
-runtests 'all' 'stable'
-
-msgmsg 'Test in single arch environment'
-configarchitecture 'amd64'
-runtests 'native'
-runtests 'all'
-runtests 'native' 'stable'
-runtests 'all' 'stable'
+ msgmsg 'Test in single arch environment' "$@"
+ configarchitecture 'amd64'
+ runtestround "$@"
+}
+testround
+testround --solver apt