Browse Source

Package DNF plugin for both python2 and python3

DNF in Fedora 22 uses python2, but in Fedora 23 - python3. Package both
of them, in separate packages (according to Fedora packaging guidelines)
and depend on the right one depending on target distribution version.

Fixes QubesOS/qubes-issues#1529
Marek Marczykowski-Górecki 8 years ago
parent
commit
2478cb5c05
3 changed files with 53 additions and 10 deletions
  1. 6 6
      Makefile
  2. 16 3
      misc/Makefile
  3. 31 1
      rpm_spec/core-vm.spec

+ 6 - 6
Makefile

@@ -10,6 +10,8 @@ SYSLIBDIR ?= /lib
 
 PYTHON = /usr/bin/python2
 PYTHON_SITEARCH = `python2 -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)'`
+PYTHON2_SITELIB = `python2 -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()'`
+PYTHON3_SITELIB = `python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())'`
 
 # This makefile uses some bash-isms, make uses /bin/sh by default.
 SHELL = /bin/bash
@@ -131,11 +133,9 @@ install-rh: install-systemd install-systemd-dropins install-sysvinit
 		$(DESTDIR)/usr/lib/dracut/dracut.conf.d/30-qubes.conf
 
 	install -D -m 0644 misc/dnf-qubes-hooks.py \
-		$(DESTDIR)/usr/lib/python2.7/site-packages/dnf-plugins/qubes-hooks.py
-	install -D -m 0644 misc/dnf-qubes-hooks.pyc \
-		$(DESTDIR)/usr/lib/python2.7/site-packages/dnf-plugins/qubes-hooks.pyc
-	install -D -m 0644 misc/dnf-qubes-hooks.pyo \
-		$(DESTDIR)/usr/lib/python2.7/site-packages/dnf-plugins/qubes-hooks.pyo
+		$(DESTDIR)$(PYTHON2_SITELIB)/dnf-plugins/qubes-hooks.py
+	install -D -m 0644 misc/dnf-qubes-hooks.py \
+		$(DESTDIR)$(PYTHON3_SITELIB)/dnf-plugins/qubes-hooks.py
 	install -D -m 0644 misc/dnf-qubes-hooks.conf $(DESTDIR)/etc/dnf/plugins/qubes-hooks.conf
 
 
@@ -239,7 +239,7 @@ install-common:
 ifeq ($(shell lsb_release -is), Debian)
 	install -m 0644 misc/xdg.py $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
 else
-	install -m 0644 misc/xdg.py* $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
+	install -m 0644 misc/py2/xdg.py* $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
 endif
 
 	install -d $(DESTDIR)/mnt/removable

+ 16 - 3
misc/Makefile

@@ -11,8 +11,21 @@ xenstore-watch: xenstore-watch.o
 	$(CC) -o xenstore-watch xenstore-watch.o -lxenstore
 close-window: close-window.c
 	$(CC) -o $@ $< -lX11
-python:
-	python -m compileall .
-	python -O -m compileall .
+python: python2 python3
+python2:
+	rm -rf py2
+	mkdir -p py2
+	cp *.py py2/
+	python2 -m compileall py2
+	python2 -O -m compileall py2
+
+# Only some scripts does support python3 for now
+python3:
+	rm -rf py3
+	mkdir -p py3
+	cp dnf-qubes-hooks.py xdg.py py3/
+	python3 -m compileall py3
+	python3 -O -m compileall py3
+
 clean:
 	rm -f xenstore-watch *.o *~ *.pyc *.pyo

+ 31 - 1
rpm_spec/core-vm.spec

@@ -68,6 +68,11 @@ Requires:   pygtk2
 Requires:   zenity
 Requires:   qubes-libvchan
 Requires:   qubes-db-vm
+%if 0%{fedora} >= 23
+Requires:   python3-dnf-plugins-qubes-hooks
+%else
+Requires:   python2-dnf-plugins-qubes-hooks
+%endif
 Obsoletes:  qubes-core-vm-kernel-placeholder <= 1.0
 Obsoletes:  qubes-upgrade-vm < 3.1
 BuildRequires: xen-devel
@@ -75,6 +80,26 @@ BuildRequires: libX11-devel
 BuildRequires: qubes-utils-devel >= 3.1.3
 BuildRequires: qubes-libvchan-%{backend_vmm}-devel
 
+%package -n python2-dnf-plugins-qubes-hooks
+Summary:	DNF plugin for Qubes specific post-installation actions
+BuildRequires: python2-devel
+%{?python_provide:%python_provide python2-dnf-plugins-qubes-hooks}
+
+%description -n python2-dnf-plugins-qubes-hooks
+DNF plugin for Qubes specific post-installation actions:
+ * notify dom0 that updates were installed
+ * refresh applications shortcut list
+
+%package -n python3-dnf-plugins-qubes-hooks
+Summary:	DNF plugin for Qubes specific post-installation actions
+BuildRequires: python3-devel
+%{?python_provide:%python_provide python3-dnf-plugins-qubes-hooks}
+
+%description -n python3-dnf-plugins-qubes-hooks
+DNF plugin for Qubes specific post-installation actions:
+ * notify dom0 that updates were installed
+ * refresh applications shortcut list
+
 %define _builddir %(pwd)
 
 %define kde_service_dir /usr/share/kde4/services
@@ -390,7 +415,6 @@ rm -f %{name}-%{version}
 /usr/lib/qubes/upgrades-installed-check
 /usr/lib/qubes/upgrades-status-notify
 /usr/lib/yum-plugins/yum-qubes-hooks.py*
-/usr/lib/python2.7/site-packages/dnf-plugins/qubes-hooks.py*
 /usr/lib/dracut/dracut.conf.d/30-qubes.conf
 /usr/lib64/python2.7/site-packages/qubes/xdg.py*
 /usr/sbin/qubes-firewall
@@ -409,6 +433,12 @@ rm -f %{name}-%{version}
 %dir /mnt/removable
 %dir /rw
 
+%files -n python2-dnf-plugins-qubes-hooks
+%{python2_sitelib}/dnf-plugins/*
+
+%files -n python3-dnf-plugins-qubes-hooks
+%{python3_sitelib}/dnf-plugins/*
+
 %package sysvinit
 Summary:        Qubes unit files for SysV init style or upstart
 License:        GPL v2 only