From 4ce12011a316f26d098dc76a46fd6323b63b1980 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Mon, 19 Dec 2022 20:47:08 +0100
Subject: [PATCH] Simplify transitional Requires and Obsoletes for legacy
 packages

---
 libxcrypt.spec | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/libxcrypt.spec b/libxcrypt.spec
index 1089182..9a89433 100644
--- a/libxcrypt.spec
+++ b/libxcrypt.spec
@@ -1,5 +1,5 @@
 # Build with new api?
-%if 0%{?fedora} >= 30 || 0%{?rhel} >= 9
+%if 0%{?fedora} || 0%{?rhel} > 8
 %bcond_without new_api
 %else
 %bcond_with    new_api
@@ -15,7 +15,7 @@
 
 
 # Replace obsolete functions with a stub?
-%if (0%{?fedora} >= 30 || 0%{?rhel} >= 9) && %{with compat_pkg}
+%if %{with new_api} && %{with compat_pkg}
 %bcond_without enosys_stubs
 %else
 %bcond_with    enosys_stubs
@@ -65,6 +65,12 @@
 %global man_pages_minver 4.15-3
 
 
+# Need versioned requires on glibc and man-pages?
+%if !(0%{?fedora} || 0%{?rhel} > 9)
+%global trans_pkg        1
+%endif
+
+
 # Hash methods and API supported by libcrypt.
 # NEVER EVER touch this, if you do NOT know what you are doing!
 %global hash_methods   all
@@ -162,7 +168,7 @@ fi                                          \
 
 Name:           libxcrypt
 Version:        4.4.33
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Extended crypt library for descrypt, md5crypt, bcrypt, and others
 
 # For explicit license breakdown, see the
@@ -185,7 +191,9 @@ Patch0001:      %{url}/commit/59823543d095.patch#/%{name}-4.4.33-SHA512_Maj_opti
 BuildRequires:  coreutils
 BuildRequires:  fipscheck
 BuildRequires:  gcc
+%if 0%{?trans_pkg}
 BuildRequires:  glibc-devel                  >= %{glibc_minver}
+%endif
 BuildRequires:  make
 BuildRequires:  perl-interpreter             >= %{perl_minver}
 BuildRequires:  perl(Class::Struct)
@@ -210,7 +218,7 @@ BuildRequires:  gnupg2
 %endif
 
 # We do not need to keep this forever.
-%if !(0%{?fedora} > 31 || 0%{?rhel} > 9)
+%if 0%{?trans_pkg}
 # Inherited from former libcrypt package.
 Obsoletes:      libcrypt-nss           < %{glibc_minver}
 Provides:       libcrypt-nss           = %{glibc_minver}
@@ -226,18 +234,16 @@ Provides:       libcrypt%{?_isa}       = %{glibc_minver}
 # Obsolete former libxcrypt-common properly.
 Obsoletes:      %{name}-common         < 4.3.3-4
 Provides:       %{name}-common         = %{version}-%{release}
+
+# We need a version of glibc, that doesn't build libcrypt anymore.
+Requires:       glibc%{?_isa}         >= %{glibc_minver}
 %endif
 
 %if %{with new_api} && %{without compat_pkg}
 Obsoletes:      %{name}-compat         < %{version}-%{release}
 %endif
 
-%if !(0%{?fedora} > 34 || 0%{?rhel} > 9)
-# We need a version of glibc, that doesn't build libcrypt anymore.
-Requires:       glibc%{?_isa}         >= %{glibc_minver}
-%endif
-
-%if 0%{?fedora} >= 30
+%if 0%{?fedora}
 Recommends:     mkpasswd
 %endif
 
@@ -274,11 +280,6 @@ BuildRequires:  libxcrypt-compat
 
 Requires:       %{name}%{?_isa}        = %{version}-%{release}
 
-%if !(0%{?fedora} > 34 || 0%{?rhel} > 9)
-# We need a version of glibc, that doesn't build libcrypt anymore.
-Requires:       glibc%{?_isa}         >= %{glibc_minver}
-%endif
-
 %description    compat
 This package contains the library providing the compatibility API
 for applications that are linked against glibc's libxcrypt, or that
@@ -295,10 +296,12 @@ work unmodified with the library supplied by this package.
 %package        devel
 Summary:        Development files for %{name}
 
-Conflicts:      man-pages              < %{man_pages_minver}
-
 Requires:       %{name}%{?_isa}        = %{version}-%{release}
+Requires:       glibc-devel%{?_isa}
+%if 0%{?trans_pkg}
+Conflicts:      man-pages              < %{man_pages_minver}
 Requires:       glibc-devel%{?_isa}   >= %{glibc_minver}
+%endif
 
 %description    devel
 The %{name}-devel package contains libraries and header files for
@@ -310,8 +313,10 @@ developing applications that use %{name}.
 Summary:        Static library for -static linking with %{name}
 
 Requires:       %{name}-devel%{?_isa}  = %{version}-%{release}
-Requires:       glibc-devel%{?_isa}   >= %{glibc_minver}
+Requires:       glibc-static%{?_isa}
+%if 0%{?trans_pkg}
 Requires:       glibc-static%{?_isa}  >= %{glibc_minver}
+%endif
 
 %description    static
 This package contains the libxcrypt static library for -static
@@ -577,6 +582,9 @@ done
 
 
 %changelog
+* Mon Dec 19 2022 Björn Esser <besser82@fedoraproject.org> - 4.4.33-5
+- Simplify transitional Requires and Obsoletes for legacy packages
+
 * Tue Dec 13 2022 Björn Esser <besser82@fedoraproject.org> - 4.4.33-4
 - Add upstream patch to improve performance on SHA512 computation