File micropolis.spec of Package micropolis

#
# spec file for package micropolis
#
# Copyright (c) 2024 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/
#


%define name	micropolis
Name:           %{name}
Version:        4.0
Release:        0
# activity/activity.info = 7
# src/sim/sim.c and about = 4.0
Summary:        City simulation based on Maxis SimCity
License:        GPL-3.0-or-later
Group:          Amusements/Games/Strategy/Real Time
URL:            https://www.donhopkins.com/home/micropolis/
Source:         https://git.zerfleddert.de/micropolis/micropolis-activity-source.tgz
Source1:        micropolis.desktop
# Lots of fixes from https://git.zerfleddert.de/micropolis/ -  1654344785 - 2022-06-04 14:13
Patch0:         https://git.zerfleddert.de/micropolis/patches/micropolis_git-1654344785-6f873e16d6a1a8f6f59c1e5a75ec5f52ce5c89b6.patch
BuildRequires:  ImageMagick
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(SDL_mixer)
BuildRequires:  pkgconfig(sdl)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xext)
BuildRequires:  pkgconfig(xpm)
# Plays audio through aplay:
Recommends:     alsa-utils

%description
City-building simulation game originally released as SimCity by
Maxis and subsequently released as free software, renamed to
Micropolis.

%prep
%setup -q -n micropolis-activity
%patch -P 0 -p1

v=$(sed -r -n 's,^.*MicropolisVersion = "(.+)".*$,\1,p' src/sim/sim.c)
#[ $(sed -n 's,activity_version = ,,p' activity/activity.info) = %version ]
[ "$v" = %{version} ]

sed -i -e 's|export SIMHOME=`pwd`|export SIMHOME="%{_libexecdir}/%{name}"|' Micropolis
perl -pi -e 's,GAMESDATADIR,%{_datadir}/%{name},;s,LIBDIR,%{_libdir},' Micropolis

# Re-enable air crash:
perl -pi -e 's,-DNO_AIRCRASH,,' src/sim/makefile

%build
%make_build -j 1 OPTFLAGS="%{optflags}" -C src

%install
%make_install LIBEXECDIR=%{_libexecdir}/%{name} PREFIX=%{_prefix} DESTDIR=%{buildroot}

install -d -m 755 %{buildroot}%{_datadir}/icons/hicolor/16x16/apps
install -d -m 755 %{buildroot}%{_datadir}/icons/hicolor/32x32/apps
install -d -m 755 %{buildroot}%{_datadir}/icons/hicolor/48x48/apps

convert -strip Micropolis.png -resize x16 %{buildroot}%{_datadir}/icons/hicolor/16x16/apps/%{name}.png
convert -strip Micropolis.png -resize x32 %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
convert -strip Micropolis.png -resize x48 %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png

%suse_update_desktop_file -i %{name} Game StrategyGame
%fdupes %{buildroot}%{_datadir}

%files
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_libexecdir}/%{name}
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%{_datadir}/doc/micropolis/

%changelog
openSUSE Build Service is sponsored by