File gearhead1.spec of Package gearhead1

#
# spec file for package gearhead1
#
# Copyright (c) 2021 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:           gearhead1
Version:        1.310
Release:        0
Summary:        Futuristic Roguelike Game
Group:          Amusements/Games/Strategy/Other
License:        LGPL-2.0-only
URL:            https://gearheadrpg.com
Source0:        https://github.com/jwvhewitt/gearhead-1/archive/v%{version}/gearhead-1-%{version}.tar.gz
Source9:        %{name}.desktop
Source10:       %{name}-icon-128px.png
Source11:       %{name}-icon-96px.png
Source12:       %{name}-icon-48px.png
Source20:       %{name}-sdl.appdata.xml
BuildRequires:  bitstream-vera
BuildRequires:  SDL-devel
BuildRequires:  SDL_image-devel
BuildRequires:  SDL_ttf-devel
BuildRequires:  update-desktop-files
BuildRequires:  dos2unix
BuildRequires:  fontconfig
BuildRequires:  fpc
BuildRequires:  glibc-devel
BuildRequires:  hicolor-icon-theme

%description
Set a century and a half after nuclear war, in this game you explore a world
where various factions compete to determine the future of the human race.

Features include random plot generation and over two hundred mecha designs.
Pilot a giant robot, a city smashing tank, a living jet fighter, or
anything else that can be built using the game's sophisticated design system.

%package textmode
Summary:        Futuristic Roguelike Game (textmode version)
Requires:       %{name}-data = %{version}

%description textmode
Textmode build of GearHead Arena - a roguelike to explore the world of
"mecha" (giant robots).

%package SDL
Summary:        Futuristic Roguelike Game (SDL version)
Requires:       %{name}-data = %{version}
Requires:       %{name}-data-gfx = %{version}

%description SDL
Graphical build of GearHead Arena, based on the SDL library.

%package data
Summary:        Data files for %{name}
BuildArch:      noarch

%description data
Data files required to play GearHead Arena.

%package data-gfx
Summary:        Graphics and fonts for %{name}-SDL
Requires:       bitstream-vera
Requires:       %{name}-data = %{version}
BuildArch:      noarch

%description data-gfx
Images and fonts required to play the graphical version of GearHead Arena.

%prep
%setup -q -n gearhead-1-%{version}

# Convert files from \r\n to \n
find doc/ -type f -exec dos2unix '{}' ';'
dos2unix readme.md

# The game looks for the data files in the current working directory
cat > wrapper-textmode.sh << EOF
#!/bin/sh
cd %{_datadir}/%{name}
%{_libexecdir}/%{name}/%{name}-textmode \$@
EOF

cat > wrapper-sdl.sh << EOF
#!/bin/sh
cd %{_datadir}/%{name}
%{_libexecdir}/%{name}/%{name}-sdl \$@
EOF

# Copy over the icons
cp -a %{SOURCE10} %{SOURCE11} %{SOURCE12} ./


%build
%global buildflags -gw -O2
# build the terminal version
fpc %{buildflags} -o'gharena-textmode' gharena.pas

# make clean
rm *.a || true
rm *.o || true
rm *.ppu || true

# build the SDL version
fpc %{buildflags} -d'SDLMODE' -o'gharena-sdl' gharena.pas


%install
install -m 755 -d %{buildroot}%{_bindir}
install -m 755 -d %{buildroot}%{_libexecdir}/%{name}

for BUILD in textmode sdl; do
	install -m 755  "wrapper-${BUILD}.sh"  "%{buildroot}%{_bindir}/%{name}-${BUILD}"
	install -m 755  "gharena-${BUILD}"  "%{buildroot}%{_libexecdir}/%{name}/%{name}-${BUILD}"
done

install -m 755 -d %{buildroot}%{_datadir}/%{name}
cp -a Design GameData Image Series  %{buildroot}%{_datadir}/%{name}

# Replace the bundled Bitstream Vera fonts
# with symlinks to fonts provided by bitstream-vera-* packages
for FONT in  \
	"Vera/Sans:regular" "VeraBd/Sans:bold" "VeraIt/Sans:italic" "VeraBI/Sans:bold:italic"  \
	"VeraMono/Sans Mono:regular" "VeraMoBd/Sans Mono:bold" "VeraMoIt/Sans Mono:italic" "VeraMoBI/Sans Mono:bold:italic"  \
	"VeraSe/Serif:regular" "VeraSeBd/Serif:bold";
do
	FONT_FILE="$(echo "$FONT" | cut '-d/' -f1)"
	FONT_NAME="Bitstream Vera $(echo "$FONT" | cut '-d/' -f2-)"
	ln -sf  \
		"$(fc-match -f "%%{file}" "${FONT_NAME}")"  \
		"%{buildroot}%{_datadir}/%{name}/Image/${FONT_FILE}.ttf"
done

install -Dm 644 %{S:9} %{buildroot}%{_datadir}/applications/%{name}-sdl.desktop

for SIZE in 128 96 48; do
	ICONDIR="%{buildroot}%{_datadir}/icons/hicolor/${SIZE}x${SIZE}/apps"
	install -m 755 -d "${ICONDIR}"
	install -m 644 "%{name}-icon-${SIZE}px.png" "${ICONDIR}/%{name}.png"
done

install -Dm 644 %{S:20} %{buildroot}%{_datadir}/metainfo/%{name}-sdl.appdata.xml

%files textmode
%{_bindir}/%{name}-textmode
%dir %{_libexecdir}/%{name}/
%{_libexecdir}/%{name}/%{name}-textmode

%files SDL
%{_bindir}/%{name}-sdl
%dir %{_libexecdir}/%{name}/
%{_libexecdir}/%{name}/%{name}-sdl
%{_datadir}/applications/%{name}-sdl.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/metainfo/%{name}-sdl.appdata.xml

%files data
%doc doc/
%doc readme.md
%license license.txt
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/Image/

%files data-gfx
%{_datadir}/%{name}/Image/

%changelog
openSUSE Build Service is sponsored by