all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 49828@debbugs.gnu.org
Cc: Leo Prikler <leo.prikler@student.tugraz.at>,
	Maxime Devos <maximedevos@telenet.be>
Subject: [bug#49828] [PATCH v3 02/20] gnu: minetest: Search for mods in MINETEST_MOD_PATH.
Date: Tue, 10 Aug 2021 17:07:16 +0200	[thread overview]
Message-ID: <20210810150734.11778-3-maximedevos@telenet.be> (raw)
In-Reply-To: <20210810150734.11778-1-maximedevos@telenet.be>

* gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch:
  New file.
* gnu/packages/games.scm
  (minetest)[source]{patches}: Add it.
  (minetest)[native-search-paths]: Add "MINETEST_MOD_PATH".
* gnu/local.mk (dist_patch_DATA): Add the patch.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/games.scm                        |   8 +-
 ...vironment-variable-MINETEST_MOD_PATH.patch | 156 ++++++++++++++++++
 3 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c80a9af78c..d96d4e3dbc 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -801,6 +801,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/abseil-cpp-fix-gtest.patch		\
   %D%/packages/patches/abseil-cpp-fix-strerror_test.patch	\
   %D%/packages/patches/adb-add-libraries.patch			\
+  %D%/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch	\
   %D%/packages/patches/aegis-constness-error.patch         	\
   %D%/packages/patches/aegis-perl-tempdir1.patch           	\
   %D%/packages/patches/aegis-perl-tempdir2.patch           	\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 3e7086b398..48d46a0379 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -3553,6 +3553,9 @@ match, cannon keep, and grave-itation pit.")
                (base32
                 "062ilb7s377q3hwfhl8q06vvcw2raydz5ljzlzwy2dmyzmdcndb8"))
               (modules '((guix build utils)))
+              (patches
+               (search-patches
+                "Add-environment-variable-MINETEST_MOD_PATH.patch"))
               (snippet
                '(begin
                   ;; Delete bundled libraries.
@@ -3599,7 +3602,10 @@ match, cannon keep, and grave-itation pit.")
     (native-search-paths
      (list (search-path-specification
             (variable "MINETEST_SUBGAME_PATH")
-            (files '("share/minetest/games")))))
+            (files '("share/minetest/games")))
+           (search-path-specification
+            (variable "MINETEST_MOD_PATH")
+            (files '("share/minetest/mods")))))
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
diff --git a/gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch b/gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch
new file mode 100644
index 0000000000..a74034a2c5
--- /dev/null
+++ b/gnu/packages/patches/Add-environment-variable-MINETEST_MOD_PATH.patch
@@ -0,0 +1,156 @@
+From d10ea2ad7efc2364a8a2007b4c6d3e85511e2f84 Mon Sep 17 00:00:00 2001
+From: Maxime Devos <maximedevos@telenet.be>
+Date: Tue, 3 Aug 2021 01:00:23 +0200
+Subject: [PATCH] Add environment variable MINETEST_MOD_PATH
+
+This adds an environment variable MINETEST_MOD_PATH.
+When it exists, Minetest will look there for mods
+in addition to ~/.minetest/mods/.  Mods can still be
+installed to ~/.minetest/mods/ with the built-in installer.
+
+With thanks to Leo Prikler.
+---
+ builtin/mainmenu/pkgmgr.lua       |  7 +++----
+ doc/menu_lua_api.txt              |  8 +++++++-
+ src/content/subgames.cpp          | 11 +++++++++++
+ src/script/lua_api/l_mainmenu.cpp | 23 +++++++++++++++++++++++
+ src/script/lua_api/l_mainmenu.h   |  2 ++
+ 5 files changed, 46 insertions(+), 5 deletions(-)
+
+diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
+index 787936e31..d8fba0ebe 100644
+--- a/builtin/mainmenu/pkgmgr.lua
++++ b/builtin/mainmenu/pkgmgr.lua
+@@ -682,10 +682,9 @@ function pkgmgr.preparemodlist(data)
+ 	local game_mods = {}
+ 
+ 	--read global mods
+-	local modpath = core.get_modpath()
+-
+-	if modpath ~= nil and
+-		modpath ~= "" then
++	local modpaths = core.get_modpaths()
++	--XXX what was ‘modpath ~= ""’ and ‘modpath ~= nil’ for?
++	for _,modpath in ipairs(modpaths) do
+ 		get_mods(modpath,global_mods)
+ 	end
+ 
+diff --git a/doc/menu_lua_api.txt b/doc/menu_lua_api.txt
+index b3975bc1d..132444b14 100644
+--- a/doc/menu_lua_api.txt
++++ b/doc/menu_lua_api.txt
+@@ -218,7 +218,13 @@ Package - content which is downloadable from the content db, may or may not be i
+     * returns path to global user data,
+       the directory that contains user-provided mods, worlds, games, and texture packs.
+ * core.get_modpath() (possible in async calls)
+-    * returns path to global modpath
++    * returns path to global modpath, where mods can be installed
++* core.get_modpaths() (possible in async calls)
++    * returns list of paths to global modpaths, where mods have been installed
++
++      The difference with "core.get_modpath" is that no mods should be installed in these
++      directories by Minetest -- they might be read-only.
++
+ * core.get_clientmodpath() (possible in async calls)
+     * returns path to global client-side modpath
+ * core.get_gamepath() (possible in async calls)
+diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp
+index e9dc609b0..d73f95a1f 100644
+--- a/src/content/subgames.cpp
++++ b/src/content/subgames.cpp
+@@ -61,6 +61,12 @@ std::string getSubgamePathEnv()
+ 	return subgame_path ? std::string(subgame_path) : "";
+ }
+ 
++std::string getModPathEnv()
++{
++	char *mod_path = getenv("MINETEST_MOD_PATH");
++	return mod_path ? std::string(mod_path) : "";
++}
++
+ SubgameSpec findSubgame(const std::string &id)
+ {
+ 	if (id.empty())
+@@ -110,6 +116,11 @@ SubgameSpec findSubgame(const std::string &id)
+ 	std::set<std::string> mods_paths;
+ 	if (!user_game)
+ 		mods_paths.insert(share + DIR_DELIM + "mods");
++
++	Strfnd mod_search_paths(getModPathEnv());
++	while (!mod_search_paths.at_end())
++		mods_paths.insert(mod_search_paths.next(PATH_DELIM));
++
+ 	if (user != share || user_game)
+ 		mods_paths.insert(user + DIR_DELIM + "mods");
+ 
+diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
+index 3e9709bde..903ac3a22 100644
+--- a/src/script/lua_api/l_mainmenu.cpp
++++ b/src/script/lua_api/l_mainmenu.cpp
+@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+ #include "lua_api/l_internal.h"
+ #include "common/c_content.h"
+ #include "cpp_api/s_async.h"
++#include "util/strfnd.h"
+ #include "gui/guiEngine.h"
+ #include "gui/guiMainMenu.h"
+ #include "gui/guiKeyChangeMenu.h"
+@@ -502,6 +503,26 @@ int ModApiMainMenu::l_get_modpath(lua_State *L)
+ 	return 1;
+ }
+ 
++/******************************************************************************/
++int ModApiMainMenu::l_get_modpaths(lua_State *L)
++{
++	const char *c_modpath = getenv("MINETEST_MOD_PATH");
++	if (c_modpath == NULL)
++		c_modpath = "";
++	int index = 1;
++	lua_newtable(L);
++	Strfnd mod_search_paths{std::string(c_modpath)};
++	while (!mod_search_paths.at_end()) {
++		std::string component = mod_search_paths.next(PATH_DELIM);
++		lua_pushstring(L, component.c_str());
++		lua_rawseti(L, -2, index);
++		index++;
++	}
++	ModApiMainMenu::l_get_modpath(L);
++	lua_rawseti(L, -2, index);
++	return 1;
++}
++
+ /******************************************************************************/
+ int ModApiMainMenu::l_get_clientmodpath(lua_State *L)
+ {
+@@ -949,6 +970,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
+ 	API_FCT(get_mapgen_names);
+ 	API_FCT(get_user_path);
+ 	API_FCT(get_modpath);
++	API_FCT(get_modpaths);
+ 	API_FCT(get_clientmodpath);
+ 	API_FCT(get_gamepath);
+ 	API_FCT(get_texturepath);
+@@ -983,6 +1005,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
+ 	API_FCT(get_mapgen_names);
+ 	API_FCT(get_user_path);
+ 	API_FCT(get_modpath);
++	API_FCT(get_modpaths);
+ 	API_FCT(get_clientmodpath);
+ 	API_FCT(get_gamepath);
+ 	API_FCT(get_texturepath);
+diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
+index 33ac9e721..a6a54a2cb 100644
+--- a/src/script/lua_api/l_mainmenu.h
++++ b/src/script/lua_api/l_mainmenu.h
+@@ -112,6 +112,8 @@ class ModApiMainMenu: public ModApiBase
+ 
+ 	static int l_get_modpath(lua_State *L);
+ 
++	static int l_get_modpaths(lua_State *L);
++
+ 	static int l_get_clientmodpath(lua_State *L);
+ 
+ 	static int l_get_gamepath(lua_State *L);
+-- 
+2.32.0
+
-- 
2.32.0





  parent reply	other threads:[~2021-08-10 15:11 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 15:46 [bug#49828] [PATCH 00/20] Add minetest mods Maxime Devos
2021-08-02 15:50 ` [bug#49828] [PATCH 01/20] gnu: minetest: Respect --without-tests Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 02/20] gnu: minetest: Search for mods in MINETEST_MOD_PATH Maxime Devos
2021-08-02 17:28     ` Leo Prikler
2021-08-02 17:53       ` Maxime Devos
2021-08-02 18:47         ` Leo Prikler
2021-08-03 11:09           ` Maxime Devos
2021-08-03 11:10             ` Maxime Devos
2021-08-03 11:54               ` Leo Prikler
2021-08-02 15:50   ` [bug#49828] [PATCH 03/20] gnu: minetest: New package module Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 04/20] build-system: Add 'minetest-mod-build-system' Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 05/20] build-system: minetest: Don't retain references to "bash-minimal" Maxime Devos
2021-08-03  9:17     ` Leo Prikler
2021-08-03 11:59       ` Maxime Devos
2021-08-03 12:28         ` Leo Prikler
2021-08-05 11:01           ` Maxime Devos
2021-08-05 12:04             ` Leo Prikler
2021-08-05 13:16               ` Maxime Devos
2021-08-05 13:42                 ` Leo Prikler
2021-08-05 14:41                   ` Maxime Devos
2021-08-05 15:15                     ` Leo Prikler
2021-08-02 15:50   ` [bug#49828] [PATCH 06/20] guix: Add ContentDB importer Maxime Devos
2021-08-05 16:41     ` Leo Prikler
2021-08-07 18:31       ` Maxime Devos
2021-08-07 19:47         ` Leo Prikler
2021-08-09 20:00           ` [bug#49828] [PATCH 06/20] guix: Add ContentDB importer. (XXX Don't send yet) Maxime Devos
2021-08-09 20:04             ` Maxime Devos
2021-08-09 21:45             ` [bug#49828] [PATCH 06/20] guix: Add ContentDB importer. (XXX Yes send now) Leo Prikler
2021-08-10 11:02               ` [bug#49828] [PATCH 06/20] guix: Add ContentDB importer Maxime Devos
2021-08-10 12:16                 ` Leo Prikler
2021-08-10 15:07                 ` [bug#49828] [PATCH v3 00/20] Add minetest mods Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 01/20] gnu: minetest: Respect --without-tests Maxime Devos
2021-08-10 15:07                   ` Maxime Devos [this message]
2021-08-20 11:45                     ` bug#49828: [PATCH v3 02/20] gnu: minetest: Search for mods in MINETEST_MOD_PATH Leo Prikler
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 03/20] gnu: minetest: New package module Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 04/20] build-system: Add 'minetest-mod-build-system' Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 05/20] import/utils: Recognise GPL-3.0-or-later and friends Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 06/20] guix: Add ContentDB importer Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 07/20] gnu: Add minetest-mesecons Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 08/20] gnu: Add minetest-basic-materials Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 09/20] gnu: Add minetest-unifieddyes Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 10/20] gnu: Add minetest-pipeworks Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 11/20] gnu: Add minetest-coloredwood Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 12/20] gnu: Add minetest-ethereal Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 13/20] gnu: Add minetest-technic Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 14/20] gnu: Add minetest-throwing Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 15/20] gnu: Add minetest-throwing-arrows Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 16/20] gnu: Add minetest-unified-inventory Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 17/20] gnu: Add minetest-worldedit Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 18/20] gnu: Add minetest-mobs Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 19/20] gnu: Add minetest-mobs-animal Maxime Devos
2021-08-10 15:07                   ` [bug#49828] [PATCH v3 20/20] gnu: Add minetest-homedecor-modpack Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 07/20] gnu: Add minetest-mesecons Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 08/20] gnu: Add minetest-basic-materials Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 09/20] gnu: Add minetest-unifieddyes Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 10/20] gnu: Add minetest-pipeworks Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 11/20] gnu: Add minetest-coloredwood Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 12/20] gnu: Add minetest-ethereal Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 13/20] gnu: Add minetest-technic Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 14/20] gnu: Add minetest-throwing Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 15/20] gnu: Add minetest-throwing-arrows Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 16/20] gnu: Add minetest-unified-inventory Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 17/20] gnu: Add minetest-worldedit Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 18/20] gnu: Add minetest-mobs Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 19/20] gnu: Add minetest-mobs-animal Maxime Devos
2021-08-02 15:50   ` [bug#49828] [PATCH 20/20] gnu: Add minetest-homedecor-modpack Maxime Devos
2021-08-02 17:14   ` [bug#49828] [PATCH 01/20] gnu: minetest: Respect --without-tests Leo Prikler
2021-08-02 17:18     ` Maxime Devos
2021-08-02 17:22       ` Leo Prikler
2021-08-05 12:46 ` [bug#49828] [PATCH 00/20] Add minetest mods Andrew Ward
2021-08-05 21:10   ` Maxime Devos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210810150734.11778-3-maximedevos@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=49828@debbugs.gnu.org \
    --cc=leo.prikler@student.tugraz.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.