Verified Commit 1a4138be authored by Karel Koci's avatar Karel Koci 🤘

Don't expect remove action in filter_required

"remove" actions are no longer created in "required_pkgs". Only place
where such actions can be created is now filter_required it self, so
"remove" actions are not expected in its input any more and if they
occur there, it's bug.
parent a444adb6
......@@ -371,15 +371,13 @@ Take list of available packages (in the format of pkg candidate groups
produced in postprocess.available_packages) and list of requests what
to install and remove. Produce list of packages, in the form:
{
{action = "require"/"reinstall"/"remove", package = pkg_source, modifier = modifier}
{action = "require"/"reinstall", package = pkg_source, modifier = modifier}
}
The action specifies if the package should be made present in the system (installed
if missing), reinstalled (installed no matter if it is already present) or
removed from the system.
if missing) or reinstalled (installed no matter if it is already present)
• Required to be installed
• Required to be reinstalled even when already present (they ARE part of the previous set)
• Required to be removed if present (they are not present in the previous two lists)
The pkg_source is the package object (in case it contains the source field or is virtual)
or the description produced from parsing the repository. The modifier is the object
......@@ -486,9 +484,10 @@ function required_pkgs(pkgs, requests)
end
--[[
Go through the list of requests on the input. Pass the needed ones through
and leave the extra (eg. requiring already installed package) out. Add
requests to remove not required packages.
Go through the list of requests on the input. Pass the needed ones through and
leave the extra (eg. requiring already installed package) out. And creates
additional requests with action "remove", such package is present on system, but
is not required any more and should be removed.
]]
function filter_required(status, requests)
local installed = {}
......@@ -514,22 +513,11 @@ function filter_required(status, requests)
unused[request.name] = nil
elseif request.action == "reinstall" then
-- Make a shallow copy and change the action requested
local new_req = {}
for k, v in pairs(request) do
new_req[k] = v
end
local new_req = utils.shallow_copy(request)
new_req.action = "require"
DBG("Want to reinstall " .. request.name)
table.insert(result, new_req)
unused[request.name] = nil
elseif request.action == "remove" then
if installed[request.name] then
DBG("Want to remove " .. request.name)
table.insert(result, request)
else
DBG("Package " .. request.name .. " not installed, ignoring request to remove")
end
unused[request.name] = nil
else
DIE("Unknown action " .. request.action)
end
......
......@@ -717,9 +717,6 @@ function test_filter_required()
},
pkg4 = {
Version = "4"
},
pkg5 = {
Version = "5"
}
}
local requests = {
......@@ -753,22 +750,13 @@ function test_filter_required()
},
modifier = {}
},
{
-- Installed and we want to remove it
action = "remove",
name = "pkg4",
package = {
Version = "4",
repo = def_repo
}
},
-- The pkg5 is not mentioned, it shall be uninstalled at the end
-- The pkg4 is not mentioned, it shall be uninstalled at the end
{
-- Not installed and we want it
action = "require",
name = "pkg6",
name = "pkg5",
package = {
Version = "6",
Version = "5",
repo = def_repo
},
modifier = {}
......@@ -787,12 +775,11 @@ function test_filter_required()
modifier = {}
},
requests[4],
requests[5],
{
action = "remove",
name = "pkg5",
name = "pkg4",
package = {
Version = "5"
Version = "4"
-- No repo field here, this comes from the status, there are no repositories
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment