summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: de5527d31dd2d254eecad888ccf1b1790a66492e (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
pkgname=waylyrics
pkgver=0.3.8
pkgrel=2
pkgdesc="the furry way to show desktop lyrics"
arch=("x86_64")
url="https://waylyrics.github.io/waylyrics/waylyrics/"
license=("MIT")
depends=(
    "openssl" "dbus" "gcc-libs" "glibc" "glib2" "cairo" "dconf" "gtk4" "gettext"
    "opencc"
)
makedepends=(
    "rust"
)
source=(
    "$pkgname-$pkgver.tar.gz::https://github.com/waylyrics/waylyrics/archive/refs/tags/v$pkgver.tar.gz"
)
sha256sums=('7bd25ea50c55dbb294b7f903281bc597b82af473a482b88004692250b2889fd8')
options=("!lto")
optdepends=('xdg-desktop-portal: file dialog to import LRC')

prepare() {
    cd "$srcdir/$pkgname-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}
build() {
    cd "$srcdir/$pkgname-$pkgver"
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/$pkgname/themes"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo build --release --frozen --all-targets --all-features
}
check() {
    cd "$srcdir/$pkgname-$pkgver"
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/$pkgname/themes"
    export RUSTUP_TOOLCHAIN=stable
    cargo test --release --frozen --all-features
}
package() {
    depends+=("hicolor-icon-theme")
    local _id=io.github.waylyrics.Waylyrics
    cd "$srcdir/$pkgname-$pkgver"
    install -Dm755 target/release/$pkgname "$pkgdir/usr/bin/$pkgname"
    install -Dm644 metainfo/$_id.desktop \
        "$pkgdir/usr/share/applications/$_id.desktop"
    install -Dm644 metainfo/$_id.gschema.xml \
        "$pkgdir/usr/share/glib-2.0/schemas/$_id.gschema.xml"
    install -Dm644 metainfo/$_id.metainfo.xml \
        "$pkgdir/usr/share/metainfo/$_id.metainfo.xml"
    local theme locale
    for theme in themes/*.css
    do
        echo "Installing theme $theme..."
        install -Dm644 "$theme" "$pkgdir/usr/share/$pkgname/$theme"
    done
    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/$_id.svg \
        "$pkgdir/usr/share/icons/hicolor/scalable/apps/$_id.svg"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}