alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
3f3ddd
From 137ecc2e1841c2b27b99d4db9006253dd1c73dde Mon Sep 17 00:00:00 2001
3f3ddd
From: Michael Schroeder <mls@suse.de>
3f3ddd
Date: Fri, 4 Jun 2021 23:30:49 +0200
3f3ddd
Subject: [PATCH] Unbreak checking of installed rich dependencies
3f3ddd
3f3ddd
Commit ddb32b9187e9ce85819a84ca8d202131fd9f8b9f added an
3f3ddd
extra check that tests if the provide we are checking really
3f3ddd
intersects the dependency from rpmdb. Unfortunately the
3f3ddd
rpmdsCompare() call does not understand rich dependencies and
3f3ddd
will consider them as not intersecting.
3f3ddd
3f3ddd
Unbreak the check by not doing the intersection test for
3f3ddd
rich dependencies. We'll improve this in a later commit.
3f3ddd
3f3ddd
Also add test cases for dependency problems with installed
3f3ddd
rich dependencies.
3f3ddd
---
3f3ddd
 lib/depends.c    |  2 +-
3f3ddd
 tests/rpmdeps.at | 99 ++++++++++++++++++++++++++++++++++++++++++++++++
3f3ddd
 2 files changed, 100 insertions(+), 1 deletion(-)
3f3ddd
3f3ddd
diff --git a/lib/depends.c b/lib/depends.c
3f3ddd
index c10ba4bda..fecbd9675 100644
3f3ddd
--- a/lib/depends.c
3f3ddd
+++ b/lib/depends.c
3f3ddd
@@ -846,7 +846,7 @@ static void checkInstDeps(rpmts ts, depCache dcache, rpmte te,
3f3ddd
 	rpmdsSetIx(ds, rpmdbGetIteratorFileNum(mi));
3f3ddd
 
3f3ddd
 	/* Is it in our range at all? (but file deps have no range) */
3f3ddd
-	if (depds)
3f3ddd
+	if (depds && !rpmdsIsRich(ds))
3f3ddd
 	    match = rpmdsCompare(ds, depds);
3f3ddd
 
3f3ddd
 	if (match && unsatisfiedDepend(ts, dcache, ds) == is_problem) {
3f3ddd
diff --git a/tests/rpmdeps.at b/tests/rpmdeps.at
3f3ddd
index 67bde1dc8..8357af9df 100644
3f3ddd
--- a/tests/rpmdeps.at
3f3ddd
+++ b/tests/rpmdeps.at
3f3ddd
@@ -732,3 +732,102 @@ runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarc
3f3ddd
 [],
3f3ddd
 [])
3f3ddd
 AT_CLEANUP
3f3ddd
+
3f3ddd
+# ------------------------------
3f3ddd
+#
3f3ddd
+AT_SETUP([install to break installed rich dependency])
3f3ddd
+AT_KEYWORDS([install, boolean])
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg one" \
3f3ddd
+	--define "cfls (deptest-three or deptest-five)" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg two" \
3f3ddd
+	--define "reqs (deptest-five if deptest-four)" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg three" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg four" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+
3f3ddd
+# installed conflict with "or" clause
3f3ddd
+AT_CHECK([
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
3f3ddd
+],
3f3ddd
+[1],
3f3ddd
+[],
3f3ddd
+[error: Failed dependencies:
3f3ddd
+	(deptest-three or deptest-five) conflicts with (installed) deptest-one-1.0-1.noarch
3f3ddd
+])
3f3ddd
+
3f3ddd
+# installed requires with "if" clause
3f3ddd
+AT_CHECK([
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm
3f3ddd
+],
3f3ddd
+[1],
3f3ddd
+[],
3f3ddd
+[error: Failed dependencies:
3f3ddd
+	(deptest-five if deptest-four) is needed by (installed) deptest-two-1.0-1.noarch
3f3ddd
+])
3f3ddd
+AT_CLEANUP
3f3ddd
+
3f3ddd
+# ------------------------------
3f3ddd
+#
3f3ddd
+AT_SETUP([erase to break installed rich dependency])
3f3ddd
+AT_KEYWORDS([install, boolean])
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg one" \
3f3ddd
+	--define "reqs (deptest-three or deptest-five)" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg two" \
3f3ddd
+	--define "cfls (deptest-five unless deptest-four)" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg three" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg four" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+runroot rpmbuild --quiet -bb \
3f3ddd
+	--define "pkg five" \
3f3ddd
+	  /data/SPECS/deptest.spec
3f3ddd
+
3f3ddd
+# installed requires with "or" clause
3f3ddd
+AT_CHECK([
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm
3f3ddd
+runroot rpm -e deptest-three
3f3ddd
+],
3f3ddd
+[1],
3f3ddd
+[],
3f3ddd
+[error: Failed dependencies:
3f3ddd
+	(deptest-three or deptest-five) is needed by (installed) deptest-one-1.0-1.noarch
3f3ddd
+])
3f3ddd
+
3f3ddd
+# installed conflicts with "unless" clause
3f3ddd
+AT_CHECK([
3f3ddd
+RPMDB_INIT
3f3ddd
+
3f3ddd
+runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-four-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-five-1.0-1.noarch.rpm
3f3ddd
+runroot rpm -e deptest-four
3f3ddd
+],
3f3ddd
+[1],
3f3ddd
+[],
3f3ddd
+[error: Failed dependencies:
3f3ddd
+	(deptest-five unless deptest-four) conflicts with (installed) deptest-two-1.0-1.noarch
3f3ddd
+])
3f3ddd
+AT_CLEANUP
3f3ddd
-- 
3f3ddd
2.33.1
3f3ddd