Package Details: mpv-discord-git 1.6.1.r0.g861bfe5-3

Git Clone URL: https://aur.archlinux.org/mpv-discord-git.git (read-only, click to copy)
Package Base: mpv-discord-git
Description: A cross-platform Discord Rich Presence integration for mpv
Upstream URL: https://github.com/tnychn/mpv-discord
Licenses: MIT
Submitter: selpast
Maintainer: selpast (mochaa)
Last Packager: selpast
Votes: 1
Popularity: 0.000000
First Submitted: 2022-03-09 10:54 (UTC)
Last Updated: 2022-03-19 20:20 (UTC)

Latest Comments

mochaa commented on 2022-03-19 16:50 (UTC) (edited on 2022-03-19 16:54 (UTC) by mochaa)

From 02ec99a00678e2bb3122f3513deb172f7aeb6728 Mon Sep 17 00:00:00 2001
From: mochaaP <git@mochaa.ws>
Date: Sun, 20 Mar 2022 00:48:39 +0800
Subject: [PATCH] go: build from source

---
 .SRCINFO               |  8 +++++--
 .gitignore             |  5 +++++
 0010-binary-path.patch | 26 +++++++++++++++++++++++
 PKGBUILD               | 48 +++++++++++++++++++++++++++---------------
 binary_path.patch      | 11 ----------
 5 files changed, 68 insertions(+), 30 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 0010-binary-path.patch
 delete mode 100644 binary_path.patch

diff --git a/.SRCINFO b/.SRCINFO
index d437a8d..5d14b0c 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,12 +1,16 @@
 pkgbase = mpv-discord-git
    pkgdesc = A cross-platform Discord Rich Presence integration for mpv
    pkgver = 1.6.1.r0.g861bfe5
-   pkgrel = 1
+   pkgrel = 2
    url = https://github.com/tnychn/mpv-discord
    arch = any
    license = MIT
+   depends = mpv
    depends = luajit
-   source = git+https://github.com/tnychn/mpv-discord.git
+   depends = go>=1.15
+   source = mpv-discord::git+https://github.com/tnychn/mpv-discord.git
+   source = 0010-binary-path.patch
    sha256sums = SKIP
+   sha256sums = 38a7d09c939e3a7914723aadc3026b45bc52a92e3e3915ec188fb1704886e02d

 pkgname = mpv-discord-git
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7334925
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*
+!.gitignore
+!.SRCINFO
+!PKGBUILD
+!*.patch
diff --git a/0010-binary-path.patch b/0010-binary-path.patch
new file mode 100644
index 0000000..2ae03bf
--- /dev/null
+++ b/0010-binary-path.patch
@@ -0,0 +1,26 @@
+diff --git a/script-opts/discord.conf b/script-opts/discord.conf
+index d69c102..f867bd5 100644
+--- a/script-opts/discord.conf
++++ b/script-opts/discord.conf
+@@ -1,7 +1,7 @@
+ key=D
+ active=yes
+ client_id=737663962677510245
+-binary_path=
++binary_path=/usr/lib/mpv-discord/mpv-discord
+ socket_path=/tmp/mpvsocket
+ use_static_socket_path=yes
+ autohide_threshold=0
+diff --git a/scripts/discord.lua b/scripts/discord.lua
+index e7d5046..5046a08 100644
+--- a/scripts/discord.lua
++++ b/scripts/discord.lua
+@@ -6,7 +6,7 @@ local options = {
+   key = "D",
+   active = true,
+   client_id = "737663962677510245",
+-  binary_path = "",
++  binary_path = "/usr/lib/mpv-discord/mpv-discord",
+   socket_path = "/tmp/mpvsocket",
+   use_static_socket_path = true,
+   autohide_threshold = 0,
diff --git a/PKGBUILD b/PKGBUILD
index e01892c..67a1b2a 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,31 +1,45 @@
 # Maintainer: selpast <selpast@pm.me>
+# Maintainer: mochaaP <aur@mochaa.ws>
+
 _pkgbase=mpv-discord
 pkgname=$_pkgbase-git
 pkgver=1.6.1.r0.g861bfe5
-pkgrel=1
+pkgrel=2
 pkgdesc='A cross-platform Discord Rich Presence integration for mpv'
-url='https://github.com/tnychn/mpv-discord'
-arch=('any')
-license=(MIT)
-depends=(luajit)
-source=(git+${url}.git)
-sha256sums=(SKIP)
+url="https://github.com/tnychn/${_pkgbase}"
+arch=($CARCH)
+license=('MIT')
+depends=('mpv' 'luajit' 'go>=1.15')
+source=(${_pkgbase}::git+${url}.git
+        '0010-binary-path.patch')
+sha256sums=('SKIP'
+            '38a7d09c939e3a7914723aadc3026b45bc52a92e3e3915ec188fb1704886e02d')
 pkgver() {
-    cd $_pkgbase
+    cd ${srcdir}/${_pkgbase}
     git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
 }

 prepare() {
-    cd $srcdir/$_pkgbase/script-opts
-    patch --forward --input="${srcdir}/../binary_path.patch"
+    cd ${srcdir}
+    patch -p1 -d ${_pkgbase} < 0010-binary-path.patch
+    mkdir -p build/
+}
+
+build() {
+    cd ${srcdir}/${_pkgbase}/${_pkgbase}
+
+    export CGO_CPPFLAGS="${CPPFLAGS}"
+    export CGO_CFLAGS="${CFLAGS}"
+    export CGO_CXXFLAGS="${CXXFLAGS}"
+    export CGO_LDFLAGS="${LDFLAGS}"
+    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
+    go build -o build/$_pkgbase .
 }

 package() {
-    cd $srcdir/$_pkgbase
-    mkdir -p $pkgdir/etc/mpv/scripts/
-    mkdir -p $pkgdir/etc/mpv/script-opts/
-    mkdir -p $pkgdir/usr/lib/mpv-discord/
-    install -Dm644 "scripts/discord.lua" "${pkgdir}/etc/mpv/scripts/"
-    install -Dm644 "script-opts/discord.conf" "${pkgdir}/etc/mpv/script-opts/"
-    install -Dm644 "bin/linux/mpv-discord" "${pkgdir}/usr/lib/mpv-discord/"
+    cd ${srcdir}/${_pkgbase}
+
+    install -Dm644 scripts/discord.lua "$pkgdir"/usr/share/mpv/scripts/discord.lua
+    install -Dm644 script-opts/discord.conf "$pkgdir"/usr/share/doc/$_pkgbase/discord.conf
+    install -Dm755 $_pkgbase/build/$_pkgbase "$pkgdir"/usr/lib/$_pkgbase/$_pkgbase
 }
diff --git a/binary_path.patch b/binary_path.patch
deleted file mode 100644
index 3cac3c5..0000000
--- a/binary_path.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- discord.conf   2022-03-09 14:21:59.949510578 +0400
-+++ discord.conf   2022-03-09 14:27:07.542841948 +0400
-@@ -1,7 +1,7 @@
- key=D
- active=yes
- client_id=737663962677510245
--binary_path=
-+binary_path=/usr/lib/mpv-discord/mpv-discord
- socket_path=/tmp/mpvsocket
- use_static_socket_path=yes
- autohide_threshold=0
-- 
2.35.1