Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit c9c5c42

Browse files
committed
Rewrite dependencies for binary package, assuming semantic versioning
1 parent 670d8e1 commit c9c5c42

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

dist/package.lua

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,50 @@ function build_pkg(src_dir, deploy_dir, variables)
274274
if not ok then return nil, "Error when testing the module '" .. pkg_name .. "' with CTest." end
275275
end
276276

277+
-- Rewrite dependencies for binary package
278+
if info.depends then
279+
local dependencies = {}
280+
-- collect all dependencies in single table
281+
for k, dep in pairs(info.depends) do
282+
-- if 'depend' is a table of OS specific dependencies for
283+
-- this arch, add them to the normal dependencies of pkg
284+
if type(dep) == "table" then
285+
if k == cfg.arch then
286+
for _, os_specific_depend in pairs(dep) do
287+
table.insert(dependencies, os_specific_depend)
288+
end
289+
end
290+
elseif type(dep) == "string" then
291+
table.insert(dependencies, dep)
292+
end
293+
end
294+
295+
-- Search for installed dependencies
296+
local installed = depends.get_installed(deploy_dir)
297+
for k, dep in pairs(dependencies) do
298+
print("2:"..k.." ; "..dep)
299+
local version
300+
local name = depends.split_name_constraint(dep)
301+
for i, package in pairs(installed) do
302+
if (package.name == name) then
303+
version = package.version
304+
end
305+
end
306+
dependencies[k] = name
307+
308+
-- Convert version to major/minor only, assuming semantic versioning
309+
if version then
310+
local ver = constraints.parseVersion(version)
311+
if ( ver and ver[1] and ver[2] ) then
312+
version = ver[1].."."..ver[2]
313+
dependencies[k] = name.."~="..version
314+
end
315+
end
316+
end
317+
-- Store the dependencies
318+
info.depends = dependencies
319+
end
320+
277321
-- save modified 'dist.info' file
278322
local pkg_distinfo_dir = sys.make_path(deploy_dir, cfg.distinfos_dir, pkg_name)
279323
sys.make_dir(pkg_distinfo_dir)

0 commit comments

Comments
 (0)