Subject: [bug#73931] [PATCH v2 1/2] gnu: Add vdrift-data.

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 22 Oct 2024 15:53:31 +0900

* gnu/packages/patches/vdrift-data-extra-resolutions.patch: New file.
* gnu/packages/patches/vdrift-data-icons.patch: Likewise.
* gnu/local.mk (dist_patch_DATA): Register them.
* gnu/packages/games.scm (vdrift-data): New variable.

Change-Id: I960e2222ea7e9506a306692db552dc1dcc229b01
---
 gnu/local.mk                                  |  2 +
 gnu/packages/games.scm                        | 35 +++++++++++++++++
 .../vdrift-data-extra-resolutions.patch       | 24 ++++++++++++
 gnu/packages/patches/vdrift-data-icons.patch  | 38 +++++++++++++++++++
 4 files changed, 99 insertions(+)
 create mode 100644 gnu/packages/patches/vdrift-data-extra-resolutions.patch
 create mode 100644 gnu/packages/patches/vdrift-data-icons.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 89a795bfbd..a046a6122f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2287,6 +2287,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/vboot-utils-fix-tests-show-contents.patch	\
   %D%/packages/patches/vboot-utils-skip-test-workbuf.patch	\
   %D%/packages/patches/vcmi-disable-privacy-breach.patch	\
+  %D%/packages/patches/vdrift-data-extra-resolutions.patch	\
+  %D%/packages/patches/vdrift-data-icons.patch			\
   %D%/packages/patches/vinagre-newer-freerdp.patch             \
   %D%/packages/patches/vinagre-newer-rdp-parameters.patch      \
   %D%/packages/patches/virtuoso-ose-remove-pre-built-jar-files.patch	\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index c594b8ac2a..6525e1cb81 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -788,6 +788,41 @@ (define-public tetrinet
 attacks you can use on opponents.")
     (license license:public-domain)))
 
+(define-public vdrift-data
+  ;; There are no tags or releases for the vdrift data; use the latest SVN
+  ;; revision available.
+  (let ((commit 1460)
+        (revision "0"))
+    ;; The package is hidden as the game data is *required* by the install
+    ;; target of vdrift itself, and there is no need for users to manually
+    ;; install it.
+    (hidden-package
+     (package
+       (name "vdrift-data")
+       ;; The date is the last modified time shown next to the 'vdrift-data'
+       ;; directory when visiting
+       ;; https://sourceforge.net/p/vdrift/code/HEAD/tree/.
+       (version (format #f "2023-03-07-~a.~a" revision commit))
+       (source (origin
+                 (method svn-fetch)
+                 (uri (svn-reference
+                       (url "https://svn.code.sf.net/p/vdrift/code/vdrift-data")
+                       (revision commit)))
+                 (file-name (string-append name "-" version "-checkout"))
+                 (sha256
+                  (base32
+                   "0izzi2na6lbp6ji83nq975w7rm2vmhsi8ngdnmwznm545ws75iai"))
+                 (patches
+                  (search-patches "vdrift-data-extra-resolutions.patch"
+                                  "vdrift-data-icons.patch"))))
+       (build-system copy-build-system)
+       (arguments (list #:install-plan #~'(("." "share/games/vdrift/data"))))
+       (home-page "https://vdrift.net/")
+       (synopsis "Game data for Vdrift")
+       (description "This package contains the assets for the Vdrift racing
+game.")
+       (license license:gpl3+)))))      ;assumed same as Vdrift itself
+
 (define-public vitetris
   (package
     (name "vitetris")
diff --git a/gnu/packages/patches/vdrift-data-extra-resolutions.patch b/gnu/packages/patches/vdrift-data-extra-resolutions.patch
new file mode 100644
index 0000000000..49b557d897
--- /dev/null
+++ b/gnu/packages/patches/vdrift-data-extra-resolutions.patch
@@ -0,0 +1,24 @@
+Upstream status: https://github.com/VDrift/vdrift/issues/200
+
+Index: vdrift-data/settings/options.config
+===================================================================
+--- vdrift-data/settings/options.config	(revision 1460)
++++ vdrift-data/settings/options.config	(working copy)
+@@ -316,7 +316,7 @@
+ type = string
+ default = 800,600
+ values = list
+-num_vals = 21
++num_vals = 22
+ opt00 = 640 x 480
+ val00 = 640,480
+ opt01 = 800 x 480
+@@ -359,6 +359,8 @@
+ val19 = 2560,1440
+ opt20 = 2560 x 1600
+ val20 = 2560,1600
++opt21 = 3840 x 2160
++val21 = 3840,2160
+ 
+ [ display.shadow_distance ]
+ desc = Set the distance at which shadows become visible
diff --git a/gnu/packages/patches/vdrift-data-icons.patch b/gnu/packages/patches/vdrift-data-icons.patch
new file mode 100644
index 0000000000..6c6003cc27
--- /dev/null
+++ b/gnu/packages/patches/vdrift-data-icons.patch
@@ -0,0 +1,38 @@
+Upstream-status: https://github.com/VDrift/vdrift/pull/202
+
+Index: vdrift-data/SConscript
+===================================================================
+--- vdrift-data/SConscript	(revision 1460)
++++ vdrift-data/SConscript	(working copy)
+@@ -10,6 +10,7 @@
+ #---------#
+ src = []
+ 
++# Install every single file to the data directory.
+ for root, dirs, files in os.walk("."):
+   if root.find('.svn') == -1:
+     for file in [f for f in files if not f.endswith('~')]:
+@@ -40,3 +41,6 @@
+     env.MoBuild(mo_file, po_file)
+     install = env.InstallAs(os.path.join(env.subst('$locale_directory'), mo_tgt_file), mo_file)
+     env.Alias("install", install)
++
++# Also copy the icons to a suitable location for the system.
++SConscript('textures/icons/SConscript')
+Index: vdrift-data/textures/icons/SConscript
+===================================================================
+--- vdrift-data/textures/icons/SConscript	(revision 1460)
++++ vdrift-data/textures/icons/SConscript	(working copy)
+@@ -19,5 +19,10 @@
+ #--------------------#
+ # Install data files #
+ #--------------------#
+-install = env.Install(Dir(env.subst('$data_directory/textures/icons')), src)
+-env.Alias('install', install)
++# Install the icons per the Icon Theme Specification (see:
++# https://specifications.freedesktop.org/icon-theme-spec/)
++iconsdir = Dir(env.subst('$icons_directory')).abspath
++install1 = env.InstallAs(iconsdir + '/16x16/apps/vdrift.png', 'vdrift-16x16.png')
++install2 = env.InstallAs(iconsdir + '/32x32/apps/vdrift.png', 'vdrift-32x32.png')
++install3 = env.InstallAs(iconsdir + '/64x64/apps/vdrift.png', 'vdrift-64x64.png')
++env.Alias('install', [install1, install2, install3])

base-commit: 59b2a60d0041882d732e1766e28f0df5a1ef1ac1
-- 
2.46.0