File tv-maxe.spec of Package tv-maxe

#
# spec file for package tv-maxe
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           tv-maxe
Summary:        Watch TV channels on Linux
Version:        0.09
Release:        0
Source0:        http://tv-maxe.googlecode.com/files/%{name}-%{version}.tar.gz
Source1:        %{name}.desktop
Source2:        %{name}
Source3:	    %{name}.svg
Source4:	    channel-editor.tar.gz
# FIX FOR UPSTREAM zh_*.patch i@marguerite.su provides zh translations.
Patch1:		fix-for-upstream-zh_CN-translation.patch
Patch2:		fix-for-upstream-zh_TW-translation.patch
# FIX FOR UPSTREAM standard-locale-dir.patch i@marguerite.su switch locale dir to openSUSE standard.
Patch3:		fix-for-upstream-standard-locale-dir.patch
# FIX FOR UPSTREAM China-channels-subscriptions.patch i@marguerite.su add some Chinese channels.
Patch4:		fix-for-upstream-China-channels-subscriptions.patch
BuildRequires:  update-desktop-files
BuildRequires:	python-devel
BuildRequires:	rsvg-view fdupes
Url:            http://code.google.com/p/tv-maxe
Group:          Productivity/Multimedia/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# Main project is GPL-3.0, vlc.py is GPL-2.0+, workerpool is MIT(compabile with GPL-3.0), so license is
License:        GPL-3.0
Requires:       python 
Requires:       python-gtk
Requires:       sopcast
Requires:       vlc 
Requires:       MPlayer
Obsoletes:      tvmaxe < %{version}
Provides:	    tvmaxe = %{version}
BuildArch:      noarch

%lang_package

%description
TV-MAXE is an application which provides the ability to watch TV stations and listen radio via different streams, such is SopCast. Currently it has a large number of channels, both romanian and international.

%prep 
%setup -q -n %{name}-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

%build

%install
# menu
mkdir -pv %{buildroot}%{_datadir}/applications
cp %{SOURCE1}  %{buildroot}%{_datadir}/applications/%{name}.desktop

# binaries
mkdir -pv %{buildroot}%{_bindir}
cp %{SOURCE2} %{buildroot}%{_bindir}/%{name}
chmod 755 %{buildroot}%{_bindir}/%{name}

# icons
mkdir -pv %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
cp %{S:3} %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/
pushd %{buildroot}%{_datadir}/icons/hicolor
ICONSIZE="16 22 32 48 64"
for i in $ICONSIZE; do
	mkdir -pv ${i}x${i}/apps/
	rsvg-convert -h $i -w $i scalable/apps/%{name}.svg -o ${i}x${i}/apps/%{name}.png
done
popd

# build zh translation files
pushd lng/zh_CN/LC_MESSAGES/
msgfmt tvmaxe.po
mv messages.mo tvmaxe.mo
popd
pushd lng/zh_TW/LC_MESSAGES/
msgfmt tvmaxe.po
mv messages.mo tvmaxe.mo
popd

# add channel editor for advanced user 
cp -r %{S:4} ./
tar -xzf channel-editor.tar.gz
rm -rf channel-editor.tar.gz
chmod +x channel-editor/channeleditor.py

# libraries
mkdir -pv %{buildroot}%{_datadir}/%{name}
cp -r * %{buildroot}%{_datadir}/%{name}/
# remove non-needed
rm -rf %{buildroot}%{_datadir}/%{name}/CHANGELOG
rm -rf %{buildroot}%{_datadir}/%{name}/%{name}.png
# link channel editor
ln -sf %{_datadir}/%{name}/channel-editor/channeleditor.py %{buildroot}%{_bindir}/%{name}-channeleditor

# fix locale
mkdir -pv %{buildroot}%{_datadir}/locale
mkdir -pv %{buildroot}%{_datadir}/help
mv %{buildroot}%{_datadir}/%{name}/lng/* %{buildroot}%{_datadir}/locale/
rm -rf %{buildroot}%{_datadir}/%{name}/lng
find %{buildroot}%{_datadir}/locale/ -type f -name "tvmaxe.po" -delete -print
find %{buildroot}%{_datadir}/locale/ -type f -name "tvmaxe.mo" -exec bash -c 'i={}; mv $i ${i/tvmaxe/tv-maxe}' \; -print

# fix W:non-executable-script
pushd %{buildroot}%{_datadir}/%{name}/
find ./ -type f -name "*.py" | xargs sed -i '/^#!\/usr\/bin\/env python$/,+1 d'
find ./ -type f -name "*.py" | xargs sed -i '/^#!\/usr\/bin\/python$/,+1 d'
find ./ -type f -name "*.py" | xargs sed -i '/^#!\ \/usr\/bin\/python$/,+1 d'
# add shebang to channeleditor
sed -i "1i#!\/usr\/bin\/env python" %{buildroot}%{_datadir}/%{name}/channel-editor/channeleditor.py

# fix W:python-bytecode-inconsistent-mtime
%py_compile .
popd

%suse_update_desktop_file %{name} AudioVideo Recorder
%find_lang %{name}
rm -rf %{buildroot}%{_datadir}/help

fdupes %{buildroot}

%files
%defattr(-, root, root,)
%doc CHANGELOG
%{_bindir}/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/%{name}

%files lang -f %{name}.lang

%changelog
openSUSE Build Service is sponsored by