%if 0%{?rhel} %global with_python3 0 %else # %%{?rhel} %global with_python3 1 %endif # %%{?rhel} Name: udiskie Version: 1.2.0 Release: 1%{?dist} Summary: Removable disk auto-mounter License: MIT URL: https://pypi.python.org/pypi/%{name} Source0: https://pypi.python.org/packages/source/u/%{name}/%{name}-%{version}.tar.gz Source1: 50-udiskie.rules BuildArch: noarch BuildRequires: asciidoc gettext BuildRequires: python2-devel python-setuptools %if 0%{?with_python3} BuildRequires: python3-devel python3-setuptools %endif # with_python3 # Require the module for the correct python %if 0%{with_python3} %if 0%{?fedora} > 21 Requires: python3-%{name} = %{version}-%{release} %else Requires: python-%{name} = %{version}-%{release} %endif # fedora > 21 %else Requires: python-%{name} = %{version}-%{release} %endif # with_python3 # Require package implementing required functionality Requires: polkit hicolor-icon-theme %description %{name} is a front-end for UDisks written in python. Its main purpose is automatically mounting removable media, such as CDs or flash drives. It has optional mount notifications, a GTK tray icon and user level CLIs for manual mounting and unmounting operations. # Define packages required by both python versions %global shared_requires udisks2 gtk3 %package -n python-%{name} Summary: Python 2 module for %{name} disk automounter %global py2_requires %{shared_requires} pygobject3 python-docopt PyYAML BuildRequires: %{py2_requires} Requires: %{py2_requires} %description -n python-%{name} %{name} is a front-end for UDisks written in python. This package provides the python 2 modules used by the %{name} binaries. %if 0%{?with_python3} %package -n python3-%{name} Summary: Python 3 module for udisks disk automounting %global py3_requires %{shared_requires} python3-gobject python3-docopt python3-PyYAML BuildRequires: %{py3_requires} Requires: %{py3_requires} %description -n python3-%{name} %{name} is a front-end for UDisks written in python. This package provides the python 3 modules used by the %{name} binaries. %endif # with_python3 %prep %setup -qc mv %{name}-%{version} python2 pushd python2 find -name '*.txt' | xargs chmod -x # Copy common doc files to the top dir cp -prt.. doc CONTRIBUTORS COPYING README.rst popd %if 0%{with_python3} cp -a python2 python3 find python3 -name '*.py' | xargs sed -i 's|^#!python|#!%{__python3}|' %endif # with_python3 find python2 -name '*.py' | xargs sed -i 's|^#!python|#!%{__python2}|' %build pushd python2 CFLAGS="%{optflags}" %{__python2} setup.py build popd %if 0%{with_python3} pushd python3 CFLAGS="%{optflags}" LC_ALL="en_US.utf8" %{__python3} setup.py build popd %endif # with_python3 # Build man page make %{?_smp_mflags} -C doc %install # Define functions for installing both python2 and python3, then use in desired order function install_py2 { pushd python2 %{__python2} setup.py install --skip-build --root %{buildroot} popd find %{buildroot}%{python2_sitelib} -name '*.exe' -delete } function install_py3 { pushd python3 LC_ALL="en_US.utf8" %{__python3} setup.py install --skip-build --root %{buildroot} popd find %{buildroot}%{python3_sitelib} -name '*.exe' -delete } %if 0%{with_python3} %if 0%{?fedora} > 21 install_py2; install_py3 %else install_py3; install_py2 %endif # fedra > 21 %else # with_python3 install_py2 %endif # Install polkit rules install -p -D -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/polkit-1/rules.d/50-%{name}.rules # Install man page install -d %{buildroot}%{_mandir}/man8 install -p -m644 -t %{buildroot}%{_mandir}/man8 doc/%{name}.8 # Create man pages for other binaries for other in %{name}-mount %{name}-umount; do echo ".so man8/%{name}.8" > %{buildroot}%{_mandir}/man8/"${other}.8" done # Find all localization files %find_lang %{name} # Update icon cache # https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Icon_Cache %post /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || : %postun if [ $1 -eq 0 ] ; then /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : fi %posttrans /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %check pushd python2 %{__python2} setup.py test popd %if 0%{with_python3} pushd python3 LC_ALL="en_US.utf8" %{__python3} setup.py test popd %endif # with_python3 %files -f %{name}.lang %{_mandir}/man8/%{name}*.8* %doc CONTRIBUTORS README.rst %license COPYING %config(noreplace) %{_sysconfdir}/polkit-1/rules.d/50-%{name}.rules %{_bindir}/%{name} %{_bindir}/%{name}-mount %{_bindir}/%{name}-umount %{_datadir}/icons/hicolor/scalable/actions/udiskie* %files -n python-%{name} %doc CONTRIBUTORS README.rst %license COPYING %{python2_sitelib}/* %if 0%{with_python3} %files -n python3-%{name} %doc CONTRIBUTORS README.rst %license COPYING %{python3_sitelib}/* %endif # with_python3 %changelog * Thu Jun 04 2015 Jan Stanek - 1.2.0-1 - Initial package