File wireshark.spec of Package wireshark

# Note that this is NOT a relocatable package
# XXX is this still true?
# says that recent CMake versions take care of rpathification.

# To do:
# - Set version in version.h
# - Add bcond_with clang

%bcond_with	ninja
%bcond_with	ccache
%bcond_without	qt5
%bcond_with	lua
%bcond_with	mmdbresolve
%bcond_with	lz4_and_snappy
%bcond_with	c_ares
%bcond_with	spandsp
%bcond_with	bcg729
%bcond_with	libxml2
%bcond_with	nghttp2
%bcond_with	sdjournal
%bcond_with	guides
%bcond_with	brotli
%bcond_with	zstd

# Set at most one of these two:
# Note that setcap requires rpmbuild 4.7.0 or later.
%global setuid_dumpcap 0
%global setcap_dumpcap 1
%global _prefix /opt/nio

# Set to 1 if you want a group called 'wireshark' which users must be a member
# of in order to run dumpcap.  Only used if setuid_dumpcap or setcap_dumpcap
# are set.
%global use_wireshark_group 1

%global package_version 3.2.0

AutoReqProv: no
Summary:	Wireshark is the world's foremost protocol analyzer
Name:		wireshark
Version:	3.2.0
Release:	1
License:	GPLv2+
Group:		Applications/Internet
# Or this URL for automated builds:
#Source:		wireshark-3.2.0.tar.gz
Packager:	Gerald Combs <gerald[AT]>

BuildRoot:	/tmp/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%if 0%{?rhel}
BuildRequires:	cmake3 >= 3.5
BuildRequires:	cmake >= 3.5
BuildRequires:  python3
BuildRequires:	gcc
BuildRequires:	perl
BuildRequires:	flex
BuildRequires:	bison
%if %{with guides}
BuildRequires:	asciidoctor

BuildRequires:	glib2-devel >= 2.32.0
Requires:	glib2
BuildRequires:	libpcap-devel
%if 0%{?suse_version}
Requires:	libpcap1
Requires:	libpcap
BuildRequires:	zlib-devel
Requires:	zlib
BuildRequires:	libgcrypt-devel
%if 0%{?suse_version}
Requires:	libgcrypt20
Requires:	libgcrypt

%if %{with lz4_and_snappy}
%if 0%{?suse_version}
BuildRequires:	liblz4-devel
%if 0%{?sle_version} >= 150000
Requires:	liblz4-1
Requires:	liblz4-1_4
BuildRequires:	snappy-devel
Requires:	libsnappy1
BuildRequires:	lz4-devel
Requires:	lz4
BuildRequires:	snappy-devel
Requires:	snappy

%if %{with c_ares}
%if 0%{?suse_version}
# SUSE uses these package names (yes 2!):
BuildRequires:	libcares-devel
Requires:	libcares2
# ... while Red Hat uses this one:
# (What other RPM-based distros do will have to be determined...)
BuildRequires:	c-ares-devel
Requires:	c-ares

%if %{with lua}
%if 0%{?fedora}
BuildRequires:	compat-lua-devel < 5.3
Requires:	compat-lua < 5.3
%if 0%{?suse_version}
BuildRequires:	lua51-devel
Requires:	lua51
BuildRequires:	lua-devel < 5.3
Requires:	lua < 5.3

%if %{with nghttp2}
BuildRequires:	libnghttp2-devel
%if 0%{?suse_version}
Requires:	libnghttp2-14
Requires:	libnghttp2

%if %{with sdjournal}
BuildRequires:	systemd-devel
%if 0%{?suse_version}
Requires:	libsystemd0
Requires:	systemd-libs

%if %{with brotli}
%if 0%{?suse_version}
BuildRequires:	libbrotli-devel
# On SUSE libbrotli-devel installs the,
# and symlinks, but only installs the libbrotlicommon1 and libbrotlienc1
# packages, leaving the symlink broken, so we have to include libbrotlidec1
# as a build-time dependency...
BuildRequires:	libbrotlidec1
Requires:	libbrotlidec1
BuildRequires:	brotli-devel
Requires:	brotli

%if %{with zstd}
BuildRequires:	libzstd-devel
%if 0%{?suse_version}
Requires:	libzstd1
Requires:	libzstd

# Uncomment these if you want to be sure you get them...
#BuildRequires:	krb5-devel
#BuildRequires:	libsmi-devel
#BuildRequires:	pcre-devel
#BuildRequires:	libselinux
#BuildRequires:	gnutls-devel
#BuildRequires:	libcap-devel

%if %{with mmdbresolve}
BuildRequires:	libmaxminddb-devel
%if 0%{?suse_version}
Requires:	libmaxminddb0
Requires:	libmaxminddb

%if %{use_wireshark_group}
%if 0%{?suse_version}
# SUSE's groupadd is in this package:
Requires(pre):	pwdutils
# ... while Red Hat's is in this one:
Requires(pre):	shadow-utils

%if %{setcap_dumpcap}
# 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

# NOTE: the below description has been copied to wireshark.appdata.xml (in the
# top-level directory).
Wireshark allows you to examine protocol data stored in files or as it is
captured from wired or wireless (WiFi or Bluetooth) networks, USB devices,
and many other sources.  It supports dozens of protocol capture file formats
and understands more than a thousand protocols.

It has many powerful features including a rich display filter language
and the ability to reassemble multiple protocol packets in order to, for
example, view a complete TCP stream, save the contents of a file which was
transferred over HTTP or CIFS, or play back an RTP audio stream.

This package contains command-line utilities, plugins, and documentation for
Wireshark. A Qt graphical user interface is packaged separately.

%if %{with qt5}
%package	qt
Summary:	Wireshark's Qt-based GUI
Group:		Applications/Internet
Obsoletes:	wireshark-gnome wireshark-gtk
%description qt
This package contains the Qt Wireshark GUI and desktop integration files.

Requires:	%{name} = %{version}-%{release}
BuildRequires:	gcc-c++
%if 0%{?suse_version}
BuildRequires:	libQt5Core-devel
Requires:	libQt5Core5
BuildRequires:	libQt5Gui-devel
Requires:	libQt5Gui5
BuildRequires:	libQt5Widgets-devel
Requires:	libQt5Widgets5
BuildRequires:	libQt5PrintSupport-devel
Requires:	libQt5PrintSupport5
BuildRequires:	libqt5-qtmultimedia-devel
Requires:	libQt5Multimedia5
# Need this for SUSE's suse_update_desktop_file macro
BuildRequires:	update-desktop-files
BuildRequires:	qt5-qtbase-devel
Requires:	qt5-qtbase
Requires:	qt5-qtbase-gui
BuildRequires:	qt5-qtmultimedia-devel
Requires:	qt5-qtmultimedia
Requires:	xdg-utils
Requires:	hicolor-icon-theme
BuildRequires:	desktop-file-utils
Requires(post):	desktop-file-utils
# Add this for more readable fonts on some distributions/versions
#Requires:	dejavu-sans-mono-fonts

%package	devel
Summary:	Development headers for Wireshark
Group:		Applications/Internet
Requires:	%{name} = %{version}-%{release}
%description devel
The wireshark-devel package contains the header and other files required for
development of Wireshark scripts and plugins.

%setup -q -n %{name}-%{package_version}

%if 0%{?rhel}
cmake3 \
%cmake \
%if %{with ccache}
  -DBUILD_wireshark=OFF \
  -DBUILD_tshark=ON \
  -DBUILD_mmdbresolve=OFF \
%if %{with c_ares}
%if %{with spandsp}
%if %{with bcg729}
%if %{with libxml2}
%if %{with sdjournal}
  -DBUILD_sdjournal=ON \
  -DBUILD_sdjournal=OFF \
%if %{with brotli}
%if %{with ninja}
  -G Ninja \

%if %{with ninja}
# Older RPM-based distributions used ninja-build in order to prevent a collision with
# the Ninja IRC client:
NINJA=$(type ninja >/dev/null 2>&1 && echo ninja || echo ninja-build)
# Suggestion: put this in your ~/.rpmmacros (without the hash sign, of course):
# %_smp_mflags -j %(grep -c processor /proc/cpuinfo)
make %{?_smp_mflags}

%if 0%{?suse_version}
cd build
%if %{with ninja}
NINJA=$(type ninja >/dev/null 2>&1 && echo ninja || echo ninja-build)
%if %{with guides}
%if %{with guides}
make DESTDIR=$RPM_BUILD_ROOT install_guides
%if 0%{?suse_version}
cd -

# If we're being installed in an unusual prefix tell the loader where
# to find our libraries.
%if "%{_prefix}" != "/usr"
	%define install_ld_so_conf 1
	mkdir -p $RPM_BUILD_ROOT/etc/
	echo %{_libdir} > $RPM_BUILD_ROOT/etc/


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

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig



# Include the User Guide:
%docdir %{_datadir}/doc/wireshark/

# Don't pick up any of the wireshark (GUI) binaries here
#%exclude %{_bindir}/wireshark*

# This generates a warning because dumpcap is listed twice. That's
# probably preferable to listing each program (and keeping the list up to
# date)...
%if %{use_wireshark_group} && %{setuid_dumpcap}
# Setuid but only executable by members of the 'wireshark' group
%attr(4750, root, wireshark) %{_bindir}/dumpcap
%if %{use_wireshark_group} && %{setcap_dumpcap}
# Setcap but only executable by members of the 'wireshark' group
%attr(0750, root, wireshark) %caps(cap_net_raw,cap_net_admin=ep) %{_bindir}/dumpcap
%if %{setuid_dumpcap}
# Setuid and executable by all
%attr(4755, root, root) %{_bindir}/dumpcap
%if %{setcap_dumpcap}
# Setcap and executable by all
%attr(0755, root, root) %caps(cap_net_raw,cap_net_admin=ep) %{_bindir}/dumpcap
# Executable by all but with no special permissions
%attr(0755, root, root) %{_bindir}/dumpcap

%exclude %{_prefix}/lib64/lib*.so
# Don't pick up the cmake files here
#%exclude %{_libdir}/wireshark/cmake
%exclude %{_prefix}/lib64/wireshark/cmake
# Don't pick up the wireshark (GUI) man page here
%exclude %{_mandir}/man1/wireshark.*

%if 0%{?install_ld_so_conf}


#Devel files

* Thu Aug 15 2019 Gerald Combs
- Add zstd
openSUSE Build Service is sponsored by