rpm-software-management / spec-cleaner

spec-cleaner
BSD 3-Clause "New" or "Revised" License
27 stars 33 forks source link

cleaning seriously damages spec preambles #291

Open frispete opened 2 years ago

frispete commented 2 years ago

Given, spec-cleaning nowadays is mandatory in working with osc, it should be save to use in all cases, but it's not:

Check out this beauty: https://build.opensuse.org/package/rdiff/home:frispete:test/freerdp?opackage=freerdp&oproject=openSUSE%3AFactory&rev=3

--- freerdp.spec (revision 49)
+++ freerdp.spec (revision 3)
@@ -16,16 +16,24 @@
 #

-# X264 and OPENH264 are disabled because openSUSE does not provide the codecs
-# enable -DWITH_GSSAPI=ON again after #gh/FreeRDP/FreeRDP/4348 has been fixed
-#global _with_gss 1
-#
 %define major_version 2
 %define uwac_version 0
 %define uwac_package %{uwac_version}-%{uwac_version}
 %ifarch aarch64 %{arm}
 %define _lto_cflags %{nil}
 %endif
+%{?_with_lame:BuildRequires:  lame-devel}
+%{?_with_openh264:BuildRequires:  openh264-devel}
+%{?_with_x264:BuildRequires:  x264-devel}
+%{?_with_gss:BuildRequires:  pkgconfig(krb5) >= 1.13}
+%{?_with_soxr:BuildRequires:  pkgconfig(soxr)}
+%if 0%{?is_opensuse}
+%global _with_ffmpeg 1
+#global _with_x264 1
+#global _with_openh264 1
+#global _with_soxr 1
+#global _with_lame 1
+%endif
 Name:           freerdp
 Version:        2.4.0
 Release:        0
@@ -52,7 +60,8 @@
 BuildRequires:  pkgconfig(gstreamer-1.0)
 BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
 BuildRequires:  pkgconfig(icu-i18n)
-BuildRequires:  pkgconfig(krb5)
+BuildRequires:  pkgconfig(libavcodec) >= 57.48.101
+BuildRequires:  pkgconfig(libavutil)
 BuildRequires:  pkgconfig(libpcsclite)
 BuildRequires:  pkgconfig(libpulse)
 BuildRequires:  pkgconfig(libsystemd)
@@ -73,6 +82,8 @@
 BuildRequires:  pkgconfig(xtst)
 BuildRequires:  pkgconfig(xv)
 Requires:       lib%{name}%{major_version} = %{version}-%{release}
+%{?_with_ffmpeg:
+}

I combined some elements from the Fedora spec with ours. The result is pure mess after spec-cleaner went over it.

From top to bottom: it removed an important comment for no good reason. Let's call it 3rd comment section. Sure, I can imagine, that it's hard to safely replace/update the copyright header, but you never should remove any auxiliary comments. By the way, I started with adding the somewhat prefered pattern in Fedora of:

%global _with_ffmpeg 1
#global _with_x264 1
#global _with_openh264 1
#global _with_soxr 1
#global _with_lame 1

only to find them vanished. After reading the source, I came up with the %if/%endif clause to protect this, and I put this in front of the now eliminated 3rd comment section originally.

The %{?_with_ clauses where intermingled in the rest of the BuildRequires of course.

Last, but not least, these lines:

+BuildRequires:  pkgconfig(libavcodec) >= 57.48.101
+BuildRequires:  pkgconfig(libavutil)

were inside

+%{?_with_ffmpeg:
+}

before.

Given, spec-cleaner is mandatory in the obs build process, this isn't going to fly, to put it kindly.