fix(meta): only tag new top-level pkg fragment as optional

This commit is contained in:
Folke Lemaitre 2024-06-25 20:38:16 +02:00
parent aff7ee8e89
commit 25981e1f39
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 6 additions and 3 deletions

View File

@ -34,13 +34,16 @@ function M:load_pkgs()
return return
end end
for _, pkg in ipairs(Pkg.get()) do for _, pkg in ipairs(Pkg.get()) do
local last_id = self.fragments._fid
local meta, fragment = self:add(pkg.spec) local meta, fragment = self:add(pkg.spec)
if meta and fragment then if meta and fragment then
meta._.pkg = pkg meta._.pkg = pkg
-- tag all package fragments as optional -- tag all top-level package fragments that were added as optional
for _, fid in ipairs(meta._.frags) do for _, fid in ipairs(meta._.frags) do
local frag = self.fragments:get(fid) if fid > last_id then
frag.spec.optional = true local frag = self.fragments:get(fid)
frag.spec.optional = true
end
end end
-- keep track of the top-level package fragment -- keep track of the top-level package fragment
self.pkgs[pkg.dir] = fragment.id self.pkgs[pkg.dir] = fragment.id