%define name lastfm-player
%define oname player
%define version 1.4.2.58240

Summary: Last.fm web radio player
Name: %{name}
Version: %{version}
Release: 1%{?_dist_release}
# svn://svn.audioscrobbler.net/client
Source0: http://cdn.last.fm/client/src/last.fm-%version.src.tar.bz2
Source1: http://www.mehercule.net/lastfm/icons.tar.gz
Source2: http://www.mehercule.net/lastfm/trayicons22.tar.gz
Patch0: http://mehercule.net/lastfm/00_build-fixes.diff
Patch1: http://mehercule.net/lastfm/no-fingerprint.diff
Patch2: http://mehercule.net/lastfm/02_tray-icon-size.diff
Patch3: http://mehercule.net/lastfm/03_no-scrobble-directories.diff
License: GPL
Group: Applications/Multimedia
Url: http://www.last.fm/tools/downloads/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: qt4-devel >= 4.2, qt4-designer
BuildRequires: alsa-lib-devel, libsamplerate-devel, fftw3-devel, libmad-devel, libgpod-devel
Requires: alsa-lib, libsamplerate, fftw3, libmad, libgpod
Provides: player
Obsoletes: player

%description
This is the custom radio player program for last.fm, formerly known as
audioscrobbler.com.

%prep
%setup -q -a 1 -n last.fm-%version
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

bzcat %{SOURCE2} | tar -C bin/data/icons -xf - 

chmod -R +r .
perl -pi -e "s|\r\n|\n|" ChangeLog

%build
qmake -config release
make

cd i18n
lrelease *.ts
mkdir -p ../bin/data/i18n
cp *.qm ../bin/data/i18n/
cd ..

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %buildroot{%_bindir,%_libdir/}
cp -r bin %buildroot%_libdir/%name
cat << EOF > %buildroot%_bindir/%name
#!/bin/sh
/usr/lib/%name/last.fm.sh \$*
EOF

install -d -m 755 $RPM_BUILD_ROOT%_datadir/services 

cat > $RPM_BUILD_ROOT%_datadir/services/lastfm.protocol << EOF
[Protocol]
 exec=%_bindir/%name "%u"
 protocol=lastfm
 input=none
 output=none
 helper=true
 listing=
 reading=false
 writing=false
 makedir=false
 deleting=false
EOF

mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
cat > $RPM_BUILD_ROOT%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Name=Last.FM Player
Comment=Play the last.fm internet radio
Exec=%name %U
Icon=lastfm
Terminal=false
Type=Application
StartupNotify=true
Categories=Qt;AudioVideo;Audio;Player;
EOF

mkdir -p %buildroot%_datadir/icons
cp -r icons/hicolor %buildroot%_datadir/icons/hicolor
find %buildroot -name .svn |xargs rm -rf

rm %buildroot%_libdir/lastfm-player/*.lib

%clean
rm -rf $RPM_BUILD_ROOT

%post

%postun

%files
%defattr(-,root,root)
%doc ChangeLog README
%attr(755,root,root) %_bindir/%name
%_datadir/applications/*
%_datadir/icons/hicolor/*/apps/lastfm*
%_libdir/%name
%_datadir/services/lastfm.protocol


%changelog
* Sun Apr 13 2008 Satoshi MACHINO <machino@vinelinux.org> 1.4.2.58240-1vl5
- new upstream release.
- update Source[012] URLs and Url.
- change Group from Sound to Applications/Multimedia.
- fixed hicolor icons's cp

* Fri Jan 04 2008 Satoshi MACHINO <machino@vinelinux.org> 1.4.1.57486-0vl1
- first build for VineLinux


