Subject: [PATCH] gnu: gzdoom: Update to 4.13.2

From: Andrew Wong <[email-masked]>
Date: Wed, 25 Dec 2024 18:17:22 -0500

Change-Id: I73e6a86944ab3433d4425f3b3c345b509210a16d
---
GZDoom has changed a lot since its last update here, and it (and it's new
dependency, zmusic) have a lot of new bundled libraries. I'm not sure how to
un-bundle most of them, so help on that front would be appreciated. The patches
no longer work correctly either, so I've removed them; they seem unnecessary
now, anyways. 
 gnu/packages/games.scm                        | 132 ++++++++----------
 .../patches/gzdoom-find-system-libgme.patch   |  21 ---
 .../gzdoom-search-in-installed-share.patch    |  23 ---
 3 files changed, 56 insertions(+), 120 deletions(-)
 delete mode 100644 gnu/packages/patches/gzdoom-find-system-libgme.patch
 delete mode 100644 gnu/packages/patches/gzdoom-search-in-installed-share.patch

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index c2bb9aa1c4..d966f742ef 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -8403,67 +8403,44 @@ (define-public colobot
     (home-page "https://colobot.info")
     (license license:gpl3+)))
 
+(define-public zmusic
+  (package
+    (name "zmusic")
+    (version "1.1.14")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ZDoom/ZMusic")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+	(base32 "19arzkbwdj84vw1cfawc6930dfxdhhq4k6yawkkppaphj8qkfhdc"))))
+    (arguments (list #:tests? #f))
+    (build-system cmake-build-system)
+    (native-inputs (list pkg-config glib))
+    (home-page "https://github.com/ZDoom/ZMusic")
+    (synopsis "GZDoom's music system as a standalone library")
+    (description "GZDoom's music system as a standalone library, for use with
+GZDoom, Raze, and PrBoom+.")
+    (license license:gpl3)))
+
 (define-public gzdoom
   (package
     (name "gzdoom")
-    (version "4.3.2")
+    (version "4.13.2")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
-             (url "https://github.com/coelckers/gzdoom")
+             (url "https://github.com/ZDoom/gzdoom")
              (commit (string-append "g" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0i4hyg72z84fc6ca2ic9q82q5cbgrbd7bynl3kpkypxvyasq08wz"))
-       (patches (search-patches "gzdoom-search-in-installed-share.patch"
-                                "gzdoom-find-system-libgme.patch"))
-       (modules '((guix build utils)
-                  (ice-9 regex)))
-       (snippet
-        '(begin
-           ;; Remove files which mustn't be commercially redistributed.  See
-           ;; <https://zdoom.org/wiki/License#Commercial_use>, the ‘Contribution
-           ;; Guidelines’ at <https://github.com/ZDoom>, and Guix issue #73435.
-           (for-each
-            (lambda (directory)
-              (delete-file-recursively directory)
-              (substitute* "CMakeLists.txt"
-                (((string-append "add_subdirectory\\([[:blank:]]*"
-                                 directory
-                                 "[[:blank:]]*\\)"))
-                 "")))
-            '( ;; "wadsrc_extra"        ;game_support.pk3
-              "wadsrc_bm"))             ;brightmaps.pk3
-
-           ;; Removing game_support.pk3 entirely would break Freedoom & remove
-           ;; users' ability to play commercial games, despite owning (only) the
-           ;; non-functional data.  That can't be right.  Out of an abundance of
-           ;; caution, remove anything from the PK3 that could conceivably be
-           ;; derived from copyrightable data that's not freely redistributable.
-           (display "Keeping only the following game_support.pk3 files:\n")
-           (let* ((regexps (list "/font\\.inf$"
-                                 "/harmony/.*\\.(txt|zs)$"
-                                 "/(iwadinfo|mapinfo|sprofs)\\.txt$"
-                                 "\\.z$"))
-                  (regexp* (format #f "(~{~a~^|~})" regexps))
-                  (regexp  (make-regexp regexp* regexp/icase)))
-             (define (keep-file? file stat)
-               (let ((keep? (regexp-exec regexp file)))
-                 (when keep?
-                   (format #t "  ~a~%" file))
-                 keep?))
-
-             (for-each delete-file (find-files "wadsrc_extra/static"
-                                               (negate keep-file?))))
-
-           ;; Remove some bundled libraries.  XXX There are more, but removing
-           ;; them would require, at least, patching the build system.
-           (with-directory-excursion "libraries"
-             (delete-file-recursively "bzip2")
-             (delete-file-recursively "game-music-emu")
-             (delete-file-recursively "jpeg")
-             (delete-file-recursively "zlib"))))))
+	(base32 "0zlvrdayrj1rk5x2hwnc57l8pl29bl64zmfq3qc9yfypknj1syfy"))
+       ;; (patches (search-patches "gzdoom-search-in-installed-share.patch"
+       ;;                          "gzdoom-find-system-libgme.patch"))
+       ))
     (arguments
      (list
       #:tests? #f
@@ -8484,30 +8461,33 @@ (define (keep-file? file stat)
          "-DDYN_GTK=OFF"
          "-DDYN_MPG123=OFF"
          "-DDYN_SNDFILE=OFF")
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-before 'configure 'fix-file-names
-            (lambda* (#:key inputs #:allow-other-keys)
-              (substitute* "src/CMakeLists.txt"
-                (("COMMAND /bin/sh")
-                 (string-append "COMMAND " (which "sh"))))
-              (substitute*
-                  "libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp"
-                (("/usr/share/sounds/sf2/FluidR3_GM.sf2")
-                 (search-input-file inputs
-                                    "share/soundfonts/FluidR3Mono_GM.sf3")))
-              (substitute*
-                  "libraries/zmusic/mididevices/music_timiditypp_mididevice.cpp"
-                (("(exename = \")(timidity)(\".*)" _ prefix exe suffix)
-                 (string-append prefix
-                                (search-input-file inputs
-                                                   (string-append "bin/" exe))
-                                suffix))))))))
+      ;; #:phases
+      ;; #~(modify-phases %standard-phases
+      ;;     (add-before 'configure 'fix-file-names
+      ;;       (lambda* (#:key inputs #:allow-other-keys)
+      ;;         ;; (substitute* "src/CMakeLists.txt"
+      ;;         ;;   (("COMMAND /bin/sh")
+      ;;         ;;    (string-append "COMMAND " (which "sh"))))
+      ;;         (substitute*
+      ;;             "libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp"
+      ;;           (("/usr/share/sounds/sf2/FluidR3_GM.sf2")
+      ;;            (search-input-file inputs
+      ;;                               "share/soundfonts/FluidR3Mono_GM.sf3")))
+      ;;         (substitute*
+      ;;             "libraries/zmusic/mididevices/music_timiditypp_mididevice.cpp"
+      ;;           (("(exename = \")(timidity)(\".*)" dum prefix exe suffix)
+      ;;            (string-append prefix
+      ;;                           (search-input-file inputs
+      ;;                                              (string-append "bin/" exe))
+      ;;                           suffix))))))
+      ))
     (build-system cmake-build-system)
-    (inputs (list bzip2
+    (inputs (list zmusic
+		  libvpx
+		  bzip2
                   fluid-3
                   fluidsynth
-                  gtk+
+                   gtk+
                   libgme
                   libjpeg-turbo
                   libsndfile
@@ -8517,7 +8497,7 @@ (define (keep-file? file stat)
                   sdl2
                   timidity++
                   zlib))
-    (native-inputs (list pkg-config unzip))
+    (native-inputs (list pkg-config unzip python))
     (synopsis "Modern Doom 2 source port")
     (description "GZdoom is a port of the Doom 2 game engine, with a modern
 renderer.  It improves modding support with ZDoom's advanced mapping features
@@ -8526,9 +8506,9 @@ (define (keep-file? file stat)
     (home-page "https://zdoom.org/index")
     ;; The source uses x86 assembly
     (supported-systems '("x86_64-linux" "i686-linux"))
-    (license (list license:gpl3+         ; gzdoom game
-                   license:lgpl3+        ; gzdoom renderer
-                   license:expat         ; gdtoa
+    (license (list license:gpl3+	; gzdoom game
+                   license:lgpl3+	; gzdoom renderer
+                   license:expat	; gdtoa
                    (license:non-copyleft ; modified dumb
                     "file://dumb/licence.txt"
                     "Dumb license, explicitly GPL compatible.")))))
diff --git a/gnu/packages/patches/gzdoom-find-system-libgme.patch b/gnu/packages/patches/gzdoom-find-system-libgme.patch
deleted file mode 100644
index a7f277d614..0000000000
--- a/gnu/packages/patches/gzdoom-find-system-libgme.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- /CMakeLists.txt	2020-01-20 21:47:35.460119141 +0100
-+++ /CMakeLists.txt	2020-01-20 21:47:47.690112400 +0100
-@@ -195,12 +195,12 @@
- #endif()
- 
- # GME
--#find_path( GME_INCLUDE_DIR gme/gme.h )
--#find_library( GME_LIBRARIES gme )
--#mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES )
--#FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME
--#	REQUIRED_VARS GME_LIBRARIES GME_INCLUDE_DIR
--#)
-+find_path( GME_INCLUDE_DIR gme/gme.h )
-+find_library( GME_LIBRARIES gme )
-+mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES )
-+FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME
-+	REQUIRED_VARS GME_LIBRARIES GME_INCLUDE_DIR
-+)
- 
- if( MSVC )
- 	# Eliminate unreferenced functions and data
diff --git a/gnu/packages/patches/gzdoom-search-in-installed-share.patch b/gnu/packages/patches/gzdoom-search-in-installed-share.patch
deleted file mode 100644
index f312686566..0000000000
--- a/gnu/packages/patches/gzdoom-search-in-installed-share.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-Lookup gzdoom pk3 files in the installed directory in
-addition to the path that is stored in ~/.config/gzdoom/.
-
-Simply replacing the hardcoded /usr/share would leave the
-configfile pointing to outdated guix builds, which could get
-garbage collected and break the gzdoom installation.
-This ensures that the files installed with the corresponding
-build will be used.
-
---- /src/d_main.cpp	2018-01-16 22:13:09.700602781 +0200
-+++ /src/d_main.cpp	2018-01-16 22:22:36.560617961 +0200
-@@ -1716,6 +1716,11 @@
- 		return wad;
- 	}
- 
-+    mysnprintf (wad, countof(wad), "%s/%s", GUIX_OUT_PK3, file);
-+    if (DirEntryExists (wad)) {
-+        return wad;
-+    }
-+
- 	if (GameConfig != NULL && GameConfig->SetSection ("FileSearch.Directories"))
- 	{
- 		const char *key;
-- 
2.46.0