%global goipath codeberg.org/gbcox/beetbrainz %global forgeurl https://codeberg.org/gbcox/beetbrainz %global commit bb1da8b397fc1e7e3da3f2b52518279ce54bec85 %define debug_package %{nil} # Disables debuginfo package, common for Go binaries %global golicenses LICENSE.md %global godocs README.md %global common_description %{expand: Beetbrainz - Webhook integration for Listenbrainz scrobbling.} %gometa -L -f Name: %{goname} Version: 1.0.6 Release: %autorelease Summary: Beetbrainz - Webhook integration for Listenbrainz scrobbling License: GPL-3.0-or-later URL: %{gourl} Source0: %{gosource} Source1: %{name}.rpmlintrc BuildRequires: golang > 1.24 BuildRequires: systemd Requires: beets %description %{summary} Beetbrainz is a simple Go-based webhook listener that integrates various media server playback events (Plex, Emby, Tautulli) with ListenBrainz to scrobble music playback. It uses Beets.io for enriched metadata where available. %gopkg %prep %goprep %build export GOFLAGS="-mod=readonly" export LDFLAGS="-s -w \ -X main.appVersion=%{version} \ -X main.commit=%{commit} \ -X main.shortCommit=%{shortcommit} \ -linkmode external -extldflags \"-pie -fPIE -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes\"" %gobuild -o beetbrainz . %check %gocheck %install %gopkginstall # Create destination directories install -v -d -m 755 %{buildroot}%{_bindir} install -v -d -m 755 %{buildroot}%{_unitdir} install -v -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig/ # Install the compiled binary install -v -m 755 beetbrainz %{buildroot}%{_bindir}/beetbrainz # GENERATE and install the systemd service file directly cat > %{buildroot}%{_unitdir}/beetbrainz.service << EOF [Unit] Description=Beetbrainz Webhook Scrobbler Documentation=%{url} Wants=network-online.target After=network-online.target [Service] EnvironmentFile=/etc/sysconfig/beetbrainz ExecStart=%{_bindir}/beetbrainz StandardOutput=journal StandardError=journal SyslogIdentifier=beetbrainz Restart=always RestartSec=5s [Install] WantedBy=multi-user.target EOF chmod 644 %{buildroot}%{_unitdir}/beetbrainz.service # Ensure correct permissions # Install the environment file template cat > %{buildroot}%{_sysconfdir}/sysconfig/beetbrainz << EOF # Configuration for beetbrainz # Place your ListenBrainz API tokens here. Format: USER1:TOKEN1,USER2:TOKEN2 # Example: USER_TOKENS="johndoe:xyz123abc,janedoe:def456ghi" USER_TOKENS="" # Beets.io IP and Port for metadata enrichment BEETS_IP="127.0.0.1" BEETS_PORT="8337" # IP address and Port for Beetbrainz to listen on BEETBRAINZ_IP="127.0.0.1" BEETBRAINZ_PORT="5000" EOF chmod 640 %{buildroot}%{_sysconfdir}/sysconfig/beetbrainz %post %systemd_post beetbrainz.service %preun %systemd_preun beetbrainz.service %postun %systemd_postun beetbrainz.service %files %config(noreplace) %{_sysconfdir}/sysconfig/beetbrainz %{_bindir}/beetbrainz %{_unitdir}/beetbrainz.service %gopkgfiles %changelog %autochangelog