Attempt to fix Qt dependencies for SUSE.
[metze/wireshark/wip.git] / packaging / rpm / SPECS / wireshark.spec.in
index f53d9651a0a4852b6351f9884a7832447e61f919..0957de4b3147a409714b1e2f1f8b1c25ab21c1fe 100644 (file)
@@ -10,6 +10,8 @@
 
 # Set to 1 if you want GTK3 instead of GTK2:
 %global with_gtk3 0
+# Set to 1 if you want the Qt GUI too
+%global with_qt 1
 
 # Set at most one of these two:
 # Note that setcap requires rpmbuild 4.7.0 or later.
@@ -91,21 +93,31 @@ Requires(pre):      pwdutils
 Requires(pre): shadow-utils
 %endif
 %endif
-Requires(post):        desktop-file-utils
 
 %if %{setcap_dumpcap}
-%if 0%{?suse_version}
-# SuSE's rpmbuild is in this package:
+# Actually we require rpmbuild (the program) >= 4.7.0 but the package name
+# where we can find it varies.  So we check the 'rpm' version because either
+# rpmbuild is in that package (e.g., in older distros) or it's in the
+# 'rpm-build' package which generally requires a matching version of 'rpm'.
+#
+# All of this is to save users the trouble of getting through an full compile
+# only to have rpmbuild barf because it doesn't understand capabilities.
 BuildRequires: rpm >= 4.7.0
-%else
-# ... while Redhat's is in this one:
-BuildRequires: rpm-build >= 4.7.0
-%endif
 %endif
 
+%description
+Wireshark is a free network protocol analyzer for Unix and Windows. It
+allows you to examine data from a live network or from a capture file
+on disk. You can interactively browse the capture data, viewing summary
+and detail information for each packet. Wireshark has several powerful
+features, including a rich display filter language and the ability to
+view the reconstructed stream of a TCP session.
+
+This package contains command-line utilities, plugins, and documentation for
+Wireshark. A GTK+ and a Qt graphical user interface are packaged separately.
 
 %package       gnome
-Summary:       Gnome desktop integration for wireshark
+Summary:       Gnome desktop integration for Wireshark
 Group:         Applications/Internet
 %if %{with_gtk3}
 Requires:      gtk3 >= @GTK3_MIN_VERSION@
@@ -114,10 +126,13 @@ BuildRequires:    gtk3-devel >= @GTK3_MIN_VERSION@
 Requires:      gtk2 >= @GTK2_MIN_VERSION@
 BuildRequires: gtk2-devel >= @GTK2_MIN_VERSION@
 %endif
-Requires:      wireshark = %{version}-%{release}
+Requires:      %{name} = %{version}-%{release}
 Requires:      xdg-utils
 Requires:      hicolor-icon-theme
 BuildRequires: desktop-file-utils
+Requires(post):        desktop-file-utils
+Requires(post): %{_sbindir}/update-alternatives
+Requires(postun): %{_sbindir}/update-alternatives
 %if 0%{?suse_version}
 # Need this for SuSE's suse_update_desktop_file macro
 BuildRequires: update-desktop-files
@@ -133,20 +148,37 @@ Requires: portaudio
 # Add this for more readable fonts on some distributions/versions
 #Requires:     dejavu-sans-mono-fonts
 
+%description gnome
+Contains the Gnome (GTK+) Wireshark GUI and desktop integration files.
 
-%description
-Wireshark is a free network protocol analyzer for Unix and Windows. It
-allows you to examine data from a live network or from a capture file
-on disk. You can interactively browse the capture data, viewing summary
-and detail information for each packet. Wireshark has several powerful
-features, including a rich display filter language and the ability to
-view the reconstructed stream of a TCP session.
+%if %{with_qt}
+%package       qt
+Summary:       Qt GUI for Wireshark
+Group:         Applications/Internet
+%if 0%{?suse_version}
+Requires:      libqt4 >= @QT_MIN_VERSION@
+BuildRequires: libqt4-devel >= @QT_MIN_VERSION@
+%else
+Requires:      qt >= @QT_MIN_VERSION@
+BuildRequires: qt-devel >= @QT_MIN_VERSION@
+%endif
+Requires:      %{name} = %{version}-%{release}
+Requires:      xdg-utils
+Requires:      hicolor-icon-theme
+BuildRequires: desktop-file-utils
+Requires(post):        desktop-file-utils
+Requires(post): %{_sbindir}/update-alternatives
+Requires(postun): %{_sbindir}/update-alternatives
+BuildRequires: gcc-c++
+%if 0%{?suse_version}
+# Need this for SuSE's suse_update_desktop_file macro
+BuildRequires: update-desktop-files
+%endif
 
-This package contains command-line utilities, plugins, and documentation for
-Wireshark. A GTK+ graphical user interface is packaged separately.
+%description qt
+Contains the Qt Wireshark GUI and desktop integration files.
+%endif
 
-%description gnome
-Contains the Gnome (GTK+) Wireshark GUI and desktop integration files.
 
 %prep
 %setup -q -n %{name}-%{version}
@@ -171,14 +203,25 @@ Contains the Gnome (GTK+) Wireshark GUI and desktop integration files.
 %endif
 %if %{with_gtk3}
   --with-gtk3 \
+%else
+  --with-gtk2 \
+%endif
+%if %{with_qt}
+  --with-qt \
 %endif
   --disable-warnings-as-errors
 
+# Suggestion: put this in your ~/.rpmmacros (without the hash sign, of course):
+# %_smp_mflags -j %(grep -c processor /proc/cpuinfo)
 make %{?_smp_mflags}
 
 %install
 rm -rf $RPM_BUILD_ROOT
 make DESTDIR=$RPM_BUILD_ROOT install
+# Change the program name for 'alternatives'
+mv %{buildroot}%{_bindir}/wireshark %{buildroot}%{_bindir}/wireshark-gtk
+# Create the 'alternative' file
+touch %{buildroot}%{_bindir}/wireshark
 make DESTDIR=$RPM_BUILD_ROOT install_desktop_files
 %if 0%{?suse_version}
 # SuSE's packaging conventions
@@ -207,6 +250,8 @@ getent group wireshark >/dev/null || groupadd -r wireshark
 update-desktop-database &> /dev/null ||:
 update-mime-database /usr/share/mime &> /dev/null || :
 touch --no-create /usr/share/icons/hicolor &>/dev/null || :
+%{_sbindir}/update-alternatives --install %{_bindir}/wireshark \
+  %{name} %{_bindir}/wireshark-gtk 50
 
 %postun gnome
 update-desktop-database &> /dev/null ||:
@@ -214,7 +259,26 @@ update-mime-database /usr/share/mime &> /dev/null || :
 if [ $1 -eq 0 ] ; then
        touch --no-create /usr/share/icons/hicolor &>/dev/null || :
        gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
+       %{_sbindir}/update-alternatives --remove %{name} %{_bindir}/wireshark-gtk
+fi
+
+%if %{with_qt}
+%post qt
+update-desktop-database &> /dev/null ||:
+update-mime-database /usr/share/mime &> /dev/null || :
+touch --no-create /usr/share/icons/hicolor &>/dev/null || :
+%{_sbindir}/update-alternatives --install %{_bindir}/wireshark \
+  %{name} %{_bindir}/wireshark-qt 10
+
+%postun qt
+update-desktop-database &> /dev/null ||:
+update-mime-database /usr/share/mime &> /dev/null || :
+if [ $1 -eq 0 ] ; then
+       touch --no-create /usr/share/icons/hicolor &>/dev/null || :
+       gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
+       %{_sbindir}/update-alternatives --remove %{name} %{_bindir}/wireshark-qt
 fi
+%endif
 
 # Is this really needed?
 %posttrans
@@ -226,6 +290,8 @@ gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
 %doc AUTHORS COPYING ChangeLog INSTALL INSTALL.configure NEWS README*
 # Don't pick up the wireshark (GUI) binary here
 %exclude %{_bindir}/wireshark
+%exclude %{_bindir}/wireshark-gtk
+%exclude %{_bindir}/wireshark-qt
 %{_bindir}/*
 
 # This generates a warning because dumpcap is listed twice. That's
@@ -271,10 +337,33 @@ gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
 /usr/share/icons/hicolor/*/apps/*
 /usr/share/icons/hicolor/*/mimetypes/*
 /usr/share/mime/packages/wireshark.xml
-%{_bindir}/wireshark
+%{_bindir}/wireshark-gtk
+%{_mandir}/man1/wireshark.*
+%ghost %{_bindir}/wireshark
+
+%if %{with_qt}
+%files qt
+%defattr(-,root,root)
+/usr/share/applications/wireshark.desktop
+/usr/share/icons/hicolor/*/apps/*
+/usr/share/icons/hicolor/*/mimetypes/*
+/usr/share/mime/packages/wireshark.xml
+%{_bindir}/wireshark-qt
 %{_mandir}/man1/wireshark.*
+%ghost %{_bindir}/wireshark
+%endif
 
 %changelog
+* Tue Nov 12 2013 Jeff Morriss
+- Add q qt package using 'alternatives' to allow the administrator to choose
+  which one they actually use.
+
+* Fri Sep 20 2013 Jeff Morriss
+- If we're not using gtk3 add --with-gtk2 (since Wireshark now defaults to gtk3)
+
+* Thu Mar 28 2013 Jeff Morriss
+- Simplify check for rpmbuild's version.
+
 * Fri Mar  8 2013 Jeff Morriss
 - Put all icons in hicolor
 - Use SuSE's desktop-update macro.