From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EPuTLgyXEmEiowAAgWs5BA (envelope-from ) for ; Tue, 10 Aug 2021 17:11:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id kL0ZKgyXEmHSTgAAbx9fmQ (envelope-from ) for ; Tue, 10 Aug 2021 15:11:08 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 10E6F2CA4D for ; Tue, 10 Aug 2021 17:11:08 +0200 (CEST) Received: from localhost ([::1]:41472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDTPH-0000T5-3P for larch@yhetil.org; Tue, 10 Aug 2021 11:11:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDTMJ-0003f0-Te for guix-patches@gnu.org; Tue, 10 Aug 2021 11:08:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDTMJ-00022Y-NC for guix-patches@gnu.org; Tue, 10 Aug 2021 11:08:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDTMJ-0007YC-Ic for guix-patches@gnu.org; Tue, 10 Aug 2021 11:08:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49828] [PATCH v3 02/20] gnu: minetest: Search for mods in MINETEST_MOD_PATH. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Aug 2021 15:08:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49828@debbugs.gnu.org Cc: Leo Prikler , Maxime Devos Received: via spool by 49828-submit@debbugs.gnu.org id=B49828.162860805928809 (code B ref 49828); Tue, 10 Aug 2021 15:08:03 +0000 Received: (at 49828) by debbugs.gnu.org; 10 Aug 2021 15:07:39 +0000 Received: from localhost ([127.0.0.1]:60323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDTLu-0007UR-L0 for submit@debbugs.gnu.org; Tue, 10 Aug 2021 11:07:39 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:47590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDTLs-0007U9-FM for 49828@debbugs.gnu.org; Tue, 10 Aug 2021 11:07:37 -0400 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by michel.telenet-ops.be with bizsmtp id fr7a2500W0mfAB406r7bj1; Tue, 10 Aug 2021 17:07:35 +0200 From: Maxime Devos Date: Tue, 10 Aug 2021 17:07:16 +0200 Message-Id: <20210810150734.11778-3-maximedevos@telenet.be> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810150734.11778-1-maximedevos@telenet.be> References: <20210810150734.11778-1-maximedevos@telenet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1628608055; bh=JZpD2bVhpS5aeRSzOQ9bhTioT0ZsylAJ7BRP1vQmRsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=geUo400UyquPQBwfuhyeZFOcZjGZkoFC1l7uIZ1Xk2bkUEhinWx3VCEKfYoOFWmuE VF1HT4NiOaXx7sBxD17gTc5Kw7X8ah0lLgk80aKPwGjIzo+7xgbIkRkz7ockoBMgKl pLbiB1IBx5tNNXNnAo6F2PQwGVh9KKQHWXJtI5K84admcDF7eZuc2aY8ir5/GjNErF AUnwnPh+RpVPFuSgYBcjkYqulewR+uF9TgVq8Ki4/OMR8bcj1vJO73dguJdLYOnnH6 /dTegVLNt+ojAj3egUwLkwFQG13PZvzb3vEyPx3kkmAS3uVR/I1I7cBAPk/Y1CfYiA +uA46rU8xkGyw== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628608268; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=JZpD2bVhpS5aeRSzOQ9bhTioT0ZsylAJ7BRP1vQmRsE=; b=jf0KF6w1tkCTWhKewS0ZthS9JjGzYO41FDeJ6rCVLQoIgtIQfOD+8f2MTDMYllMMZjw8WA 5zPsLvb/FTCZl3SUjofqBmUdvjJ7qHXb6xN5T2tCAQRKImETFz/kyDmwyNG6aWG+mSLf/D ZJSJrRqUlkmM+wfnLe/Sea1ow6arcfRdSxVGMM8+HyILn2hGHTjTtVD9oG4AJAlPwFFtYi N0v48NB0mhdJRfpOOeSX5kuWGY4IXkjCOqH463aeAzZawebMNSIf++DL0QbQCt4LMuGzE2 eiBvXIGR36fno3hyxJ7SbnyMcIcXe7uw5/WbVeXA7aLLujl7voChBfwbbEeu0w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628608268; a=rsa-sha256; cv=none; b=G1OJg9SJYWa+Hes+MTN00BTmMO19jqp8jJpY5FlNn6zNBLCJG/c7F+OjHLNrLX9H33qZJi LUM6QW6ATiU5g55be5XUw7U2CTAGvHSejhpTeRLULBns5juV6Osy+Uc5rYchJdW8T8wYdg RFxbIS9ZULsFm+iU8itbck+98dLxIj4SBr42fSzp5kiR4Yb1jnpJ0BtuVomlOT/oG7KIFS sqzog7iyNaoC2IaoDEBE18TftcOqfY5OjRhduj7JohpyHN+iaKTwWaUL0earWGg4kJKJuF Y9yLdiY0CEUBJo98E+nzJpuWNAa6x1MemxIW1LV0cVpDtWDrAUVt/UGDeG7JIA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=geUo400U; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=geUo400U; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 10E6F2CA4D X-Spam-Score: -0.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: cqtyjD/PU8Ey * 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 +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 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