The branch stable/15 has been updated by ivy:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2bf7d850c53e55ffced055235de432055f0cb9e2

commit 2bf7d850c53e55ffced055235de432055f0cb9e2
Author:     Isaac Freund <ifre...@freebsdfoundation.org>
AuthorDate: 2025-09-16 19:38:54 +0000
Commit:     Lexi Winter <i...@freebsd.org>
CommitDate: 2025-09-19 01:18:42 +0000

    release: use sets to select base packages
    
    The introduction of package sets allows us to replace the current
    fragile string matching with this simpler and more robust alternative.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 seconds
    Reviewed by:    emaste, ivy
    Differential Revision:  https://reviews.freebsd.org/D52592
    
    (cherry picked from commit 6cdca18d79b9e247d8a34e266fe2215e4bfa1b05)
---
 release/scripts/pkgbase-stage.lua | 96 ++++++++++++---------------------------
 1 file changed, 28 insertions(+), 68 deletions(-)

diff --git a/release/scripts/pkgbase-stage.lua 
b/release/scripts/pkgbase-stage.lua
index a12ec372d1a9..9e968fd150f8 100755
--- a/release/scripts/pkgbase-stage.lua
+++ b/release/scripts/pkgbase-stage.lua
@@ -18,87 +18,47 @@ local function capture(command)
        return output:match("(.-)\n$") or output
 end
 
-local function append_list(list, other)
-       for _, item in ipairs(other) do
-               table.insert(list, item)
-       end
-end
-
 -- Returns a list of packages to be included in the given media
 local function select_packages(pkg, media, all_libcompats)
-       local components = {
-               kernel = {},
-               kernel_dbg = {},
-               base = {},
-               base_dbg = {},
-               src = {},
-               tests = {},
-       }
-
-       for compat in all_libcompats:gmatch("%S+") do
-               components["lib" .. compat] = {}
-               components["lib" .. compat .. "_dbg"] = {}
-       end
-
+       local components = {}
        local rquery = capture(pkg .. "rquery -U -r FreeBSD-base %n")
        for package in rquery:gmatch("[^\n]+") do
-               if package == "FreeBSD-src" or 
package:match("^FreeBSD%-src%-.*") then
-                       table.insert(components["src"], package)
-               elseif package == "FreeBSD-tests" or 
package:match("^FreeBSD%-tests%-.*") then
-                       table.insert(components["tests"], package)
-               elseif package:match("^FreeBSD%-kernel%-.*") and
-                       package ~= "FreeBSD-kernel-man"
-               then
-                       -- Kernels other than FreeBSD-kernel-generic are ignored
-                       if package == "FreeBSD-kernel-generic" then
-                               table.insert(components["kernel"], package)
-                       elseif package == "FreeBSD-kernel-generic-dbg" then
-                               table.insert(components["kernel_dbg"], package)
-                       end
-               elseif package:match(".*%-dbg$") then
-                       table.insert(components["base_dbg"], package)
-               else
-                       local found = false
-                       for compat in all_libcompats:gmatch("%S+") do
-                               if package:match(".*%-dbg%-lib" .. compat .. 
"$") then
-                                       table.insert(components["lib" .. compat 
.. "_dbg"], package)
-                                       found = true
-                                       break
-                               elseif package:match(".*%-lib" .. compat .. 
"$") then
-                                       table.insert(components["lib" .. 
compat], package)
-                                       found = true
-                                       break
-                               end
-                       end
-                       if not found then
-                               table.insert(components["base"], package)
-                       end
+               local set = package:match("^FreeBSD%-set%-(.*)$")
+               if set then
+                       components[set] = package
+               -- Kernels other than FreeBSD-kernel-generic are ignored
+               -- Note that on powerpc64 and powerpc64le the names are
+               -- slightly different.
+               elseif package:match("^FreeBSD%-kernel%-generic.*-dbg") then
+                       components["kernel-dbg"] = package
+               elseif package:match("^FreeBSD%-kernel%-generic.*") then
+                       components["kernel"] = package
                end
        end
-       assert(#components["kernel"] == 1)
-       assert(#components["base"] > 0)
+       assert(components["kernel"])
+       assert(components["base"])
 
        local selected = {}
        if media == "disc" then
-               append_list(selected, components["base"])
-               append_list(selected, components["kernel"])
-               append_list(selected, components["kernel_dbg"])
-               append_list(selected, components["src"])
-               append_list(selected, components["tests"])
+               table.insert(selected, components["base"])
+               table.insert(selected, components["kernel"])
+               table.insert(selected, components["kernel-dbg"])
+               table.insert(selected, components["src"])
+               table.insert(selected, components["tests"])
                for compat in all_libcompats:gmatch("%S+") do
-                       append_list(selected, components["lib" .. compat])
+                       table.insert(selected, components["lib" .. compat])
                end
        else
                assert(media == "dvd")
-               append_list(selected, components["base"])
-               append_list(selected, components["base_dbg"])
-               append_list(selected, components["kernel"])
-               append_list(selected, components["kernel_dbg"])
-               append_list(selected, components["src"])
-               append_list(selected, components["tests"])
+               table.insert(selected, components["base"])
+               table.insert(selected, components["base-dbg"])
+               table.insert(selected, components["kernel"])
+               table.insert(selected, components["kernel-dbg"])
+               table.insert(selected, components["src"])
+               table.insert(selected, components["tests"])
                for compat in all_libcompats:gmatch("%S+") do
-                       append_list(selected, components["lib" .. compat])
-                       append_list(selected, components["lib" .. compat .. 
"_dbg"])
+                       table.insert(selected, components["lib" .. compat])
+                       table.insert(selected, components["lib" .. compat .. 
"-dbg"])
                end
        end
 
@@ -136,7 +96,7 @@ local function main()
 
        local packages = select_packages(pkg, media, all_libcompats)
 
-       assert(os.execute(pkg .. "fetch -o " .. target .. " " .. 
table.concat(packages, " ")))
+       assert(os.execute(pkg .. "fetch -d -o " .. target .. " " .. 
table.concat(packages, " ")))
        assert(os.execute(pkg .. "repo " .. target))
 end
 

Reply via email to