From 712b5af825450dcace01ad5979518461b6a3b924 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 1/14] refactor the py2/py3 macro flags --- diff --git a/koji.spec b/koji.spec index 4d6868a..99d81cb 100644 --- a/koji.spec +++ b/koji.spec @@ -1,17 +1,47 @@ -# Enable Python 3 builds for Fedora/RHEL8 -%if 0%{?fedora} || 0%{?rhel} >= 8 %bcond_without python3 -# If the definition isn't available for python3_pkgversion, define it -%{?!python3_pkgversion:%global python3_pkgversion 3} +%bcond_without python2 + +# We can build varying amounts of Koji for python2 and python3 based on +# the py[23]_support macro values. Valid values are: +# undefined or 0 -- do not build +# 1 -- build just the cli and lib +# 2 -- build everything we can +# For executable scripts, py3 wins if we build it +# The following rules tweak these settings based on options and environment + +# Default to building both fully +%define py2_support 2 +%define py3_support 2 + +# No python3 for older rhel +%if 0%{?rhel} < 8 +%define py3_support 0 %else -%bcond_with python3 +# and no python2 on rhel8+ +%define py2_support 0 %endif -# don't build py2 packages for py3-only systems -%if 0%{with python3} && (0%{?fedora} > 32 || 0%{?rhel} > 7) - %define with_python2 0 +%if 0%{?fedora} < 30 +# match what these Fedoras already have +%define py2_support 2 +%define py3_support 1 %else - %define with_python2 1 +%if 0%{?fedora} < 33 +%define py2_support 1 +%define py3_support 2 +%else +# no py2 after F33 +%define py2_support 0 +%define py3_support 2 +%endif +%endif + +# Lastly enforce the bcond parameters +%if %{without python2} +%define py2_support 0 +%endif +%if %{without python3} +%define py3_support 0 %endif # Compatibility with RHEL. These macros have been added to EPEL but @@ -23,6 +53,9 @@ %{!?py2_build: %global py2_build %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} build --executable="%{__python2} -s"}} %{!?py2_install: %global py2_install %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} install -O1 --skip-build --root %{buildroot}}} +# If the definition isn't available for python3_pkgversion, define it +%{?!python3_pkgversion:%global python3_pkgversion 3} + %if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 %global use_systemd 1 %else @@ -48,7 +81,7 @@ URL: https://pagure.io/koji Source: https://releases.pagure.org/koji/koji-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch -%if 0%{with python3} +%if 0%{py3_support} Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} Requires: python%{python3_pkgversion}-libcomps %else @@ -66,7 +99,7 @@ BuildRequires: pkgconfig Koji is a system for building and tracking RPMS. The base package contains shared libraries and the command-line interface. -%if 0%{with_python2} +%if 0%{py2_support} %package -n python2-%{name} Summary: Build system tools python library %{?python_provide:%python_provide python2-%{name}} @@ -90,7 +123,7 @@ Requires: python-six desc %endif -%if 0%{with python3} +%if 0%{py3_support} %package -n python%{python3_pkgversion}-%{name} Summary: Build system tools python library %{?python_provide:%python_provide python%{python3_pkgversion}-%{name}} @@ -110,7 +143,7 @@ Requires: python%{python3_pkgversion}-six desc %endif -%if 0%{with_python2} +%if 0%{py2_support} %package -n python2-%{name}-cli-plugins Summary: Koji client plugins Group: Applications/Internet @@ -121,7 +154,7 @@ Requires: %{name} = %{version}-%{release} Plugins to the koji command-line interface %endif -%if 0%{with python3} +%if 0%{py3_support} %package -n python%{python3_pkgversion}-%{name}-cli-plugins Summary: Koji client plugins Group: Applications/Internet @@ -146,6 +179,7 @@ Suggests: python%{python3_pkgversion}-%{name}-hub-plugins %description hub koji-hub is the XMLRPC interface to the koji database +%if 0%{py2_support} > 1 %package -n python2-%{name}-hub Summary: Koji XMLRPC interface Group: Applications/Internet @@ -165,8 +199,9 @@ Provides: %{name}-hub-code = %{version}-%{release} %description -n python2-%{name}-hub koji-hub is the XMLRPC interface to the koji database +%endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %package -n python%{python3_pkgversion}-%{name}-hub Summary: Koji XMLRPC interface Group: Applications/Internet @@ -200,6 +235,7 @@ Suggests: python%{python3_pkgversion}-%{name}-hub-plugins %description hub-plugins Plugins to the koji XMLRPC interface +%if 0%{py2_support} > 1 %package -n python2-%{name}-hub-plugins Summary: Koji hub plugins Group: Applications/Internet @@ -214,8 +250,9 @@ Provides: %{name}-hub-plugins-code %description -n python2-%{name}-hub-plugins Plugins to the koji XMLRPC interface +%endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %package -n python%{python3_pkgversion}-%{name}-hub-plugins Summary: Koji hub plugins Group: Applications/Internet @@ -264,7 +301,7 @@ Requires: /usr/bin/cvs Requires: /usr/bin/svn Requires: /usr/bin/git Requires: createrepo >= 0.9.2 -%if 0%{with python3} +%if 0%{py3_support} > 1 Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} Requires: python%{python3_pkgversion}-multilib Requires: python%{python3_pkgversion}-cheetah @@ -320,7 +357,7 @@ Requires(postun): systemd %description utils Utilities for the Koji system -%if 0%{with_python2} +%if 0%{py2_support} > 1 %package -n python2-%{name}-web Summary: Koji Web UI Group: Applications/Internet @@ -344,7 +381,7 @@ Obsoletes: koji-web < 1.16.2 koji-web is a web UI to the Koji system. %endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %package -n python%{python3_pkgversion}-%{name}-web Summary: Koji Web UI Group: Applications/Internet @@ -370,11 +407,28 @@ koji-web is a web UI to the Koji system. %install rm -rf $RPM_BUILD_ROOT -%if 0%{with_python2} + +%if 0%{py2_support} < 2 && 0%{py3_support} < 2 +echo "At least one python must be built with full support" +exit 1 +%endif + +# python2 build +%if 0%{py2_support} > 1 make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install +%else +%if 0%{py2_support} +for d in koji cli plugins ; do + pushd $d + make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install + popd +done %endif -%if 0%{with python3} -for d in koji cli plugins hub www ; do +%endif + +# python3 build +%if 0%{py3_support} > 1 +for d in koji cli plugins hub www builder ; do pushd $d make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install popd @@ -382,6 +436,19 @@ done # alter python interpreter in koji CLI sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/bin/koji sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/sbin/kojid +%else +%if 0%{py3_support} +# minimal +for d in koji cli plugins ; do + pushd $d + make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install + popd +done +# alter python interpreter in koji CLI +sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/bin/koji +# remove the hub plugins pycache +rm -rf $RPM_BUILD_ROOT/usr/lib/koji-hub-plugins/__pycache__ +%endif %endif %clean @@ -394,20 +461,20 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/koji.conf.d %doc docs Authors COPYING LGPL -%if 0%{with_python2} +%if 0%{py2_support} %files -n python2-%{name} %defattr(-,root,root) %{python2_sitelib}/%{name} %{python2_sitelib}/koji_cli %endif -%if 0%{with python3} +%if 0%{py3_support} %files -n python%{python3_pkgversion}-koji %{python3_sitelib}/%{name} %{python3_sitelib}/koji_cli %endif -%if 0%{with_python2} +%if 0%{py2_support} %files -n python2-%{name}-cli-plugins %defattr(-,root,root) %{python2_sitelib}/koji_cli_plugins @@ -416,7 +483,7 @@ rm -rf $RPM_BUILD_ROOT #%%config(noreplace) %%{_sysconfdir}/koji/plugins/*.conf %endif -%if 0%{with python3} +%if 0%{py3_support} %files -n python%{python3_pkgversion}-%{name}-cli-plugins %defattr(-,root,root) %{python3_sitelib}/koji_cli_plugins @@ -432,13 +499,13 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) /etc/koji-hub/hub.conf %dir /etc/koji-hub/hub.conf.d -%if 0%{with_python2} +%if 0%{py2_support} > 1 %files -n python2-%{name}-hub %defattr(-,root,root) %{_datadir}/koji-hub/*.py* %endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %files -n python%{python3_pkgversion}-%{name}-hub %defattr(-,root,root) %{_datadir}/koji-hub/*.py @@ -449,20 +516,20 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/koji-hub/plugins %config(noreplace) /etc/koji-hub/plugins/*.conf -%if 0%{with_python2} +%if 0%{py2_support} > 1 %files -n python2-%{name}-hub-plugins %defattr(-,root,root) %{_prefix}/lib/koji-hub-plugins/*.py* %endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %files -n python%{python3_pkgversion}-%{name}-hub-plugins %defattr(-,root,root) %{_prefix}/lib/koji-hub-plugins/*.py %{_prefix}/lib/koji-hub-plugins/__pycache__ %endif -%if 0%{with_python2} +%if 0%{py2_support} > 1 %files builder-plugins %defattr(-,root,root) %dir /etc/kojid/plugins @@ -471,7 +538,7 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/lib/koji-builder-plugins/*.py* %endif -%if 0%{with_python2} +%if 0%{py2_support} %files utils %defattr(-,root,root) %{_sbindir}/kojira @@ -491,7 +558,7 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) /etc/koji-shadow/koji-shadow.conf %endif -%if 0%{with_python2} +%if 0%{py2_support} > 1 %files -n python2-%{name}-web %defattr(-,root,root) %{_datadir}/koji-web @@ -501,7 +568,7 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/kojiweb/web.conf.d %endif -%if 0%{with python3} +%if 0%{py3_support} > 1 %files -n python%{python3_pkgversion}-%{name}-web %defattr(-,root,root) %{_datadir}/koji-web @@ -511,7 +578,6 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/kojiweb/web.conf.d %endif -%if 0%{with_python2} %files builder %defattr(-,root,root) %{_sbindir}/kojid @@ -552,9 +618,8 @@ if [ $1 = 0 ]; then /sbin/chkconfig --del kojid fi %endif -%endif -%if 0%{with_python2} +%if 0%{py2_support} > 1 %files vm %defattr(-,root,root) %{_sbindir}/kojivmd From f24835bc76d8b7441d3c758e3f007594db983f40 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 2/14] reverse distro check order and correctly handle null case --- diff --git a/koji.spec b/koji.spec index 99d81cb..b98d9e3 100644 --- a/koji.spec +++ b/koji.spec @@ -13,26 +13,30 @@ %define py2_support 2 %define py3_support 2 -# No python3 for older rhel -%if 0%{?rhel} < 8 -%define py3_support 0 -%else +%if 0%{?rhel} >= 8 # and no python2 on rhel8+ %define py2_support 0 +%else +%if 0%{?rhel} +# No python3 for older rhel +%define py3_support 0 +%endif %endif -%if 0%{?fedora} < 30 -# match what these Fedoras already have -%define py2_support 2 -%define py3_support 1 +%if 0%{?fedora} >= 33 +# no py2 after F33 +%define py2_support 0 +%define py3_support 2 %else -%if 0%{?fedora} < 33 +%if 0%{?fedora} >= 30 %define py2_support 1 %define py3_support 2 %else -# no py2 after F33 -%define py2_support 0 -%define py3_support 2 +%if 0%{?fedora} +# match what the older Fedoras already have +%define py2_support 2 +%define py3_support 1 +%endif %endif %endif From fb29b5f580ebcbae06377923e539182dee93a848 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 3/14] no koji-utils for py3 yet --- diff --git a/koji.spec b/koji.spec index b98d9e3..4faf5fe 100644 --- a/koji.spec +++ b/koji.spec @@ -344,6 +344,8 @@ Requires: qemu-img koji-vm contains a supplemental build daemon that executes certain tasks in a virtual machine. This package is not required for most installations. +%if 0%{py2_support} > 1 +# for now the utils subpackage is py2 only %package utils Summary: Koji Utilities Group: Applications/Internet @@ -360,6 +362,7 @@ Requires(postun): systemd %description utils Utilities for the Koji system +%endif %if 0%{py2_support} > 1 %package -n python2-%{name}-web @@ -542,7 +545,7 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/lib/koji-builder-plugins/*.py* %endif -%if 0%{py2_support} +%if 0%{py2_support} > 1 %files utils %defattr(-,root,root) %{_sbindir}/kojira From 56f9d38e3e52a05dd67676863da1510e89737aef Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 4/14] builder-plugins not py2 only anymore --- diff --git a/koji.spec b/koji.spec index 4faf5fe..6dacf17 100644 --- a/koji.spec +++ b/koji.spec @@ -536,14 +536,12 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/lib/koji-hub-plugins/__pycache__ %endif -%if 0%{py2_support} > 1 %files builder-plugins %defattr(-,root,root) %dir /etc/kojid/plugins %config(noreplace) /etc/kojid/plugins/*.conf %dir %{_prefix}/lib/koji-builder-plugins %{_prefix}/lib/koji-builder-plugins/*.py* -%endif %if 0%{py2_support} > 1 %files utils From 6e57936e95d4490fa4d2ae4e97251565e9df98a8 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 5/14] stop blocking py3 builder plugins in Makefile --- diff --git a/plugins/Makefile b/plugins/Makefile index 0d97881..3d352b3 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -34,13 +34,11 @@ install: $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(HUBPLUGINDIR)', 1, '$(HUBPLUGINDIR)', 1)"; \ mkdir -p $(DESTDIR)/$(HUBCONFDIR); \ install -p -m 644 $(HUBCONFFILES) $(DESTDIR)/$(HUBCONFDIR); \ - if [ "$(PYMAJORVER)" == "2" ] ; then \ - mkdir -p $(DESTDIR)/$(BUILDERPLUGINDIR); \ - install -p -m 644 $(BUILDERFILES) $(DESTDIR)/$(BUILDERPLUGINDIR); \ - $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(BUILDERPLUGINDIR)', 1, '$(BUILDERPLUGINDIR)', 1)"; \ - mkdir -p $(DESTDIR)/$(BUILDERCONFDIR); \ - install -p -m 644 $(BUILDERCONFFILES) $(DESTDIR)/$(BUILDERCONFDIR); \ - fi + mkdir -p $(DESTDIR)/$(BUILDERPLUGINDIR); \ + install -p -m 644 $(BUILDERFILES) $(DESTDIR)/$(BUILDERPLUGINDIR); \ + $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(BUILDERPLUGINDIR)', 1, '$(BUILDERPLUGINDIR)', 1)"; \ + mkdir -p $(DESTDIR)/$(BUILDERCONFDIR); \ + install -p -m 644 $(BUILDERCONFFILES) $(DESTDIR)/$(BUILDERCONFDIR); \ mkdir -p $(DESTDIR)/$(CLIPLUGINDIR) install -p -m 644 $(CLIFILES) $(DESTDIR)/$(CLIPLUGINDIR) From 3703c24495f154748eb94b53acd80a1c1bb90d75 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 6/14] add KOJI_MINIMAL flag to plugins Makefile --- diff --git a/koji.spec b/koji.spec index 6dacf17..491fccf 100644 --- a/koji.spec +++ b/koji.spec @@ -427,7 +427,7 @@ make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install %if 0%{py2_support} for d in koji cli plugins ; do pushd $d - make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install + make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python2} %{?install_opt} install popd done %endif @@ -448,7 +448,7 @@ sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/ # minimal for d in koji cli plugins ; do pushd $d - make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install + make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python3} %{?install_opt} install popd done # alter python interpreter in koji CLI diff --git a/plugins/Makefile b/plugins/Makefile index 3d352b3..98128e5 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -29,6 +29,7 @@ install: echo "ERROR: A destdir is required"; \ exit 1; \ fi + ifndef KOJI_MINIMAL mkdir -p $(DESTDIR)/$(HUBPLUGINDIR); \ install -p -m 644 $(HUBFILES) $(DESTDIR)/$(HUBPLUGINDIR); \ $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(HUBPLUGINDIR)', 1, '$(HUBPLUGINDIR)', 1)"; \ @@ -40,6 +41,7 @@ install: mkdir -p $(DESTDIR)/$(BUILDERCONFDIR); \ install -p -m 644 $(BUILDERCONFFILES) $(DESTDIR)/$(BUILDERCONFDIR); \ + endif mkdir -p $(DESTDIR)/$(CLIPLUGINDIR) install -p -m 644 $(CLIFILES) $(DESTDIR)/$(CLIPLUGINDIR) $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(CLIPLUGINDIR)', 1, '$(CLIPLUGINDIR)', 1)" From b976e222fc9ada597fe7dedd2e6cc47477e65d4b Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 7/14] force python3 if that's all we're building --- diff --git a/koji.spec b/koji.spec index 491fccf..2b33912 100644 --- a/koji.spec +++ b/koji.spec @@ -48,6 +48,11 @@ %define py3_support 0 %endif +%if ! %{py2_support} +# use python3 +%define __python %{__python3} +%endif + # Compatibility with RHEL. These macros have been added to EPEL but # not yet to RHEL proper. # https://bugzilla.redhat.com/show_bug.cgi?id=1307190 From f869f08042e342db4f5bd639301f7f9343d84dfc Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 8/14] builder-plugins can include pycache now --- diff --git a/koji.spec b/koji.spec index 2b33912..eea22e9 100644 --- a/koji.spec +++ b/koji.spec @@ -547,6 +547,9 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) /etc/kojid/plugins/*.conf %dir %{_prefix}/lib/koji-builder-plugins %{_prefix}/lib/koji-builder-plugins/*.py* +%if 0%{py3_support} > 1 +%{_prefix}/lib/koji-builder-plugins/__pycache__ +%endif %if 0%{py2_support} > 1 %files utils From 1b8763b449f4236ffbb975a44907c74cb88970db Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 9/14] more readable sed expression --- diff --git a/koji.spec b/koji.spec index eea22e9..1433aca 100644 --- a/koji.spec +++ b/koji.spec @@ -446,8 +446,8 @@ for d in koji cli plugins hub www builder ; do popd done # alter python interpreter in koji CLI -sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/bin/koji -sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/sbin/kojid +sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/koji +sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/sbin/kojid %else %if 0%{py3_support} # minimal @@ -457,7 +457,7 @@ for d in koji cli plugins ; do popd done # alter python interpreter in koji CLI -sed -i 's/\#\!\/usr\/bin\/python2/\#\!\/usr\/bin\/python3/' $RPM_BUILD_ROOT/usr/bin/koji +sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/koji # remove the hub plugins pycache rm -rf $RPM_BUILD_ROOT/usr/lib/koji-hub-plugins/__pycache__ %endif From e0207c6ce8a0033294099eb90d5d74dbc386273a Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 10/14] vm and utils subpackages for py3 too --- diff --git a/koji.spec b/koji.spec index 1433aca..91b0d06 100644 --- a/koji.spec +++ b/koji.spec @@ -349,8 +349,6 @@ Requires: qemu-img koji-vm contains a supplemental build daemon that executes certain tasks in a virtual machine. This package is not required for most installations. -%if 0%{py2_support} > 1 -# for now the utils subpackage is py2 only %package utils Summary: Koji Utilities Group: Applications/Internet @@ -367,7 +365,6 @@ Requires(postun): systemd %description utils Utilities for the Koji system -%endif %if 0%{py2_support} > 1 %package -n python2-%{name}-web @@ -440,14 +437,13 @@ done # python3 build %if 0%{py3_support} > 1 -for d in koji cli plugins hub www builder ; do - pushd $d - make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install - popd -done +make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install # alter python interpreter in koji CLI -sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/koji -sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/sbin/kojid +scripts='/usr/bin/koji /usr/sbin/kojid /usr/sbin/kojira /usr/sbin/koji-shadow + /usr/sbin/koji-gc /usr/sbin/kojivmd' +for fn in $scripts ; do + sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT$fn +done %else %if 0%{py3_support} # minimal @@ -551,7 +547,6 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/lib/koji-builder-plugins/__pycache__ %endif -%if 0%{py2_support} > 1 %files utils %defattr(-,root,root) %{_sbindir}/kojira @@ -569,7 +564,6 @@ rm -rf $RPM_BUILD_ROOT %{_sbindir}/koji-shadow %dir /etc/koji-shadow %config(noreplace) /etc/koji-shadow/koji-shadow.conf -%endif %if 0%{py2_support} > 1 %files -n python2-%{name}-web @@ -632,7 +626,6 @@ if [ $1 = 0 ]; then fi %endif -%if 0%{py2_support} > 1 %files vm %defattr(-,root,root) %{_sbindir}/kojivmd @@ -668,7 +661,6 @@ if [ $1 = 0 ]; then /sbin/service kojivmd stop &> /dev/null /sbin/chkconfig --del kojivmd fi -%endif %if %{use_systemd} From fd9ab03df1880f3a58ee091ee8693f092677258b Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 11/14] remove qpid requires --- diff --git a/koji.spec b/koji.spec index 91b0d06..30d2134 100644 --- a/koji.spec +++ b/koji.spec @@ -250,10 +250,7 @@ Summary: Koji hub plugins Group: Applications/Internet License: LGPLv2 Requires: python2-%{name}-hub = %{version}-%{release} -Requires: python-qpid >= 0.7 -%if 0%{?fedora} >= 27 || 0%{?rhel} >= 6 -Requires: python-qpid-proton -%endif +Requires: python2-qpid-proton Requires: cpio Provides: %{name}-hub-plugins-code @@ -267,10 +264,7 @@ Summary: Koji hub plugins Group: Applications/Internet License: LGPLv2 Requires: python%{python3_pkgversion}-%{name}-hub = %{version}-%{release} -Requires: python-qpid >= 0.7 -%if 0%{?fedora} >= 27 || 0%{?rhel} >= 6 Requires: python%{python3_pkgversion}-qpid-proton -%endif Requires: cpio Provides: %{name}-hub-plugins-code From f6125e2a0377784e377fe7e8eead76d6ecd4fe02 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 12/14] handle byte-compiling for fedora --- diff --git a/koji.spec b/koji.spec index 30d2134..6edb240 100644 --- a/koji.spec +++ b/koji.spec @@ -1,5 +1,6 @@ %bcond_without python3 %bcond_without python2 +%global _python_bytecompile_extra 0 # We can build varying amounts of Koji for python2 and python3 based on # the py[23]_support macro values. Valid values are: @@ -157,7 +158,7 @@ desc Summary: Koji client plugins Group: Applications/Internet License: LGPLv2 -Requires: %{name} = %{version}-%{release} +Requires: python2-%{name} = %{version}-%{release} %description -n python2-%{name}-cli-plugins Plugins to the koji command-line interface @@ -168,7 +169,7 @@ Plugins to the koji command-line interface Summary: Koji client plugins Group: Applications/Internet License: LGPLv2 -Requires: %{name} = %{version}-%{release} +Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} %description -n python%{python3_pkgversion}-%{name}-cli-plugins Plugins to the koji command-line interface @@ -200,8 +201,6 @@ Requires: mod_wsgi Requires: mod_auth_gssapi %endif Requires: python-psycopg2 -Requires: %{name} = %{version}-%{release} -# we need the python2 lib here Requires: python2-%{name} = %{version}-%{release} # py2 xor py3 Provides: %{name}-hub-code = %{version}-%{release} @@ -222,8 +221,6 @@ Requires: mod_wsgi Requires: mod_auth_gssapi %endif Requires: python-psycopg2 -Requires: %{name} = %{version}-%{release} -# we need the python2 lib here Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} # py2 xor py3 Provides: %{name}-hub-code = %{version}-%{release} @@ -236,7 +233,7 @@ koji-hub is the XMLRPC interface to the koji database Summary: Koji hub plugins Group: Applications/Internet License: LGPLv2 -Requires: %{name}-hub-plugins-code +Requires: %{name}-hub-plugins-code = %{version}-%{release} %if 0%{?fedora} || 0%{?rhel} > 7 Suggests: python%{python3_pkgversion}-%{name}-hub-plugins %endif @@ -252,7 +249,7 @@ License: LGPLv2 Requires: python2-%{name}-hub = %{version}-%{release} Requires: python2-qpid-proton Requires: cpio -Provides: %{name}-hub-plugins-code +Provides: %{name}-hub-plugins-code = %{version}-%{release} %description -n python2-%{name}-hub-plugins Plugins to the koji XMLRPC interface @@ -266,7 +263,7 @@ License: LGPLv2 Requires: python%{python3_pkgversion}-%{name}-hub = %{version}-%{release} Requires: python%{python3_pkgversion}-qpid-proton Requires: cpio -Provides: %{name}-hub-plugins-code +Provides: %{name}-hub-plugins-code = %{version}-%{release} %description -n python%{python3_pkgversion}-%{name}-hub-plugins Plugins to the koji XMLRPC interface @@ -348,8 +345,6 @@ Summary: Koji Utilities Group: Applications/Internet License: LGPLv2 Requires: python-psycopg2 -Requires: %{name} = %{version}-%{release} -# we need the python2 lib here Requires: python2-%{name} = %{version}-%{release} %if %{use_systemd} Requires(post): systemd @@ -429,6 +424,7 @@ done %endif %endif + # python3 build %if 0%{py3_support} > 1 make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install @@ -448,8 +444,6 @@ for d in koji cli plugins ; do done # alter python interpreter in koji CLI sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/koji -# remove the hub plugins pycache -rm -rf $RPM_BUILD_ROOT/usr/lib/koji-hub-plugins/__pycache__ %endif %endif diff --git a/plugins/Makefile b/plugins/Makefile index 98128e5..500d944 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -29,23 +29,24 @@ install: echo "ERROR: A destdir is required"; \ exit 1; \ fi - ifndef KOJI_MINIMAL - mkdir -p $(DESTDIR)/$(HUBPLUGINDIR); \ - install -p -m 644 $(HUBFILES) $(DESTDIR)/$(HUBPLUGINDIR); \ - $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(HUBPLUGINDIR)', 1, '$(HUBPLUGINDIR)', 1)"; \ - mkdir -p $(DESTDIR)/$(HUBCONFDIR); \ - install -p -m 644 $(HUBCONFFILES) $(DESTDIR)/$(HUBCONFDIR); \ - mkdir -p $(DESTDIR)/$(BUILDERPLUGINDIR); \ - install -p -m 644 $(BUILDERFILES) $(DESTDIR)/$(BUILDERPLUGINDIR); \ - $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(BUILDERPLUGINDIR)', 1, '$(BUILDERPLUGINDIR)', 1)"; \ - mkdir -p $(DESTDIR)/$(BUILDERCONFDIR); \ - install -p -m 644 $(BUILDERCONFFILES) $(DESTDIR)/$(BUILDERCONFDIR); \ + ifndef KOJI_MINIMAL + mkdir -p $(DESTDIR)/$(HUBPLUGINDIR); + install -p -m 644 $(HUBFILES) $(DESTDIR)/$(HUBPLUGINDIR); + $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(HUBPLUGINDIR)', 1, '$(HUBPLUGINDIR)', 1)"; + mkdir -p $(DESTDIR)/$(HUBCONFDIR); + install -p -m 644 $(HUBCONFFILES) $(DESTDIR)/$(HUBCONFDIR); + mkdir -p $(DESTDIR)/$(BUILDERPLUGINDIR); + install -p -m 644 $(BUILDERFILES) $(DESTDIR)/$(BUILDERPLUGINDIR); + $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(BUILDERPLUGINDIR)', 1, '$(BUILDERPLUGINDIR)', 1)"; + mkdir -p $(DESTDIR)/$(BUILDERCONFDIR); + install -p -m 644 $(BUILDERCONFFILES) $(DESTDIR)/$(BUILDERCONFDIR); endif + mkdir -p $(DESTDIR)/$(CLIPLUGINDIR) install -p -m 644 $(CLIFILES) $(DESTDIR)/$(CLIPLUGINDIR) $(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(CLIPLUGINDIR)', 1, '$(CLIPLUGINDIR)', 1)" mkdir -p $(DESTDIR)/$(CLICONFDIR) ifneq "$(CLICONFFILES)" "" - install -p -m 644 $(CLICONFFILES) $(DESTDIR)/$(CLICONFDIR) + install -p -m 644 $(CLICONFFILES) $(DESTDIR)/$(CLICONFDIR) endif From 3998d6d486603486420442059f04192cd12a25e4 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:33:52 +0000 Subject: [PATCH 13/14] manually trigger extra byte compilation --- diff --git a/koji.spec b/koji.spec index 6edb240..bed2ef4 100644 --- a/koji.spec +++ b/koji.spec @@ -429,8 +429,8 @@ done %if 0%{py3_support} > 1 make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install # alter python interpreter in koji CLI -scripts='/usr/bin/koji /usr/sbin/kojid /usr/sbin/kojira /usr/sbin/koji-shadow - /usr/sbin/koji-gc /usr/sbin/kojivmd' +scripts='%{_bindir}/koji %{_sbindir}/kojid %{_sbindir}/kojira %{_sbindir}/koji-shadow + %{_sbindir}/koji-gc %{_sbindir}/kojivmd' for fn in $scripts ; do sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT$fn done @@ -447,6 +447,26 @@ sed -i 's|#!/usr/bin/python2|#!/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/koji %endif %endif +%if 0%{?fedora} >= 28 +# handle extra byte compilation +extra_dirs=' + %{_prefix}/lib/koji-builder-plugins + %{_prefix}/koji-hub-plugins + %{_datadir}/koji-hub + %{_datadir}/koji-web/lib/kojiweb + %{_datadir}/koji-web/scripts' +%if 0%{py2_support} > 1 +for fn in $extra_dirs ; do + %py_byte_compile %{__python2} %{buildroot}$fn +done +%endif +%if 0%{py3_support} > 1 +for fn in $extra_dirs ; do + %py_byte_compile %{__python3} %{buildroot}$fn +done +%endif +%endif + %clean rm -rf $RPM_BUILD_ROOT From 79c3b679eb29cf93a191e3c4637f9c294e4929e2 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 18 2019 03:54:32 +0000 Subject: [PATCH 14/14] keep config in koji-web package --- diff --git a/koji.spec b/koji.spec index bed2ef4..ef68800 100644 --- a/koji.spec +++ b/koji.spec @@ -355,6 +355,19 @@ Requires(postun): systemd %description utils Utilities for the Koji system +%package web +Summary: Koji Web UI +Group: Applications/Internet +License: LGPLv2 +Requires: %{name} = %{version}-%{release} +Requires: %{name}-web-code = %{version}-%{release} +%if 0%{?fedora} || 0%{?rhel} > 7 +Suggests: python%{python3_pkgversion}-%{name}-web +%endif + +%description web +koji-web is a web UI to the Koji system. + %if 0%{py2_support} > 1 %package -n python2-%{name}-web Summary: Koji Web UI @@ -372,8 +385,7 @@ Requires: python-krbV >= 1.0.13 Requires: python-psycopg2 Requires: python-cheetah Requires: python2-%{name} = %{version}-%{release} -Provides: koji-web = %{version}-%{release} -Obsoletes: koji-web < 1.16.2 +Provides: %{name}-web-code = %{version}-%{release} %description -n python2-%{name}-web koji-web is a web UI to the Koji system. @@ -391,8 +403,7 @@ Requires: mod_auth_gssapi Requires: python%{python3_pkgversion}-psycopg2 Requires: python%{python3_pkgversion}-cheetah Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} -Provides: koji-web = %{version}-%{release} -Obsoletes: koji-web < 1.16.2 +Provides: %{name}-web-code = %{version}-%{release} %description -n python%{python3_pkgversion}-%{name}-web koji-web is a web UI to the Koji system. @@ -573,24 +584,23 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/koji-shadow %config(noreplace) /etc/koji-shadow/koji-shadow.conf -%if 0%{py2_support} > 1 -%files -n python2-%{name}-web +%files web %defattr(-,root,root) -%{_datadir}/koji-web %dir /etc/kojiweb %config(noreplace) /etc/kojiweb/web.conf %config(noreplace) /etc/httpd/conf.d/kojiweb.conf %dir /etc/kojiweb/web.conf.d + +%if 0%{py2_support} > 1 +%files -n python2-%{name}-web +%defattr(-,root,root) +%{_datadir}/koji-web %endif %if 0%{py3_support} > 1 %files -n python%{python3_pkgversion}-%{name}-web %defattr(-,root,root) %{_datadir}/koji-web -%dir /etc/kojiweb -%config(noreplace) /etc/kojiweb/web.conf -%config(noreplace) /etc/httpd/conf.d/kojiweb.conf -%dir /etc/kojiweb/web.conf.d %endif %files builder