rpm-software-management / spec-cleaner

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

spec-cleaner deletes the whole header section of a .spec file #34

Closed szotsaki closed 10 years ago

szotsaki commented 10 years ago

I ran the latest version of spec-cleaner on file https://build.opensuse.org/package/view_file/home:szotsaki:sflphone-git/sflphone/sflphone.spec?expand=0 and it deleted the whole header section of that file.

Briefly, this is the diff it generated:

--- sflphone.spec   2014-07-08 07:33:03.060444106 +0200
+++ sflphone.spec   2014-07-08 07:45:17.798770079 +0200
@@ -1,9 +1,9 @@
 #
 # spec file for package sflphone
 #
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 # Copyright (c) 2013-2014  Ákos Szőts <szotsaki@gmail.com>
 # Copyright (c) 2009-2010  Vovochka404 <vovochka13@gmail.com>
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,93 +17,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #

-%bcond_without common
-%bcond_without kde4
-%bcond_without plugins
-%bcond_without gnome
-
-Name:           sflphone
-Version:        1.3.0.git
-Release:        0
-Summary:        Open source SIP/IAX2 compatible enterprise-class softphone
-License:        GPL-3.0
-Group:          Productivity/Telephony/SIP/Clients
-Url:            http://sflphone.org/
-Source0:        %{name}-%{version}.tar.xz
-Source1:        %{name}-kde-%{version}.tar.xz
-BuildRequires:  autoconf
-BuildRequires:  fdupes
-BuildRequires:  find
-BuildRequires:  libtool
-BuildRequires:  sed
-BuildRequires:  update-desktop-files
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
-%if %{with common}
-BuildRequires:  ilbc
-BuildRequires:  libasound2
-BuildRequires:  libgsm-devel
-BuildRequires:  libyaml-devel
-BuildRequires:  patch
-BuildRequires:  pkgconfig(alsa)
-BuildRequires:  pkgconfig(celt)
-BuildRequires:  pkgconfig(cppunit)
-BuildRequires:  pkgconfig(cryptopp)
-BuildRequires:  pkgconfig(dbus-1)
-BuildRequires:  pkgconfig(dbus-c++-1)
-BuildRequires:  pkgconfig(dbus-c++-glib-1)
-BuildRequires:  pkgconfig(expat)
-BuildRequires:  pkgconfig(gnutls)
-BuildRequires:  pkgconfig(jack)
-BuildRequires:  pkgconfig(libccext2)
-BuildRequires:  pkgconfig(libccgnu2)
-BuildRequires:  pkgconfig(libccrtp)
-BuildRequires:  pkgconfig(libcrypto)
-BuildRequires:  pkgconfig(libpcre)
-BuildRequires:  pkgconfig(libpcre16)
-BuildRequires:  pkgconfig(libpcrecpp)
-BuildRequires:  pkgconfig(libpcreposix)
-BuildRequires:  pkgconfig(libpulse)
-BuildRequires:  pkgconfig(libpulse-mainloop-glib)
-BuildRequires:  pkgconfig(libpulse-simple)
-BuildRequires:  pkgconfig(libssl)
-BuildRequires:  pkgconfig(libsystemd-daemon)
-BuildRequires:  pkgconfig(libsystemd-id128)
-BuildRequires:  pkgconfig(libsystemd-journal)
-BuildRequires:  pkgconfig(libsystemd-login)
-BuildRequires:  pkgconfig(libzrtpcpp)
-BuildRequires:  pkgconfig(openssl)
-BuildRequires:  pkgconfig(opus)
-BuildRequires:  pkgconfig(rarian)
-BuildRequires:  pkgconfig(samplerate)
-BuildRequires:  pkgconfig(sndfile)
-BuildRequires:  pkgconfig(speex)
-BuildRequires:  pkgconfig(speexdsp)
-BuildRequires:  pkgconfig(systemd)
-BuildRequires:  pkgconfig(uuid)
-Suggests:       %{name}-client-gnome
-Suggests:       %{name}-client-kde4
-%endif
-
-%if %{with kde4}
-# For KDE 4.12
-BuildRequires:  akonadi-runtime
-BuildRequires:  cmake
-BuildRequires:  libkde4-devel
-BuildRequires:  libkdepimlibs4-devel
-%endif
-
-%if %{with gnome}
-BuildRequires:  gnome-common
-BuildRequires:  intltool
-BuildRequires:  yelp-tools
-BuildRequires:  pkgconfig(clutter-gtk-1.0)
-BuildRequires:  pkgconfig(dbus-glib-1)
-BuildRequires:  pkgconfig(gnome-doc-utils)
-BuildRequires:  pkgconfig(libnotify)
-%endif

-%if %{with plugins}
 %if 0%{?suse_version} >= 1310
 BuildRequires:  pkgconfig(camel-1.2)
 BuildRequires:  pkgconfig(evolution-data-server-1.2)
@@ -116,7 +30,15 @@
 BuildRequires:  pkgconfig(libedata-cal-1.2)
 BuildRequires:  pkgconfig(libedataserver-1.2)
 %else
-BuildRequires:  evolution-data-server-devel
+BuildRequires:  pkgconfig(camel-1.2)
+BuildRequires:  pkgconfig(evolution-data-server-1.2)
+BuildRequires:  pkgconfig(libebackend-1.2)
+BuildRequires:  pkgconfig(libebook-1.2)
+BuildRequires:  pkgconfig(libebook-contacts-1.2)
+BuildRequires:  pkgconfig(libecal-1.2)
+BuildRequires:  pkgconfig(libedata-book-1.2)
+BuildRequires:  pkgconfig(libedata-cal-1.2)
+BuildRequires:  pkgconfig(libedataserver-1.2)
 %endif # 0% {?suse_version}
 %endif

@@ -132,7 +54,7 @@
 # For building with KDE 4.12
 # % kde4_akonadi_requires == "Requires: akonadi-runtime  >= 1.10.2 akonadi-runtime < 1.10.40" (on openSUSE 13.1)
 # Requires:       akonadi-runtime >= % ( echo `rpm -q --queryformat '%{VERSION}' akonadi-runtime`)
-%requies_eq     akonadi_runtime
+%{requies_eq}     akonadi_runtime
 %{kde4_runtime_requires}
 %{kde4_pimlibs_requires}

@@ -217,19 +139,19 @@
 %install
 %if %{with common}
 pushd daemon
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with plugins}
 pushd plugins
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with kde4}
 pushd kde/build/
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 rm -rf %{buildroot}/%{_includedir}
 rm -f %{buildroot}/%{_libdir}/*.so
 popd
@@ -243,7 +165,7 @@

 %if %{with gnome}
 pushd gnome
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %suse_update_desktop_file -r %{name} Network Telephony
 %find_lang %{name} %{name}-gnome.lang --without-gnome --without-kde
@@ -293,6 +215,7 @@
 %desktop_database_postun

 # GIT: unnecessary:  -f % {name}-kde.lang
+
 %files -n %{name}-client-kde4
 %defattr(-,root,root)
 %dir %{_kde4_appsdir}/%{name}-client-kde/
scarabeusiv commented 10 years ago

Whoopsie we didn't match endifs if there was comment at the end like here. So patched it up. Are you able to use git version or would you fancy new release?

scarabeusiv commented 10 years ago

https://github.com/openSUSE/spec-cleaner/commit/ed93fb4a7d913e78c998fa520fcc49cb70253f92

szotsaki commented 10 years ago

Thank you for the quick reply. Unfortunately, the provided patch doesn't fix this issue, but it seems it reintroduces bug #22.

Here is the diff with the patched git master:

--- sflphone.spec   2014-07-09 08:45:07.144730102 +0200
+++ sflphone.spec   2014-07-09 08:46:56.611545970 +0200
@@ -1,9 +1,9 @@
 #
 # spec file for package sflphone
 #
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 # Copyright (c) 2013-2014  Ákos Szőts <szotsaki@gmail.com>
 # Copyright (c) 2009-2010  Vovochka404 <vovochka13@gmail.com>
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,93 +17,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #

-%bcond_without common
-%bcond_without kde4
-%bcond_without plugins
-%bcond_without gnome
-
-Name:           sflphone
-Version:        1.3.0.git
-Release:        0
-Summary:        Open source SIP/IAX2 compatible enterprise-class softphone
-License:        GPL-3.0
-Group:          Productivity/Telephony/SIP/Clients
-Url:            http://sflphone.org/
-Source0:        %{name}-%{version}.tar.xz
-Source1:        %{name}-kde-%{version}.tar.xz
-BuildRequires:  autoconf
-BuildRequires:  fdupes
-BuildRequires:  find
-BuildRequires:  libtool
-BuildRequires:  sed
-BuildRequires:  update-desktop-files
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
-%if %{with common}
-BuildRequires:  ilbc
-BuildRequires:  libasound2
-BuildRequires:  libgsm-devel
-BuildRequires:  libyaml-devel
-BuildRequires:  patch
-BuildRequires:  pkgconfig(alsa)
-BuildRequires:  pkgconfig(celt)
-BuildRequires:  pkgconfig(cppunit)
-BuildRequires:  pkgconfig(cryptopp)
-BuildRequires:  pkgconfig(dbus-1)
-BuildRequires:  pkgconfig(dbus-c++-1)
-BuildRequires:  pkgconfig(dbus-c++-glib-1)
-BuildRequires:  pkgconfig(expat)
-BuildRequires:  pkgconfig(gnutls)
-BuildRequires:  pkgconfig(jack)
-BuildRequires:  pkgconfig(libccext2)
-BuildRequires:  pkgconfig(libccgnu2)
-BuildRequires:  pkgconfig(libccrtp)
-BuildRequires:  pkgconfig(libcrypto)
-BuildRequires:  pkgconfig(libpcre)
-BuildRequires:  pkgconfig(libpcre16)
-BuildRequires:  pkgconfig(libpcrecpp)
-BuildRequires:  pkgconfig(libpcreposix)
-BuildRequires:  pkgconfig(libpulse)
-BuildRequires:  pkgconfig(libpulse-mainloop-glib)
-BuildRequires:  pkgconfig(libpulse-simple)
-BuildRequires:  pkgconfig(libssl)
-BuildRequires:  pkgconfig(libsystemd-daemon)
-BuildRequires:  pkgconfig(libsystemd-id128)
-BuildRequires:  pkgconfig(libsystemd-journal)
-BuildRequires:  pkgconfig(libsystemd-login)
-BuildRequires:  pkgconfig(libzrtpcpp)
-BuildRequires:  pkgconfig(openssl)
-BuildRequires:  pkgconfig(opus)
-BuildRequires:  pkgconfig(rarian)
-BuildRequires:  pkgconfig(samplerate)
-BuildRequires:  pkgconfig(sndfile)
-BuildRequires:  pkgconfig(speex)
-BuildRequires:  pkgconfig(speexdsp)
-BuildRequires:  pkgconfig(systemd)
-BuildRequires:  pkgconfig(uuid)
-Suggests:       %{name}-client-gnome
-Suggests:       %{name}-client-kde4
-%endif
-
-%if %{with kde4}
-# For KDE 4.12
-BuildRequires:  akonadi-runtime
-BuildRequires:  cmake
-BuildRequires:  libkde4-devel
-BuildRequires:  libkdepimlibs4-devel
-%endif
-
-%if %{with gnome}
-BuildRequires:  gnome-common
-BuildRequires:  intltool
-BuildRequires:  yelp-tools
-BuildRequires:  pkgconfig(clutter-gtk-1.0)
-BuildRequires:  pkgconfig(dbus-glib-1)
-BuildRequires:  pkgconfig(gnome-doc-utils)
-BuildRequires:  pkgconfig(libnotify)
-%endif

-%if %{with plugins}
 %if 0%{?suse_version} >= 1310
 BuildRequires:  pkgconfig(camel-1.2)
 BuildRequires:  pkgconfig(evolution-data-server-1.2)
@@ -116,7 +30,15 @@
 BuildRequires:  pkgconfig(libedata-cal-1.2)
 BuildRequires:  pkgconfig(libedataserver-1.2)
 %else
-BuildRequires:  evolution-data-server-devel
+BuildRequires:  pkgconfig(camel-1.2)
+BuildRequires:  pkgconfig(evolution-data-server-1.2)
+BuildRequires:  pkgconfig(libebackend-1.2)
+BuildRequires:  pkgconfig(libebook-1.2)
+BuildRequires:  pkgconfig(libebook-contacts-1.2)
+BuildRequires:  pkgconfig(libecal-1.2)
+BuildRequires:  pkgconfig(libedata-book-1.2)
+BuildRequires:  pkgconfig(libedata-cal-1.2)
+BuildRequires:  pkgconfig(libedataserver-1.2)
 %endif # 0% {?suse_version}
 %endif

@@ -131,7 +53,14 @@
 Requires:       %{name} = %{version}-%{release}
 # For building with KDE 4.12
 # % kde4_akonadi_requires == "Requires: akonadi-runtime  >= 1.10.2 akonadi-runtime < 1.10.40" (on openSUSE 13.1)
-Requires:       akonadi-runtime >= % ( echo `rpm -q --queryformat '%{VERSION}' akonadi-runtime`)
+Requires:       '%{VERSION}'
+Requires:       (
+Requires:       --queryformat
+Requires:       -q
+Requires:       `rpm
+Requires:       akonadi-runtime >= %
+Requires:       akonadi-runtime`)
+Requires:       echo
 # % {requies_eq}     akonadi_runtime
 %{kde4_runtime_requires}
 %{kde4_pimlibs_requires}
@@ -217,19 +146,19 @@
 %install
 %if %{with common}
 pushd daemon
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with plugins}
 pushd plugins
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with kde4}
 pushd kde/build/
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 rm -rf %{buildroot}/%{_includedir}
 rm -f %{buildroot}/%{_libdir}/*.so
 popd
@@ -243,7 +172,7 @@

 %if %{with gnome}
 pushd gnome
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %suse_update_desktop_file -r %{name} Network Telephony
 %find_lang %{name} %{name}-gnome.lang --without-gnome --without-kde
@@ -293,6 +222,7 @@
 %desktop_database_postun

 # GIT: unnecessary:  -f % {name}-kde.lang
+
 %files -n %{name}-client-kde4
 %defattr(-,root,root)
 %dir %{_kde4_appsdir}/%{name}-client-kde/
szotsaki commented 9 years ago

Could you please open this bug?

scarabeusiv commented 9 years ago

In all honesty I can't reproduce it.

scarabeus@arcarius: ~/remote/work/opensource/spec-cleaner $ python spec_cleaner/__init__.py ~/Downloads/sflphone.spec  > ~/Downloads/sflphone.spec.2
scarabeus@arcarius: ~/remote/work/opensource/spec-cleaner $ diff ~/Downloads/sflphone.spec ~/Downloads/sflphone.spec.2
--- /home/scarabeus/Downloads/sflphone.spec     2014-07-15 19:46:42.034439398 +0200
+++ /home/scarabeus/Downloads/sflphone.spec.2   2014-07-15 19:47:32.381394774 +0200
@@ -1,9 +1,9 @@
 #
 # spec file for package sflphone
 #
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 # Copyright (c) 2013-2014  Ákos Szőts <szotsaki@gmail.com>
 # Copyright (c) 2009-2010  Vovochka404 <vovochka13@gmail.com>
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,11 +17,11 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #

+
 %bcond_without common
 %bcond_without kde4
 %bcond_without plugins
 %bcond_without gnome
-
 Name:           sflphone
 Version:        1.3.0.git
 Release:        0
@@ -38,7 +38,6 @@
 BuildRequires:  sed
 BuildRequires:  update-desktop-files
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
 %if %{with common}
 BuildRequires:  ilbc
 BuildRequires:  libasound2
@@ -84,7 +83,6 @@
 Suggests:       %{name}-client-gnome
 Suggests:       %{name}-client-kde4
 %endif
-
 %if %{with kde4}
 # For KDE 4.12
 BuildRequires:  akonadi-runtime
@@ -92,7 +90,6 @@
 BuildRequires:  libkde4-devel
 BuildRequires:  libkdepimlibs4-devel
 %endif
-
 %if %{with gnome}
 BuildRequires:  gnome-common
 BuildRequires:  intltool
@@ -102,7 +99,6 @@
 BuildRequires:  pkgconfig(gnome-doc-utils)
 BuildRequires:  pkgconfig(libnotify)
 %endif
-
 %if %{with plugins}
 %if 0%{?suse_version} >= 1310
 BuildRequires:  pkgconfig(camel-1.2)
@@ -217,19 +213,19 @@
 %install
 %if %{with common}
 pushd daemon
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with plugins}
 pushd plugins
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %endif

 %if %{with kde4}
 pushd kde/build/
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 rm -rf %{buildroot}/%{_includedir}
 rm -f %{buildroot}/%{_libdir}/*.so
 popd
@@ -243,7 +239,7 @@

 %if %{with gnome}
 pushd gnome
-%{makeinstall} INSTALL_ROOT=%{buildroot}
+make DESTDIR=%{buildroot} install %{?_smp_mflags} INSTALL_ROOT=%{buildroot}
 popd
 %suse_update_desktop_file -r %{name} Network Telephony
 %find_lang %{name} %{name}-gnome.lang --without-gnome --without-kde
@@ -293,6 +289,7 @@
 %desktop_database_postun

 # GIT: unnecessary:  -f % {name}-kde.lang
+
 %files -n %{name}-client-kde4
 %defattr(-,root,root)
 %dir %{_kde4_appsdir}/%{name}-client-kde/
szotsaki commented 9 years ago

Hmm, that's really interesting. I've just upgraded to the latest version 0ffe60ea6ae and ran it in the following form: [...]/spec-cleaner/bin/spec-cleaner -pif sflphone.spec and I still got the diff above.

Should I invoke the program some other way?

scarabeusiv commented 9 years ago

If you invoke it with bin/spec-cleaner it uses SYSTEM version of spec-cleaner it finds, so maybe that is the reason it fails?

Also that is why I use it by calling python spec_cleaner/init.py

szotsaki commented 9 years ago

Sorry, I didn't know that the /bin/spec-cleaner somehow calls the system-wide installed version. The init.py version worked and this issue has really been fixed.