diff --git a/Makefile b/Makefile index 8f41aa2..4943dda 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ SBINDIR=/usr/local/sbin UNITDIR=/etc/systemd/system DESTDIR= PROGNAME=qubes-network-server +PYTHON=/usr/bin/python3 all: src/qubes-routing-manager.service @@ -32,8 +33,10 @@ rpm: dist install-template: all install -Dm 755 src/qubes-routing-manager -t $(DESTDIR)/$(SBINDIR)/ + sed -i "s,^#!.*,#!$(PYTHON)," $(DESTDIR)/$(SBINDIR)/qubes-routing-manager install -Dm 644 src/qubes-routing-manager.service -t $(DESTDIR)/$(UNITDIR)/ +# Python 3 is always used for Qubes admin package. install-dom0: PYTHONDONTWRITEBYTECODE=1 python3 setup.py install $(PYTHON_PREFIX_ARG) -O0 --root $(DESTDIR) diff --git a/qubes-network-server.spec b/qubes-network-server.spec index 6a44fa2..9549e6e 100644 --- a/qubes-network-server.spec +++ b/qubes-network-server.spec @@ -15,44 +15,70 @@ Source0: https://github.com/Rudd-O/%{name}/archive/{%version}.tar.gz#/%{n BuildRequires: make BuildRequires: coreutils BuildRequires: tar -BuildRequires: gawk BuildRequires: findutils -BuildRequires: systemd +%if 1%{?fc30} == 11 +BuildRequires: python2 +BuildRequires: python2-rpm-macros +%global pythoninterp %{_bindir}/python2 +%else +BuildRequires: python3 +BuildRequires: python3-rpm-macros +%global pythoninterp %{_bindir}/python3 +%endif + +%if 1%{?fc25} == 1 BuildRequires: systemd-rpm-macros +%else +%global _presetdir %{_prefix}/lib/systemd/system-preset +%global _unitdir %{_prefix}/lib/systemd/system +%endif Requires: qubes-core-agent-networking >= 4.0.51-1 -Requires: qubes-core-agent-networking < 4.1 -Requires: python3 -Requires: python3-qubesdb +Conflicts: qubes-core-agent-networking >= 4.1 +Requires: python2 +Requires: python2-qubesdb %description This package lets you turn your Qubes OS into a network server. Install this -in the TemplateVM of your NetVM. Then install the companion %{name}-dom0 package -in your dom0. +in the TemplateVM of your NetVM. Then install the companion +qubes-core-admin-addon-network-server package in your dom0. -Please see README.md enclosed in the package for instructions on how to use this. +Please see README.md enclosed in the package for instructions on how to use +this software. %package -n qubes-core-admin-addon-network-server Summary: dom0 administrative extension for Qubes network server +BuildRequires: make +BuildRequires: coreutils +BuildRequires: tar +BuildRequires: findutils +BuildRequires: python3 +BuildRequires: python3-rpm-macros + +Requires: python3 Requires: qubes-core-dom0 >= 4.0.49-1 +Conflicts: qubes-core-dom0 >= 4.1 %description -n qubes-core-admin-addon-network-server This package lets you turn your Qubes OS into a network server. Install this in your dom0. Then install the companion qubes-network-server package in the TemplateVM of your NetVM. +Please see README.md enclosed in the package for instructions on how to use +this software. + %prep %setup -q %build # variables must be kept in sync with install -make DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir} UNITDIR=%{_unitdir} +make DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir} UNITDIR=%{_unitdir} PYTHON=%{pythoninterp} %install rm -rf $RPM_BUILD_ROOT # variables must be kept in sync with build -make install DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir} UNITDIR=%{_unitdir} +make install DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir} UNITDIR=%{_unitdir} PYTHON=%{pythoninterp} mkdir -p "$RPM_BUILD_ROOT"/%{_presetdir} echo 'enable qubes-routing-manager.service' > "$RPM_BUILD_ROOT"/%{_presetdir}/75-%{name}.preset @@ -76,10 +102,18 @@ echo 'enable qubes-routing-manager.service' > "$RPM_BUILD_ROOT"/%{_presetdir}/75 %systemd_postun_with_restart qubes-routing-manager.service %post -n qubes-core-admin-addon-network-server +%if 1%{?fc25} == 11 +systemctl try-restart qubesd.service +%else %systemd_post qubesd.service +%endif %postun -n qubes-core-admin-addon-network-server +%if 1%{?fc25} == 11 +systemctl try-restart qubesd.service +%else %systemd_postun_with_restart qubesd.service +%endif %changelog * Mon Apr 13 2020 Manuel Amador (Rudd-O) diff --git a/src/qubes-routing-manager b/src/qubes-routing-manager index 26e0701..e850eb0 100755 --- a/src/qubes-routing-manager +++ b/src/qubes-routing-manager @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python2 ''' This program reads the /qubes-firewall/{ip}/qubes-routing-method file @@ -42,7 +42,7 @@ class AdjunctWorker(object): def run_ipt(*args): return subprocess.check_call([cmd, '-w'] + list(args)) - out = subprocess.check_output([cmd + '-save', '-w'], universal_newlines=True).splitlines() + out = subprocess.check_output([cmd + '-save'], universal_newlines=True).splitlines() if enable: # Create necessary prerouting chain.