File wireshark.spec of Package wireshark

#
# spec file for package wireshark
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


# define libraries
%define libutil libwsutil8
%define libwire libwireshark9
%define libtap libwiretap7
%define libcodecs libwscodecs1
# disable caps
%define use_caps 0
# Enable new Qt gui on new releases and build old GTK2 gui on old releases
%bcond_without gnutls
%bcond_without qt
%bcond_with gtk
%bcond_without geoip
Name:           wireshark
Version:        2.4.5
Release:        0
Summary:        A Network Traffic Analyser
License:        GPL-2.0+ AND GPL-3.0+
Group:          Productivity/Networking/Diagnostic
Url:            https://www.wireshark.org/
Source:         https://www.wireshark.org/download/src/%{name}-%{version}.tar.xz
Source2:        https://www.wireshark.org/download/SIGNATURES-%{version}.txt
Source3:        https://www.wireshark.org/download/gerald_at_wireshark_dot_org.gpg#/wireshark.keyring
# PATCH-FIX-OPENSUSE wireshark-1.6.3-disable-warning-dialog.patch bnc#349782 prusnak@suse.cz -- don't show warning when running as root
Patch1:         wireshark-1.2.0-disable-warning-dialog.patch
# PATCH-FEATURE-OPENSUSE wireshark-1.2.0-geoip.patch prusnak@suse.cz -- search in /var/lib/GeoIP if user hasn't set any GeoIP folders
Patch2:         wireshark-1.2.0-geoip.patch
Patch4:         wireshark-1.10.0-enable_lua.patch
# for patch7 wireshark-1.12.6-fix-QT-PIC-PIE.patch
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  glib2-devel
BuildRequires:  hicolor-icon-theme
BuildRequires:  krb5-devel
BuildRequires:  libcares-devel
BuildRequires:  libgcrypt-devel >= 1.4.2
BuildRequires:  libpcap-devel
BuildRequires:  libsmi-devel
BuildRequires:  libtool
BuildRequires:  net-snmp-devel
BuildRequires:  openssl-devel
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  portaudio-devel
BuildRequires:  tcpd-devel
BuildRequires:  update-desktop-files
BuildRequires:  zlib-devel
Requires:       hicolor-icon-theme
Requires(pre):  shadow
Recommends:     wireshark-ui = %{version}
Provides:       ethereal = %{version}
Obsoletes:      ethereal < %{version}
%if !0%{use_caps}
Requires:       xdg-utils
%else
BuildRequires:  libcap-devel
Requires(pre):  permissions
%endif
%if 0%{?suse_version} > 1310
BuildRequires:  pkgconfig(libnl-3.0)
%endif
BuildRequires:  cairo-devel
BuildRequires:  gtk2-devel >= 2.12.0
%if 0%{?suse_version} > 1320
BuildRequires:  lua51-devel
%else
BuildRequires:  lua-devel
%endif
%if 0%{?suse_version} <= 1110
BuildRequires:  xz
%endif

%description
Wireshark is a network protocol analyzer. It allows examining data
from a live network or from a capture file on disk. You can
interactively browse the capture data, viewing summary and detailed
information for each packet. Wireshark has several features,
including a rich display filter language and the ability to view the
reconstructed stream of a TCP session.

%package -n %{libutil}
Summary:        Library for wireshark utilities
Group:          System/Libraries

%description -n %{libutil}
The libwsutil library provides utility functions for libwireshark.

%package -n %{libwire}
Summary:        Network packet dissection library
Group:          System/Libraries

%description -n %{libwire}
The libwireshark library provides the network packet dissection services
developed by the Wireshark project.

%package -n %{libtap}
Summary:        Wireshark library for tapping
Group:          System/Libraries

%description -n %{libtap}
Wiretap, part of the Wireshark project, is a library that allows one to read
and write several packet capture file formats.

%package -n %{libcodecs}
Summary:        Network packet dissection codecs library
Group:          System/Libraries

%description -n %{libcodecs}
The libwscodecs library provides codec functions for libwireshark.

%package devel
Summary:        A Network Traffic Analyser
Group:          Development/Libraries/C and C++
Requires:       %{libcodecs} = %{version}
Requires:       %{libtap} = %{version}
Requires:       %{libutil} = %{version}
Requires:       %{libwire} = %{version}
Requires:       %{name} = %{version}
Requires:       glib2-devel
Requires:       glibc-devel
Provides:       ethereal-devel = %{version}
Obsoletes:      ethereal-devel < %{version}

%description devel
Wireshark is a network protocol analyzer. It allows examining data
from a live network or from a capture file on disk.


%package ui-gtk
Summary:        A Network Traffic Analyser - GTK+ UI
Group:          Productivity/Networking/Diagnostic
Requires:       %{name} = %{version}
Provides:       %{name}-ui = %{version}

%description ui-gtk
This package contains the GTK+ UI of Wireshark.


%prep
# The publisher doesn't sign the source tarball, but a signatures file containing multiple hashes.
# Verify hashes in that file against source tarball.
echo "`grep %{name}-%{version}.tar.xz %{SOURCE2} | grep SHA1 | head -n1 | cut -d= -f2`  %{SOURCE0}" | sha1sum -c
echo "`grep %{name}-%{version}.tar.xz %{SOURCE2} | grep SHA256 | head -n1 | cut -d= -f2`  %{SOURCE0}" | sha256sum -c

%setup -q
%patch2 -p1
%patch4 -p1

%if ! %{use_caps}
%patch1 -p1
# open capture files without root privileges bsc#1025714
for X in wireshark{,-gtk}.desktop; do
	cp -pv $X ${X/wireshark/wireshark-file}
	echo "NoDisplay=true" >> ${X/wireshark/wireshark-file}
done
sed -i '/^MimeType.*/d' wireshark{,-gtk}.desktop
# run as root if not using caps
sed -i 's!^Exec=wireshark!Exec=%{_bindir}/xdg-su -c %{_bindir}/wireshark!' wireshark{,-gtk}.desktop
%endif
sed -i 's/^Icon=wireshark.png$/Icon=wireshark/' wireshark*.desktop

%build
export CFLAGS="%{optflags} -fPIC"
export CXXFLAGS="%{optflags} -fPIC"
export LDFLAGS="-pie"



%configure \
    --with-gtk=2 \
    --with-qt=no \
    --with-ssl \
    --with-gnutls=no \
    --with-plugins=%{_libdir}/%{name}/plugins/%{version} \
    --with-pic=yes

make %{?_smp_mflags} V=1

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print

# Ethereal support (remove when SLE-11 is out of scope
ln -fs wireshark-gtk %{buildroot}%{_bindir}/ethereal
ln -fs tshark %{buildroot}%{_bindir}/tethereal

install -d -m 0755 %{buildroot}%{_sysconfdir}
install -d -m 0755 %{buildroot}%{_mandir}/man1/
# install separate appdata files corresponding to .desktop files for AppStore integration
rm -f %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml


# -devel
install -d -m 0755  %{buildroot}%{_includedir}/wireshark
IDIR="%{buildroot}%{_includedir}/wireshark"
mkdir -p "${IDIR}/epan"
mkdir -p "${IDIR}/epan/crypt"
mkdir -p "${IDIR}/epan/ftypes"
mkdir -p "${IDIR}/epan/dfilter"
mkdir -p "${IDIR}/epan/dissectors"
mkdir -p "${IDIR}/epan/wmem"
mkdir -p "${IDIR}/wiretap"
mkdir -p "${IDIR}/wsutil"
install -m 644 *.h                              "${IDIR}/"
install -m 644 epan/*.h				"${IDIR}/epan/"
install -m 644 epan/crypt/*.h			"${IDIR}/epan/crypt"
install -m 644 epan/ftypes/*.h			"${IDIR}/epan/ftypes"
install -m 644 epan/dfilter/*.h			"${IDIR}/epan/dfilter"
install -m 644 epan/dissectors/*.h		"${IDIR}/epan/dissectors"
install -m 644 epan/wmem/*.h			"${IDIR}/epan/wmem"
install -m 644 wiretap/*.h			"${IDIR}/wiretap"
install -m 644 wsutil/*.h			"${IDIR}/wsutil"


install -D -m 0644 image/wsicon48.png %{buildroot}%{_datadir}/pixmaps/wireshark-gtk.png
install -D -m 0644 wireshark-gtk.desktop %{buildroot}%{_datadir}/applications/wireshark-gtk.desktop
%suse_update_desktop_file -n %{name}-gtk
%if ! %{use_caps}
install -D -m 0644 wireshark-file-gtk.desktop %{buildroot}%{_datadir}/applications/wireshark-file-gtk.desktop
%suse_update_desktop_file -n %{name}-file-gtk
%endif


%if %{use_caps}
%pre
getent group wireshark >/dev/null || groupadd -r wireshark

%verifyscript
%{verify_permissions -e %{_bindir}/dumpcap}
%endif

%post
%if %{use_caps}
%if 0%{?set_permissions:1} > 0
%set_permissions %{_bindir}/dumpcap
%else
%run_permissions
%endif
%endif # use_caps
exit 0

%post -n %{libutil} -p /sbin/ldconfig
%postun -n %{libutil} -p /sbin/ldconfig
%post -n %{libwire} -p /sbin/ldconfig
%postun -n %{libwire} -p /sbin/ldconfig
%post -n %{libtap} -p /sbin/ldconfig
%postun -n %{libtap} -p /sbin/ldconfig
%post -n %{libcodecs} -p /sbin/ldconfig
%postun -n %{libcodecs} -p /sbin/ldconfig

%files
%doc AUTHORS COPYING NEWS README README.linux README.vmware
%{_mandir}/man1/[^i]*
%{_mandir}/man4/*
%{_bindir}/capinfos
%{_bindir}/captype
%{_bindir}/dftest
%{_bindir}/editcap
%{_bindir}/idl2wrs
%{_bindir}/mergecap
%{_bindir}/randpkt
%{_bindir}/rawshark
%{_bindir}/reordercap
%{_bindir}/tethereal
%{_bindir}/text2pcap
%{_bindir}/tshark
%{_bindir}/sharkd
%if %{use_caps}
%verify(not mode caps) %attr(0750,root,wireshark) %caps(cap_net_raw,cap_net_admin=eip) %{_bindir}/dumpcap
%else
%{_bindir}/dumpcap
%endif
%{_libdir}/wireshark/
%{_datadir}/wireshark/
%{_datadir}/icons/hicolor/*/apps/wireshark.png
%{_datadir}/icons/hicolor/*/mimetypes/application-wireshark-doc.png
%{_datadir}/icons/hicolor/scalable/apps/wireshark.svg
%{_datadir}/mime/packages/wireshark.xml

%files -n %{libutil}
%{_libdir}/libwsutil*.so.*

%files -n %{libwire}
%{_libdir}/libwireshark.so.*

%files -n %{libtap}
%{_libdir}/libwiretap.so.*

%files -n %{libcodecs}
%{_libdir}/libwscodecs.so.*

%files devel
%doc doc/README.*
%{_includedir}/wireshark
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/wireshark.pc


%files ui-gtk
%{_bindir}/wireshark-gtk
%{_bindir}/ethereal
%{_datadir}/applications/wireshark-gtk.desktop
%if ! %{use_caps}
%{_datadir}/applications/wireshark-file-gtk.desktop
%{_datadir}/applications/wireshark.desktop
%endif
%{_datadir}/pixmaps/wireshark-gtk.png

%post ui-gtk
test -f %{_bindir}/update-mime-database && %{_bindir}/update-mime-database %{_datadir}/mime > /dev/null || :
test -f %{_bindir}/update-desktop-database && %{_bindir}/update-desktop-database > /dev/null || :
test -f /sbin/conf.d/SuSEconfig.gtk2 && SuSEconfig --module gtk2 > /dev/null || :
test -f /sbin/conf.d/SuSEconfig.glib2 && SuSEconfig --module glib2 > /dev/null || :

%postun ui-gtk
test -f %{_bindir}/update-mime-database && %{_bindir}/update-mime-database %{_datadir}/mime > /dev/null || :
test -f %{_bindir}/update-desktop-database && %{_bindir}/update-desktop-database > /dev/null || :
test -f /sbin/conf.d/SuSEconfig.gtk2 && SuSEconfig --module gtk2 > /dev/null || :
test -f /sbin/conf.d/SuSEconfig.glib2 && SuSEconfig --module glib2 > /dev/null || :


%changelog
openSUSE Build Service is sponsored by