summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7fed29498ab82e327db909a176b6b6afb13a12a6 (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
# Maintainer: Patrick Northon <northon_patrick3@yahoo.ca>

: ${_install_path:=opt}

_pkgname='hacki'
pkgname=${_pkgname}
_pkgreponame='Hacki'
pkgver=2.9.7
pkgrel=1
pkgdesc='A Hacker News reader.'
url='https://github.com/Livinglist/Hacki'
arch=('x86_64')
license=('GPL3')
depends=(
	'gtk3'
	'gstreamer'
	'gst-plugins-base-libs'
	'libsecret')
makedepends=('fvm' 'git' 'patchelf')
source=("git+${url}.git#tag=v${pkgver}")
sha256sums=('eb0f5c3f7fce5cb981d0f87a1023e0e6d27b4314bd7166e4e65977efeb90f3b9')

_srcdir="${_pkgreponame}"
_engine_version=3.24.5

build() {
	export FVM_CACHE_PATH="$SRCDEST/fvm-cache"

	cd "${_srcdir}"
	fvm install "$_engine_version"
	fvm use -f "$_engine_version"

	fvm flutter create --project-name='hacki' --platforms='linux' --no-pub --no-overwrite .

	fvm flutter --disable-analytics

	fvm flutter --no-version-check pub get
	fvm flutter build linux --release
}

package() {
	# Make install dir
	install -dm755 "${pkgdir}/${_install_path}/${_pkgname}/"

	# License
	cd "${_srcdir}"
	install -Dm644 'LICENSE' -t "${pkgdir}/usr/share/licenses/${_pkgname}"

	# Executable install
	cd 'build/linux/x64/release/bundle'
	local execfile="$(find . -mindepth 1 -maxdepth 1 -type f -perm /111)"
	install -Dm755 \
		"${execfile}" \
		"${pkgdir}/${_install_path}/${_pkgname}/${_pkgname}"

	# Folders install
	cp -r 'lib/' "${pkgdir}/${_install_path}/${_pkgname}/"
	cp -r 'data/' "${pkgdir}/${_install_path}/${_pkgname}/"

	# Fix runpath
	patchelf --set-rpath '$ORIGIN/lib' "$pkgdir/${_install_path}/$_pkgname/${execfile}"
	for i in "$pkgdir/${_install_path}/$_pkgname/lib"/*.so; do
		[ -z "$(patchelf --print-rpath "$i")" ] && continue
		patchelf --set-rpath '$ORIGIN' "$i"
	done

	# Symlink executable
	install -dm755 "${pkgdir}/usr/bin"
	ln -s \
		"/${_install_path}/${_pkgname}/${_pkgname}" \
		"${pkgdir}/usr/bin/${_pkgname}"

	# Icon for .desktop
	install -Dm644 \
		"${srcdir}/${_srcdir}/build/flutter_assets/assets/images/hacki_icon.png" \
		"${pkgdir}/usr/share/icons/${_pkgname}.png"

	# .desktop file
	install -Dm644 <(cat << EOF
[Desktop Entry]
Type=Application
Name=Hacki
Exec=/usr/bin/${_pkgname}
Comment=${pkgdesc}
Categories=Internet
Icon=${_pkgname}
EOF
	) "${pkgdir}/usr/share/applications/${_pkgname}.desktop"
}