summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f13e78ff05a3c591cf33f57ccfe7a8fa1114ae48 (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
# Maintainer: poly000 <1348292515@qq.com>

pkgname=waylyrics-git
_pkgname=waylyrics
_appname="io.github.waylyrics.Waylyrics"
pkgver=0.3.5_r21.ga7f8b8ac
pkgrel=1
pkgdesc="the furry way to show desktop lyrics (git version)"
url="https://github.com/waylyrics/waylyrics"
conflicts=('waylyrics')
provides=('waylyrics')
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('openssl' 'hicolor-icon-theme'
    # base
    'dbus' 'gcc-libs' 'glibc'
    # gtk4
    'glib2' 'cairo' 'dconf' 'gtk4'
    # restart task
    'sh'
    # i18n
    'gettext'
)
makedepends=('rust' 'git' 'jq')
optdepends=(
    'breeze-icons: better tray-icon icons'
    'xdg-desktop-portal: file dialog to import LRC'
)

source=("git+${url}.git")

sha256sums=('SKIP')

options=('!lto')

prepare() {
    cd "${_pkgname}"

    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target ${CARCH}-unknown-linux-gnu
}

pkgver() {
    cd "${_pkgname}"

    export RUSTUP_TOOLCHAIN=stable
    semver=$( cargo metadata --no-deps --format-version=1 |
        jq -r '.packages | .[0] | .version' )
    echo "${semver}_r$(git rev-list --count v${semver}..HEAD).g$(git rev-parse --short HEAD)"
}

build() {
    cd "${_pkgname}"

    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    # template files
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${_pkgname}/themes"

    cargo build --frozen --release --all-targets
}


check() {
    cd "${_pkgname}"

    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${_pkgname}/themes"
    
    cargo test --frozen --release
}

package() {
    cd "${_pkgname}"

    install -vDm644 metainfo/"${_appname}.desktop" -t "${pkgdir}/usr/share/applications/"

    install -vDm755 "target/release/${_pkgname}" -t "${pkgdir}/usr/bin/"
    install -vDm644 metainfo/"${_appname}.gschema.xml" -t "${pkgdir}/usr/share/glib-2.0/schemas/"

    install -vdm755 "${pkgdir}/usr/share/${_pkgname}/themes"
    cp -arv themes/* "${pkgdir}/usr/share/${_pkgname}/themes/"
    cp -arv res/icons "${pkgdir}/usr/share/icons"
    
    # Locale files
    (
        cd locales
        for po in $(find . -type f -name '*.po')
        do
            mkdir -p "${pkgdir}/usr/share/locale/${po#/*}" 
            msgfmt -o "${pkgdir}/usr/share/locale/${po%.po}.mo" ${po}
        done
    )

    # License
    install -vDm644 "LICENSE" -t "${pkgdir}/usr/share/licenses/${_pkgname}"
}