diff --git a/usr.sbin/bsdinstall/scripts/pkgbase.in b/usr.sbin/bsdinstall/scripts/pkgbase.in --- a/usr.sbin/bsdinstall/scripts/pkgbase.in +++ b/usr.sbin/bsdinstall/scripts/pkgbase.in @@ -77,20 +77,24 @@ -- traditional tarball component selection dialog. local function select_components(components, options) local descriptions = { - kernel_dbg = "Kernel debug info", - base_dbg = "Base system debug info", - src = "System source tree", - tests = "Test suite", - lib32 = "32-bit compatibility libraries", - lib32_dbg = "32-bit compatibility libraries debug info", + ["kernel-dbg"] = "Kernel debug info", + ["minimal"] = "The minimal multi-user system (required)", + ["devel"] = "C/C++ compilers and related utilities", + ["base"] = "The complete base system (includes minimal and devel)", + ["src"] = "System source tree", + ["tests"] = "Test suite", + ["lib32"] = "32-bit compatibility libraries", + ["debug"] = "Debug symbols for the selected components", } local defaults = { - kernel_dbg = "on", - base_dbg = "off", - src = "off", - tests = "off", - lib32 = "on", - lib32_dbg = "off", + ["kernel-dbg"] = "off", + ["minimal"] = "on", + ["devel"] = "off", + ["base"] = "off", + ["src"] = "off", + ["tests"] = "off", + ["lib32"] = "off", + ["debug"] = "off", } -- Sorting the components is necessary to ensure that the ordering is @@ -103,9 +107,8 @@ local checklist_items = {} for _, component in ipairs(sorted_components) do - if component ~= "base" and component ~= "kernel" and - not (component == "kernel_dbg" and options.no_kernel) and - #components[component] > 0 then + if component ~= "kernel" and not + (component == "kernel-dbg" and options.no_kernel) then local description = descriptions[component] or "''" local default = defaults[component] or "off" table.insert(checklist_items, component) @@ -120,7 +123,7 @@ "--nocancel", "--disable-esc", "--separate-output", - "--checklist", "Choose optional system components to install:", + "--checklist", "Choose system components to install:", "0", "0", "0", -- autosize } append_list(bsddialog_args, checklist_items) @@ -132,10 +135,12 @@ -- hopefully useful stack trace. assert(exit_code == 0) - local selected = {"base"} + local selected = {} + if not options.no_kernel then table.insert(selected, "kernel") end + for component in output:gmatch("[^\n]+") do table.insert(selected, component) end @@ -146,17 +151,18 @@ -- Returns a list of pkgbase packages selected by the user local function select_packages(pkg, options) local components = { - kernel = {}, - kernel_dbg = {}, - base = {}, - base_dbg = {}, - src = {}, - tests = {}, + ["kernel"] = {}, + ["kernel-dbg"] = {}, + ["devel"] = {}, + ["base"] = {}, + ["minimal"] = {}, + ["src"] = {}, + ["tests"] = {}, + ["debug"] = {}, } for compat in all_libcompats:gmatch("%S+") do components["lib" .. compat] = {} - components["lib" .. compat .. "_dbg"] = {} end local rquery = capture(pkg .. "rquery -U -r FreeBSD-base %n") @@ -172,40 +178,82 @@ if package == "FreeBSD-kernel-generic" then table.insert(components["kernel"], package) elseif package == "FreeBSD-kernel-generic-dbg" then - table.insert(components["kernel_dbg"], package) + table.insert(components["kernel-dbg"], package) end - elseif package:match(".*%-dbg$") then - table.insert(components["base_dbg"], package) + elseif package:match("^FreeBSD%-set%-minimal$") then + table.insert(components["minimal"], package) + elseif package:match("^FreeBSD%-set%-devel$") then + table.insert(components["devel"], package) + elseif package:match("^FreeBSD%-set%-base$") then + table.insert(components["base"], 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 + if package:match("^FreeBSD%-set%-lib"..compat.."$") then table.insert(components["lib" .. compat], package) - found = true break end end - if not found then - table.insert(components["base"], package) - end end end + -- Don't assert the existence of dbg, tests, and src packages here. If using -- a custom local repository with BSDINSTALL_PKG_REPOS_DIR we shouldn't -- require it to have all packages. assert(#components["kernel"] == 1) - assert(#components["base"] > 0) + assert(#components["minimal"] == 0 or #components["minimal"] == 1) + assert(#components["devel"] == 0 or #components["devel"] == 1) + assert(#components["base"] == 0 or #components["base"] == 1) + + local selected = nil + while not selected do + local proposal = select_components(components, options) + local have_minimal = false + + -- Either minimal or base are required, or the installed system + -- won't be functional. + for _, c in ipairs(proposal) do + if c == "base" or c == "minimal" then + have_minimal = true + break + end + end - local selected = {} - for _, component in ipairs(select_components(components, options)) do - append_list(selected, components[component]) + if not have_minimal then + bsddialog{ + "--backtitle", "FreeBSD Installer", + "--title", "Error", + "--nocancel", + "--disable-esc", + "--msgbox", + "One of the 'base' or 'minimal' components is required.", + "0", "0" + } + else + selected = proposal + end end - return selected + local debug = false + for _, component in ipairs(selected) do + if component == "debug" then + debug = true + break + end + end + + local packages = {} + for _, component in ipairs(selected) do + local pkglist = components[component] + append_list(packages, pkglist) + for _, c in ipairs(pkglist) do + if debug and c:match("^FreeBSD%-set%-") then + append_list(packages, {c.."-dbg"}) + end + end + end + + return packages end local function parse_options()