Subject: [bug#75991] [PATCH v2 3/3] gnu: speed-dreams: Update to 2.4.0.

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 2 Feb 2025 15:42:03 +0900

* gnu/packages/games.scm (speed-dreams-version)
(speed-dreams-svn-revision): Delete variables.
(speed-dreams-source-tarball): Delete procedure.
(speed-dreams-base-tarball, speed-dreams-hq-cars-and-tracks-tarball)
(speed-dreams-more-hq-cars-and-tracks-tarball)
(speed-dreams-wip-cars-and-tracks-tarball)
(speed-dreams-unmaintained-tarball): Delete variables.
(speed-dreams-data): New variable.
(speed-dreams): Update to 2.4.0.
[source]: Fetch from git.  Apply patches.
[configure-flags]: Remove the SD_DATADIR, SD_LIBDIR, OPTION_3RDPARTY_SOLID,
CMAKE_MODULE_LINKER_FLAGS, and CMAKE_BUILD_RPATH_USE_ORIGIN flags.  Add the
VERSION_LONG flag.
[phases]: Delete phases.
[native-inputs]: Add speed-dreams-data.
[inputs]: Add cjson, glm, minizip, rhash and tinygltf.

Change-Id: Ie782a65dadaafb5d6c3a7d4d6c28212eef2b36f7
---
 gnu/packages/games.scm | 138 +++++++++++++++--------------------------
 1 file changed, 50 insertions(+), 88 deletions(-)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 0e5dc016a1..75a669d577 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -9332,116 +9332,78 @@ (define-public endless-sky
                    license:cc-by-sa4.0
                    license:public-domain))))
 
-(define speed-dreams-version "2.3.0")
-(define speed-dreams-svn-revision "8786")
-(define (speed-dreams-source-tarball name sha256sum)
-  (origin
-    (method url-fetch)
-    (uri (string-append "mirror://sourceforge/speed-dreams/"
-                        speed-dreams-version "/"
-                        "speed-dreams-src-" name "-" speed-dreams-version "-r"
-                        speed-dreams-svn-revision ".tar.xz"))
-    (sha256 (base32 sha256sum))))
-
-;;; We use the release tarballs instead of the SVN repository for their
-;;; reduced weight (the tarballs do not provide the sources of the 3D models
-;;; used, which are heavy, for example).
-(define speed-dreams-base-tarball       ;about 240 MiB
-  (speed-dreams-source-tarball
-   "base" "190480qzkllykl07s6bxd5wdbjgavs7haw6mk0hgdm7bs6rqqk0d"))
-
-(define speed-dreams-hq-cars-and-tracks-tarball ;about 670 MiB
-  (speed-dreams-source-tarball
-   "hq-cars-and-tracks" "16zcgwax3n0gf79hw1dg42lzsyxbnxfw6hjxdi919q5hxgm9cgsr"))
-
-(define speed-dreams-more-hq-cars-and-tracks-tarball ;about 760 MiB
-  (speed-dreams-source-tarball
-   "more-hq-cars-and-tracks"
-   "1acwiacf77qk5azyg3bbxsydk3wsp5fvgwwnhxpk273mwszjkh56"))
-
-;;; Although these are marked as 'WIP', the game throws (non-fatal) errors
-;;; when it fails finding some "drivers" included within this pack.
-(define speed-dreams-wip-cars-and-tracks-tarball ;about 400 MiB
-  (speed-dreams-source-tarball
-   "wip-cars-and-tracks"
-   "0wqd9bpis9bg87rsqk0dyvljax4zrp9h57mz7z3zrn6fayl1nh1q"))
-
-;;; This is to allow selecting the legacy Simu V2 engine (configurable in the
-;;; game options).
-(define speed-dreams-unmaintained-tarball ;about 60 KiB
-  (speed-dreams-source-tarball
-   "unmaintained" "1cxcrjm2508najpz2b65i8gxgvgiq7fcp13xvicpiqp6xhq3hsyi"))
+(define-public speed-dreams-data
+  ;; Use the commit corresponding to the 'speed-dreams-data' submodule
+  ;; (https://forge.a-lec.org/speed-dreams/speed-dreams-data).
+  (hidden-package
+   (package
+     (name "speed-dreams-data")
+     (version "2.4.0")
+     (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+              (url (string-append "https://forge.a-lec.org/speed-dreams/"
+                                  name))
+              (commit (string-append "v" version))))
+        (file-name (git-file-name name version))
+        (sha256
+         (base32
+          "0ki620pq5gcn10l5328qsh6jdjsgrvyb4fhvgi0s9fvflzzg6905"))))
+     (build-system cmake-build-system)
+     (arguments (list #:tests? #f))   ;no test suite
+     (home-page "https://www.speed-dreams.net/en")
+     (synopsis "Data for the Speed Dreams racing game")
+     (description "This package contains the non-functional data for the
+Speed Dreams racing game.")
+     (license license:gpl2+))))
 
 (define-public speed-dreams
   (package
     (name "speed-dreams")
-    (version speed-dreams-version)
-    (source speed-dreams-base-tarball)
+    (version "2.4.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url (string-append "https://forge.a-lec.org/"
+                                 name "/" name "-code.git"))
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "150mwjdv9pmc3cjchfbkprnlbsnw2gv57350lir5vbh77xrgpn8c"))))
     (build-system cmake-build-system)
     (arguments
      (list
       #:tests? #f                       ;no test suite
       #:build-type "Release"
       #:configure-flags
-      #~(list
-         "-DOPTION_OFFICIAL_ONLY=ON"                    ;build with content
-         (string-append "-DSD_BINDIR=" #$output "/bin") ;instead of 'games'
-         (string-append "-DSD_DATADIR=" #$output "/share/speed-dreams-2")
-         ;; Libdir defaults to a 'lib64/games' prefix.
-         (string-append "-DSD_LIBDIR=" #$output "/lib/speed-dreams-2")
-         ;; Use system-provided Expat and FreeSOLID
-         ;; libraries instead of the bundled ones.
-         "-DOPTION_3RDPARTY_EXPAT=ON"
-         "-DOPTION_3RDPARTY_SOLID=ON"
-         ;; Drivers and other shared objects are linked to private/internal
-         ;; shared libraries; have their location on the RUNPATH to satisfy
-         ;; the validate-runpath phase.
-         (string-append "-DCMAKE_MODULE_LINKER_FLAGS=-Wl,-rpath="
-                        #$output "/lib/speed-dreams-2/lib")
-         ;; The following flag is to avoid bogus RUNPATH warnings from the
-         ;; validate-runpath phase; without it, -rpath links referring to the
-         ;; build directory would be baked in driver modules.
-         "-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON")
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'unpack 'extract-cars-and-tracks-data
-            (lambda _
-              ;; XXX: The current working directory is inside the cmake/
-              ;; sudbirectory following the unpack phase, for some reason.
-              (chdir "..")
-              (invoke "tar" "-xvf" #$speed-dreams-hq-cars-and-tracks-tarball)
-              (invoke "tar" "-xvf" #$speed-dreams-more-hq-cars-and-tracks-tarball)
-              (invoke "tar" "-xvf" #$speed-dreams-wip-cars-and-tracks-tarball)
-              (invoke "tar" "-xvf" #$speed-dreams-unmaintained-tarball)))
-          (add-after 'install 'install-desktop-entry
-            (lambda* (#:key outputs #:allow-other-keys)
-              (make-desktop-entry-file
-               (string-append #$output
-                              "/share/applications/speed-dreams.desktop")
-               #:name "Speed Dreams 2"
-               #:comment "3D racing cars simulator"
-               #:exec (search-input-file outputs "bin/speed-dreams-2")
-               #:icon (search-input-file
-                       outputs "share/speed-dreams-2/data/icons/icon.png")
-               #:categories '("Game" "Simulation")))))))
-    (native-inputs
-     (list pkg-config))
+      #~(list "-DOPTION_3RDPARTY_EXPAT=ON" ;use system expat library
+              "-DSD_BINDIR:PATH=bin"       ;install to /bin instead of /games
+              (string-append "-DVERSION_LONG=" #$version))))
+    (native-inputs (list pkg-config speed-dreams-data))
     (inputs
-     (list curl
+     (list cjson
+           curl
            enet
            expat
            freeglut
            freesolid
            freetype
+           glm
            libjpeg-turbo
            libogg
            libpng
            libvorbis
+           minizip
            openal
            openscenegraph
            plib
+           rhash
            sdl2
            sdl2-mixer
+           tinygltf
            zlib))
     (home-page "https://sourceforge.net/projects/speed-dreams/")
     (synopsis "Car racing simulator")
@@ -9450,9 +9412,9 @@ (define-public speed-dreams
 realism.  Initially forked from TORCS, it features improvements to the
 graphics and physics simulation, and supports modern input methods such as
 gamepads by use of the SDL library.  It features more than 20 tracks and more
-than 80 cars to race with.")
-    (license (list license:gpl2+        ;game code
-                   license:lal1.3))))   ;assets
+than 80 cars to race with.  Extra (freely licensed) assets can be downloaded
+via the in-game download manager.")
+    (license (list license:gpl2+))))
 
 (define-public stepmania
   (package
-- 
2.47.1