URL: https://github.com/freeipa/freeipa/pull/272 Author: pspacek Title: #272: Build: makerpms.sh generates Python 2 & 3 packages at the same time Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/272/head:pr272 git checkout pr272
From bb1ac496aeb43c19af16a8281352eb701d9ebb6d Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Thu, 24 Nov 2016 17:35:24 +0100 Subject: [PATCH] Build: makerpms.sh generates Python 2 & 3 packages at the same time Petr Viktorin recommended me to copy the whole build directory and run configure twice, with different values for PYTHON variable. After thinking a bit about that, it seems as cleanest approach. Building for two versions of Python at the same time should be temporary state so I decided not to complicate Autotools build system with conditional spagetti for two versions of Python. For proper Python2/3 distiction in the two separate builds, I added find/grep/sed combo which replaces shebangs with system-wide Python interpreter as necessary. This is workaround for the fact that FreeIPA does not use setuptools properly. Honza told me that proper use of setuptools is not trivial so we decided to go with this for now. https://fedorahosted.org/freeipa/ticket/157 --- freeipa.spec.in | 146 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index c683ad3..b472c18 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -5,7 +5,7 @@ %if 0%{?rhel} %global with_python3 0 %else -%global with_python3 0 +%global with_python3 1 %endif # lint is not executed during rpmbuild @@ -267,6 +267,37 @@ and integration with Active Directory based infrastructures (Trusts). If you are installing an IPA server, you need to install this package. +%if 0%{?with_python3} + +%package -n python3-ipaserver +Summary: Python libraries used by IPA server +Group: System Environment/Libraries +BuildArch: noarch +%{?python_provide:%python_provide python3-ipaserver} +Requires: %{name}-server-common = %{version}-%{release} +Requires: %{name}-common = %{version}-%{release} +Requires: python3-ipaclient = %{version}-%{release} +Requires: python3-pyldap >= 2.4.15 +Requires: python3-lxml +Requires: python3-gssapi >= 1.1.2 +Requires: python3-sssdconfig +Requires: python3-pyasn1 +Requires: python3-dbus +Requires: python3-dns >= 1.11.1 +Requires: python3-kdcproxy >= 0.3 +Requires: rpm-libs + +%description -n python3-ipaserver +IPA is an integrated solution to provide centrally managed Identity (users, +hosts, services), Authentication (SSO, 2FA), and Authorization +(host access control, SELinux user roles, services). The solution provides +features for further integration with Linux based clients (SUDO, automount) +and integration with Active Directory based infrastructures (Trusts). +If you are installing an IPA server, you need to install this package. + +%endif # with_python3 + + %package server-common Summary: Common files used by IPA server Group: System Environment/Base @@ -684,6 +715,11 @@ This package contains tests that verify IPA functionality under Python 3. %prep %setup -n freeipa-%{version} -q +%if 0%{?with_python3} +# Workaround: We want to build Python things twice. To be sure we do not mess +# up something, do two separate builds in separate directories. +cp -r %{_builddir}/freeipa-%{version} %{_builddir}/freeipa-%{version}-python3 +%endif # with_python3 %build @@ -691,9 +727,32 @@ This package contains tests that verify IPA functionality under Python 3. export JAVA_STACK_SIZE="8m" # PATH is workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1005235 export PATH=/usr/bin:/usr/sbin:$PATH +export PYTHON=%{__python2} +# Workaround: make sure all shebangs are pointing to Python 2 +# This should be solved properly using setuptools +# and this hack should be removed. +find \ + ! -name '*.pyc' -a \ + ! -name '*.pyo' -a \ + -type f -exec grep -qsm1 '^#!.*\bpython' {} \; \ + -exec sed -i -e '1 s|^#!.*\bpython[^ ]*|#!%{__python2}|' {} \; %configure --with-vendor-suffix=-%{release} %make_build +%if 0%{?with_python3} +pushd %{_builddir}/freeipa-%{version}-python3 +export PYTHON=%{__python3} +# Workaround: make sure all shebangs are pointing to Python 3 +# This should be solved properly using setuptools +# and this hack should be removed. +find \ + ! -name '*.pyc' -a \ + ! -name '*.pyo' -a \ + -type f -exec grep -qsm1 '^#!.*\bpython' {} \; \ + -exec sed -i -e '1 s|^#!.*\bpython[^ ]*|#!%{__python3}|' {} \; +%configure --with-vendor-suffix=-%{release} +popd +%endif # with_python3 %check %if ! %{ONLY_CLIENT} @@ -712,16 +771,25 @@ make %{?_smp_mflags} client-check VERBOSE=yes LIBDIR=%{_libdir} # All files and directories created by spec install should be marked as ghost. # (These are typically configuration files created by IPA installer.) # All other artifacts should be created by make install. +# +# Exception to this rule are test programs which where want to install +# Python2/3 versions at the same time so we need to rename them. Yuck. %make_install -# remove files which are useful only for make uninstall -find %{buildroot} -wholename '*/site-packages/*/install_files.txt' -exec rm {} \; - mv %{buildroot}%{_bindir}/ipa-run-tests %{buildroot}%{_bindir}/ipa-run-tests-%{python2_version} mv %{buildroot}%{_bindir}/ipa-test-config %{buildroot}%{_bindir}/ipa-test-config-%{python2_version} mv %{buildroot}%{_bindir}/ipa-test-task %{buildroot}%{_bindir}/ipa-test-task-%{python2_version} + %if 0%{?with_python3} -(cd ipatests && %{__python3} setup.py install --root %{buildroot}) +pushd %{_builddir}/freeipa-%{version}-python3 +(cd ipaclient && %make_install) +(cd ipalib && %make_install) +(cd ipaplatform && %make_install) +(cd ipapython && %make_install) +(cd ipaserver && %make_install) +(cd ipatests && %make_install) +popd + mv %{buildroot}%{_bindir}/ipa-run-tests %{buildroot}%{_bindir}/ipa-run-tests-%{python3_version} mv %{buildroot}%{_bindir}/ipa-test-config %{buildroot}%{_bindir}/ipa-test-config-%{python3_version} mv %{buildroot}%{_bindir}/ipa-test-task %{buildroot}%{_bindir}/ipa-test-task-%{python3_version} @@ -730,6 +798,8 @@ ln -s %{_bindir}/ipa-test-config-%{python3_version} %{buildroot}%{_bindir}/ipa-t ln -s %{_bindir}/ipa-test-task-%{python3_version} %{buildroot}%{_bindir}/ipa-test-task-3 %endif # with_python3 + +# test framework defaults to Python 2 ln -s %{_bindir}/ipa-run-tests-%{python2_version} %{buildroot}%{_bindir}/ipa-run-tests-2 ln -s %{_bindir}/ipa-test-config-%{python2_version} %{buildroot}%{_bindir}/ipa-test-config-2 ln -s %{_bindir}/ipa-test-task-%{python2_version} %{buildroot}%{_bindir}/ipa-test-task-2 @@ -737,17 +807,9 @@ ln -s %{_bindir}/ipa-run-tests-%{python2_version} %{buildroot}%{_bindir}/ipa-run ln -s %{_bindir}/ipa-test-config-%{python2_version} %{buildroot}%{_bindir}/ipa-test-config ln -s %{_bindir}/ipa-test-task-%{python2_version} %{buildroot}%{_bindir}/ipa-test-task -%if 0%{?with_python3} -(cd ipalib && make PYTHON=%{__python3} IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} DESTDIR=%{buildroot} LIBDIR=%{_libdir} install) -(cd ipapython && make PYTHON=%{__python3} IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} DESTDIR=%{buildroot} LIBDIR=%{_libdir} install) -(cd ipaplatform && %{__python3} setup.py install --root %{buildroot}) -(cd ipaclient && %{__python3} setup.py install --root %{buildroot}) -%endif # with_python3 -# Switch shebang of /usr/bin/ipa -# XXX: ipa cli is not stable enough for enabling py3 support, keep it in py2 -# in any case -sed -i -e'1s/python\(3\|$\)/python2/' %{buildroot}%{_bindir}/ipa +# remove files which are useful only for make uninstall +find %{buildroot} -wholename '*/site-packages/*/install_files.txt' -exec rm {} \; %find_lang %{gettext_domain} @@ -796,15 +858,6 @@ touch %{buildroot}%{_libdir}/krb5/plugins/libkrb5/winbind_krb5_locator.so %if ! %{ONLY_CLIENT} mkdir -p %{buildroot}%{_sysconfdir}/cron.d - -(cd %{buildroot}/%{python_sitelib}/ipaserver && find . -type f | \ - sed -e 's,\.py.*$,.*,g' | sort -u | \ - sed -e 's,\./,%%{python_sitelib}/ipaserver/,g' ) >server-python.list - -(cd %{buildroot}/%{python_sitelib}/ipatests && find . -type f | \ - sed -e 's,\.py.*$,.*,g' | sort -u | \ - sed -e 's,\./,%%{python_sitelib}/ipatests/,g' ) >tests-python.list - %endif # ONLY_CLIENT @@ -1058,18 +1111,24 @@ fi %{_mandir}/man1/ipa-winsync-migrate.1* -%files -n python2-ipaserver -f server-python.list +%files -n python2-ipaserver %defattr(-,root,root,-) %doc README Contributors.txt %license COPYING -%{python_sitelib}/ipaserver-*.egg-info -%dir %{python_sitelib}/ipaserver -%dir %{python_sitelib}/ipaserver/install -%dir %{python_sitelib}/ipaserver/install/plugins -%dir %{python_sitelib}/ipaserver/install/server -%dir %{python_sitelib}/ipaserver/advise -%dir %{python_sitelib}/ipaserver/advise/plugins -%dir %{python_sitelib}/ipaserver/plugins +%{python2_sitelib}/ipaserver +%{python2_sitelib}/ipaserver-*.egg-info + + +%if 0%{?with_python3} + +%files -n python3-ipaserver +%defattr(-,root,root,-) +%doc README Contributors.txt +%license COPYING +%{python3_sitelib}/ipaserver +%{python3_sitelib}/ipaserver-*.egg-info + +%endif # with_python3 %files server-common @@ -1326,21 +1385,12 @@ fi %if ! %{ONLY_CLIENT} -%files -n python2-ipatests -f tests-python.list +%files -n python2-ipatests %defattr(-,root,root,-) %doc README Contributors.txt %license COPYING -%dir %{python_sitelib}/ipatests -%dir %{python_sitelib}/ipatests/test_cmdline -%dir %{python_sitelib}/ipatests/test_install -%dir %{python_sitelib}/ipatests/test_ipalib -%dir %{python_sitelib}/ipatests/test_ipapython -%dir %{python_sitelib}/ipatests/test_ipaserver -%dir %{python_sitelib}/ipatests/test_ipaserver/test_install -%dir %{python_sitelib}/ipatests/test_ipaserver/data -%dir %{python_sitelib}/ipatests/test_pkcs10 -%dir %{python_sitelib}/ipatests/test_webui -%dir %{python_sitelib}/ipatests/test_xmlrpc +%{python_sitelib}/ipatests +%{python_sitelib}/ipatests-*.egg-info %{_bindir}/ipa-run-tests %{_bindir}/ipa-test-config %{_bindir}/ipa-test-task @@ -1350,7 +1400,6 @@ fi %{_bindir}/ipa-run-tests-%{python2_version} %{_bindir}/ipa-test-config-%{python2_version} %{_bindir}/ipa-test-task-%{python2_version} -%{python_sitelib}/ipatests-*.egg-info %{_mandir}/man1/ipa-run-tests.1* %{_mandir}/man1/ipa-test-config.1* %{_mandir}/man1/ipa-test-task.1* @@ -1361,15 +1410,14 @@ fi %defattr(-,root,root,-) %doc README Contributors.txt %license COPYING - -%{python3_sitelib}/ipatests/ +%{python3_sitelib}/ipatests +%{python3_sitelib}/ipatests-*.egg-info %{_bindir}/ipa-run-tests-3 %{_bindir}/ipa-test-config-3 %{_bindir}/ipa-test-task-3 %{_bindir}/ipa-run-tests-%{python3_version} %{_bindir}/ipa-test-config-%{python3_version} %{_bindir}/ipa-test-task-%{python3_version} -%{python3_sitelib}/ipatests-*.egg-info %endif # with_python3
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code