File phun.spec of Package phun

#
# spec file for package phun
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#

# norootforbuild

Name:           phun
Summary:        2D physics sandbox
Version:        5.28
Release:        1
License:        Free for non-commercial use
Url:            http://www.algodoo.com/
Group:          Productivity/Other
Vendor:         openSUSE-Education
Requires:       glew
Requires:       libpng16-compat-devel
BuildRequires:  libpng16-compat-devel
BuildRequires:  ImageMagick
BuildRequires:  boost-devel
BuildRequires:  sed
%define boost_license_pkg %(rpmqpack | grep boost-license | head -n 1)
%define boost_lib_version %( echo "%boost_license_pkg" | sed -e "s|boost-license||g" )
# normally, boost_filesystem should be enough
Requires:       libboost_filesystem%{boost_lib_version} 
# but to be shure...
Requires:       libboost_iostreams%{boost_lib_version} 
Requires:       libboost_math%{boost_lib_version} 
Requires:       libboost_program_options%{boost_lib_version} 
Requires:       libboost_signals%{boost_lib_version} 
Requires:       libboost_system%{boost_lib_version} 
Requires:       libboost_thread%{boost_lib_version} 
Requires:       libboost_wave%{boost_lib_version} 
Requires:       libboost_regex%{boost_lib_version}
AutoReqProv:    off
Requires:       SDL_image
Requires:       SDL
%if 0%{?suse_version}
BuildRequires:  update-desktop-files 
%endif
BuildRequires:  chrpath 
%ifarch         %ix86 ppc
Source0:        Phun_beta_5_28_linux32.tar.bz2
%else
Source0:        Phun_beta_5_28_linux64.tar.bz2
BuildRequires:  glew-devel
BuildRequires:  boost-devel
%endif
Source1:        phun.png
Source2:        phun.desktop
%define         transdate 20090922
Source3:        phun-translations-%{transdate}.tar.bz2
Source4:        phun-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         phundir %_libdir/phun

%description
Phun is a Master of Science Thesis by Computing Science student Emil Ernerfeldt
for supervisor Kenneth Bodin at VRLab, Umeå University. The solver is based on
work by Claude Lacoursière

Phun is meant to be a playground where people can be creative. It can also be
used as an educational tool to learn about physics concepts such as restitution
and friction.


Author:
-------
    Emil Ernerfeldt


%prep
%setup -q -n Phun -b3
%ifarch         %ix86 ppc
chrpath -r %{phundir} %name.bin
%endif
pushd %{_builddir}/phun-translations-%{transdate}
for file in $(find . -type f); do
	test -f %{_builddir}/Phun/$file || cp -v $file %{_builddir}/Phun/$(dirname $file)/
done
popd
rm data/language/Espa*
#
# fix wrong file encodings
#
sed -i "s|||" *.txt

%build

%install
install -D -m644 %SOURCE1 %buildroot/%_datadir/pixmaps/%{name}.png
install -D -m644 %SOURCE2 %buildroot/%_datadir/applications/%{name}.desktop
mkdir -p %buildroot/%{phundir}
mkdir -p %buildroot/%{_bindir}
cp -a * %buildroot/%{phundir}/
rm %buildroot/%{phundir}/*.txt
#
# create wrapper start script
#
cat > %buildroot/%{_bindir}/%name << EOF
#!/bin/sh
cd %{phundir} || exit 1
export LD_LIBRARY_PATH=".:%{phundir}/lib:${LD_LIBRARY_PATH}" 
./phun.bin $@
EOF
chmod +x %buildroot/%_bindir/%name
rm %buildroot/%{phundir}/phun
#
# fix language files
#
pushd %buildroot/%{phundir}/data/language
for lang in $(ls *.txt *.cfg | sed "s/ /_/g" | sed "s/\(//g" | sed "s/\)//g" ); do
	echo "$lang"
	dos2unix -qo "$lang"
	if [ "$lang" != "$(echo $lang|iconv -f 8859_1 -t utf8 -)" ]; then	
		mv -v "$lang" "$(echo $lang|iconv -f 8859_1 -t utf8 -)"
	fi
done
popd
#
# desktop files and cleanup
#
%if 0%{?suse_version}
%suse_update_desktop_file -n %name Education X-KDE-Edu-Teaching
%endif
#
# fix libpng warning: iCCP known incorrect sRGB profile
#
for i in $(find "%buildroot/%{phundir}" type -f -name "*.png" ); do 
	mogrify "$i";
done
#
# 64 bit packaging failure
#
%ifarch         x86_64
GLEWLIB=$(ls %{_libdir}/libGLEW.so.* | head -n 1)
GLEWLIBVERSION=$(echo ${GLEWLIB#*.*.*})
ln -s $GLEWLIB %buildroot/%{phundir}/libGLEW.so.${GLEWLIBVERSION}
# hardcoded pathname in the binary, but works also with other GLEW library versions
ln -s $GLEWLIB %buildroot/%{phundir}/libGLEW.so.1.5
BOOSTLIB=$(ls %{_libdir}/libboost_filesystem.so.* | head -n 1)
BOOSTLIBVERSION=$(echo ${BOOSTLIB#*.*.*})
ln -s $BOOSTLIB %buildroot/%{phundir}/libboost_filesystem-gcc41-%{boost_lib_version}.so.$BOOSTLIBVERSION
ln -s %{_libdir}/libpng.so %buildroot/%{phundir}/libpng.so.3
%endif

%if ! 0%{?suse_version}
%post
%update_menus
/sbin/ldconfig

%postun
%clean_menus
/sbin/ldconfig
%else
%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig
%endif

%clean
rm -rf %buildroot

%files
%defattr(-,root,root)
%doc *.txt 
%_datadir/applications/%{name}.desktop
%_datadir/pixmaps/%{name}.png
%_bindir/phun
%{phundir}

%changelog
openSUSE Build Service is sponsored by