pkg: Don't require the dirs to terminate with /

parent 05e1734d
......@@ -606,7 +606,7 @@ function pkg_merge_control(dir, name, files)
for fname in pairs(ls(info_dir)) do
if fname:sub(1, plen) == prefix then
DBG("Removing previous version control file " .. fname)
local _, err = os.remove(info_dir .. fname)
local _, err = os.remove(info_dir .. "/" .. fname)
if err then
error(err)
end
......@@ -632,11 +632,11 @@ function pkg_merge_control(dir, name, files)
DBG("Putting control file " .. fname .. " into place")
table.insert(events, run_command(function (ecode, killed, stdout, stderr)
err = stderr
end, nil, nil, cmd_timeout, cmd_kill_timeout, "/bin/cp", "-Lpf", dir .. fname, info_dir .. fname))
end, nil, nil, cmd_timeout, cmd_kill_timeout, "/bin/cp", "-Lpf", dir .. "/" .. fname, info_dir .. "/" .. fname))
end
end
-- Create the list of files
local f, err = io.open(info_dir .. name .. ".list", "w")
local f, err = io.open(info_dir .. "/" .. name .. ".list", "w")
if err then
error(err)
end
......@@ -705,7 +705,7 @@ function control_cleanup(status)
WARN("Control file " .. file .. " has a wrong name format")
elseif not status[pname] then
DBG("Removing control file " .. file)
local _, err = os.remove(info_dir .. file)
local _, err = os.remove(info_dir .. "/" .. file)
if err then
ERROR(err)
end
......
......@@ -608,25 +608,25 @@ function test_merge_control()
--[[
Create a control file in some directory.
]]
local src_dir = mkdtemp() .. "/"
local src_dir = mkdtemp()
table.insert(tmp_dirs, src_dir)
local f, err = io.open(src_dir .. "pkg1.control", "w")
local f, err = io.open(src_dir .. "/pkg1.control", "w")
assert_not_nil(f, err)
f:write("test\n")
f:close()
local dst_dir = mkdtemp() .. "/"
local dst_dir = mkdtemp()
table.insert(tmp_dirs, dst_dir)
B.info_dir = dst_dir
-- Place an "outdated" file in the destination, which should disappear by the merge
local f, err = io.open(dst_dir .. "pkg1.outdated", "w")
local f, err = io.open(dst_dir .. "/pkg1.outdated", "w")
assert_not_nil(f, err)
f:write("Old\n")
f:close()
B.pkg_merge_control(src_dir, "pkg1", { file = true })
-- The files are in the destination directory with the right content
assert_table_equal({["pkg1.control"] = 'r', ["pkg1.list"] = 'r'}, ls(dst_dir))
assert_equal("test\n", utils.slurp(dst_dir .. "pkg1.control"))
assert_equal("file\n", utils.slurp(dst_dir .. "pkg1.list"))
assert_equal("test\n", utils.slurp(dst_dir .. "/pkg1.control"))
assert_equal("file\n", utils.slurp(dst_dir .. "/pkg1.list"))
-- The file stayed at the origin as well
assert_table_equal({["pkg1.control"] = 'r'}, ls(src_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