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