Verified Commit ee03f14c authored by Karel Koci's avatar Karel Koci 🤘

Fix info files cleanup

When package has name with dot, updater would clean up its info files
every execution, because it expected that package can't have any dot in
name. This is now changed to instead cut everything from first dot to
end to only cut from last dot to end.
parent 327aa502
......@@ -846,14 +846,19 @@ function control_cleanup(status)
if tp ~= 'r' and tp ~= '?' then
WARN("Non-file " .. file .. " in control directory")
else
local pname = file:match("^([^%.]+)%.")
if not pname then
-- Remove suffix from file name, but only suffix.
local suffix_index = file:find("%.([^%.]+)$")
if not suffix_index or suffix_index == 1 then
-- If name doesn't have suffix or as suffix was identified whole name
WARN("Control file " .. file .. " has a wrong name format")
elseif utils.multi_index(status, pname, "Status", 3) ~= "installed" then
DBG("Removing control file " .. file)
local _, err = os.remove(info_dir .. "/" .. file)
if err then
ERROR(err)
else
local pname = file:sub(1, suffix_index - 1)
if utils.multi_index(status, pname, "Status", 3) ~= "installed" then
DBG("Removing control file " .. file)
local _, err = os.remove(info_dir .. "/" .. file)
if err then
ERROR(err)
end
end
end
end
......
......@@ -616,7 +616,7 @@ function test_control_cleanup()
end
assert_table_equal(all_files, ls(test_dir))
--[[
Run the cleanup, but with both pkg1 and pkg2 installed. Also, the strange files should stay.
Run the cleanup, but with both pkg1 and pkg2 installed. Also, the strange files should stay except pkg2.xyz.abc, because it would be for package pkg2.xyz.
The control_cleanup doesn't care about the content of the packages, so be lazy a bit.
]]
......@@ -626,6 +626,7 @@ function test_control_cleanup()
Status = {"install", "user", "installed"}
}
end
all_files["pkg2.xyz.abc"] = nil
B.control_cleanup({
pkg1 = pkg_gen "pkg1",
pkg2 = pkg_gen "pkg2"
......@@ -634,7 +635,6 @@ function test_control_cleanup()
-- Drop the things belonging to pkg2
B.control_cleanup({ pkg1 = pkg_gen "pkg1" })
all_files["pkg2.control"] = nil
all_files["pkg2.xyz.abc"] = nil
assert_table_equal(all_files, ls(test_dir))
end
......
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