From ee6453c4beadf5afd04b10c8a251f1374bbfb03d Mon Sep 17 00:00:00 2001
From: Aaron LI <aly@aaronly.me>
Date: Wed, 23 Sep 2020 09:25:38 -0700
Subject: [PATCH] Bring back multimedia/quodlibet with latest version 4.3.0

* Bring back multimedia/quodlibet and update to the latest version
  4.3.0 and Python 3.6+
* Take maintainership as this port hasn't been updated by its original
  maintainer for years
* Remove old configure options since they're just optional runtime
  dependencies and don't affect the build
* Add the new configure option 'PULSEAUDIO' to make QuodLibet correctly
  works with PulseAudio (require the 'pulse' Gstreamer plugin)
* Add a 'pkg-message' to mention those optional runtime dependencies so
  that users can choose and know what to install
---
 multimedia/quodlibet/Makefile                 | 37 +++++++++++++++++++
 multimedia/quodlibet/distinfo                 |  3 ++
 multimedia/quodlibet/files/patch-gdist_man.py | 11 ++++++
 .../patch-quodlibet_player_gstbe_util.py      | 20 ++++++++++
 multimedia/quodlibet/pkg-descr                |  6 +++
 multimedia/quodlibet/pkg-message              | 22 +++++++++++
 6 files changed, 99 insertions(+)
 create mode 100644 multimedia/quodlibet/Makefile
 create mode 100644 multimedia/quodlibet/distinfo
 create mode 100644 multimedia/quodlibet/files/patch-gdist_man.py
 create mode 100644 multimedia/quodlibet/files/patch-quodlibet_player_gstbe_util.py
 create mode 100644 multimedia/quodlibet/pkg-descr
 create mode 100644 multimedia/quodlibet/pkg-message

diff --git a/multimedia/quodlibet/Makefile b/multimedia/quodlibet/Makefile
new file mode 100644
index 000000000000..b384bfd376b7
--- /dev/null
+++ b/multimedia/quodlibet/Makefile
@@ -0,0 +1,37 @@
+# Created by: Byung-Hee HWANG <bh@izb.knu.ac.kr>
+# $FreeBSD$
+
+PORTNAME=	quodlibet
+DISTVERSION=	4.3.0
+CATEGORIES=	multimedia audio python
+MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/release-${DISTVERSION}/
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	aly@aaronly.me
+COMMENT=	Music library/editor/player written in Python
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}cairo>0:graphics/py-cairo@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}dbus>0:devel/py-dbus@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}feedparser>0:textproc/py-feedparser@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}mutagen>=1.34:audio/py-mutagen@${PY_FLAVOR} \
+		${LOCALBASE}/libexec/notification-daemon:deskutils/notification-daemon
+LIB_DEPENDS=	libsoup-2.4.so:devel/libsoup
+
+USES=		desktop-file-utils gettext gnome python:3.6+ shebangfix
+SHEBANG_FILES=	exfalso.py operon.py quodlibet.py
+USE_PYTHON=	distutils autoplist
+USE_GNOME=	gtk30 pygobject3
+USE_GSTREAMER1=	good
+
+NO_ARCH=	yes
+CONFLICTS_INSTALL=	${PORTNAME}
+
+OPTIONS_DEFINE=		PULSEAUDIO
+
+PULSEAUDIO_DESC=	Support PulseAudio
+PULSEAUDIO_USE=		GSTREAMER1=pulse
+
+.include <bsd.port.mk>
diff --git a/multimedia/quodlibet/distinfo b/multimedia/quodlibet/distinfo
new file mode 100644
index 000000000000..620d74df343e
--- /dev/null
+++ b/multimedia/quodlibet/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1600701937
+SHA256 (quodlibet-4.3.0.tar.gz) = a2e5c027a69f138364c57e4adf72f5c08c235bc09a4bcd8f668e2847d76427e0
+SIZE (quodlibet-4.3.0.tar.gz) = 4752295
diff --git a/multimedia/quodlibet/files/patch-gdist_man.py b/multimedia/quodlibet/files/patch-gdist_man.py
new file mode 100644
index 000000000000..e27a5c15a9e0
--- /dev/null
+++ b/multimedia/quodlibet/files/patch-gdist_man.py
@@ -0,0 +1,11 @@
+--- gdist/man.py.orig	2019-10-05 20:22:11 UTC
++++ gdist/man.py
+@@ -54,7 +54,7 @@ class install_man(Command):
+         )
+ 
+         if self.mandir is None:
+-            self.mandir = os.path.join(self.install_dir, 'share', 'man')
++            self.mandir = os.path.join(self.install_dir, 'man')
+ 
+         self.man_pages = self.distribution.man_pages
+         for man_page in self.man_pages:
diff --git a/multimedia/quodlibet/files/patch-quodlibet_player_gstbe_util.py b/multimedia/quodlibet/files/patch-quodlibet_player_gstbe_util.py
new file mode 100644
index 000000000000..e003d75057ed
--- /dev/null
+++ b/multimedia/quodlibet/files/patch-quodlibet_player_gstbe_util.py
@@ -0,0 +1,20 @@
+--- quodlibet/player/gstbe/util.py.orig	2020-10-15 13:54:35 UTC
++++ quodlibet/player/gstbe/util.py
+@@ -28,14 +28,9 @@ def pulse_is_running():
+         element.set_state(Gst.State.NULL)
+         return res != Gst.StateChangeReturn.FAILURE
+ 
+-    # In case we don't have it call the pulseaudio binary
+-    try:
+-        subprocess.check_call(["pulseaudio", "--check"])
+-    except subprocess.CalledProcessError:
+-        return False
+-    except OSError:
+-        return False
+-    return True
++    # NOTE: Don't check with 'pulseaudio --check' because it can't guarantee
++    #       Gstreamer works with PA (e.g., 'pulsesink' not installed).
++    return False
+ 
+ 
+ def link_many(elements):
diff --git a/multimedia/quodlibet/pkg-descr b/multimedia/quodlibet/pkg-descr
new file mode 100644
index 000000000000..ea237d587aef
--- /dev/null
+++ b/multimedia/quodlibet/pkg-descr
@@ -0,0 +1,6 @@
+Quod Libet is a music management program.  It provides several different
+ways to view your audio library, as well as support for Internet radio
+and audio feeds.  It has extremely flexible metadata tag editing and
+searching capabilities.
+
+WWW: https://quodlibet.readthedocs.org/
diff --git a/multimedia/quodlibet/pkg-message b/multimedia/quodlibet/pkg-message
new file mode 100644
index 000000000000..09d2fd394612
--- /dev/null
+++ b/multimedia/quodlibet/pkg-message
@@ -0,0 +1,22 @@
+[
+{ type: install
+  message: <<EOM
+Consider to install the following ports to support additional audio formats:
+
+* multimedia/gstreamer1-plugins-faad : AAC audio support
+* multimedia/gstreamer1-plugins-flac : FLAC audio support
+* multimedia/gstreamer1-plugins-mpg123 : MP3 audio support
+* multimedia/gstreamer1-plugins-ogg : Ogg audio support
+* multimedia/gstreamer1-plugins-speex : Speex audio support
+* multimedia/gstreamer1-plugins-vorbis : Vorbis audio support
+* multimedia/gstreamer1-plugins-wavpack : WAV audio support
+* multimedia/gstreamer1-libav : Many more audio (e.g., WMA) support
+
+Some Quodlibet plugins require additional ports to be installed:
+
+* audio/py-musicbrainzngs : for Musicbrainz plugin
+* devel/py-pyinotify : for audio library update plugin
+* www/webkit2-gtk3 : for lyrics window plugin
+EOM
+}
+]
-- 
2.28.0

