From 267e19047903fd73fb5e4c103675a3175cfd151c Mon Sep 17 00:00:00 2001 From: Robert Scheck Date: Tue, 31 Jan 2017 20:57:44 +0100 Subject: [PATCH 1/2] Fix python2 build --- ufw.spec | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ufw.spec b/ufw.spec index 97dede6..e266a6f 100644 --- a/ufw.spec +++ b/ufw.spec @@ -1,3 +1,10 @@ +%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} +%if 0%{?fedora} +%global with_python3 1 +%else +%global with_python3 0 +%endif + Name: ufw Version: 0.35 Release: 7%{?dist} @@ -39,7 +46,12 @@ Patch8: ufw-0.35-no-pointless-env.patch BuildArch: noarch +%if %{with_python3} BuildRequires: python3-devel +%else +BuildRequires: python-devel +%endif + BuildRequires: iptables BuildRequires: gettext BuildRequires: systemd @@ -72,10 +84,19 @@ rm -f profiles/*.additional-profiles %patch8 -p1 -b .no-pointless-env %build +%if %{with_python3} %py3_build +%else +%py2_build +%endif %install +%if %{with_python3} %py3_install +%else +%py2_install +%endif + install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ufw.service %find_lang %{name} @@ -93,8 +114,14 @@ install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ufw.service %doc ChangeLog README TODO AUTHORS %{_sbindir}/ufw %{_libexecdir}/ufw/ +%if %{with_python3} %{python3_sitelib}/ufw-%{version}-py*.egg-info %{python3_sitelib}/ufw/ +%else +%{python2_sitelib}/ufw-%{version}-py*.egg-info +%{python2_sitelib}/ufw/ +%endif + %{_datadir}/ufw/ %{_unitdir}/ufw.service # config files under /etc, directly user-editable, should survive updates @@ -120,6 +147,9 @@ install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ufw.service %changelog +* Wed Jan 19 2017 Helge Wiethoff 0.35-8 +- Fix python2 build + * Tue Jan 03 2017 Kevin Kofler 0.35-7 - Bump Release for official build From 24cf3157a591bd8f169311968a085b969bcaac6e Mon Sep 17 00:00:00 2001 From: Robert Scheck Date: Tue, 31 Jan 2017 21:13:40 +0100 Subject: [PATCH 2/2] Adjust packaging to allow building for RHEL 6 and 7 --- ufw.init | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ufw.spec | 69 ++++++++++++++++++++++++++++++++--------- 2 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 ufw.init diff --git a/ufw.init b/ufw.init new file mode 100644 index 0000000..002fa08 --- /dev/null +++ b/ufw.init @@ -0,0 +1,94 @@ +#!/bin/sh +# +# ufw - Uncomplicated firewall +# +# chkconfig: - 08 92 +# description: The Uncomplicated Firewall(ufw) is a front-end for netfilter, which aims to \ +# make it easier for people unfamiliar with firewall concepts. Ufw provides a \ +# framework for managing netfilter as well as manipulating the firewall. + +### BEGIN INIT INFO +# Provides: ufw +# Default-Start: +# Default-Stop: 0 1 6 +# Short-Description: Uncomplicated firewall +# Description: The Uncomplicated Firewall(ufw) is a front-end for netfilter, which aims to +# make it easier for people unfamiliar with firewall concepts. Ufw provides a +# framework for managing netfilter as well as manipulating the firewall. +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +prog="Uncomplicated firewall" +exec="/usr/libexec/ufw/ufw-init" +lockfile="/var/lock/subsys/ufw" + +[ -e /etc/sysconfig/ufw ] && . /etc/sysconfig/ufw + +start() { + [ -x $exec ] || exit 5 + echo -n $"Starting $prog: " + $exec start + RETVAL=$? + [ $RETVAL -eq 0 ] && (touch $lockfile; success) || failure + echo + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + $exec stop + RETVAL=$? + [ $RETVAL -eq 0 ] && (rm -f $lockfile; success) || failure + echo + return $RETVAL +} + +rh_status() { + if [ -f $lockfile ]; then + echo $"${prog} is running..." + return 0 + else + echo $"${prog} is stopped" + return 3 + fi +} + +rh_status_q() { + rh_status > /dev/null 2>&1 +} + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + stop + start + ;; + reload) + exit 3 + ;; + force-reload) + restart + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + stop + start + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac + +exit $? diff --git a/ufw.spec b/ufw.spec index e266a6f..debf88f 100644 --- a/ufw.spec +++ b/ufw.spec @@ -1,13 +1,18 @@ -%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} -%if 0%{?fedora} -%global with_python3 1 +%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8 +%bcond_without python3 %else -%global with_python3 0 +%bcond_with python3 +%endif + +%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 +%bcond_without systemd +%else +%bcond_with systemd %endif Name: ufw Version: 0.35 -Release: 7%{?dist} +Release: 9%{?dist} Summary: Uncomplicated Firewall License: GPLv3 @@ -15,6 +20,8 @@ URL: https://launchpad.net/%{name} Source0: https://launchpad.net/%{name}/%{version}/%{version}/+download/ufw-%{version}.tar.gz # systemd service file Source1: ufw.service +# System V init script file +Source2: ufw.init # Install translations to the systemwide standard location for %%find_lang Patch0: ufw-0.35-trans-dir.patch # Separate libexec_dir from state_dir because the state files must go into /var, @@ -46,21 +53,26 @@ Patch8: ufw-0.35-no-pointless-env.patch BuildArch: noarch -%if %{with_python3} +%if %{with python3} BuildRequires: python3-devel %else -BuildRequires: python-devel +BuildRequires: python2-devel %endif - BuildRequires: iptables BuildRequires: gettext +%if %{with systemd} BuildRequires: systemd - Requires(post): systemd Requires(preun): systemd Requires(postun): systemd - Requires: systemd +%else +BuildRequires: iptables-ipv6 +Requires(post): /sbin/chkconfig +Requires(preun): /sbin/service, /sbin/chkconfig +Requires(postun): /sbin/service +Requires: iptables-ipv6 +%endif Requires: iptables %description @@ -84,46 +96,70 @@ rm -f profiles/*.additional-profiles %patch8 -p1 -b .no-pointless-env %build -%if %{with_python3} +%if %{with python3} %py3_build %else %py2_build %endif %install -%if %{with_python3} +%if %{with python3} %py3_install %else %py2_install %endif - +%if %{with systemd} install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ufw.service +%else +install -D -p -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name} +%endif %find_lang %{name} %post +%if %{with systemd} %systemd_post ufw.service +%else +/sbin/chkconfig --add %{name} +%endif %preun +%if %{with systemd} %systemd_preun ufw.service +%else +if [ $1 -eq 0 ]; then + /sbin/service %{name} stop > /dev/null 2>&1 || : + /sbin/chkconfig --del %{name} +fi +%endif %postun +%if %{with systemd} %systemd_postun_with_restart ufw.service +%else +if [ $1 -ne 0 ]; then + /sbin/service %{name} condrestart > /dev/null 2>&1 || : +fi +%endif %files -f %{name}.lang +%{!?_licensedir:%global license %%doc} %license COPYING %doc ChangeLog README TODO AUTHORS %{_sbindir}/ufw %{_libexecdir}/ufw/ -%if %{with_python3} +%if %{with python3} %{python3_sitelib}/ufw-%{version}-py*.egg-info %{python3_sitelib}/ufw/ %else %{python2_sitelib}/ufw-%{version}-py*.egg-info %{python2_sitelib}/ufw/ %endif - %{_datadir}/ufw/ +%if %{with systemd} %{_unitdir}/ufw.service +%else +%{_sysconfdir}/rc.d/init.d/%{name} +%endif # config files under /etc, directly user-editable, should survive updates %dir %{_sysconfdir}/ufw/ %config(noreplace) %{_sysconfdir}/ufw/after.init @@ -147,6 +183,9 @@ install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/ufw.service %changelog +* Tue Jan 31 2017 Robert Scheck 0.35-9 +- Adjust packaging to allow building for RHEL 6 and 7 + * Wed Jan 19 2017 Helge Wiethoff 0.35-8 - Fix python2 build