summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7ee43a3eb6ad3de1418a816398b244699dd0b0d0 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Maintainer: HurricanePootis <hurricanepootis@protonmail.com>
_pkgname=ValveResourceFormat
pkgbase=source2viewer
pkgname=(source2viewer source2viewer-cli)
pkgver=18.0
pkgrel=1
pkgdesc="Valve's Source 2 resource file format parser, decompiler, and exporter."
arch=('x86_64')
url="https://github.com/ValveResourceFormat/ValveResourceFormat"
license=('MIT' 'CC-BY-2.5')
depends=('glibc' 'gcc-libs' 'zlib' 'wine' 'bash' 'hicolor-icon-theme' 'dotnet-runtime')
makedepends=('dotnet-sdk-bin' 'gendesk')
options=(!strip !debug)
conflicts=('valveresourceformat')
replaces=('valveresourcefromat')
source=("$url/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('a2a49fcbd2478700de36a57c2f7ae444ce5d7549a173a74ed0be549d453d9faa')

prepare() {
	cd "$srcdir/$_pkgname-$pkgver"
}



build() {
	export NUGET_PACKAGES="${srcdir}/.nuget"
	export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
	export DOTNET_NOLOGO=true
	export DOTNET_CLI_TELEMETRY_OPTOUT=true

	cd "$srcdir/$_pkgname-$pkgver/CLI"
	dotnet publish -r linux-x64 --self-contained false

	cd "$srcdir/$_pkgname-$pkgver/GUI"
	dotnet publish -r win-x64 -p:EnableWindowsTargeting=true

	# Stop dotnet build server
	dotnet build-server shutdown

	cd "$srcdir"
	gendesk -n -f --pkgname=source2viewer \
	--pkgdesc="$pkgdesc" \
	--exec="${pkgname}" \
	--name="Source 2 Viewer" \
	--icon="${pkgname}" \
	--terminal=false \
	--categories="Development;Utility;Wine" \
	--custom="PrefersNonDefaultGPU=true" \
	--mimetypes="application/x-source2viewer-vpk"
}

package_source2viewer() {
	install=$pkgbase.install
	install -Dm644 "$srcdir/$_pkgname-$pkgver/GUI/bin/Release/win-x64/publish/Source2Viewer.exe" "$pkgdir/usr/lib/$pkgname/$pkgname.exe"
	install -dm755 "$pkgdir/usr/bin"
	cat >> "$pkgdir/usr/bin/$pkgname" <<-EOF
#!/usr/bin/env bash
export WINEPREFIX="\$HOME/.$pkgname/wine"
if [ ! -d "\$HOME"/.$pkgname ];
then
	mkdir -p "\$HOME/.$pkgname/wine"
	wineboot -u
fi
cd "\$HOME/.$pkgname"
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 DOTNET_BUNDLE_EXTRACT_BASE_DIR=./ wine /usr/lib/$pkgname/$pkgname.exe "\$@"
EOF
	cat >> "$pkgdir/usr/bin/$pkgname-wine" <<-EOF
#!/usr/bin/env bash
export WINEPREFIX="\$HOME/.$pkgname/wine"
if [ ! -d "\$HOME"/.$pkgname ];
then
	mkdir -p "\$HOME/.$pkgname/wine"
	wineboot -u
fi
wine "\$@"
EOF
	chmod 755 "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/bin/$pkgname-wine"

	install -Dm644 "$srcdir/$_pkgname-$pkgver/Misc/Icons/source2viewer.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/$pkgname.png"
	install -Dm644 "$srcdir/source2viewer.desktop" "$pkgdir/usr/share/applications/source2viewer.desktop"

	install -dm755 "$pkgdir/usr/share/mime/packages"
	cat >> "$pkgdir/usr/share/mime/packages/${pkgname}.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
	<mime-type type="application/x-source2viewer-vpk">
		<comment>Valve Pack File</comment>
		<icon name="source2viewer"/>
		<acronym>VPK</acronym>
		<expanded-acronym>Valve Pack File</expanded-acronym>
		<global-deleteall/>
		<glob pattern="*.vpk"/>
		<glob pattern="*.VPK"/>
	</mime-type>
</mime-info>
EOF
}

package_source2viewer-cli() {
	depends=('glibc' 'gcc-libs')
	cd "$srcdir/$_pkgname-$pkgver/CLI/bin/Release/linux-x64/publish"
	install -Dm755 Source2Viewer-CLI "$pkgdir/usr/bin/${pkgbase}-cli"
}