mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Offer ContentDB updates for leftover bundled Minetest Game (#13906)
This commit is contained in:
		@@ -698,9 +698,7 @@ local function resolve_auto_install_spec()
 | 
			
		||||
	local resolved = nil
 | 
			
		||||
 | 
			
		||||
	for _, pkg in ipairs(store.packages_full_unordered) do
 | 
			
		||||
		if pkg.author == auto_install_spec.author and
 | 
			
		||||
				(pkg.name == auto_install_spec.name or
 | 
			
		||||
					(pkg.type == "game" and pkg.name == auto_install_spec.name .. "_game")) then
 | 
			
		||||
		if pkg.id == auto_install_spec then
 | 
			
		||||
			resolved = pkg
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
@@ -777,26 +775,26 @@ function store.update_paths()
 | 
			
		||||
	local mod_hash = {}
 | 
			
		||||
	pkgmgr.refresh_globals()
 | 
			
		||||
	for _, mod in pairs(pkgmgr.global_mods:get_list()) do
 | 
			
		||||
		if mod.author and mod.release > 0 then
 | 
			
		||||
			local id = mod.author:lower() .. "/" .. mod.name
 | 
			
		||||
			mod_hash[store.aliases[id] or id] = mod
 | 
			
		||||
		local cdb_id = pkgmgr.get_contentdb_id(mod)
 | 
			
		||||
		if cdb_id then
 | 
			
		||||
			mod_hash[store.aliases[cdb_id] or cdb_id] = mod
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local game_hash = {}
 | 
			
		||||
	pkgmgr.update_gamelist()
 | 
			
		||||
	for _, game in pairs(pkgmgr.games) do
 | 
			
		||||
		if game.author ~= "" and game.release > 0 then
 | 
			
		||||
			local id = game.author:lower() .. "/" .. game.id
 | 
			
		||||
			game_hash[store.aliases[id] or id] = game
 | 
			
		||||
		local cdb_id = pkgmgr.get_contentdb_id(game)
 | 
			
		||||
		if cdb_id then
 | 
			
		||||
			game_hash[store.aliases[cdb_id] or cdb_id] = game
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local txp_hash = {}
 | 
			
		||||
	for _, txp in pairs(pkgmgr.get_texture_packs()) do
 | 
			
		||||
		if txp.author and txp.release > 0 then
 | 
			
		||||
			local id = txp.author:lower() .. "/" .. txp.name
 | 
			
		||||
			txp_hash[store.aliases[id] or id] = txp
 | 
			
		||||
		local cdb_id = pkgmgr.get_contentdb_id(txp)
 | 
			
		||||
		if cdb_id then
 | 
			
		||||
			txp_hash[store.aliases[cdb_id] or cdb_id] = txp
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
@@ -815,6 +813,7 @@ function store.update_paths()
 | 
			
		||||
			package.installed_release = content.release or 0
 | 
			
		||||
		else
 | 
			
		||||
			package.path = nil
 | 
			
		||||
			package.installed_release = nil
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -1193,7 +1192,7 @@ end
 | 
			
		||||
--- @param type string | nil
 | 
			
		||||
--- Sets initial package filter. "game", "mod", "txp" or nil (no filter).
 | 
			
		||||
--- @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.
 | 
			
		||||
function create_store_dlg(type, install_spec)
 | 
			
		||||
	search_string = ""
 | 
			
		||||
 
 | 
			
		||||
@@ -777,6 +777,30 @@ function pkgmgr.update_gamelist()
 | 
			
		||||
	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
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ local function has_packages_from_cdb()
 | 
			
		||||
	pkgmgr.update_gamelist()
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
@@ -114,18 +114,13 @@ function update_detector.get_all()
 | 
			
		||||
	local ret = {}
 | 
			
		||||
	local all_content = pkgmgr.get_all()
 | 
			
		||||
	for _, content in ipairs(all_content) do
 | 
			
		||||
		if content.author and content.release > 0 then
 | 
			
		||||
			-- 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 cdb_id = pkgmgr.get_contentdb_id(content)
 | 
			
		||||
 | 
			
		||||
			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
 | 
			
		||||
				latest_release = latest_releases[id .. "_game"]
 | 
			
		||||
				latest_release = latest_releases[cdb_id .. "_game"]
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			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 dlg = create_store_dlg(nil, { author = "Minetest", name = "minetest_game" })
 | 
			
		||||
		local dlg = create_store_dlg(nil, "minetest/minetest")
 | 
			
		||||
		dlg:set_parent(maintab)
 | 
			
		||||
		maintab:hide()
 | 
			
		||||
		dlg:show()
 | 
			
		||||
 
 | 
			
		||||
@@ -254,7 +254,7 @@ local function handle_buttons(tabview, fields, tabname, tabdata)
 | 
			
		||||
 | 
			
		||||
	if fields.btn_mod_mgr_update then
 | 
			
		||||
		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)
 | 
			
		||||
		tabview:hide()
 | 
			
		||||
		dlg:show()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user