summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 90eb5987e94cad6ce4af8a5b04459a441f16056a (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# AUR maintainer: Swyter <swyterzone+aur@gmail.com>
# Original Linux porter: cfcohen <https://github.com/cfcohen>

# For more info and discussion about the Linux version go here:
# https://forums.taleworlds.com/index.php/topic,313683.0.html

pkgname=openbrf-git
pkgdesc='Mount&Blade resource editor by Marco Tarini.'
pkgver=2024.11.03
pkgrel=1
arch=('i686' 'x86_64' 'armv7h' 'aarch64')
url="https://forums.taleworlds.com/index.php?topic=72279.0"
license=('GPL')
depends=('qt6-base' 'glu')
replaces=('openbrf')
conflicts=('openbrf')
makedepends=('icoutils' 'git' 'coreutils') # add coreutils for nproc
install=openbrf.install
source=('git+https://github.com/Swyter/openbrf-redux')
md5sums=('SKIP')

pkgver()
{
	base_ver=$(cat    "${srcdir}/openbrf-redux/main_info.cpp" | grep applVersion\ \= | cut -d'"' -f2)
	date_ver=$(TZ=UTC git -C "${srcdir}/openbrf-redux" show -s --date=format-local:'%Y.%m.%d' --format=%cd HEAD)
	git_hash=$(TZ=UTC git -C "${srcdir}/openbrf-redux" rev-parse --short HEAD)
	echo "${date_ver}"
}

build()
{
	cd "openbrf-redux"

	# extract all the Windows icon sub-images, we can later grab the 256px
	# version and use it in Linux as XDG PNG icon.
	icotool -x openBrf.ico

	# build it as fast as possible, but leaving a free CPU core for other stuff!
	qmake6 -makefile openBrf.pro
	make -j $[ (n = `nproc` - 1) < 1 ? 1 : n ] # swy: don't make the thread count zero (-j 0) when there's only one available core (due to the system-threads - 1 thing)
}

package()
{
	mkdir -p "${pkgdir}/opt/openbrf"

	install -D -m711 -s "${srcdir}/openbrf-redux/openBrf"                    "${pkgdir}/opt/openbrf/openbrf"
	install -D -m644    "${srcdir}/openbrf-redux/_build/carry_positions.txt" "${pkgdir}/opt/openbrf/carry_positions.txt"
	install -D -m644    "${srcdir}/openbrf-redux/_build/reference.brf"       "${pkgdir}/opt/openbrf/reference.brf"

	mkdir -p "${pkgdir}/usr/bin"

	echo 'env LC_NUMERIC=C /opt/openbrf/openbrf "$@"' > "${pkgdir}/usr/bin/openbrf"
	chmod 755 "${pkgdir}/usr/bin/openbrf"

	install -D -m644    "${srcdir}/openbrf-redux/openBrf_6_256x256x32.png" "${pkgdir}/usr/share/pixmaps/openbrf.png"
	install -D -m644    "${srcdir}/openbrf-redux/openBrf_6_256x256x32.png" "${pkgdir}/opt/openbrf/openbrf.png"

	# add a shortcut that handles application/x-openbrf files
	mkdir -p "${pkgdir}/usr/share/applications"
	cat <<EOF > "${pkgdir}/usr/share/applications/openbrf.desktop"
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=OpenBRF Redux
Comment=Mount&Blade resource editor by Marco Tarini and Swyter.
Exec=openbrf
Icon=openbrf
MimeType=application/x-openbrf
Categories=Graphics
EOF

	# add our custom mime type for application/x-openbrf => *.brf files
	mkdir -p    "${pkgdir}/usr/share/mime/packages"
        cat <<EOF > "${pkgdir}/usr/share/mime/packages/openbrf.xml"
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-openbrf">
  <generic-icon name="openbrf"/>
  <acronym>BRF</acronym>
  <comment>Mount&amp;Blade Binary Resource File</comment>
  <comment xml:lang="es">Recurso binario de Mount&amp;Blade</comment>
  <glob pattern="*.brf"/>
</mime-type>
</mime-info>
EOF
}