Skip to content

How to building a package for Fedora or CentOS.md

Alexander Pavlov edited this page Dec 29, 2023 · 17 revisions

How to building a package for Fedora/CentOS.

Introduction

This implementation of the source code provides for installation in the system, in the /usr/bin, /usr/lib, /usr/share directories.

During the launch of the game, the engine determines the place of launch, and if the launch occurred from the /usr/bin directory, it switches to the libraries search mode in the system directories. Also adds searching for game data in various directories. About the search for game data will be written below.

Otherwise, the engine considers that a local launch of the game has occurred and will look for game data in the root directory of the game. User data, such as game settings, log, saves, demos will be located in:

~/.local/share/Serious-Engine/serioussam/ - for TFE
~/.local/share/Serious-Engine/serioussamse/ - for TSE

If you start the game with the +portable key, then there will be a full portable mode and user data, such as game settings, log, saves, demos will also be located in the root directory of the game.

Naming conventions for executable files and libraries

Internal game name for Serious Sam The First Encounter is s serioussam, for Serious Sam The Second Encounter is serioussamse. These names are initially accepted in the engine and are used for example in a network game and a master server.

Location of executables, libraries, and modification libraries.

The executable files of the game are located in the '/usr/bin' directory.

/usr/bin/"internal game name"

The dedicated server and the font creation utility for the game are also located in this directory.

/usr/bin/"internal game name"-ded
/usr/bin/"internal game name"-mkfont

The game libraries will be searched in the following directories:

/usr/lib/"internal game name"/
/usr/lib64/"internal game name"/
/usr/lib/i386-linux-gnu/"internal game name"/
/usr/lib/x86_64-linux-gnu/"internal game name"/
/usr/lib/arm-linux-gnueabihf/"internal game name"/
/usr/lib/aarch64-linux-gnu/"internal game name"/
/usr/lib/riscv64-linux-gnu/"internal game name"/
/usr/lib/powerpc64-linux-gnu/"internal game name"/
/usr/lib/s390x-linux-gnu/"internal game name"/

The location of the libraries of modifications is also on the same principle.

/usr/lib/"internal game name"/Mods/"Mod name"/
/usr/lib64/"internal game name"/Mods/"Mod name"/
/usr/lib/i386-linux-gnu/"internal game name"/Mods/"Mod name"/
/usr/lib/x86_64-linux-gnu/"internal game name"/Mods/"Mod name"/
/usr/lib/arm-linux-gnueabihf/"internal game name"/Mods/"Mod name"/
/usr/lib/aarch64-linux-gnu/"internal game name"/Mods/"Mod name"/
/usr/lib/riscv64-linux-gnu/"internal game name"/Mods/"Mod name"/
/usr/lib/powerpc64-linux-gnu/"internal game name"/Mods/"Mod name"/
/usr/lib/s390x-linux-gnu/"internal game name"/Mods/"Mod name"/

Game libraries are assigned a suffix defined in file ModEXT.txt The suffix is assigned to both game libraries and mod libraries.

The game library engine must be located in the standard library search area. In one of:

/usr/lib
/usr/lib64
/usr/lib/i386-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/lib/aarch64-linux-gnu
/usr/lib/riscv64-linux-gnu
/usr/lib/powerpc64-linux-gnu
/usr/lib/s390x-linux-gnu

The game executable first loads the engine library, which loads the remaining libraries from the subdirectory with the game's internal name.

To get output names by convention, use the cmake build key -DCMAKE_INSTALL_PREFIX:PATH=/usr

In accordance with the naming convention, we get the following location of the executable files, game libraries Serious Sam The First Encounter and Serious Sam The Second Encounter for Fedora/CentOS x86_64:

/usr/bin/serioussam
/usr/bin/serioussam-ded
/usr/bin/serioussam-mkfont
/usr/lib64/libEngine.so
/usr/lib64/serioussam/libShaders.so
/usr/lib64/serioussam/libGame.so
/usr/lib64/serioussam/libEntities.so
/usr/lib64/serioussam/libamp11lib.so
/usr/bin/serioussamse
/usr/bin/serioussamse-ded
/usr/bin/serioussamse-mkfont
/usr/lib64/libEngineMP.so
/usr/lib64/serioussamse/libShaders.so
/usr/lib64/serioussamse/libGameMP.so
/usr/lib64/serioussamse/libEntitiesMP.so
/usr/lib64/serioussamse/libamp11lib.so

For mod XPLUS:

/usr/lib64/serioussam/Mods/XPLUS/libGame.so
/usr/lib64/serioussam/Mods/XPLUS/libEntities.so
/usr/lib64/serioussamse/Mods/XPLUS/libGameMP.so
/usr/lib64/serioussamse/Mods/XPLUS/libEntitiesMP.so

For mod Serious Sam Alpha Remake (SSA):

/usr/lib64/serioussam/Mods/SSA/libGame.so
/usr/lib64/serioussam/Mods/SSA/libEntities.so

Location of game data, user data, and data modifications

During the launch of the game, the engine determines the launch location, and if the launch occurred from the /usr/bin directory, then the game data will be searched for the recommended paths. If the game data is not found using the recommended paths, then the search will be in the home directory, and when the game files are found, the path will be written to the configuration file (not recommended). If the game files are not found, a message box will appear.

Recommended paths for hosting game data:

/usr/share/serioussam/ - for TFE
/usr/share/serioussamse/ - for TSE

or

~/.local/share/Serious-Engine/serioussam/ - for TFE
~/.local/share/Serious-Engine/serioussamse/ - for TSE

Mod Data:

/usr/share/serioussam/Mods/"Mod name" - for TFE
/usr/share/serioussamse/Mods/"Mod name" - for TSE

or

~/.local/share/Serious-Engine/serioussam/Mods/"Mod name" - for TFE
~/.local/share/Serious-Engine/serioussamse/Mods/"Mod name" - for TSE

t is not allowed to arrange game data parts in different recommended paths. Also, if you chose your own path (which is not recommended), it must be the only one.

The file SE1_10b.gro is not included in the game data distributed on CDs or digital stores. If you chose the first recommended option, set it to:

/usr/share/serioussam/SE1_10b.gro - for TFE
/usr/share/serioussamse/SE1_10b.gro - for TSE

If you have chosen the second recommended option, then add additional lines to the post install script:
(Note: not needed since version 1.10.5)

%post

USER_NAME=$(logname)
if test -z "$USER_NAME" ; then USER_NAME=$(loginctl user-status|awk 'NR==1{print $1}')  ; fi
USER_GROUP=$(id -gn $USER_NAME)
HOME_DIR=$(cat /etc/passwd | grep $USER_NAME |  sed -r 's!^[^/]+!!' | sed -r 's/:.+//')
mkdir -p $HOME_DIR/.local/share/Serious-Engine
mkdir -p $HOME_DIR/.local/share/Serious-Engine/serioussam
mkdir -p $HOME_DIR/.local/share/Serious-Engine/serioussamse
cp -rf /usr/share/serioussam/SE1_10b.gro $HOME_DIR/.local/share/Serious-Engine/serioussam
cp -rf /usr/share/serioussamse/SE1_10b.gro $HOME_DIR/.local/share/Serious-Engine/serioussamse
chown -R $USER_NAME:$USER_GROUP $HOME_DIR/.local/share/Serious-Engine
%postun

USER_NAME=$(logname)
if test -z "$USER_NAME" ; then USER_NAME=$(loginctl user-status|awk 'NR==1{print $1}')  ; fi
HOME_DIR=$(cat /etc/passwd | grep $USER_NAME |  sed -r 's!^[^/]+!!' | sed -r 's/:.+//')
rm -rf $HOME_DIR/.local/share/Serious-Engine/serioussam/SE1_10b.gro
rm -rf $HOME_DIR/.local/share/Serious-Engine/serioussamse/SE1_10b.gro

As an example, when creating packages and placing data, we will choose the second option of the recommended location.

Now that we know how the executable files, libraries and game data should be located, let's start building rpm packages for Fedora/CentOS x86_64. It is better to use a separate computer or a virtual machine for package building work.

Installing dependencies

Install packages:

sudo dnf install rpmdevtools rpmlint
  • Where:
  • rpmdevtools - will allow us to use the rpmdev-setuptree utility, with which we can create a working environment in the form of build directories. -rpmlint - allows you to test an RPM package.

We also put:

sudo dnf group install "Development Tools"
  • this group of packages includes everything you need to build. It is not recommended to install it on a working computer, as it installs a lot of garbage that is unnecessary for a standard system.

We will also install

sudo dnf install dnf-utils

We create a user

It is very dangerous to make pre-installed package builds as root. If we make a mistake with the paths, the files can overwrite or remove directories that are important for the work. It is worth creating a separate user and working under it. However, if we work in a virtual environment, we are not afraid. Then this item can be skipped and work as root.

sudo dnf useradd builder -m
  • in this example, we will create a builder user. The -m option will immediately create a home directory for the user. Now we go under this user - we will execute the following commands from him:
su - builder

Let's create the directory structure for the build:

rpmdev-setuptree

An rpmbuild folder should appear in our current directory - and in it:

  • BUILD - contains all the files that appear when a package is created.
  • RPMS - ready-made packages will be added here.
  • SOURCES - for sources from which RPM packages will be built.
  • SPECS - for files describing the build process.
  • SRPMS - for source RPM files.

We are ready to assemble.

Let's create spec files:

rpmdev-newspec rpmbuild/SPECS/serioussamclassic-vk.spec
rpmdev-newspec rpmbuild/SPECS/serioussamclassic-xplus.spec
rpmdev-newspec rpmbuild/SPECS/serioussamclassic-alpha.spec

Now let's open them and bring them to the form:

nano -w rpmbuild/SPECS/serioussamclassic-vk.spec
Name: serioussamclassic-vk
Version: 1.10.5
Release: 1%{?dist}
Summary: Serious Sam Classic native Linux version with Vulkan support

License: GPL2
URL: https://github.com/tx00100xt/SeriousSamClassic-VK
Source0: %{name}-%{version}.tar.gz
Source1: serioussam.png
Group: Games

BuildRequires: sed cmake glibc-devel libstdc++-devel
BuildRequires: zlib-devel libogg-devel libvorbis-devel
BuildRequires: gcc-c++ python3-devel SDL2-devel ImageMagick nasm bison flex gawk
BuildRequires: vulkan-headers vulkan-loader vulkan-loader-devel vulkan-validation-layers-devel
Requires: glibc SDL2 zlib libogg libvorbis libstdc++ mesa-vulkan-drivers vulkan-loader vulkan-validation-layers sed gawk
Conflicts: serioussamclassic
ExclusiveArch:  %ix86 %{arm} aarch64 x86_64

%description
Open source game engine version developed by Croteam for Serious Sam Classic  with Vulkan support (Windows, Linux, FreeBSD, Raspberry Pi OS)
Playing Serious Sam: The First and Second Encounter still requires a legitimate copy of
the game. You can purchase a copy from Steam or your favorite retailer.

Place .gro game files and Levels, Help folders from the Serious Sam installation to:
$HOME/.local/share/Serious-Engine/serioussam   - for Serious Sam: The First Encounter
$HOME/.local/share/Serious-Engine/serioussamse - for Serious Sam: The Second Encounter

%prep

%autosetup

%build

# standart x86_64 build
%ifarch x86_64
echo "Fedora arch x86_64"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for previous fedora os
%ifarch %ix86
echo "Fedora arch i686"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for raspberry pi4
%ifarch aarch64
MODEL_PI=$(cat /proc/cpuinfo | grep Model)
if [[ $MODEL_PI = *"Raspberry Pi 4"* ]]; then echo $MODEL_PI;
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE -DRPI4=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
echo "Build for model Raspberry Pi4"
else
echo "CMAKE_ARGS $CMAKE_ARGS"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE"
echo "Stadart aarch64 build"
fi
%endif

NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`

if [[ $NCPU -eq 0 ]]
then
  let NCPU='4'
else
  let NCPU=$NCPU
fi
echo "Cores: $NCPU"

find . -name "CMakeLists.txt" -exec sed -i 's/-march=native/-mtune=generic/g' {} +

rm -rf %_arch-fc38-linux
mkdir %_arch-fc38-linux
cd $_
cmake .. $CMAKE_ARGS
make -j$NCPU

%install
mkdir -p %buildroot%_bindir
mkdir -p %buildroot%_libdir/serioussam
mkdir -p %buildroot%_libdir/serioussamse
mkdir -p %buildroot%_datadir/serioussam
mkdir -p %buildroot%_datadir/serioussamse
mkdir -p %buildroot%_datadir/applications
mkdir -p %buildroot%_datadir/{icons,icons/hicolor}
for N in 16 32 48 64 128;
do
mkdir -p %buildroot%_datadir/{icons/hicolor/${N}x${N},icons/hicolor/${N}x${N}/apps}
done

cat > %buildroot%_datadir/applications/serioussam.desktop << EOF
[Desktop Entry]
Name=Serious Sam The first Encounter
Comment=Linux port of Serious Sam Classic The First Encounter
Exec=serioussam
TryExec=serioussam
Icon=serioussam.png
Terminal=false
Type=Application
Categories=Game;
EOF

cat > %buildroot%_datadir/applications/serioussamse.desktop << EOF
[Desktop Entry]
Name=Serious Sam The Second Encounter
Comment=Linux port of Serious Sam Classic The Second Encounter
Exec=serioussamse
TryExec=serioussamse
Icon=serioussam.png
Terminal=false
Type=Application
Categories=Game;
EOF

# install menu icons
for N in 16 32 48 64 128;
do
convert %SOURCE1 -scale ${N}x${N} $N.png;
install -D -m 0644 $N.png %buildroot%_datadir/icons/hicolor/${N}x${N}/apps/serioussam.png
done

install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/serioussam %buildroot%_bindir
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/serioussam-ded %buildroot%_bindir
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/serioussam-mkfont %buildroot%_bindir

install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libEngine.so %buildroot%_libdir/
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libGame.so %buildroot%_libdir/serioussam
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libEntities.so %buildroot%_libdir/serioussam
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libShaders.so %buildroot%_libdir/serioussam
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libamp11lib.so %buildroot%_libdir/serioussam

install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/serioussamse %buildroot%_bindir
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/serioussamse-ded %buildroot%_bindir
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/serioussamse-mkfont %buildroot%_bindir

install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libEngineMP.so %buildroot%_libdir/
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libGameMP.so %buildroot%_libdir/serioussamse
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libEntitiesMP.so %buildroot%_libdir/serioussamse
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libShaders.so %buildroot%_libdir/serioussamse
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libamp11lib.so %buildroot%_libdir/serioussamse

install -D -m0755 ./SamTFE/SE1_10b.gro %buildroot%_datadir/serioussam/
install -D -m0755 ./SamTSE/SE1_10b.gro %buildroot%_datadir/serioussamse/

%files

%_bindir/serioussam
%_bindir/serioussam-ded
%_bindir/serioussam-mkfont
%_bindir/serioussamse
%_bindir/serioussamse-ded
%_bindir/serioussamse-mkfont

%_libdir/libEngine.so
%_libdir/libEngineMP.so
%_libdir/serioussam/libGame.so
%_libdir/serioussam/libEntities.so
%_libdir/serioussam/libShaders.so
%_libdir/serioussam/libamp11lib.so
%_libdir/serioussamse/libGameMP.so
%_libdir/serioussamse/libEntitiesMP.so
%_libdir/serioussamse/libShaders.so
%_libdir/serioussamse/libamp11lib.so

%_datadir/serioussam/SE1_10b.gro
%_datadir/serioussamse/SE1_10b.gro
%{_datadir}/applications/serioussam.desktop
%{_datadir}/applications/serioussamse.desktop

%{_datadir}/icons/hicolor/16x16/apps/serioussam.png
%{_datadir}/icons/hicolor/32x32/apps/serioussam.png
%{_datadir}/icons/hicolor/48x48/apps/serioussam.png
%{_datadir}/icons/hicolor/64x64/apps/serioussam.png
%{_datadir}/icons/hicolor/128x128/apps/serioussam.png

%post
update-desktop-database

%postun
update-desktop-database

%changelog
* Mon Apr 24 2023 tx00100xt initial SPEC file.
-
nano -w  rpmbuild/SPECS/serioussamclassic-xplus.spec
Name: serioussamclassic-xplus
Version: 1.10.5
Release: 1%{?dist}
Summary: Serious Sam Classic native Linux modification

License: GPL2
URL: https://github.com/tx00100xt/SeriousSamClassic
Source0: %{name}-%{version}.tar.gz
Group: Games

BuildRequires: sed cmake glibc-devel libstdc++-devel
BuildRequires: zlib-devel libogg-devel libvorbis-devel
BuildRequires: gcc-c++ python3-devel SDL2-devel bison flex gawk
Requires: glibc SDL2 zlib libogg libvorbis libstdc++ sed gawk (serioussamclassic or serioussamclassic-vk)
ExclusiveArch:  %ix86 %{arm} aarch64 x86_64

%description
 Open source nodifications based on game engine version developed by Croteam for Serious Sam Classic (Windows, Linux, FreeBSD, Raspberry Pi OS)
Playing Serious Sam: The First and Second Encounter still requires a legitimate copy of
the game. You can purchase a copy from Steam or your favorite retailer.

Place .gro game files and Levels, Help folders from the Serious Sam installation to:
$HOME/.local/share/Serious-Engine/serioussam   - for Serious Sam: The First Encounter
$HOME/.local/share/Serious-Engine/serioussamse - for Serious Sam: The Second Encounter

Place Mods game files to:
$HOME/.local/share/Serious-Engine/serioussam/Mods   - for Serious Sam: The First Encounter
$HOME/.local/share/Serious-Engine/serioussamse/Mods - for Serious Sam: The Second Encounter

%prep
%autosetup

%build

# standart x86_64 build
%ifarch x86_64
echo "Fedora arch x86_64"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for previous fedora os
%ifarch %ix86
echo "Fedora arch i686"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for raspberry pi4
%ifarch aarch64
MODEL_PI=$(cat /proc/cpuinfo | grep Model)
if [[ $MODEL_PI = *"Raspberry Pi 4"* ]]; then echo $MODEL_PI;
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE -DRPI4=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
echo "Build for model Raspberry Pi4"
else
echo "CMAKE_ARGS $CMAKE_ARGS"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE"
echo "Stadart aarch64 build"
fi
%endif

NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`

if [[ $NCPU -eq 0 ]]
then
  let NCPU='4'
else
  let NCPU=$NCPU
fi
echo "Cores: $NCPU"

find . -name "CMakeLists.txt" -exec sed -i 's/-march=native/-mtune=generic/g' {} +
rm -rf ./%_arch-fc38-linux
mkdir ./%_arch-fc38-linux
cd $_
cmake .. $CMAKE_ARGS -DXPLUS=TRUE
make -j$NCPU

%install
mkdir -p %buildroot%_libdir/{serioussam,serioussam/Mods,serioussam/Mods/XPLUS}
mkdir -p %buildroot%_libdir/{serioussamse,serioussamse/Mods,serioussamse/Mods/XPLUS}

install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libGame.so %buildroot%_libdir/serioussam/Mods/XPLUS
install -D -m0755 ./%_arch-fc38-linux/SamTFE/Sources/Debug/libEntities.so %buildroot%_libdir/serioussam/Mods/XPLUS

install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libGameMP.so %buildroot%_libdir/serioussamse/Mods/XPLUS
install -D -m0755 ./%_arch-fc38-linux/SamTSE/Sources/Debug/libEntitiesMP.so %buildroot%_libdir/serioussamse/Mods/XPLUS

%files

%_libdir/serioussam/Mods/XPLUS/libGame.so
%_libdir/serioussam/Mods/XPLUS/libEntities.so
%_libdir/serioussamse/Mods/XPLUS/libGameMP.so
%_libdir/serioussamse/Mods/XPLUS/libEntitiesMP.so

%post

%postun

%changelog
* Mon Apr 24 2023 tx00100xt initial SPEC file.
- 
nano -w  rpmbuild/SPECS/serioussamclassic-alpha.spec
Name: serioussamclassic-alpha
Version: 1.5.2
Release: 1%{?dist}
Summary: Serious Sam Classic native Linux modification

License: GPL2
URL: https://github.com/tx00100xt/SeriousSamAlphaRemake
Source0: %{name}-%{version}.tar.gz
Group: Games

BuildRequires: sed cmake glibc-devel libstdc++-devel
BuildRequires: zlib-devel libogg-devel libvorbis-devel
BuildRequires: gcc-c++ python3-devel SDL2-devel bison flex gawk
Requires: glibc SDL2 zlib libogg libvorbis libstdc++ sed gawk (serioussamclassic or serioussamclassic-vk)   
ExclusiveArch:  %ix86 %{arm} aarch64 x86_64

%description
 Open source nodifications based on game engine version developed by Croteam for Serious Sam Classic (Windows, Linux, FreeBSD, Raspberry Pi OS)
Playing Serious Sam: The First and Second Encounter still requires a legitimate copy of
the game. You can purchase a copy from Steam or your favorite retailer.

Place .gro game files and Levels, Help folders from the Serious Sam installation to:
$HOME/.local/share/Serious-Engine/serioussam   - for Serious Sam: The First Encounter
$HOME/.local/share/Serious-Engine/serioussamse - for Serious Sam: The Second Encounter

Place Mods game files to:
$HOME/.local/share/Serious-Engine/serioussam/Mods   - for Serious Sam: The First Encounter
$HOME/.local/share/Serious-Engine/serioussamse/Mods - for Serious Sam: The Second Encounter

%prep
%autosetup

%build

# standart x86_64 build
%ifarch x86_64
echo "Fedora arch x86_64"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for previous fedora os
%ifarch %ix86
echo "Fedora arch i686"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
%endif

# for raspberry pi4
%ifarch aarch64
MODEL_PI=$(cat /proc/cpuinfo | grep Model)
if [[ $MODEL_PI = *"Raspberry Pi 4"* ]]; then echo $MODEL_PI;
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE -DRPI4=TRUE"
echo "CMAKE_ARGS $CMAKE_ARGS"
echo "Build for model Raspberry Pi4"
else
echo "CMAKE_ARGS $CMAKE_ARGS"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DUSE_I386_NASM_ASM=FALSE"
echo "Stadart aarch64 build"
fi
%endif

NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`

if [[ $NCPU -eq 0 ]]
then
  let NCPU='4'
else
  let NCPU=$NCPU
fi
echo "Cores: $NCPU"

find . -name "CMakeLists.txt" -exec sed -i 's/-march=native/-mtune=generic/g' {} +
rm -rf ./Sources/%_arch-fc38-linux
mkdir ./Sources/%_arch-fc38-linux
cd $_
cmake .. $CMAKE_ARGS -DTFE=TRUE
make ecc
make -j$NCPU
cd ../../

%install

mkdir -p %buildroot%_libdir/{serioussam,serioussam/Mods,serioussam/Mods/SSA}
ln -sf ../../libamp11lib.so %buildroot%_libdir/serioussam/Mods/SSA/libamp11lib.so
install -D -m0755 ./Sources/%_arch-fc38-linux/Debug/libGame.so %buildroot%_libdir/serioussam/Mods/SSA
install -D -m0755 ./Sources/%_arch-fc38-linux/Debug/libEntities.so %buildroot%_libdir/serioussam/Mods/SSA

%files

%_libdir/serioussam/Mods/SSA/libGame.so
%_libdir/serioussam/Mods/SSA/libEntities.so
%_libdir/serioussam/Mods/SSA/libamp11lib.so

%post

%postun

%changelog
* Mon Apr 24 2023 tx00100xt initial SPEC file.
- 

Install the dependencies that are necessary for the build (BuildRequires):

sudo dnf builddep rpmbuild/SPECS/serioussamclassic-vk.spec
  • The builddep utility itself reads the dependencies needed to build and installs the missing packages.

Preparing the source code

Now we clone the repositories to your computer:

git clone https://github.com/tx00100xt/SeriousSamClassic-VK.git serioussamclassic-vk-1.10.5
git clone https://github.com/tx00100xt/SeriousSamClassic.git serioussamclassic-xplus-1.10.5
git clone https://github.com/tx00100xt/SeriousSamAlphaRemake.git serioussamclassic-alpha-1.5.2

We remove unnecessary:

rm -rf serioussamclassic-vk-1.10.5/.gi*
rm -rf serioussamclassic-xplus-1.10.5/.gi*
rm -rf serioussamclassic-alpha-1.5.2/.gi*
rm -rf serioussamclassic-vk-1.10.5/Images
rm -rf serioussamclassic-xplus-1.10.5/Images
rm -rf serioussamclassic-alpha-1.5.2/Images

We prepare the archive and place it in the rpmbuild/SOURCES directory:

tar -czvf rpmbuild/SOURCES/serioussamclassic-vk-1.10.5.tar.gz serioussamclassic-vk-1.10.5
tar -czvf rpmbuild/SOURCES/serioussamclassic-xplus-1.10.5.tar.gz serioussamclassic-xplus-1.10.5
tar -czvf rpmbuild/SOURCES/serioussamclassic-alpha-1.5.2.tar.gz serioussamclassic-alpha-1.5.2

Checking the correctness of the SPEC files:

rpmlint  rpmbuild/SPECS/serioussamclassic-vk.spec
rpmlint  rpmbuild/SPECS/serioussamclassic-xplus.spec
rpmlint  rpmbuild/SPECS/serioussamclassic-alpha.spec

In our case, the command returned a response:

rpmbuild/SPECS/serioussamclassic.spec: W: invalid-url Source0: serioussamclassic-1.10.5.tar.gz
0 packages and 1 specfiles checked; 0 errors, 1 warnings.
  • This warning can be ignored.

Build rpm packages:

rpmbuild -ba rpmbuild/SPECS/serioussamclassic-vk.spec
rpmbuild -ba rpmbuild/SPECS/serioussamclassic-xplus.spec
rpmbuild -ba rpmbuild/SPECS/serioussamclassic-alpha.spec

If it passes without errors, we should find the RPM package in the rpmbuild/RPMS/x86_64 directory, where x86_64 is the package's architecture. Now we exit the user builder and install the packages using the dnf install command.

Modifications resources

Getting Aplha Remake Data

wget https://archive.org/download/serious-sam-alpha-remake-data/SeriousSamAlphaRemake_v1.5.tar.xz
tar xJvf SeriousSamAlphaRemake_v1.5.tar.xz -C SeriousSamClassic/SamTFE

or

for var in a b c d; do wget https://github.com/tx00100xt/serioussam-mods/raw/main/SamTFE-SSA/SeriousSamAlphaRemake_v1.5.tar.xz.parta$var; done; cat SeriousSamAlphaRemake_v1.5.tar.xz.part* > SeriousSamAlphaRemake_v1.5.tar.xz
tar -xJvpf SeriousSamAlphaRemake_v1.5.tar.xz 
mkdir ~/.local/share/Serious-Engine/serioussam/Mods
cp -vfr Mods/* ~/.local/share/Serious-Engine/serioussam/Mods
rm -rf Mods

Getting XPLUS Data

wget https://archive.org/download/sam-tfe-xplus/SamTFE-XPLUS.tar.xz

wget https://archive.org/download/sam-tse-xplus/SamTSE-XPLUS.tar.xz

or

for var in a b c; do wget https://github.com/tx00100xt/serioussam-mods/raw/main/SamTFE-XPLUS/SamTFE-XPLUS.tar.xz.parta$var; done; cat SamTFE-XPLUS.tar.xz.part* > SamTFE-XPLUS.tar.xz

for var in a b c; do wget https://github.com/tx00100xt/serioussam-mods/raw/main/SamTSE-XPLUS/SamTSE-XPLUS.tar.xz.parta$var; done; cat SamTSE-XPLUS.tar.xz.part* > SamTSE-XPLUS.tar.xz
tar -xJvpf SamTFE-XPLUS.tar.xz
cp -vfr Mods/* ~/.local/share/Serious-Engine/serioussam/Mods
rm -rf Mods
tar -xJvpf SamTSE-XPLUS.tar.xz
mkdir ~/.local/share/Serious-Engine/serioussamse/Mods
cp -vfr Mods/* ~/.local/share/Serious-Engine/serioussamse/Mods
rm -rf Mods

Game resources

To start the game, you'll need the original resurces of a licensed copy of Serious Sam: The First Encounter and Serious Sam: The Second Encounter.

Steam version.

If you have a digital copy of the game on Steam then the resources can be found in ~/.local/share/Steam/steamapps/common/Serious Sam Classic The Second Encounter/ (the default Steam game installation directory on Linux).

rsync --progress -rh "$HOME/.local/share/Steam/steamapps/common/Serious Sam Classic The First Encounter/" "$HOME/.local/share/Serious-Engine/serioussam"
rsync --progress -rh "$HOME/.local/share/Steam/steamapps/common/Serious Sam Classic The Second Encounter/" "$HOME/.local/share/Serious-Engine/serioussamse"

GOG version.

If you bought a digital on GOG, you can unpack the resources with the innoextract CLI tool. To install innoextract via your package manager, run:

sudo apt-get install innoextract

Copy files "setup_serious_sam_the_first_encounter_2.0.0.10.exe" and "setup_serious_sam_the_second_encounter_2.1.0.8.exe" to a home directory and run the following commands:

cd ~/.
innoextract --gog setup_serious_sam_the_first_encounter_2.0.0.10.exe
rm -rf app/Bin
cp -vfr app/* ~/.local/share/Serious-Engine/serioussam
rm setup_serious_sam_the_first_encounter_2.0.0.10.exe
rm -rf app
rm -rf tmp
innoextract --gog setup_serious_sam_the_second_encounter_2.1.0.8.exe
rm -rf app/Bin
cp -vfr app/* ~/.local/share/Serious-Engine/serioussamse
rm setup_serious_sam_the_first_encounter_2.0.0.10.exe
rm -rf app
rm -rf tmp
rm -rf commonappdata

Physical version.

If you bought a physical copy of the game and you have an ISO of your disk, you can unpack the resources with the any archive manager. Game resources are located in the Install directory of the disk. Just copy all content from there to directories ~/.local/share/Serious-Engine/serioussam and ~/.local/share/Serious-Engine/serioussamse, respectively, for games Serious Sam: The First Encounter and Serious Sam: The Second Encounter.

Launching the game.

To start the game type in consolet:

serioussam

or

serioussamse

You can also use the launch of the game through the menu:

menu

Clone this wiki locally