%if 0%{?rhel}
%global with_python3 0
%else # %%{?rhel}
%global with_python3 1
%endif # %%{?rhel}
Name: udiskie
Version: 1.4.8
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
# Recommend tag not supported on EPEL
%if 0%{?!rhel}
# Recommended for full functionality
Recommends: libnotify
%endif # %%{?rhel}
%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
# Make test folder into a proper module, if it already isn't
[ -f test/__init__.py ] || touch test/__init__.py
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
# Only run tests with satisfied dependencies
%{__python2} setup.py test --test-suite test.test_match
popd
%if 0%{with_python3}
pushd python3
# Only run tests with satisfied dependencies
LC_ALL="en_US.utf8" %{__python3} setup.py test --test-suite test.test_match
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
* Wed Feb 10 2016 Jan Stanek <jstanek@redhat.com> - 1.4.8-1
- Update to 1.4.8
* Wed Feb 03 2016 Jan Stanek <jstanek@redhat.com> - 1.4.7-1
- Update to 1.4.7
* Wed Feb 03 2016 Jan Stanek <jstanek@redhat.com> - 1.4.1-2
- Fix build failures on EPEL7
* Mon Dec 21 2015 Jan Stanek <jstanek@redhat.com> - 1.4.1-1
- Update to 1.4.1
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Fri Nov 06 2015 Jan Stanek <jstanek@redhat.com> - 1.3.2-1
- Update to 1.3.2
* Thu Sep 24 2015 Jan Stanek <jstanek@redhat.com> - 1.3.1-1
- Update to 1.3.1
- Add libnotify as weak dependency
* Thu Sep 03 2015 Jan Stanek <jstanek@redhat.com> - 1.3.0-1
- Update to 1.3.0
* Tue Sep 01 2015 Jan Stanek <jstanek@redhat.com> - 1.2.1-1
- Update to 1.2.1.
* Thu Jun 04 2015 Jan Stanek <jstanek@redhat.com> - 1.2.0-1
- Initial package