git: d76542d7123a - main - www/persepolis: new port had been added (+)

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Tue, 01 Mar 2022 11:15:37 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d76542d7123a7dbcbf9ca31b143639571b69ce1c

commit d76542d7123a7dbcbf9ca31b143639571b69ce1c
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-03-01 11:13:46 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-03-01 11:13:46 +0000

    www/persepolis: new port had been added (+)
    
    Persepolis is a download manager and GUI for Aria2 which is written
    in Python using Qt and other components.  Some functionality had been
    reimplemented to avoid pulling needless or heavy dependencies.
    
    WWW: https://persepolisdm.github.io/
---
 www/Makefile                                       |  1 +
 www/persepolis/Makefile                            | 28 +++++++++++++++
 www/persepolis/distinfo                            |  3 ++
 .../files/patch-persepolis_scripts_bubble.py       | 42 ++++++++++++++++++++++
 .../files/patch-persepolis_scripts_persepolis.py   | 24 +++++++++++++
 .../files/patch-persepolis_scripts_play.py         | 35 ++++++++++++++++++
 www/persepolis/files/patch-setup.py                | 40 +++++++++++++++++++++
 www/persepolis/pkg-descr                           |  9 +++++
 8 files changed, 182 insertions(+)

diff --git a/www/Makefile b/www/Makefile
index d0aed03de59d..c88826e2c74f 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -1376,6 +1376,7 @@
     SUBDIR += pecl-yaf
     SUBDIR += pecl-yar
     SUBDIR += perlbal
+    SUBDIR += persepolis
     SUBDIR += pglogd
     SUBDIR += phalcon
     SUBDIR += phalcon4
diff --git a/www/persepolis/Makefile b/www/persepolis/Makefile
new file mode 100644
index 000000000000..b0ece16d2c01
--- /dev/null
+++ b/www/persepolis/Makefile
@@ -0,0 +1,28 @@
+# Created by: Alexey Dokuchaev <danfe@FreeBSD.org>
+
+PORTNAME=	persepolis
+PORTVERSION=	3.2.0
+CATEGORIES=	www net ftp
+
+MAINTAINER=	danfe@FreeBSD.org
+COMMENT=	Graphical download manager (GUI for Aria2)
+
+LICENSE=	GPLv3+
+
+BUILD_DEPENDS=	aria2c:www/aria2 ffmpeg:multimedia/ffmpeg \
+		${PYTHON_PKGNAMEPREFIX}psutil>0:sysutils/py-psutil@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}setproctitle>0:devel/py-setproctitle@${PY_FLAVOR} \
+		${LOCALBASE}/share/sounds/freedesktop/stereo/complete.oga:audio/freedesktop-sound-theme
+RUN_DEPENDS:=	${BUILD_DEPENDS} \
+		${PYTHON_PKGNAMEPREFIX}PyOgg>0:audio/py-pyogg@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}dbus>0:devel/py-dbus@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR}
+
+USES=		pyqt:5 python
+USE_PYTHON=	autoplist distutils noflavors
+USE_PYQT=	pyqt5
+USE_GITHUB=	yes
+GH_ACCOUNT=	${PORTNAME}dm
+
+.include <bsd.port.mk>
diff --git a/www/persepolis/distinfo b/www/persepolis/distinfo
new file mode 100644
index 000000000000..98490ad66451
--- /dev/null
+++ b/www/persepolis/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1568666738
+SHA256 (persepolisdm-persepolis-3.2.0_GH0.tar.gz) = d27cf2a4e02b0fbe79b1903ca0ab32a6007493d51a8201443a8febb566750acd
+SIZE (persepolisdm-persepolis-3.2.0_GH0.tar.gz) = 665662
diff --git a/www/persepolis/files/patch-persepolis_scripts_bubble.py b/www/persepolis/files/patch-persepolis_scripts_bubble.py
new file mode 100644
index 000000000000..3f31210fcfb2
--- /dev/null
+++ b/www/persepolis/files/patch-persepolis_scripts_bubble.py
@@ -0,0 +1,42 @@
+--- persepolis/scripts/bubble.py.orig	2019-09-16 20:45:38 UTC
++++ persepolis/scripts/bubble.py
+@@ -29,6 +29,8 @@ if os_type == 'Darwin':
+ elif os_type == 'Windows':
+     from persepolis.scripts.windows_notification import Windows_Notification
+ 
++else: import dbus
++
+ # notifySend use notify-send program in user's system for sending notifications
+ # and use playNotification function in play.py file for playing sound
+ # notifications
+@@ -68,7 +70,7 @@ def notifySend(message1, message2, time, sound, parent
+ 
+     enable_notification = persepolis_setting.value('settings/notification')
+ 
+-    time = str(time)
++    time = int(time)
+     message1 = str(message1)
+     message2 = str(message2)
+ 
+@@ -77,14 +79,13 @@ def notifySend(message1, message2, time, sound, parent
+         parent.system_tray_icon.showMessage(message1, message2, 0, 10000)
+     else:
+         if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD':
+-            subprocess.Popen(['notify-send', '--icon', 'persepolis',
+-                              '--app-name', 'Persepolis Download Manager',
+-                              '--expire-time', time,
+-                              message1, message2],
+-                             stderr=subprocess.PIPE,
+-                             stdout=subprocess.PIPE,
+-                             stdin=subprocess.PIPE,
+-                             shell=False)
++            service = 'org.freedesktop.Notifications'
++            notify_iface = dbus.Interface(
++              dbus.SessionBus().get_object(service,
++              '/%s' % service.replace('.', '/')), service)
++            notify_iface.Notify('Persepolis Download Manager', 0,
++              '/usr/local/share/pixmaps/persepolis.svg', message1, message2,
++              [], {'urgency': 0}, time)
+ 
+         elif os_type == 'Darwin':
+             notifyMac("Persepolis Download Manager", message1, message2)
diff --git a/www/persepolis/files/patch-persepolis_scripts_persepolis.py b/www/persepolis/files/patch-persepolis_scripts_persepolis.py
new file mode 100644
index 000000000000..a699afca58ea
--- /dev/null
+++ b/www/persepolis/files/patch-persepolis_scripts_persepolis.py
@@ -0,0 +1,24 @@
+--- persepolis/scripts/persepolis.py.orig	2019-09-16 20:45:38 UTC
++++ persepolis/scripts/persepolis.py
+@@ -42,9 +42,6 @@ if os_type == 'Linux' or os_type == 'FreeBSD' or os_ty
+ 
+ # initialization
+ 
+-# find home address
+-home_address = os.path.expanduser("~")
+-
+ # persepolis config_folder
+ config_folder = determineConfigFolder()
+ 
+@@ -58,10 +55,8 @@ global lock_file_validation
+ 
+ if os_type != 'Windows':
+     import fcntl
+-    user_name_split = home_address.split('/')
+-    user_name = user_name_split[2]
+ # persepolis lock file
+-    lock_file = '/tmp/persepolis_exec_' + user_name + '.lock'
++    lock_file = '/tmp/persepolis_exec_' + os.getlogin() + '.lock'
+ 
+ # create lock file
+     fp = open(lock_file, 'w')
diff --git a/www/persepolis/files/patch-persepolis_scripts_play.py b/www/persepolis/files/patch-persepolis_scripts_play.py
new file mode 100644
index 000000000000..ddb2f02a6424
--- /dev/null
+++ b/www/persepolis/files/patch-persepolis_scripts_play.py
@@ -0,0 +1,35 @@
+--- persepolis/scripts/play.py.orig	2019-09-16 20:45:38 UTC
++++ persepolis/scripts/play.py
+@@ -16,6 +16,8 @@ from persepolis.scripts import logger
+ from PyQt5.QtCore import QSettings
+ import subprocess
+ import platform
++from pyogg import VorbisFile
++from ossaudiodev import open as ossOpen, AFMT_S16_NE
+ 
+ os_type = platform.system()
+ 
+@@ -36,18 +38,11 @@ def playNotification(file):
+     if enable_notification == 'yes':
+         if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD':
+ 
+-            pipe = subprocess.Popen(['paplay', '--volume=' + str(volume),
+-                                     str(file)],
+-                                    stderr=subprocess.PIPE,
+-                                    stdout=subprocess.PIPE,
+-                                    stdin=subprocess.PIPE,
+-                                    shell=False)
+-
+-            answer = pipe.wait()
+-
+-            if answer != 0:
+-                logger.sendToLog(
+-                    "paplay not installed!Install it for playing sound notification", "WARNING")
++            sound = VorbisFile(file)
++            dsp = ossOpen('/dev/dsp', 'w')
++            dsp.setparameters(AFMT_S16_NE, sound.channels, sound.frequency)
++            dsp.write(sound.buffer)
++            dsp.close()
+ 
+         elif os_type == 'Darwin':
+ 
diff --git a/www/persepolis/files/patch-setup.py b/www/persepolis/files/patch-setup.py
new file mode 100644
index 000000000000..bd82082de251
--- /dev/null
+++ b/www/persepolis/files/patch-setup.py
@@ -0,0 +1,40 @@
+--- setup.py.orig	2019-09-16 20:45:38 UTC
++++ setup.py
+@@ -67,14 +67,6 @@ except:
+     print("Warning: python3-psutil is not installed!")
+     not_installed = not_installed + 'psutil, '
+ 
+-# youtube_dl
+-try:
+-    import youtube_dl
+-    print('youtube-dl is found')
+-except:
+-    print('Warning: youtube-dl is not installed!')
+-    not_installed = not_installed + 'youtube-dl, '
+-
+ # aria2
+ answer = os.system('aria2c --version 1>/dev/null')
+ if answer != 0:
+@@ -82,22 +74,6 @@ if answer != 0:
+     not_installed = not_installed + 'aria2c, '
+ else:
+     print('aria2 is found!')
+-
+-# libnotify-bin
+-answer = os.system('notify-send --version 1>/dev/null')
+-if answer != 0:
+-    print("Error libnotify-bin is not installed!")
+-    not_installed = not_installed + 'libnotify-bin, '
+-else:
+-    print('libnotify-bin is found!')
+-
+-# paplay
+-answer = os.system('paplay --version 1>/dev/null')
+-if answer != 0:
+-    print("Warning: paplay not installed!You need pulseaudio for sound notifications!")
+-    not_installed = not_installed + 'paplay, '
+-else:
+-    print('paplay is found!')
+ 
+ # sound-theme-freedesktop
+ if os_type == 'Linux':
diff --git a/www/persepolis/pkg-descr b/www/persepolis/pkg-descr
new file mode 100644
index 000000000000..ce64c683460e
--- /dev/null
+++ b/www/persepolis/pkg-descr
@@ -0,0 +1,9 @@
+Persepolis is a download manager and GUI for Aria2 which is written
+in Python using Qt and other components.  It features:
+
+  - Multi-segment downloading
+  - Scheduling downloads
+  - Download queuing
+  - And many more!
+
+WWW: https://persepolisdm.github.io/