Blob Blame History Raw
# needed on EPEL7 koji: Unknown tag: %%python_provide: ERROR: python34-idstools not recognized.
%{!?py2_build:          %global py2_build               CFLAGS="%{optflags}" /usr/bin/python2 setup.py  build --executable="/usr/bin/python2 -s"}
%{!?py2_install:        %global py2_install             CFLAGS="%{optflags}" /usr/bin/python2 setup.py  install -O1 --skip-build --root %{buildroot}}
%{!?py3_build:          %global py3_build               CFLAGS="%{optflags}" /usr/bin/python3 setup.py  build --executable="/usr/bin/python3 -s"}
%{!?py3_install:        %global py3_install             CFLAGS="%{optflags}" /usr/bin/python3 setup.py  install -O1 --skip-build --root %{buildroot}}

%if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7)
%global		with_python3	1
%endif

%global		upstream_name	py-idstools
%global		pname		idstools

Name:		python-%{pname}
Version:	0.5.4
Release:	2%{?dist}
Summary:	Snort and Suricata Rule and Event Utilities
License:	BSD
URL:		https://github.com/jasonish/py-idstools
Source0:	https://github.com/jasonish/py-idstools/archive/%{version}.tar.gz#/%{upstream_name}-%{version}.tar.gz
BuildArch:	noarch

%global desc_base \
	py-idstools is a collection of Python libraries for working with IDS systems\
	(typically Snort and Suricata).


%description
%{desc_base}


%package -n python2-%{pname}
Summary:	%{summary} For Python2
%{?python_provide:%python_provide python2-%{pname}}

BuildRequires:	python2-devel
BuildRequires:	python-nose

%description -n python2-%{pname}
%{desc_base} for Python2.


%if 0%{?with_python3}

%if 0%{?fedora}
%package -n python3-%{pname}
Summary:	%{summary} for Python3
%{?python_provide:%python_provide python3-%{pname}}

BuildRequires:	python3-devel
BuildRequires:	python3-nose

%description -n python3-%{pname}
%{desc_base} for Python3.
%endif

%if 0%{?rhel} && 0%{?rhel} >= 7
%package -n python34-%{pname}
Summary:	%{summary} for Python3
%{?python_provide:%python_provide python34-%{pname}}

BuildRequires:	python34-devel
BuildRequires:	python34-nose

%description -n python34-%{pname}
%{desc_base} for Python3.
%endif

%endif # with_python3

%prep
%autosetup -n %{upstream_name}-%{version}
# remove bundled libraries
%{__rm} -rf idstools/compat
%{__sed} -i '/compat/d' setup.py
# remove shebang from scripts https://github.com/jasonish/py-idstools/issues/33
for file in `find idstools/scripts -type f`; do
%{__sed} -i '/\/usr\/bin\/env python/d' $file
done


%build
%{py2_build}

%if 0%{?with_python3}
%{py3_build}
%endif # with_python3


%install
%{py2_install}

%if 0%{?with_python3}
%{py3_install}
%endif


%check
%{__python2} setup.py nosetests

%if 0%{?with_python3}
%{__python3} setup.py nosetests
%endif


%files -n python2-%{pname}
%exclude %{_bindir}/%{pname}*
%{python2_sitelib}/%{pname}-%{version}-py%{python2_version}.egg-info
%{python2_sitelib}/%{pname}
%doc README.rst
%license

%if 0%{?with_python3}

%if 0%{?fedora}
%files -n python3-%{pname}
%{_bindir}/%{pname}-eve2pcap
%{_bindir}/%{pname}-gensidmsgmap
%{_bindir}/%{pname}-rulecat
%{_bindir}/%{pname}-u2eve
%{_bindir}/%{pname}-u2fast
%{_bindir}/%{pname}-u2json
%{python3_sitelib}/%{pname}-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/%{pname}
%doc README.rst
%license
%endif

%if 0%{?rhel} && 0%{?rhel} >= 7
%files -n python34-%{pname}
%{_bindir}/%{pname}-eve2pcap
%{_bindir}/%{pname}-gensidmsgmap
%{_bindir}/%{pname}-rulecat
%{_bindir}/%{pname}-u2eve
%{_bindir}/%{pname}-u2fast
%{_bindir}/%{pname}-u2json
%{python3_sitelib}/%{pname}-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/%{pname}
%doc README.rst
%license
%endif

%endif


%changelog
* Thu Nov 24 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.5.4-1
- initial package