Account for the horrible mishmash of Python stuff.

This commit is contained in:
Manuel Amador (Rudd-O) 2020-04-14 04:40:12 +00:00
parent 710b18a1ed
commit 45c19fb1f7
3 changed files with 49 additions and 12 deletions

View File

@ -2,6 +2,7 @@ SBINDIR=/usr/local/sbin
UNITDIR=/etc/systemd/system UNITDIR=/etc/systemd/system
DESTDIR= DESTDIR=
PROGNAME=qubes-network-server PROGNAME=qubes-network-server
PYTHON=/usr/bin/python3
all: src/qubes-routing-manager.service all: src/qubes-routing-manager.service
@ -32,8 +33,10 @@ rpm: dist
install-template: all install-template: all
install -Dm 755 src/qubes-routing-manager -t $(DESTDIR)/$(SBINDIR)/ 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)/ install -Dm 644 src/qubes-routing-manager.service -t $(DESTDIR)/$(UNITDIR)/
# Python 3 is always used for Qubes admin package.
install-dom0: install-dom0:
PYTHONDONTWRITEBYTECODE=1 python3 setup.py install $(PYTHON_PREFIX_ARG) -O0 --root $(DESTDIR) PYTHONDONTWRITEBYTECODE=1 python3 setup.py install $(PYTHON_PREFIX_ARG) -O0 --root $(DESTDIR)

View File

@ -15,44 +15,70 @@ Source0: https://github.com/Rudd-O/%{name}/archive/{%version}.tar.gz#/%{n
BuildRequires: make BuildRequires: make
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: tar BuildRequires: tar
BuildRequires: gawk
BuildRequires: findutils 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 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.0.51-1
Requires: qubes-core-agent-networking < 4.1 Conflicts: qubes-core-agent-networking >= 4.1
Requires: python3 Requires: python2
Requires: python3-qubesdb Requires: python2-qubesdb
%description %description
This package lets you turn your Qubes OS into a network server. Install this 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 the TemplateVM of your NetVM. Then install the companion
in your dom0. 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 %package -n qubes-core-admin-addon-network-server
Summary: dom0 administrative extension for Qubes 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 Requires: qubes-core-dom0 >= 4.0.49-1
Conflicts: qubes-core-dom0 >= 4.1
%description -n qubes-core-admin-addon-network-server %description -n qubes-core-admin-addon-network-server
This package lets you turn your Qubes OS into a network server. Install this 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 in your dom0. Then install the companion qubes-network-server package in the
TemplateVM of your NetVM. TemplateVM of your NetVM.
Please see README.md enclosed in the package for instructions on how to use
this software.
%prep %prep
%setup -q %setup -q
%build %build
# variables must be kept in sync with install # 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 %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
# variables must be kept in sync with build # 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} mkdir -p "$RPM_BUILD_ROOT"/%{_presetdir}
echo 'enable qubes-routing-manager.service' > "$RPM_BUILD_ROOT"/%{_presetdir}/75-%{name}.preset 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 %systemd_postun_with_restart qubes-routing-manager.service
%post -n qubes-core-admin-addon-network-server %post -n qubes-core-admin-addon-network-server
%if 1%{?fc25} == 11
systemctl try-restart qubesd.service
%else
%systemd_post qubesd.service %systemd_post qubesd.service
%endif
%postun -n qubes-core-admin-addon-network-server %postun -n qubes-core-admin-addon-network-server
%if 1%{?fc25} == 11
systemctl try-restart qubesd.service
%else
%systemd_postun_with_restart qubesd.service %systemd_postun_with_restart qubesd.service
%endif
%changelog %changelog
* Mon Apr 13 2020 Manuel Amador (Rudd-O) <rudd-o@rudd-o.com> * Mon Apr 13 2020 Manuel Amador (Rudd-O) <rudd-o@rudd-o.com>

View File

@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/python2
''' '''
This program reads the /qubes-firewall/{ip}/qubes-routing-method file This program reads the /qubes-firewall/{ip}/qubes-routing-method file
@ -42,7 +42,7 @@ class AdjunctWorker(object):
def run_ipt(*args): def run_ipt(*args):
return subprocess.check_call([cmd, '-w'] + list(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: if enable:
# Create necessary prerouting chain. # Create necessary prerouting chain.