Subject: [bug#75720] [PATCH v4 5/5] gnu: Add amarok.

From: Sughosha <[email-masked]>
Date: Sun, 2 Feb 2025 23:10:51 +0530

* gnu/packages/kde-multimedia.scm (amarok): New variable.
* gnu/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch: New file
* gnu/local.mk: Register the new file.

Change-Id: Iff82b2128b231070e6452a8f86a4349f614235b4
---
 gnu/local.mk                                  |   1 +
 gnu/packages/kde-multimedia.scm               | 109 +++++++++++++
 ...amarok-3.2.1-fix-including-mygpo-qt6.patch | 148 ++++++++++++++++++
 3 files changed, 258 insertions(+)
 create mode 100644 gnu/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b6f62568bf..a6803c26e0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -982,6 +982,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ibus-anthy-fix-tests.patch		\
   %D%/packages/patches/ibus-table-paths.patch			\
   %D%/packages/patches/anki-mpv-args.patch			\
+  %D%/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch	\
   %D%/packages/patches/antiword-CVE-2014-8123.patch			\
   %D%/packages/patches/antlr3-3_1-fix-java8-compilation.patch	\
   %D%/packages/patches/antlr3-3_3-fix-java8-compilation.patch	\
diff --git a/gnu/packages/kde-multimedia.scm b/gnu/packages/kde-multimedia.scm
index ad0b504268..8390f29f6f 100644
--- a/gnu/packages/kde-multimedia.scm
+++ b/gnu/packages/kde-multimedia.scm
@@ -31,14 +31,19 @@ (define-module (gnu packages kde-multimedia)
   #:use-module (guix utils)
   #:use-module (guix gexp)
   #:use-module (gnu packages)
+  #:use-module (gnu packages algebra)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cdrom)
+  #:use-module (gnu packages check)
+  #:use-module (gnu packages crypto)
+  #:use-module (gnu packages databases)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gpodder)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gstreamer)
@@ -46,6 +51,7 @@ (define-module (gnu packages kde-multimedia)
   #:use-module (gnu packages kde-frameworks)
   #:use-module (gnu packages kde-plasma)
   #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages mp3)
   #:use-module (gnu packages music)
@@ -54,6 +60,7 @@ (define-module (gnu packages kde-multimedia)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
@@ -98,6 +105,108 @@ (define-public audiocd-kio
     (license ;; GPL for programs, FDL for documentation
      (list license:gpl2+ license:fdl1.2+))))
 
+(define-public amarok
+  (package
+    (name "amarok")
+    (version "3.2.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://kde/stable/amarok/" version
+                                  "/amarok-" version ".tar.xz"))
+              (sha256
+               (base32
+                "14r7iismx28nnh3jhkhczhrsmsap9by8p3kfhkp7d5678c7l62g4"))
+              (patches
+               (search-patches "amarok-3.2.1-fix-including-mygpo-qt6.patch"))))
+    (build-system qt-build-system)
+    (arguments
+     (list #:qtbase qtbase
+           #:configure-flags
+           #~(list "-DBUILD_WITH_QT6=ON")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-before 'configure 'check-setup
+                 (lambda _
+                   ;; Set home directory.
+                   (setenv "HOME" "/tmp")
+                   ;; testplaylistlayout looks for "amarok/data" directory in
+                   ;; $XDG_DATA_DIRS. Maybe it is for testing after installing.
+                   ;; As a workaround, set XDG_DATA_DIRS pointing to $TMPDIR
+                   ;; which contains "amarok/data" directory.
+                   (let ((linktarget (string-append (dirname (getcwd))
+                                                    "/amarok")))
+                     (if (not (equal? (basename (getcwd)) "amarok"))
+                       (symlink (getcwd) linktarget))
+                     (setenv "XDG_DATA_DIRS"
+                             (string-append (getenv "XDG_DATA_DIRS") ":"
+                                            (dirname linktarget))))))
+               (replace 'check
+                 (lambda* (#:key tests? #:allow-other-keys)
+                   (when tests?
+                     ;; testsqlscanmanager fails, even when run manually.
+                     (invoke "ctest" "-E" "testsqlscanmanager")))))))
+    (native-inputs
+       (list extra-cmake-modules googletest kdoctools pkg-config qttools))
+    (inputs
+     (list ffmpeg
+           fftw
+           glib
+           karchive
+           kcodecs
+           kcolorscheme
+           kconfig
+           kconfigwidgets
+           kcoreaddons
+           kcmutils
+           kcrash
+           kdbusaddons
+           kdnssd
+           kglobalaccel
+           kguiaddons
+           ki18n
+           kiconthemes
+           kio
+           kirigami
+           knotifications
+           kpackage
+           kstatusnotifieritem
+           ktexteditor
+           ktextwidgets
+           kwallet
+           kwidgetsaddons
+           kwindowsystem
+           libofa
+           libmtp
+           libmygpo-qt6
+           libxcrypt
+           `(,mariadb "dev")
+           `(,mariadb "lib")
+           openssl
+           phonon
+           phonon-backend-vlc
+           python
+           qt5compat
+           qtsvg
+           qtwebengine
+           solid
+           taglib
+           taglib-extras
+           threadweaver))
+    (home-page "https://amarok.kde.org/")
+    (synopsis "Audio player for KDE")
+    (description
+     "Amarok is a music player and collection manager.  It features:
+@itemize
+@item dynamic playlists matching different criteria,
+@item collection managing with rating support,
+@item support for basic MTP and UMS music player devices,
+@item integrated internet services such as Magnatune, Ampache and more,
+@item scripting support,
+@item cover manager and
+@item replay gain support
+@end itemize")
+    (license license:gpl2+)))
+
 (define-public dragon
   (package
     (name "dragon")
diff --git a/gnu/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch b/gnu/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch
new file mode 100644
index 0000000000..d23954cf80
--- /dev/null
+++ b/gnu/packages/patches/amarok-3.2.1-fix-including-mygpo-qt6.patch
@@ -0,0 +1,148 @@
+This patch fixes including headers of libmygpo-qt6 when built with qt6.
+
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderPodcastMeta.h amarok-3.2.1-b/src/services/gpodder/GpodderPodcastMeta.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderPodcastMeta.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderPodcastMeta.h	2025-01-21 06:40:56.069282183 +0530
+@@ -22,7 +22,14 @@
+ 
+ #include "core/playlists/PlaylistProvider.h"
+ #include "core/podcasts/PodcastMeta.h"
++
++#include <QtVersionChecks>
++
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/ApiRequest.h>
++#else
++#include <mygpo-qt6/ApiRequest.h>
++#endif
+ 
+ namespace Podcasts {
+ 
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderPodcastRequestHandler.h amarok-3.2.1-b/src/services/gpodder/GpodderPodcastRequestHandler.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderPodcastRequestHandler.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderPodcastRequestHandler.h	2025-01-21 05:22:06.974221089 +0530
+@@ -20,7 +20,12 @@
+ #define GPODDERPODCASTREQUESTHANDLER_H_
+ 
+ #include "GpodderServiceModel.h"
++
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/PodcastList.h>
++#else
++#include <mygpo-qt6/PodcastList.h>
++#endif
+ 
+ #include <QModelIndex>
+ 
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderPodcastTreeItem.h amarok-3.2.1-b/src/services/gpodder/GpodderPodcastTreeItem.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderPodcastTreeItem.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderPodcastTreeItem.h	2025-01-21 05:16:21.674470671 +0530
+@@ -20,7 +20,11 @@
+ #define GPODDERPODCASTTREEITEM_H_
+ 
+ #include "GpodderTreeItem.h"
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/Podcast.h>
++#else
++#include <mygpo-qt6/Podcast.h>
++#endif
+ 
+ class GpodderPodcastTreeItem: public GpodderTreeItem
+ {
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderProvider.h amarok-3.2.1-b/src/services/gpodder/GpodderProvider.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderProvider.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderProvider.h	2025-01-21 05:21:29.153812018 +0530
+@@ -23,8 +23,15 @@
+ #include "core/podcasts/PodcastProvider.h"
+ #include "core/podcasts/PodcastReader.h"
+ #include "GpodderPodcastMeta.h"
++
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/ApiRequest.h>
+ #include <mygpo-qt5/EpisodeActionList.h>
++#else
++#include <mygpo-qt6/ApiRequest.h>
++#include <mygpo-qt6/EpisodeActionList.h>
++#endif
++
+ #include "playlistmanager/file/KConfigSyncRelStore.h"
+ #include "playlistmanager/PlaylistManager.h"
+ 
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderService.cpp amarok-3.2.1-b/src/services/gpodder/GpodderService.cpp
+--- amarok-3.2.1-a/src/services/gpodder/GpodderService.cpp	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderService.cpp	2025-01-21 05:17:27.675190295 +0530
+@@ -27,8 +27,15 @@
+ #include "GpodderServiceModel.h"
+ #include "GpodderServiceView.h"
+ #include "GpodderSortFilterProxyModel.h"
++
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/ApiRequest.h>
+ #include <mygpo-qt5/Podcast.h>
++#else
++#include <mygpo-qt6/ApiRequest.h>
++#include <mygpo-qt6/Podcast.h>
++#endif
++
+ #include "playlistmanager/PlaylistManager.h"
+ #include "widgets/SearchWidget.h"
+ 
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderServiceModel.h amarok-3.2.1-b/src/services/gpodder/GpodderServiceModel.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderServiceModel.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderServiceModel.h	2025-01-21 05:20:32.517198664 +0530
+@@ -20,8 +20,15 @@
+ #define GPODDERSERVICEMODEL_H_
+ 
+ #include "GpodderTreeItem.h"
++
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/ApiRequest.h>
+ #include <mygpo-qt5/TagList.h>
++#else
++#include <mygpo-qt6/ApiRequest.h>
++#include <mygpo-qt6/TagList.h>
++#endif
++
+ #include "NetworkAccessManagerProxy.h"
+ 
+ #include <QAbstractItemModel>
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderTagTreeItem.h amarok-3.2.1-b/src/services/gpodder/GpodderTagTreeItem.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderTagTreeItem.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderTagTreeItem.h	2025-01-21 05:18:10.983661774 +0530
+@@ -20,7 +20,11 @@
+ #define GPODDERTAGTREEITEM_H_
+ 
+ #include "GpodderTreeItem.h"
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ #include <mygpo-qt5/Tag.h>
++#else
++#include <mygpo-qt6/Tag.h>
++#endif
+ 
+ #include <QObject>
+ 
+diff -ruN amarok-3.2.1-a/src/services/gpodder/GpodderTreeItem.h amarok-3.2.1-b/src/services/gpodder/GpodderTreeItem.h
+--- amarok-3.2.1-a/src/services/gpodder/GpodderTreeItem.h	2025-01-11 23:47:50.000000000 +0530
++++ amarok-3.2.1-b/src/services/gpodder/GpodderTreeItem.h	2025-01-21 06:33:35.948536483 +0530
+@@ -19,13 +19,18 @@
+ #ifndef GPODDERTREEITEM_H_
+ #define GPODDERTREEITEM_H_
+ 
+-#include <mygpo-qt5/ApiRequest.h>
+-#include <mygpo-qt5/TagList.h>
+-
+ #include <QList>
+ #include <QModelIndex>
+ #include <QVariant>
+ 
++#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
++#include <mygpo-qt5/ApiRequest.h>
++#include <mygpo-qt5/TagList.h>
++#else
++#include <mygpo-qt6/ApiRequest.h>
++#include <mygpo-qt6/TagList.h>
++#endif
++
+ 
+ class GpodderTreeItem : public QObject
+ {
-- 
2.47.1