From b29cf129eafc780e2a04ec07c168ca6a361cab7f Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin@piware.de>
Date: Mon, 22 Jul 2019 12:44:29 +0200
Subject: [PATCH] spec: Depend on package instead of file path

This requires building the rpm with a correct `%{rhel}`. As it's rather
cumbersome to build this in a separate VM image, emulate what happens in
reality by defining (when appropriate) the `%{rhel}` macro during RPM
build.

https://bugzilla.redhat.com/show_bug.cgi?id=1731687

Closes #22
---
 Makefile               | 5 +++++
 cockpit-ostree.spec.in | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 113e2dd3..7a9283f5 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,10 @@ NODE_MODULES_TEST=node_modules/po2json
 # one example file in dist/ from webpack to check if that already ran
 WEBPACK_TEST=dist/index.html
 
+ifeq ($(TEST_OS), rhel-atomic)
+MACRO_RHEL = --define "rhel 7"
+endif
+
 all: $(WEBPACK_TEST)
 
 #
@@ -108,6 +112,7 @@ rpm: dist-gzip $(PACKAGE_NAME).spec
 	  --define "_srcrpmdir `pwd`" \
 	  --define "_rpmdir `pwd`/output" \
 	  --define "_buildrootdir `pwd`/build" \
+	  $(MACRO_RHEL) \
 	  $(PACKAGE_NAME).spec
 	find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
 	rm -r "`pwd`/rpmbuild"
diff --git a/cockpit-ostree.spec.in b/cockpit-ostree.spec.in
index e2865879..f0362e97 100644
--- a/cockpit-ostree.spec.in
+++ b/cockpit-ostree.spec.in
@@ -6,7 +6,12 @@ Summary: Cockpit user interface for rpm-ostree
 License: LGPLv2+
 Requires: cockpit-bridge >= 125
 Requires: cockpit-system >= 125
-Requires: /usr/libexec/rpm-ostreed
+# On RHEL Atomic 7, the package name is different (curiously not on CentOS Atomic)
+%if 0%{?rhel} == 7
+Requires: rpm-ostree-client
+%else
+Requires: rpm-ostree
+%endif
 
 # Download from https://github.com/cockpit-project/cockpit-ostree/releases
 Source: cockpit-ostree-%{version}.tar.gz