summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8b5bb69215a9db651c20b1427428e8366229a0d6 (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
# Maintainer: Integral <integral@member.fsf.org>

pkgname=waylyrics
pkgver=0.3.21
_opencc_rust_ver=1.1.19
pkgrel=4
pkgdesc="the furry way to show desktop lyrics"
arch=('x86_64' 'aarch64' 'riscv64')
url="https://github.com/${pkgname}/${pkgname}"
license=("MIT")
depends=(
	"openssl" "dbus" "glibc" "libgcc" "glib2" "cairo" "dconf" "gtk4" "opencc"
)
makedepends=("git" "cargo" "gettext")
optdepends=(
	"breeze-icons: better tray-icon icons"
	"xdg-desktop-portal: file dialog to import LRC"
)
source=("git+${url}#tag=v${pkgver}"
	"git+https://github.com/magiclen/opencc-rust.git#tag=v${_opencc_rust_ver}")
sha256sums=('365f4c1cdd94a6eb76d5db68ed1e1405429181cd6d60af5c6d251c9a148d07eb'
            'e707c10ee848d597f009796ca2be9676a3d0dbb12fde90aa47d00def176280fb')
options=('!lto')

_features=(--features opencc
           --features action-event
           --features offline-test)

prepare() {
	sed -i '/MAX_VERSION/d' opencc-rust/build.rs

	cd "${pkgname}/"
	echo -e "\n[patch.crates-io]\nopencc-rust = { path = '../opencc-rust' }" >> Cargo.toml

	export RUSTUP_TOOLCHAIN=stable
	cargo fetch --target host-tuple
}

build() {
	cd "${pkgname}/"
	export RUSTUP_TOOLCHAIN=stable
	export CARGO_TARGET_DIR=target
	export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${pkgname}/themes/"
	# --all-features introduced dbus/vendored feature, we prefer system dbus here.
	cargo build --release --frozen "${_features[@]}"
}

check() {
	cd "${pkgname}/"
	export RUSTUP_TOOLCHAIN=stable
	export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${pkgname}/themes/"
	cargo test --frozen "${_features[@]}"
}

package() {
	depends+=("hicolor-icon-theme")

	cd "${pkgname}/"
	local _app_id=io.github.waylyrics.Waylyrics

	install -Dm755 "target/release/${pkgname}" -t "${pkgdir}/usr/bin/"
	install -Dm644 "metainfo/${_app_id}.desktop" -t "${pkgdir}/usr/share/applications/"
	install -Dm644 "metainfo/${_app_id}.gschema.xml" -t "${pkgdir}/usr/share/glib-2.0/schemas/"
	install -Dm644 "metainfo/${_app_id}.metainfo.xml" -t "${pkgdir}/usr/share/metainfo/"
	install -Dm644 themes/*.css -t "${pkgdir}/usr/share/${pkgname}/themes/"

	for locale in locales/*/LC_MESSAGES/waylyrics.po; do
		echo "Installing locale $locale..."
		mo=${locale/#locales\//} # */LC_MESSAGES/waylyrics.po
		mo=${mo/%.po/.mo}        # */LC_MESSAGES/waylyrics.mo
		msgfmt "${locale}" -o - | install -Dm644 /dev/stdin "${pkgdir}/usr/share/locale/${mo}"
	done

	install -Dm644 "res/icons/hicolor/scalable/apps/${_app_id}.svg" -t "${pkgdir}/usr/share/icons/hicolor/scalable/apps/"
	install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}