mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Offer ContentDB updates for leftover bundled Minetest Game (#13906)
This commit is contained in:
parent
726326924d
commit
adec16790b
@ -698,9 +698,7 @@ local function resolve_auto_install_spec()
|
|||||||
local resolved = nil
|
local resolved = nil
|
||||||
|
|
||||||
for _, pkg in ipairs(store.packages_full_unordered) do
|
for _, pkg in ipairs(store.packages_full_unordered) do
|
||||||
if pkg.author == auto_install_spec.author and
|
if pkg.id == auto_install_spec then
|
||||||
(pkg.name == auto_install_spec.name or
|
|
||||||
(pkg.type == "game" and pkg.name == auto_install_spec.name .. "_game")) then
|
|
||||||
resolved = pkg
|
resolved = pkg
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -777,26 +775,26 @@ function store.update_paths()
|
|||||||
local mod_hash = {}
|
local mod_hash = {}
|
||||||
pkgmgr.refresh_globals()
|
pkgmgr.refresh_globals()
|
||||||
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
for _, mod in pairs(pkgmgr.global_mods:get_list()) do
|
||||||
if mod.author and mod.release > 0 then
|
local cdb_id = pkgmgr.get_contentdb_id(mod)
|
||||||
local id = mod.author:lower() .. "/" .. mod.name
|
if cdb_id then
|
||||||
mod_hash[store.aliases[id] or id] = mod
|
mod_hash[store.aliases[cdb_id] or cdb_id] = mod
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local game_hash = {}
|
local game_hash = {}
|
||||||
pkgmgr.update_gamelist()
|
pkgmgr.update_gamelist()
|
||||||
for _, game in pairs(pkgmgr.games) do
|
for _, game in pairs(pkgmgr.games) do
|
||||||
if game.author ~= "" and game.release > 0 then
|
local cdb_id = pkgmgr.get_contentdb_id(game)
|
||||||
local id = game.author:lower() .. "/" .. game.id
|
if cdb_id then
|
||||||
game_hash[store.aliases[id] or id] = game
|
game_hash[store.aliases[cdb_id] or cdb_id] = game
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local txp_hash = {}
|
local txp_hash = {}
|
||||||
for _, txp in pairs(pkgmgr.get_texture_packs()) do
|
for _, txp in pairs(pkgmgr.get_texture_packs()) do
|
||||||
if txp.author and txp.release > 0 then
|
local cdb_id = pkgmgr.get_contentdb_id(txp)
|
||||||
local id = txp.author:lower() .. "/" .. txp.name
|
if cdb_id then
|
||||||
txp_hash[store.aliases[id] or id] = txp
|
txp_hash[store.aliases[cdb_id] or cdb_id] = txp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -815,6 +813,7 @@ function store.update_paths()
|
|||||||
package.installed_release = content.release or 0
|
package.installed_release = content.release or 0
|
||||||
else
|
else
|
||||||
package.path = nil
|
package.path = nil
|
||||||
|
package.installed_release = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1193,7 +1192,7 @@ end
|
|||||||
--- @param type string | nil
|
--- @param type string | nil
|
||||||
--- Sets initial package filter. "game", "mod", "txp" or nil (no filter).
|
--- Sets initial package filter. "game", "mod", "txp" or nil (no filter).
|
||||||
--- @param install_spec table | nil
|
--- @param install_spec table | nil
|
||||||
--- Package specification of the form { author = string, name = string }.
|
--- ContentDB ID of package as returned by pkgmgr.get_contentdb_id().
|
||||||
--- Sets package to install or update automatically.
|
--- Sets package to install or update automatically.
|
||||||
function create_store_dlg(type, install_spec)
|
function create_store_dlg(type, install_spec)
|
||||||
search_string = ""
|
search_string = ""
|
||||||
|
@ -777,6 +777,30 @@ function pkgmgr.update_gamelist()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- Returns the ContentDB ID for an installed piece of content.
|
||||||
|
function pkgmgr.get_contentdb_id(content)
|
||||||
|
-- core.get_games() will return "" instead of nil if there is no "author" field.
|
||||||
|
if content.author and content.author ~= "" and content.release > 0 then
|
||||||
|
if content.type == "game" then
|
||||||
|
return content.author:lower() .. "/" .. content.id
|
||||||
|
end
|
||||||
|
return content.author:lower() .. "/" .. content.name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Until Minetest 5.8.0, Minetest Game was bundled with Minetest.
|
||||||
|
-- Unfortunately, the bundled MTG was not versioned (missing "release"
|
||||||
|
-- field in game.conf).
|
||||||
|
-- Therefore, we consider any installation of MTG that is not versioned,
|
||||||
|
-- has not been cloned from Git, and is not system-wide to be updatable.
|
||||||
|
if content.type == "game" and content.id == "minetest" and content.release == 0 and
|
||||||
|
not core.is_dir(content.path .. "/.git") and core.may_modify_path(content.path) then
|
||||||
|
return "minetest/minetest"
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- read initial data
|
-- read initial data
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -59,7 +59,7 @@ local function has_packages_from_cdb()
|
|||||||
pkgmgr.update_gamelist()
|
pkgmgr.update_gamelist()
|
||||||
|
|
||||||
for _, content in pairs(pkgmgr.get_all()) do
|
for _, content in pairs(pkgmgr.get_all()) do
|
||||||
if content.author and content.release > 0 then
|
if pkgmgr.get_contentdb_id(content) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -114,18 +114,13 @@ function update_detector.get_all()
|
|||||||
local ret = {}
|
local ret = {}
|
||||||
local all_content = pkgmgr.get_all()
|
local all_content = pkgmgr.get_all()
|
||||||
for _, content in ipairs(all_content) do
|
for _, content in ipairs(all_content) do
|
||||||
if content.author and content.release > 0 then
|
local cdb_id = pkgmgr.get_contentdb_id(content)
|
||||||
-- The backend will account for aliases in `latest_releases`
|
|
||||||
local id = content.author:lower() .. "/"
|
|
||||||
if content.type == "game" then
|
|
||||||
id = id .. content.id
|
|
||||||
else
|
|
||||||
id = id .. content.name
|
|
||||||
end
|
|
||||||
|
|
||||||
local latest_release = latest_releases[id]
|
if cdb_id then
|
||||||
|
-- The backend will account for aliases in `latest_releases`
|
||||||
|
local latest_release = latest_releases[cdb_id]
|
||||||
if not latest_release and content.type == "game" then
|
if not latest_release and content.type == "game" then
|
||||||
latest_release = latest_releases[id .. "_game"]
|
latest_release = latest_releases[cdb_id .. "_game"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if latest_release and latest_release > content.release then
|
if latest_release and latest_release > content.release then
|
||||||
|
@ -78,7 +78,7 @@ local function buttonhandler(this, fields)
|
|||||||
|
|
||||||
local maintab = ui.find_by_name("maintab")
|
local maintab = ui.find_by_name("maintab")
|
||||||
|
|
||||||
local dlg = create_store_dlg(nil, { author = "Minetest", name = "minetest_game" })
|
local dlg = create_store_dlg(nil, "minetest/minetest")
|
||||||
dlg:set_parent(maintab)
|
dlg:set_parent(maintab)
|
||||||
maintab:hide()
|
maintab:hide()
|
||||||
dlg:show()
|
dlg:show()
|
||||||
|
@ -254,7 +254,7 @@ local function handle_buttons(tabview, fields, tabname, tabdata)
|
|||||||
|
|
||||||
if fields.btn_mod_mgr_update then
|
if fields.btn_mod_mgr_update then
|
||||||
local pkg = packages:get_list()[tabdata.selected_pkg]
|
local pkg = packages:get_list()[tabdata.selected_pkg]
|
||||||
local dlg = create_store_dlg(nil, { author = pkg.author, name = pkg.id or pkg.name })
|
local dlg = create_store_dlg(nil, pkgmgr.get_contentdb_id(pkg))
|
||||||
dlg:set_parent(tabview)
|
dlg:set_parent(tabview)
|
||||||
tabview:hide()
|
tabview:hide()
|
||||||
dlg:show()
|
dlg:show()
|
||||||
|
Loading…
Reference in New Issue
Block a user