File sunflow.spec of Package sunflow

# spec file for package sunflow
# Copyright (c) 2017 Asterios Dramis <>.
# 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.

Name:           sunflow
Version:        0.07.2.svn396
Release:        0
Summary:        Rendering System for Photo-realistic Image Synthesis
License:        MIT AND GPL-2.0+
Group:          Productivity/Graphics/Visualization/Raytracers
# mkdir sunflow-0.07.2.svn396
# cd sunflow-0.07.2.svn396
# svn checkout -r 396 .
# find . -name .svn -type d | xargs rm -rf
# cd ..
# tar jcf sunflow-0.07.2.svn396.tar.bz2 sunflow-0.07.2.svn396/
Source0:        %{name}-%{version}.tar.bz2
Source1:        %{name}.desktop
Source2:        %{name}.png
# PATCH-FIX-OPENSUSE 10_to_use_system_janino -- Replace removed janino.jar with system janino (taken from Debian)
Patch0:         10_to_use_system_janino
# PATCH-FIX-OPENSUSE sunflow_SweetHome3D.patch -- Changes needed by SweetHome3D (taken from SweetHome3D upstream tarball, version 3.4)
Patch1:         sunflow_SweetHome3D.patch
# PATCH-FIX-OPENSUSE no_build_time.patch -- Remove build time references from javadoc, so build-compare can do its work
Patch2:         no_build_time.patch
BuildRequires:  ant
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  janino
BuildRequires:  java-devel
BuildRequires:  jpackage-utils
Requires:       java
Requires:       jpackage-utils
BuildArch:      noarch

Sunflow is an open source rendering system for photo-realistic image synthesis.
It is written in Java and built around a flexible ray tracing core and an
extensible object-oriented design.

%package javadoc
Summary:        Javadocs for sunflow
Group:          Documentation/HTML
Requires:       %{name} = %{version}

%description javadoc
This package contains the API Documentation for sunflow.

%setup -q
%patch0 -p1
%patch1 -p1

# Fix rpmlint warning "wrong-script-end-of-line-encoding"
sed -i 's/\r$//' exporters/blender/

# Fix rpmlint warning "wrong-file-end-of-line-encoding"
sed -i 's/\r$//' CHANGELOG
sed -i 's/\r$//' LICENSE
sed -i 's/\r$//' README

# Remove all third party jars
find . -iname '*.jar' | xargs rm -rf

# Fix compilation (update values for source and target)
sed -i 's/name="sunflow.jdk.level" value="5"/name="sunflow.jdk.level" value="6"/' build.xml

%{ant} jars
%{ant} javadoc

mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/blender/scripts
mkdir -p %{buildroot}%{_javadir}
mkdir -p %{buildroot}%{_javadocdir}

# jar
install -pm 0644 release/sunflow.jar %{buildroot}%{_javadir}/sunflow-%{version}.jar

# Make name of jar version agnostic
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*; do ln -sf ${jar} ${jar/-%{version}/}; done)

# blender exporter
install -pm 0644 exporters/blender/ %{buildroot}%{_datadir}/blender/scripts/

# javadoc
cp -a release/javadoc/ %{buildroot}%{_javadocdir}/sunflow-%{version}

# startscript
cat > "%{buildroot}%{_bindir}/" << EOF

exec java -jar %{_javadir}/sunflow.jar ${@}

chmod 755 %{buildroot}%{_bindir}/

# Install desktop file and icon
%if 0%{?suse_version} > 1210
desktop-file-install %{SOURCE1}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1}
install -Dpm 0644 %{SOURCE2} %{buildroot}%{_datadir}/pixmaps/sunflow.png

%fdupes -s %{buildroot}%{_javadocdir}

%dir %{_datadir}/blender
%dir %{_datadir}/blender/scripts

%files javadoc
%doc %{_javadocdir}/sunflow-%{version}/