File firehol.spec of Package firehol

#
# spec file for package firehol
#
# Copyright (c) 2016 SUSE LINUX Products 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/
#

%if 0%{?suse_version} > 1230 || 0%{?rhel_version} > 600 || 0%{?centos_version} > 600 || 0%{?fedora_version} >= 20 || 0%{?el7}%{?fc20}%{?fc21}%{?fc22}%{?fc23}%{?fc24}%{?fc25}
%bcond_without  systemd
%else
%bcond_with     systemd
%endif

Name:           firehol
Version:        3.1.3
Release:        0
License:        GPL-2.0
Summary:        A firewall and shaper solution
Url:            http://firehol.org/
Group:          Productivity/Networking/Security
Source:         http://firehol.org/download/firehol/latest/firehol-%{version}.tar.xz
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%endif
BuildRequires:  curl
Requires:       curl
BuildRequires:  iprange
Requires:       iprange
BuildRequires:  iproute2
Requires:       iproute2
BuildRequires:  ipset
Requires:       ipset
BuildRequires:  iptables
Requires:       iptables
BuildRequires:  iputils
Requires:       iputils
BuildRequires:  kmod-compat
Requires:       kmod-compat
BuildRequires:  less
Recommends:     less
BuildRequires:  nfacct
Requires:       nfacct
BuildRequires:  ncurses-utils
Recommends:     ncurses-utils
BuildRequires:  procps
Requires:       procps
BuildRequires:  screen
Requires:       screen
BuildRequires:  tcpdump
Requires:       tcpdump
BuildRequires:  traceroute
Requires:       traceroute
BuildRequires:  util-linux-systemd
Requires:       util-linux-systemd
BuildRequires:  wget
Recommends:     wget
BuildRequires:  whois
Recommends:     whois
BuildRequires:  unzip
Recommends:     unzip
BuildRequires:  git-core
Recommends:     git-core
BuildRequires:  jq
Recommends:     jq
BuildRequires:  graphviz
Recommends:     graphviz
BuildRequires:  libxml2-tools
#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
FireHOL, an iptables stateful packet filtering firewall for humans!
FireQOS, a TC based bandwidth shaper for humans!

%prep
%setup -q

%build
%configure \
  --libdir=%{_libexecdir} \
  --with-autosave=/etc/sysconfig/firehol \
  --with-autosave6=/etc/sysconfig/firehol6 \
  --docdir=%{_datadir}/doc/packages/%{name}/
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot} %{?_smp_mflags}
install -m 0644 ChangeLog COPYING README THANKS \
  %{buildroot}%{_datadir}/doc/packages/%{name}/

install -d %{buildroot}%{_unitdir}

mv %{buildroot}%{_datadir}/doc/packages/%{name}/contrib/*.service %{buildroot}%{_unitdir}

%if %{with systemd}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcfirehol
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcfireqos
%endif

chmod -Rv o= %{buildroot}%{_sysconfdir}/firehol/

for i in $(find %{buildroot}%{_sysconfdir}/firehol/ -name \*.example) ; do
  cp -v ${i%%.example}{.example,}
done

%pre
# START BIG SYSTEMD
%if %{with systemd}
%if 0%{?suse_version}
%service_add_pre firehol.service
%service_add_pre fireqos.service
%endif

%preun
%if 0%{?suse_version}
%service_del_preun firehol.service
%service_del_preun fireqos.service
%else
%systemd_preun firehol.service
%systemd_preun fireqos.service
%endif

%post
%if 0%{?suse_version}
%service_add_post firehol.service
%service_add_post fireqos.service
%else
%systemd_post firehol.service
%systemd_post fireqos.service
%endif

%postun
%if 0%{?suse_version}
%service_del_postun firehol.service
%service_del_postun fireqos.service
%else
%systemd_postun_with_restart firehol.service
%systemd_postun_with_restart fireqos.service
%endif
%endif
# /END BIG SYSTEMD

%files
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/firehol/
%{_sbindir}/firehol
%{_sbindir}/fireqos
%{_sbindir}/link-balancer
%{_sbindir}/update-ipsets
%{_sbindir}/vnetbuild
%{_libexecdir}/firehol/
%{_datadir}/update-ipsets/
%{_mandir}/man1/firehol.1.*
%{_mandir}/man1/fireqos.1.*
%{_mandir}/man1/vnetbuild.1.*
%{_mandir}/man5/firehol*.5.*
%{_mandir}/man5/fireqos*.5.*
%{_mandir}/man5/vnetbuild*.5.*
#
%doc %{_datadir}/doc/packages/%{name}/
#
%{_sbindir}/rcfirehol
%{_sbindir}/rcfireqos
%{_unitdir}/fire*service
openSUSE Build Service is sponsored by