[bug#75619,v2,04/10] gnu: retroarch-minimal: Add new search paths for database and system files.

Message ID 394ce53fdb1066c4aa9f711a27dc2b1c6312d106.1737190254.git.maxim.cournoyer@gmail.com
State New
Headers
Series [bug#75619,v2,01/10] gnu: Add soundtouch-1/integer-samples. |

Commit Message

Maxim Cournoyer Jan. 18, 2025, 8:50 a.m. UTC
  This makes it possible to locate system files provided by libretro cores, as
well as database files.

* gnu/packages/patches/retroarch-improved-search-paths.patch: Extend patch.
* gnu/packages/emulators.scm (retroarch-minimal) [native-search-paths]:
Register new search paths for the LIBRETRO_DATABASE_DIRECTORY and
LIBRETRO_SYSTEM_DIRECTORY variables.

Change-Id: I48f9a92608c0e36922ce9dcc9bbb61d6ca915002
---
 gnu/packages/emulators.scm                    |   8 ++
 .../retroarch-improved-search-paths.patch     | 127 ++++++++++++++----
 2 files changed, 108 insertions(+), 27 deletions(-)
  

Patch

diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index 2486485805..28b8914902 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -2632,6 +2632,14 @@  (define-public retroarch-minimal
               (variable "LIBRETRO_AUTOCONFIG_DIRECTORY")
               (separator #f)            ;single entry
               (files '("share/libretro/autoconfig")))
+             (search-path-specification
+              (variable "LIBRETRO_DATABASE_DIRECTORY")
+              (separator #f)            ;single entry
+            (files '("share/libretro/database/rdb")))
+             (search-path-specification
+              (variable "LIBRETRO_SYSTEM_DIRECTORY")
+              (separator #f)            ;single entry
+              (files '("share/libretro/system")))
              (search-path-specification
               (variable "LIBRETRO_VIDEO_FILTER_DIRECTORY")
               (separator #f)            ;single entry
diff --git a/gnu/packages/patches/retroarch-improved-search-paths.patch b/gnu/packages/patches/retroarch-improved-search-paths.patch
index 6fcd4745ac..037e73fa09 100644
--- a/gnu/packages/patches/retroarch-improved-search-paths.patch
+++ b/gnu/packages/patches/retroarch-improved-search-paths.patch
@@ -1,25 +1,22 @@ 
-Allows discovery of assets file via the LIBRETRO_ASSETS_DIRECTORY environment
-variable.
-
-Upstream-status: https://github.com/libretro/RetroArch/pull/17054
-
 diff --git a/configuration.c b/configuration.c
-index 5808a3f21c..0cc2909102 100644
+index 5808a3f21c..e1c56f2f1b 100644
 --- a/configuration.c
 +++ b/configuration.c
-@@ -3573,6 +3573,11 @@ static bool config_load_file(global_t *global,
+@@ -3573,6 +3573,13 @@ static bool config_load_file(global_t *global,
  {
     unsigned i;
     char tmp_str[PATH_MAX_LENGTH];
 +   char* libretro_directory                        = NULL;
 +   char* libretro_assets_directory                 = NULL;
 +   char* libretro_autoconfig_directory             = NULL;
++   char* libretro_database_directory               = NULL;
++   char* libretro_system_directory                 = NULL;
 +   char* libretro_video_filter_directory           = NULL;
 +   char* libretro_video_shader_directory           = NULL;
     static bool first_load                          = true;
     bool without_overrides                          = false;
     unsigned msg_color                              = 0;
-@@ -3848,12 +3853,6 @@ static bool config_load_file(global_t *global,
+@@ -3848,12 +3855,6 @@ static bool config_load_file(global_t *global,
           strlcpy(path_settings[i].ptr, tmp_str, PATH_MAX_LENGTH);
     }
  
@@ -32,7 +29,7 @@  index 5808a3f21c..0cc2909102 100644
  #ifdef RARCH_CONSOLE
     if (conf)
        video_driver_load_settings(global, conf);
-@@ -3861,6 +3860,20 @@ static bool config_load_file(global_t *global,
+@@ -3861,6 +3862,32 @@ static bool config_load_file(global_t *global,
  
     /* Post-settings load */
  
@@ -45,15 +42,27 @@  index 5808a3f21c..0cc2909102 100644
 +   }
 +
 +   libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY");
-+   if (libretro_autoconfig_directory)
++   if (libretro_autoconfig_directory) /* override configuration value */
 +       configuration_set_string(settings,
 +				settings->paths.directory_autoconfig,
 +				libretro_autoconfig_directory);
++
++   libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
++   if (libretro_database_directory) /* override configuration value */
++       configuration_set_string(settings,
++				settings->paths.path_content_database,
++				libretro_database_directory);
++
++   libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY");
++   if (libretro_system_directory) /* override configuration value */
++       configuration_set_string(settings,
++				settings->paths.directory_system,
++				libretro_system_directory);
 +
     if (     (rarch_flags & RARCH_FLAGS_HAS_SET_USERNAME)
           && (override_username))
     {
-@@ -4032,15 +4045,27 @@ static bool config_load_file(global_t *global,
+@@ -4032,15 +4059,27 @@ static bool config_load_file(global_t *global,
        *settings->paths.path_menu_wallpaper = '\0';
     if (string_is_equal(settings->paths.path_rgui_theme_preset, "default"))
        *settings->paths.path_rgui_theme_preset = '\0';
@@ -85,18 +94,18 @@  index 5808a3f21c..0cc2909102 100644
  #ifdef _3DS
     if (string_is_equal(settings->paths.directory_bottom_assets, "default"))
 diff --git a/docs/retroarch.6 b/docs/retroarch.6
-index 7478040e17..f864e0e0d5 100644
+index 7478040e17..f26a1219f0 100644
 --- a/docs/retroarch.6
 +++ b/docs/retroarch.6
 @@ -1,6 +1,6 @@
  .\" retroarch.6:
  
 -.TH  "RETROARCH" "6" "November 1, 2011" "RETROARCH" "System Manager's Manual: retroarch"
-+.TH  "RETROARCH" "6" "September 28, 2024" "RETROARCH" "System Manager's Manual: retroarch"
++.TH  "RETROARCH" "6" "January 18, 2025" "RETROARCH" "System Manager's Manual: retroarch"
  
  .SH NAME
  
-@@ -239,3 +239,36 @@ Disables all kinds of content patching.
+@@ -239,3 +239,48 @@ Disables all kinds of content patching.
  .TP
  \fB-D, --detach\fR
  Detach from the current console. This is currently only relevant for Microsoft Windows.
@@ -123,6 +132,18 @@  index 7478040e17..f864e0e0d5 100644
 +"joypad_autoconfig_dir" configuration file option.
 +
 +.TP
++\fBLIBRETRO_DATABASE_DIRECTORY\fR
++Specify the directory where RetroArch looks for database files,
++overriding the value of the "content_database_path" configuration file
++option.
++
++.TP
++\fBLIBRETRO_SYSTEM_DIRECTORY\fR
++Specify the directory where RetroArch looks for system files,
++overriding the value of the "system_directory" configuration file
++option.
++
++.TP
 +\fBLIBRETRO_VIDEO_FILTER_DIRECTORY\fR
 +Specify the directory where RetroArch looks for video filters,
 +overriding the value of the "video_filter_dir" configuration file
@@ -134,21 +155,23 @@  index 7478040e17..f864e0e0d5 100644
 +overriding the value of the "video_shader_dir" configuration file
 +option.
 diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c
-index c157d355a1..ddf0b5ca87 100644
+index c157d355a1..bec65ca949 100644
 --- a/frontend/drivers/platform_unix.c
 +++ b/frontend/drivers/platform_unix.c
-@@ -1324,6 +1324,10 @@ static void frontend_unix_get_env(int *argc,
+@@ -1324,6 +1324,12 @@ static void frontend_unix_get_env(int *argc,
  {
     unsigned i;
     const char* libretro_directory = getenv("LIBRETRO_DIRECTORY");
 +   const char* libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY");
 +   const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY");
++   const char* libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
++   const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY");
 +   const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY");
 +   const char* libretro_video_shader_directory = getenv("LIBRETRO_VIDEO_SHADER_DIRECTORY");
  #ifdef ANDROID
     int32_t major, minor, rel;
     char device_model[PROP_VALUE_MAX]  = {0};
-@@ -1765,12 +1769,20 @@ static void frontend_unix_get_env(int *argc,
+@@ -1765,12 +1771,20 @@ static void frontend_unix_get_env(int *argc,
              "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
     else
  #endif
@@ -174,7 +197,7 @@  index c157d355a1..ddf0b5ca87 100644
  #ifdef ASSETS_DIR
     if (path_is_directory(ASSETS_DIR "/assets"))
        fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
-@@ -1778,7 +1790,10 @@ static void frontend_unix_get_env(int *argc,
+@@ -1778,7 +1792,10 @@ static void frontend_unix_get_env(int *argc,
              "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
     else
  #endif
@@ -186,7 +209,7 @@  index c157d355a1..ddf0b5ca87 100644
        fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
              "/usr/local/share/retroarch",
              "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
-@@ -1838,7 +1853,11 @@ static void frontend_unix_get_env(int *argc,
+@@ -1838,7 +1855,11 @@ static void frontend_unix_get_env(int *argc,
              "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
     else
  #endif
@@ -199,12 +222,21 @@  index c157d355a1..ddf0b5ca87 100644
        fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER],
              "/usr/local/share/retroarch",
              "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
-@@ -1872,8 +1891,13 @@ static void frontend_unix_get_env(int *argc,
+@@ -1870,10 +1891,20 @@ static void frontend_unix_get_env(int *argc,
+          "records_config", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG]));
+    fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT], base_path,
           "records", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT]));
-    fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path,
-          "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
+-   fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path,
+-         "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
 -   fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path,
 -         "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
++   if (!string_is_empty(libretro_database_directory))
++       strlcpy(g_defaults.dirs[DEFAULT_DIR_DATABASE],
++	       libretro_database_directory,
++	       sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
++   else
++       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path,
++             "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
 +   if (!string_is_empty(libretro_video_shader_directory))
 +       strlcpy(g_defaults.dirs[DEFAULT_DIR_SHADER],
 +	       libretro_video_shader_directory,
@@ -215,16 +247,34 @@  index c157d355a1..ddf0b5ca87 100644
     fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path,
           "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
     fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path,
+@@ -1892,8 +1923,13 @@ static void frontend_unix_get_env(int *argc,
+          "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM]));
+    fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], base_path,
+          "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE]));
+-   fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], base_path,
+-         "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
++   if (!string_is_empty(libretro_system_directory))
++       strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM],
++	       libretro_system_directory,
++	       sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
++   else
++       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], base_path,
++             "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
+ #endif
+ 
+ #ifndef IS_SALAMANDER
 diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c
-index 26ed25c04f..0cc9a9dc95 100644
+index 26ed25c04f..77d415f0e7 100644
 --- a/frontend/drivers/platform_win32.c
 +++ b/frontend/drivers/platform_win32.c
-@@ -565,24 +565,38 @@ static void frontend_win32_env_get(int *argc, char *argv[],
+@@ -565,24 +565,45 @@ static void frontend_win32_env_get(int *argc, char *argv[],
  {
     const char *tmp_dir = getenv("TMP");
     const char *libretro_directory = getenv("LIBRETRO_DIRECTORY");
 +   const char *libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY");
 +   const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY");
++   const char* libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
++   const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY");
 +   const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY");
 +   const char* libretro_video_shader_directory = getenv("LIBRETRO_VIDEO_SHADER_DIRECTORY");
     if (!string_is_empty(tmp_dir))
@@ -255,15 +305,22 @@  index 26ed25c04f..0cc9a9dc95 100644
 +           ":\\filters\\video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CHEATS],
        ":\\cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
-    fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_DATABASE],
-       ":\\database\\rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
+-   fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_DATABASE],
+-      ":\\database\\rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
++   if (!string_is_empty(libretro_database_directory))
++       strlcpy(g_defaults.dirs[DEFAULT_DIR_DATABASE],
++	       libretro_database_directory,
++	       sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
++   else
++       fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_DATABASE],
++           ":\\database\\rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_PLAYLIST],
 -      ":\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
 +      ":\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG],
        ":\\config\\record", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG]));
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT],
-@@ -605,12 +619,26 @@ static void frontend_win32_env_get(int *argc, char *argv[],
+@@ -605,12 +626,26 @@ static void frontend_win32_env_get(int *argc, char *argv[],
     else
        fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE],
              ":\\cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
@@ -296,3 +353,19 @@  index 26ed25c04f..0cc9a9dc95 100644
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS],
        ":\\downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
     fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT],
+@@ -619,8 +654,13 @@ static void frontend_win32_env_get(int *argc, char *argv[],
+       ":\\saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM]));
+    fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SAVESTATE],
+       ":\\states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE]));
+-   fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SYSTEM],
+-      ":\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
++   if (!string_is_empty(libretro_system_directory))
++       strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM],
++	       libretro_system_directory,
++	       sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
++   else
++       fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SYSTEM],
++             ":\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
+    fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_LOGS],
+       ":\\logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS]));
+