File microfw.spec of Package microfw

#
# spec file for package microfw
#
# Copyright (c) 2022 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/
#


%if 0%{?suse_version} >= 1210
%define has_systemd 1
BuildRequires:  systemd
%{?systemd_requires}
%endif
Name:           microfw
Version:        2.0.1
Release:        0
Summary:        Tiny and simple firewall
License:        GPL-2.0+
Group:          Productivity/Security
URL:            https://build.opensuse.org/package/show/security/microfw
Source0:        %{name}-%{version}.tar.gz
Conflicts:      gufw
Conflicts:      shorewall
Conflicts:      ufw
Conflicts:      firewalld
Conflicts:      nfw
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
microfw is a tiny and simple firewall. It basically loads saved iptables/ip6tables rules
from %{_sysconfdir}/sysconfig/network/iptables and %{_sysconfdir}/sysconfig/network/ip6tables

%prep
%setup -q

%build


%install

install -D -m 755 %{name} %{buildroot}/%{_sbindir}/%{name}
%if 0%{?has_systemd}
install -D -m 644 %{name}.service %{buildroot}/%{_unitdir}/%{name}.service
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
%else
install -D -m 755 %{name}.init %{buildroot}%{_sysconfdir}/init.d/%{name}
ln -sf %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%endif
install -D -m 644 iptables.rules %{buildroot}/%{_sysconfdir}/sysconfig/network/iptables
install -D -m 644 ip6tables.rules %{buildroot}/%{_sysconfdir}/sysconfig/network/ip6tables

%if 0%{?suse_version} >= 1500
install -D -m 644 sysconfig/microfw %{buildroot}%{_fillupdir}/%{name}
%else
install -D -m 644 sysconfig/microfw %{buildroot}%{_localstatedir}/adm/fillup-templates/%{name}
%endif

gzip -9 %{name}.8
install -D -m 644 %{name}.8.gz %{buildroot}/%{_mandir}/man8/%{name}.8.gz

%if 0%{?has_systemd}
%pre
%service_add_pre %{name}.service
%endif

%post
%if 0%{?has_systemd}
%fillup_only %{name}
%service_add_post %{name}.service
%else
%fillup_and_insserv %{name}
%endif

%preun
%if 0%{?has_systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif

%postun
%if 0%{?has_systemd}
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif


%files
%defattr(-,root,root)
%{_sbindir}/*
%if 0%{?has_systemd}
%{_unitdir}/%{name}.service
%else
%{_sysconfdir}/init.d/%{name}
%endif
%config(noreplace) %{_sysconfdir}/sysconfig/network/*
%if 0%{?suse_version} >= 1500
%{_fillupdir}/%{name}
%else
%dir %{_localstatedir}/adm/fillup-templates/
%{_localstatedir}/adm/fillup-templates/%{name}
%endif
%{_mandir}/man8/*
%doc README LICENSE AUTHORS ChangeLog

%changelog
openSUSE Build Service is sponsored by