From nobody Thu May 22 19:02:48 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4b3Hjj1WvKz5x2vT; Thu, 22 May 2025 19:02:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b3Hjj0FsRz3nLV; Thu, 22 May 2025 19:02:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747940569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n3s1EPihie5sNMsC4Fqa4n/T/xUALUD+tImlKxFL574=; b=RmnMNRSbtNZinHBJT9EAItbyW3P9H6yNgLkUGa5/IB4RAeoDJYFJzKvX2pyiEQ9Nf58m7w /WMmsLqzh9NSeBqGzVslxg7XdjJIq0kMXhiL0A8W8UBI97/bWpqHsYcqNF2bIURA72b2nS t+mwJcZpAt7GL115XTUwxMq60ggx0Ok/GlGSNDTGuOJK/zjYdCh1P9nwttRwBPxqI9w/UN RkBlRE4bt92SnXMTJlknDASOm2sGpN3CBkYPfSmJKgSKUhEZw3L2h6XKp4fS+fCJllii3E U3h8au2FHFXUBBjWS4q+vmXeKYYDcpaohgWVTppF2WdleFJe3/ZeWfeMpSEb+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747940569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n3s1EPihie5sNMsC4Fqa4n/T/xUALUD+tImlKxFL574=; b=MXcuNXZuKmpizrM31o3fJpjErYtVpW9Tc81aj1tTr24qGuVKiLzmQDAvEbrGaUusVtjfOI 60obxBch2gWpF+cMChmR3J8pODlI7HEoojzOQtYd/vlE3lUPHQARZ+llME6f+5PC3hKeeG z3I/zaaN6ry8cCQSjlQZB3iV4GcRvPTs96epENLhLBT5G+w8WPpoSNz11r2dvVQ9CBTVjx lXgiCHCE+FjK0YRRhPCHoSYEPey2OacaFZ9gA0MvpMd1QJZ5LapcqFL5fUti0AzbGUwsWX 6ZQwIMUL5ae34kr2S4/ws0NFNSJrnOguxmqU/i7foHse5zlULPLqrNDo9t/Ujg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747940569; a=rsa-sha256; cv=none; b=ar1Otnwi8hrsU4RVlmwZr2d/KGWolC37KfjiGvdj+OmV20NBvhv+vz8q9il0owWCmK93G2 U+aswpr+B8TmufuYAKdMqOIETROvIPtG76Ev7ZGnYqOtuHG8iXiB4XEVKkDUIsirfZc6fG mzDCkAUTUhdfiTFMv261XLg41HzmRVFRWTemK5bmqAPJkdLYKHOg2oGvxgKHmHooNoDBvE Onqzi+KOX+pt/J+XhS8w6SYjAdoW0Qb8Yb/LwX/RkzpNOH+iZ1viCVB3uMjkxI/y5UKwuR TvcV15sv8xpcnG8n/cC7rWbwKQcKVTwNO5KDvJt1eaxo5amsr8ML0RunMPpKSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4b3Hjh6kMDzZPC; Thu, 22 May 2025 19:02:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54MJ2mmR021774; Thu, 22 May 2025 19:02:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54MJ2mIH021771; Thu, 22 May 2025 19:02:48 GMT (envelope-from git) Date: Thu, 22 May 2025 19:02:48 GMT Message-Id: <202505221902.54MJ2mIH021771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 3c3dd6296612 - main - bsdinstall: add pkgbase component selection dialog List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3c3dd62966123b424657983d9a4d173f675ad8c7 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3c3dd62966123b424657983d9a4d173f675ad8c7 commit 3c3dd62966123b424657983d9a4d173f675ad8c7 Author: Isaac Freund AuthorDate: 2025-05-05 17:44:20 +0000 Commit: Ed Maste CommitDate: 2025-05-22 18:59:47 +0000 bsdinstall: add pkgbase component selection dialog This matches the style of the component selection dialog for traditional tarball-based installations. The only difference is that there is currently no ports component offered when using pkgbase. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50178 --- usr.sbin/bsdinstall/scripts/pkgbase.in | 132 +++++++++++++++++++++++++++++---- 1 file changed, 118 insertions(+), 14 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/pkgbase.in b/usr.sbin/bsdinstall/scripts/pkgbase.in index 7faeee40647b..eaed23a19548 100755 --- a/usr.sbin/bsdinstall/scripts/pkgbase.in +++ b/usr.sbin/bsdinstall/scripts/pkgbase.in @@ -7,6 +7,9 @@ -- This software was developed by Isaac Freund -- under sponsorship from the FreeBSD Foundation. +local sys_wait = require("posix.sys.wait") +local unistd = require("posix.unistd") + local all_libcompats = "%%_ALL_libcompats%%" -- Run a command using the OS shell and capture the stdout @@ -38,20 +41,122 @@ local function append_list(list, other) end end --- Returns a list of pkgbase packages equivalent to the default base.txz and kernel.txz +-- Read from the given fd until EOF +-- Returns all the data read as a single string +local function read_all(fd) + local ret = "" + repeat + local buffer = assert(unistd.read(fd, 1024)) + ret = ret .. buffer + until buffer == "" + return ret +end + +-- Run bsddialog with the given argument list +-- Returns the exit code and stderr output of bsddialog +local function bsddialog(args) + local r, w = assert(unistd.pipe()) + + local pid = assert(unistd.fork()) + if pid == 0 then + assert(unistd.close(r)) + assert(unistd.dup2(w, 2)) + assert(unistd.execp("bsddialog", args)) + unistd._exit() + end + assert(unistd.close(w)) + + local output = read_all(r) + assert(unistd.close(r)) + + local _, _, exit_code = assert(sys_wait.wait(pid)) + return exit_code, output +end + +-- Creates a dialog for component selection mirroring the +-- 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", + } + local defaults = { + kernel_dbg = "on", + base_dbg = "off", + src = "off", + tests = "off", + lib32 = "on", + lib32_dbg = "off", + } + + -- Sorting the components is necessary to ensure that the ordering is + -- consistent in the UI. + local sorted_components = {} + for component, _ in pairs(components) do + table.insert(sorted_components, component) + end + table.sort(sorted_components) + + 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 + local description = descriptions[component] or "''" + local default = defaults[component] or "off" + table.insert(checklist_items, component) + table.insert(checklist_items, description) + table.insert(checklist_items, default) + end + end + + local bsddialog_args = { + "--backtitle", "FreeBSD Installer", + "--title", "Select System Components", + "--nocancel", + "--disable-esc", + "--separate-output", + "--checklist", "Choose optional system components to install:", + "0", "0", "0", -- autosize + } + append_list(bsddialog_args, checklist_items) + + local exit_code, output = bsddialog(bsddialog_args) + -- This should only be possible if bsddialog is killed by a signal + -- or buggy, we disable the cancel option and esc key. + -- If this does happen, there's not much we can do except exit with a + -- hopefully useful stack trace. + assert(exit_code == 0) + + local selected = {"base"} + if not options.no_kernel then + table.insert(selected, "kernel") + end + for component in output:gmatch("[^\n]+") do + table.insert(selected, component) + end + + return selected +end + +-- 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 = {}, + base = {}, + base_dbg = {}, + src = {}, + tests = {}, } for compat in all_libcompats:gmatch("%S+") do components["lib" .. compat] = {} - components["lib" .. compat .. "-dbg"] = {} + components["lib" .. compat .. "_dbg"] = {} end local rquery = capture(pkg .. "rquery -U -r FreeBSD-base %n") @@ -65,15 +170,15 @@ local function select_packages(pkg, options) 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) + 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) + table.insert(components["lib" .. compat .. "_dbg"], package) found = true break elseif package:match(".*%-lib" .. compat .. "$") then @@ -94,9 +199,8 @@ local function select_packages(pkg, options) assert(#components["base"] > 0) local selected = {} - append_list(selected, components["base"]) - if not options.no_kernel then - append_list(selected, components["kernel"]) + for _, component in ipairs(select_components(components, options)) do + append_list(selected, components[component]) end return selected