summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1414a004c947ddf308fd3ed6d86c86c245e2b30c (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
# Maintainer: draxaris1010 <axel.dezittere[at]gmail[dot]com>
# Contributor: FirstAirBender <noblechuk5[at]gmail[dot]com>
# Contributor: Luis Martinez <luis dot martinez at disroot dot org>
# Contributor: Philip Goto <philip.goto@gmail.com>

pkgname=librespot-avahi
_pkgname=librespot
pkgver=0.6.0
pkgrel=1
pkgdesc='Open source client library for Spotify'
arch=('x86_64')
url='https://github.com/librespot-org/librespot'
license=('MIT')
conflicts=('librespot')
provides=('librespot')
depends=(
    'alsa-lib'
)
makedepends=(
    'cargo'
)
optdepends=(
    'gst-plugins-base: Audio playback using GStreamer'
    'gst-plugins-good: Audio playback using GStreamer'
    'jack2: Audio playback using JACK'
    'libpulse: Audio playback using PulseAudio'
    'portaudio: Audio playback using PortAudio'
    'sdl2: Audio playback using SDL2'
    'avahi: Use system mDNS daemon for discovery'
)
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('9ec881edb11e37d31a2b41dd30d56a3413445eedb720e1b0d278567dccfca8fc')

prepare() {
    cd "$_pkgname-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    export PKG_FEATURES=alsa-backend,with-libmdns
    declare -A PKG_FEATURE_MAP=(
        [jack2]='jackaudio-backend'
        [gst-plugins-good]='gstreamer-backend'
        [gst-plugins-base]='gstreamer-backend'
        [sdl2]='sdl-backend'
        [libpulse]='pulseaudio-backend'
        [portaudio]='portaudio-backend'
        [avahi]='with-avahi'
    )
    for pkg in "${!PKG_FEATURE_MAP[@]}"; do
        if [[ -n `pacman -Qsq "$pkg" | sed -E "/^$pkg\$/b; /.+/d"` ]]; then
            export PKG_FEATURES="$PKG_FEATURES,${PKG_FEATURE_MAP[$pkg]}"
        fi 2>/dev/null >&2
    done
    echo >&2 "Preparing $pkgname-$pkgver with the following features: $PKG_FEATURES"
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    cd "$_pkgname-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    export CFLAGS="$CFLAGS -ffat-lto-objects"
    export CARGO_BUILD_JOBS="$(nproc --ignore $(($(nproc) / 2)))"
    echo >&2 "Building $pkgname-$pkgver with the following features: $PKG_FEATURES"
    cargo build --release --frozen --no-default-features --features "$PKG_FEATURES"
}

# check() {
#   cd "$pkgname-$pkgver"
#     export RUSTUP_TOOLCHAIN=stable
#     cargo test --frozen --no-default-features --features "$PKG_FEATURES"
# }

package() {
    cd "$_pkgname-$pkgver"
    install -Dvm0755 -t "$pkgdir/usr/bin/" "target/release/$_pkgname"
    install -Dvm644 "contrib/$_pkgname.service" -t "$pkgdir/usr/lib/systemd/system/"
    install -Dvm644 "contrib/$_pkgname.user.service" "$pkgdir/usr/lib/systemd/user/$_pkgname.service"
    install -Dvm644 LICENSE -t "$pkgdir/usr/share/licenses/$_pkgname/"
}