File wireshark.spec of Package wireshark

%define debug_enable	1
%define debug_package	1
%define orig_name wireshark
%define wireshark_version 2.6.3
%define wireshark_target x86_64-native-linuxapp-gcc
%define _prefix /opt/nio
%define _libdir %{_prefix}/lib
%define _libexecdir %{_prefix}/libexec
%define _sysconfdir /etc

%{!?machine: %define machine native}

%{!?kversion: %define kversion 3.10.0-514.16.1.el7}

%bcond_with	lua

%global use_wireshark_group 1


Summary:	Niometrics version of Wireshark. Wireshark is the world's foremost protocol analyzer
Name:		%{orig_name}
Version:	%{wireshark_version}
Release:	%{rpm_release}
License:	GPLv2+
Group:		Applications/Internet
Source:		%{orig_name}-%{wireshark_version}.tar.xz
# Or this URL for automated builds:
#Source:	https://wireshark.org/download/automated/src/%{name}-%{version}.tar.bz2
URL:		https://www.wireshark.org/
Packager:	Costas
# Some distributions create a wireshark-devel package; get rid of it
Obsoletes:	%{orig_name}-devel
BuildRoot:	%{_tmppath}/%{name}-install

BuildRequires:	libtool
BuildRequires:	gcc
BuildRequires:	python
BuildRequires:	perl

BuildRequires:	autoconf >= 2.60
BuildRequires:	automake
BuildRequires:	flex
BuildRequires:	bison

BuildRequires:	glib2-devel >= 2.16.0
BuildRequires:	libpcap-devel
BuildRequires:	zlib-devel
BuildRequires:	libgcrypt-devel
BuildRequires:	c-ares-devel
BuildRequires:	libnghttp2-devel
BuildRequires:	libxml2-devel
BuildRequires:	rpm >= 4.7.0
Requires:	glib2 >= 2.16.0
Requires:	libpcap
Requires:	zlib
Requires:	libgcrypt
Requires:	c-ares
Requires:	libnghttp2
Requires:	libxml2

Requires(pre):	shadow-utils
# Make sure nio-wireshark is removed.
Obsoletes:	nio-wireshark

%description
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 and a GTK+ graphical user interface are packaged separately.

%prep
%setup -q -n %{name}-%{version}

autoreconf --install

%configure \
  --enable-wireshark=no \
  --with-gnu-ld \
  --with-c-ares \
  --with-libxml2 \
  --without-libxml2 \
  --with-extcap \
  --with-qt=no \
  --without-gtk \
  --disable-warnings-as-errors

# Remove rpath.  It's prohibited in Fedora[1] and anyway we don't need it (and
# sometimes it gets in the way).
# [1] https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

# 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

# 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/ld.so.conf.d
	echo %{_libdir} > $RPM_BUILD_ROOT/etc/ld.so.conf.d/wireshark.conf
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%pre
getent group wireshark >/dev/null || groupadd -r wireshark
# If we have a pre-alternatives wireshark binary out there, get rid of it.
# (With 'alternatives' %{_bindir}/wireshark should be a symlink.)
if [ -f %{_bindir}/wireshark ]
then
	rm -f %{_bindir}/wireshark
fi

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL INSTALL.configure NEWS README*
# Don't pick up any of the wireshark (GUI) binaries here
%exclude %{_bindir}/wireshark*
%{_bindir}/*

%attr(0750, root, wireshark) %caps(cap_net_raw,cap_net_admin=ep) %{_bindir}/dumpcap

%{_libdir}/lib*.so*
%exclude %{_libdir}/%{name}/plugins/%{version}/*.la
%exclude %{_libdir}/*.la
%{_libdir}/wireshark
%{_libdir}/pkgconfig/wireshark.pc
# Don't pick up the wireshark (GUI) man page
%exclude %{_mandir}/man1/wireshark.*
# Our RPMs use 'alternatives' to choose the Wireshark so it doesn't make sense
# to have 2 desktop entries: one for 'wireshark' (Qt or Gtk GUI, depending on
# configuration) and one for 'wireshark-gtk' (the Gtk GUI).
%exclude %{_datadir}/applications/wireshark-gtk.desktop
%{_mandir}/man1/*
%{_mandir}/man4/*
%{_datadir}/wireshark
%{_includedir}/wireshark
%if 0%{?install_ld_so_conf}
/etc/ld.so.conf.d/wireshark.conf
%endif

%changelog
* Wed Aug 29 2018 Costas Gargerakis
- Upgraded from nio-wireshark-2.4.0 to wireshark-2.6.3