Make /usr/bin/alembic point to alembic-3 on Fedora 31+

- Make /usr/bin/alembic point to alembic-3 on Fedora 31+
  See https://fedoraproject.org/wiki/Changes/Python_means_Python3
- Avoid absolute symlinks
This commit is contained in:
Petr Viktorin 2019-07-22 18:16:06 +02:00
parent ff2ff58db3
commit 941b664318

View File

@ -7,6 +7,16 @@
%global with_python3 1
%endif
%if ( 0%{?fedora} >= 31 ) || ( 0%{?with_python2} == 0 )
# link /usr/bin/alembic to /usr/bin/alembic-3
# (https://fedoraproject.org/wiki/Changes/Python_means_Python3)
%global python_version 3
%else
# link /usr/bin/alembic to /usr/bin/alembic-2
%global python_version 2
%endif
%global modname alembic
Name: python-alembic
@ -167,21 +177,23 @@ install -d -m 0755 %{buildroot}%{_mandir}/man1
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root=%{buildroot}
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-3
ln -s %{_bindir}/%{modname}-3 %{buildroot}/%{_bindir}/%{modname}-%{python3_version}
ln -s %{modname}-3 %{buildroot}/%{_bindir}/%{modname}-%{python3_version}
install -m 0644 alembic.1 %{buildroot}%{_mandir}/man1/alembic-3.1
ln -s %{_mandir}/man1/alembic-3.1 %{buildroot}%{_mandir}/man1/alembic-%{python3_version}.1
ln -s alembic-3.1 %{buildroot}%{_mandir}/man1/alembic-%{python3_version}.1
popd
%endif
%if 0%{?with_python2}
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-2
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-%{python2_version}
install -m 0644 python2-alembic.1 %{buildroot}%{_mandir}/man1/alembic.1
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-2.1
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-%{python2_version}.1
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-2
ln -s %{modname}-2 %{buildroot}/%{_bindir}/%{modname}-%{python2_version}
install -m 0644 python2-alembic.1 %{buildroot}%{_mandir}/man1/alembic-2.1
ln -s alembic-2.1 %{buildroot}%{_mandir}/man1/alembic-%{python2_version}.1
%endif
ln -s %{modname}-%{python_version} %{buildroot}/%{_bindir}/%{modname}
ln -s alembic-%{python_version}.1 %{buildroot}%{_mandir}/man1/alembic.1
%if 0%{?rhel} && 0%{?rhel} <= 6
# Modify /usr/bin/alembic to require SQLAlchemy>=0.6
# Hacky but setuptools only creates this file after setup.py install is run :-(
@ -209,13 +221,17 @@ popd
%doc README.rst LICENSE CHANGES docs
%{python2_sitelib}/%{modname}/
%{python2_sitelib}/%{modname}-%{version}*
%if %{python_version} == 2
%{_bindir}/%{modname}
%endif
%{_bindir}/%{modname}-2
%{_bindir}/%{modname}-%{python2_version}
%if 0%{?rhel} && 0%{?rhel} <= 6
%else
%if %{python_version} == 2
%{_mandir}/man1/alembic.1*
%endif
%{_mandir}/man1/alembic-2.1*
%{_mandir}/man1/alembic-%{python2_version}.1*
%endif
@ -226,6 +242,10 @@ popd
%doc LICENSE README.rst CHANGES docs
%{python3_sitelib}/%{modname}/
%{python3_sitelib}/%{modname}-%{version}-*
%if %{python_version} == 3
%{_bindir}/%{modname}
%{_mandir}/man1/alembic.1*
%endif
%{_bindir}/%{modname}-3
%{_bindir}/%{modname}-%{python3_version}
%{_mandir}/man1/alembic-3.1*
@ -234,6 +254,11 @@ popd
%changelog
* Mon Jul 22 2019 Petr Viktorin <pviktori@redhat.com> - 1.0.11-2
- Make /usr/bin/alembic point to alembic-3 on Fedora 31+
See https://fedoraproject.org/wiki/Changes/Python_means_Python3
- Avoid absolute symlinks
* Sun Jun 30 2019 Kevin Fenzi <kevin@scrye.com> - 1.0.11-1
- Update to 1.0.11. Fixes bug #1723981