File scid.spec of Package scid

#
# spec file for package scid
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


Name:           scid
Version:        4.7.0
Release:        0
Summary:        A chess database application
License:        GPL-2.0-only
Group:          Amusements/Games/Board/Chess
URL:            http://scid.sourceforge.net/
Source:         %{name}-%{version}.tar.gz
Source1:        %{name}.png
Source2:        %{name}.desktop
Source3:        %{name}.6
BuildRequires:  dos2unix
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  phalanx
BuildRequires:  tcl-devel
BuildRequires:  tk-devel
BuildRequires:  unzip
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(x11)
Requires:       phalanx
Requires:       python
Requires:       tcl
Requires:       tk
Recommends:     snack
Obsoletes:      scid-beta < %{version}
Provides:       scid-beta = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Scid can perform many different searches, such as for particular
players, a certain opening position, material searches, and pattern
searches such as isolated pawns. It is very fast, because it uses its
own efficient format, but it can convert games to and from PGN, the
standard format for chess game files.

Scid can use a chess engine such as Crafty to analyze games and also
has a "tree" mode where it automatically shows all moves played from
the current position, their opening codes, success rates, etc.

%prep
%setup -q

%build
dos2unix COPYING ChangeLog TODO
# Fake build date
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{_sourcedir}/%{name}.changes")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
sed -i "s:__DATE__:$DATE:g" src/tkscid.cpp
# This is not autoconf
chmod 755 configure
./configure \
    BINDIR=%{_bindir} \
    SHAREDIR=%{_datadir}/scid \
    OPTIMIZE="%{optflags} -fno-rtti -fno-exceptions"
%make_build

%install
make DESTDIR=%{buildroot} install_scid
# install sound files
mkdir -p %{buildroot}%{_datadir}/scid/sounds/
install -m 644  sounds/* %{buildroot}%{_datadir}/scid/sounds/
# install desktop file & icon
install -D -m 644 %{SOURCE1} %{buildroot}%{_datadir}/pixmaps/scid.png
install -D -m 644 %{SOURCE2} %{buildroot}%{_datadir}/applications/scid.desktop
%suse_update_desktop_file -i "scid" Game BoardGame
# install man page
install -D -m 644 %{SOURCE3} %{buildroot}%{_mandir}/man6/scid.6
# Workaround: Use phalanx version from openSUSE due to broken one in scid itself
ln -s %{_bindir}/phalanx %{buildroot}%{_bindir}/phalanx-scid
# fix permissions
find %{buildroot}%{_datadir}/%{name}/books/ -type f -exec chmod 0644 {} +
%fdupes %{buildroot}%{_datadir}

%post
#show a warning reminding the user to backup his databases
echo 'WARNING !!!'
echo "Scid 4.x uses a new database format."
echo "When opening an old database,"
echo "you will be asked to convert it to the new format."
echo "So if you are updating from scid 3.x _backup_ your old databases first!"

%files
%license COPYING
%doc ChangeLog TODO
%{_datadir}/scid/
%{_datadir}/applications/scid.desktop
%{_datadir}/pixmaps/scid.png
%{_bindir}/*
%{_mandir}/man6/scid*

%changelog
openSUSE Build Service is sponsored by