summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c6ca64e685da1c7bd2363f60a098684f088a072b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Maintainer: Pierce Thompson <pierce at insprill dot net>
# Contributor: Mattias Giese <mattias.giese@posteo.net>

pkgname=beammp-server
_pkgname=BeamMP-Server
pkgver=3.9.3
pkgrel=1
pkgdesc='Server for the multiplayer mod BeamMP for BeamNG.drive'
arch=('x86_64' 'aarch64')
url='https://github.com/BeamMP/BeamMP-Server'
license=('AGPL-3.0-only')
# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/scripts/debian-13/4-install-runtime-deps.sh
depends=('lua53' 'curl')
# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/scripts/debian-13/1-install-deps.sh
makedepends=('zip' 'unzip' 'tar' 'git' 'gcc' 'cmake' 'make' 'ninja')
provides=($pkgname)
source=(
	"git+https://github.com/BeamMP/${_pkgname}.git#tag=v${pkgver}" 
	'sol2-fix-emplace.patch'
	'beammp-server.service'
	'beammp-server.sysusers'
	'beammp-server.tmpfiles'
)
sha256sums=(
	'SKIP'
	'5c6197d0534317bea578597fdec2d84ca912812eb4c82a00a9184916ae038cdd'
	'd5bd5f83e818c5174f25be79443078cefae5a632a6f72f7915c14e98ef4f98fe'
	'7e8d591152d3de0cea273b6aa212ebafab906f2f76126ff3fac73dd4d31cbfd5'
	'0a8ec12961b98c3447a434b794f9c982b4cc412176087730490d65dbc487f13a'
)

prepare() {
	cd "$srcdir/${_pkgname}"
	git submodule update --init --recursive

	# The two commands below are copied from the configure script.
	# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/scripts/debian-13/2-configure.sh
	# The `-DCMAKE_TOOLCHAIN_FILE` param is copied from the workflow file.
	# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/.github/workflows/linux.yml#L61
	./vcpkg/bootstrap-vcpkg.sh
	cmake . -B bin -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" -DBeamMP-Server_ENABLE_LTO=ON

	# Patch sol2 to fix compile errors with GCC 15 on the older version we're pinned to.
	# We ignore any errors since it won't apply during a rebuild
	# https://github.com/ThePhD/sol2/commit/d805d027e0a0a7222e936926139f06e23828ce9f
	_deps="$srcdir/${_pkgname}/bin/vcpkg_installed/$([[ $CARCH == x86_64 ]] && echo x64-linux || echo arm64-linux)"
	patch -Np1 -d "$_deps" -i "$srcdir/sol2-fix-emplace.patch" || true
}

build() {
	cd "$srcdir/${_pkgname}"
	# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/scripts/debian-13/3-build.sh
	cmake --build bin --parallel -t BeamMP-Server
	objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug
	objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug
	strip -s bin/BeamMP-Server
}

test() {
	cd "$srcdir/${_pkgname}"
	# https://github.com/BeamMP/BeamMP-Server/blob/3befc84f00b33e47663bef19cdee9d5e4d325dea/.github/workflows/linux.yml#L79
	cmake --build bin --parallel -t BeamMP-Server-tests
	./bin/BeamMP-Server-tests
}

package() {
	cd "$srcdir/${_pkgname}"
	install -Dm755 "$srcdir/$_pkgname/bin/$_pkgname" "$pkgdir/usr/bin/$_pkgname"
	install -Dm644 "$srcdir/$pkgname.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service"
	install -Dm644 "$srcdir/$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
	install -Dm644 "$srcdir/$pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
}