File tuxguitar.spec of Package tuxguitar

# spec file for package tuxguitar
# Copyright (c) 2012 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

Summary:        A multitrack tablature editor and player written in Java-SWT
License:        LGPL-2.1+
Group:          Applications/Multimedia

Name:           tuxguitar
Version:        1.2
Release:        0
Source1:        Makefile
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       itext
Requires:       java >= 1.6
Requires:       jpackage-utils
Requires:       libswt3-gtk2
Requires:       timidity
%if 0%{?suse_version} == 1130
Requires:       libswt3-gtk2 = 3.4
BuildRequires:  libswt3-gtk2 = 3.4
BuildRequires:  alsa-lib-devel
BuildRequires:  ant
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  fluidsynth-devel
BuildRequires:  itext
BuildRequires:  java-devel >= 1.6.0
BuildRequires:  jpackage-utils
BuildRequires:  libswt3-gtk2
BuildRequires:  update-desktop-files

TuxGuitar is a guitar tablature editor with player support through 
midi. It can display scores and multitrack tabs. Various features 
TuxGuitar provides include autoscrolling while playing, note 
duration management, bend/slide/vibrato/hammer-on/pull-off effects,
support for tuplets, time signature management, tempo management,
gp3/gp4/gp5 import and export.

%setup -q -n %{name}-src-%{version}
%__cp %{SOURCE1} .
# The following issues were discussed in:
# Prevent static library paths to be built in TuxGuitar.jar (META-INF/MANIFEST.MF)
sed -i 's/<attribute name="Class-Path" value="${lib.swt.jar} ${dist.share.path}"\/>//' TuxGuitar/build.xml
# Export the library path during runtime instead
sed -i 's|env_$|env_\nexport CLASSPATH=$CLASSPATH:%{_libdir}/java/swt.jar\n|' misc/
# Set place where .so files are located
sed -i 's|PACKAGE_LIB:=/usr/lib/jni|PACKAGE_LIB:=%{_libdir}/%{name}|' misc/
# OpenSuse fix for java path
sed -i 's|JAVA=${JAVA:=${JAVA_HOME}/jre/bin/java}|JAVA=${JAVA:=/usr/bin/java}|' misc/
# Disable the pdf plugin that depends on "iText" which is currently not available on Fedora
#sed -i 's/TuxGuitar-pdf \\/\\/g' Makefile
#sed -i 's/.\/TuxGuitar-pdf\/tuxguitar-pdf.jar \\/\\/g' Makefile
# Change /lib to %%{_lib}
sed -i 's/\/lib\//\/%{_lib}\//g' Makefile
sed -i 's/\/lib\//\/%{_lib}\//g' misc/
sed -i 's/\/lib\//\/%{_lib}\//g' TuxGuitar/xml/build-linux.xml
# Don't strip the binaries during %%install
sed -i 's/install -s/install -m 755/g' Makefile
# Remove pre-shipped binaries
find -name .DS_Store -exec rm {} \;
# Update desktop file
sed -i -e 's|Version=1.0|GenericName=%{name}|g' misc/tuxguitar.desktop
sed -i -e 's|Categories=AudioVideo;Audio;|Categories=AudioVideo;Music;Java|g' misc/tuxguitar.desktop

%define openjdkdir /usr/%{_lib}/jvm/java-openjdk
%if 0%{?suse_version} == 1130
make SWT_JAR=%{_datadir}/java/swt-gtk-3.4.jar CFLAGS="${RPM_OPT_FLAGS} -I%{openjdkdir}/include -I%{openjdkdir}/include/linux -fPIC"
make SWT_JAR=%{_libdir}/java/swt.jar CFLAGS="${RPM_OPT_FLAGS} -I%{openjdkdir}/include -I%{openjdkdir}/include/linux -fPIC"

install -dm 755 $RPM_BUILD_ROOT/%{_libdir}/%{name}
make DESTDIR=$RPM_BUILD_ROOT INSTALL_LIB_DIR=$RPM_BUILD_ROOT/%{_libdir}/%{name} install-linux
# Makefile does not install the plugins by default so install them manually
install -dm 755 $RPM_BUILD_ROOT/%{_datadir}/%{name}/plugins
for jardir in TuxGuitar-*; do
 if [ -e $jardir/*jar ]
  install -m 644 $jardir/*jar  $RPM_BUILD_ROOT/%{_datadir}/%{name}/plugins/
# desktop files
install -dm 755 $RPM_BUILD_ROOT/%{_datadir}/applications
install -pm 644 misc/tuxguitar.desktop $RPM_BUILD_ROOT/%{_datadir}/applications/
# mime-type icons
install -dm 755 $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/96x96/mimetypes
install -pm 644 TuxGuitar/share/skins/Lavender/icon-96x96.png $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/96x96/mimetypes/audio-x-tuxguitar.png
install -pm 644 TuxGuitar/share/skins/Lavender/icon-96x96.png $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/96x96/mimetypes/audio-x-gtp.png
install -pm 644 TuxGuitar/share/skins/Lavender/icon-96x96.png $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/96x96/mimetypes/audio-x-ptb.png
# mime-type file
install -dm 755 $RPM_BUILD_ROOT/%{_datadir}/mime/packages
install -pm 644 misc/%{name}.xml $RPM_BUILD_ROOT/%{_datadir}/mime/packages/
#install also big icon
install -D -m 644 TuxGuitar/share/skins/Lavender/icon-48x48.png $RPM_BUILD_ROOT%{_datadir}/pixmaps/tuxguitar.png
%suse_update_desktop_file -n -i tuxguitar AudioVideo Music Java


update-mime-database %{_datadir}/mime  >& /dev/null ||:
touch --no-create %{_datadir}/icons/hicolor
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :

update-mime-database %{_datadir}/mime  >& /dev/null ||:
touch --no-create %{_datadir}/icons/hicolor
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :

%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/96x96
%dir %{_datadir}/icons/hicolor/96x96/mimetypes