--- /dev/null
+Summary: Automagically add titles to mpd playlist
+Name: mpd_sima
+Version: 0.8.0
+Release: 1
+License: GPL v3+
+Group: Applications
+Source0: http://codingteam.net/project/sima/download/file/%{name}_%{version}.tgz
+# Source0-md5: 5c6e5790ce87c034ef4c437c214bad1d
+Source1: %{name}.service
+Patch0: vardir.patch
+URL: http://codingteam.net/project/sima
+BuildRequires: rpm-pythonprov
+BuildRequires: sed >= 4.0
+Requires: python-mpd
+Requires: systemd-units >= 37-0.10
+Provides: group(mpd_sima)
+Provides: user(mpd_sima)
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+MPD Sima is a python daemon meant to feed MPD playlist with artist
+similar to your currently playing track, provided that this artist is
+found in MPD library.
+
+This python code allows you to never run out of music when your
+playlist queue is getting short.
+
+%prep
+%setup -q -n %{name}_%{version}
+%patch0 -p1
+for f in src/mpd_sima src/simadb_cli; do
+ sed -i -e 's=#!/usr/bin/env python=#!/usr/bin/python=' $f
+done
+for f in data/wrappers/mpd-sima data/wrappers/simadb_cli; do
+ sed -i -e 's=#!/usr/bin/env sh=#!/bin/sh=' $f
+done
+
+%build
+%{__make} PREFIX=%{_prefix}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_sharedstatedir}/%{name},%{_sysconfdir},%{systemdunitdir}}
+
+%{__make} install \
+ PREFIX=%{_prefix} \
+ DESTDIR=$RPM_BUILD_ROOT
+
+install doc/examples/mpd_sima.cfg $RPM_BUILD_ROOT%{_sysconfdir}/mpd-sima.cfg
+install %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
+%py_comp $RPM_BUILD_ROOT%{_datadir}/mpd-sima
+%py_ocomp $RPM_BUILD_ROOT%{_datadir}/mpd-sima
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/mpd-sima/{lib,utils}/*.py
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+%groupadd -g 275 mpd_sima
+%useradd -u 275 -r -d /home/services/mpd_sima -s /bin/false -c "MPD_sima user" -g mpd_sima mpd_sima
+
+%post
+%systemd_post %{name}.service
+
+%preun
+%systemd_preun %{name}.service
+
+%postun
+if [ "$1" = "0" ]; then
+ %userremove mpd_sima
+ %groupremove mpd_sima
+fi
+%systemd_reload
+
+%files
+%defattr(644,root,root,755)
+%doc doc/AUTHORS doc/Changelog doc/copyright_holders doc/examples doc/FAQ doc/README.* doc/THANKS doc/sima_db.dia
+%attr(600,mpd_sima,mpd_sima) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mpd-sima.cfg
+%attr(755,root,root) %{_bindir}/mpd-sima
+%attr(755,root,root) %{_bindir}/simadb_cli
+%dir %{_datadir}/mpd-sima
+%attr(755,root,root) %{_datadir}/mpd-sima/mpd_sima
+%attr(755,root,root) %{_datadir}/mpd-sima/simadb_cli
+%dir %{_datadir}/mpd-sima/lib
+%{_datadir}/mpd-sima/lib/*.py[co]
+%dir %{_datadir}/mpd-sima/utils
+%{_datadir}/mpd-sima/utils/*.py[co]
+%{_mandir}/man1/mpd-sima.1*
+%{_mandir}/man1/mpd-sima.cfg.1*
+%{_mandir}/man1/simadb_cli.1*
+%{systemdunitdir}/%{name}.service
+%attr(770,mpd_sima,mpd_sima) %{_sharedstatedir}/mpd_sima
--- /dev/null
+--- mpd_sima_0.8.0/src/utils/startopt.py.wiget 2012-02-03 14:09:03.722512780 +0100
++++ mpd_sima_0.8.0/src/utils/startopt.py 2012-02-03 14:10:09.119982354 +0100
+@@ -52,6 +52,13 @@ def is_file_exist(option, opt_str, value
+ raise OptionValueError('no access to "%s"' % value)
+ setattr(parser.values, option.dest, value)
+
++def is_directory_rwable(option, opt_str, value, parser):
++ value = normalize_path(value)
++ # Check either file is write-able or not
++ if not access(value, W_OK):
++ raise OptionValueError('no write access to "%s"' % value)
++ setattr(parser.values, option.dest, value)
++
+ def obsolete_option(option, opt_str, value, parser):
+ raise parser.error('"%s" now obsolete' % option)#}}}
+
+@@ -129,7 +136,7 @@ OPTS = list([
+ 'type': 'string',
+ 'dest': 'var_dir',
+ 'action': 'callback',
+- 'callback': is_file_rwable,
++ 'callback': is_directory_rwable,
+ 'help': 'Directory to store var content (ie. database)'},
+ {
+ 'sw': ['--new-version'],