Verified Commit f850887a authored by Karel Koci's avatar Karel Koci 🤘
Browse files

src/lib/lua/planner: reinstall package if more than version not match

This extends list of fields checked for reinstall to not only Version
but also to Architecture, LinkSignature, Depends, Conflicts, Provides.

There are two reasons why we want to have these:

First reason applies on Architecture, Depends, Conflicts and Provides.
Those trigger update to get package information in sync with repository.
Updater runs planning against repository so this has no effect but in
the end if someone forgets to bump package but modifies dependencies for
example then we reinstall package anyway.

Second reason to reinstall package applies on LinkSignature and that is
field inserted with hash generated from dynamic linker information
collected for package. When this hash changes then link dependencies
changed and even if version is same we have to reinstall such package as
it most probably won't work with updated dependencies.

As a tinny bonus logs now contain info about version or any other field
if the differ and that way info about the reason to reinstall given
package.
parent 236e08ce
......@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Package "reinstall" is now performed not only if `Version` field is different
but also when `Architecture`, `LinkSignature`, `Depends`, `Conflicts` or
`Provides` are different.
## [67.0] - 2020-06-23
### Added
- Warning for packages not verified against repository index because missing hash
......
......@@ -599,25 +599,40 @@ local function check_install_version(status, requests)
local installed = {}
for pkg, desc in pairs(status) do
if not desc.Status or desc.Status[3] == "installed" then
installed[pkg] = desc.Version or ""
installed[pkg] = true
end
end
local unused = utils.clone(installed)
local install = {}
-- Go through the requests and look which ones are needed and which ones are satisfied
for _, request in ipairs(requests) do
local installed_version = installed[request.name]
local requested_version = utils.multi_index(request, "package", "Version") or ""
unused[request.name] = nil
if request.action == "require" then
if not installed_version or installed_version ~= requested_version then
if not installed[request.name] then
DBG("Want to install " .. request.name)
install[request.name] = request
else
DBG("Package " .. request.name .. " already installed")
local different = nil
for _, field in ipairs({"Version", "Architecture", "LinkSignature", "Depends", "Conflicts", "Provides"}) do
local installed_field = status[request.name][field] or ""
local requested_field = request.package[field] or ""
if installed_field ~= requested_field then
different = field
break
end
end
if different then
install[request.name] = request
DBG("Want to reinstall " .. request.name ..
" because of change in " .. different .. " (" ..
tostring(status[request.name][different]) .. " -> " ..
tostring(request.package[different]) .. ")")
else
DBG("Package " .. request.name .. " already installed")
end
end
elseif request.action == "reinstall" then
DBG("Want to reinstall " .. request.name)
DBG("Want to reinstall " .. request.name .. " as requested")
install[request.name] = request
else
DIE("Unknown action " .. request.action)
......
......@@ -1416,6 +1416,10 @@ function test_filter_required()
},
pkg5 = {
Version = "5"
},
pkg7 = {
Version = "7",
LinkSignature = "xxxx"
}
}
local requests = {
......@@ -1463,7 +1467,19 @@ function test_filter_required()
},
critical = false,
modifier = {}
}
},
{
-- Installed with correct version but different LinkSignature
action = "require",
name = "pkg7",
package = {
Version = "7",
LinkSignature = "XXXXXX",
repo = def_repo
},
critical = false,
modifier = {}
},
}
local result = planner.filter_required(status, requests, true)
local expected = {
......@@ -1479,6 +1495,7 @@ function test_filter_required()
modifier = {}
},
requests[4],
requests[5],
{
action = "remove",
name = "pkg4",
......
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