Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 May 2025 13:40:31 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 0bfa8a459626 - main - bsdinstall: improve pkgbase target retry prompts
Message-ID:  <202505231340.54NDeVXQ011019@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=0bfa8a45962644947e17b5262c5d0efa36d3f4d9

commit 0bfa8a45962644947e17b5262c5d0efa36d3f4d9
Author:     Isaac Freund <ifreund@freebsdfoundation.org>
AuthorDate: 2025-05-09 12:21:01 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-05-23 13:40:12 +0000

    bsdinstall: improve pkgbase target retry prompts
    
    These now use bsddialog rather than prompting the user for input on the
    console.
    
    Reviewed by:    emaste
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D50270
---
 usr.sbin/bsdinstall/scripts/pkgbase.in | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/usr.sbin/bsdinstall/scripts/pkgbase.in b/usr.sbin/bsdinstall/scripts/pkgbase.in
index eaed23a19548..1ff93afe817b 100755
--- a/usr.sbin/bsdinstall/scripts/pkgbase.in
+++ b/usr.sbin/bsdinstall/scripts/pkgbase.in
@@ -23,18 +23,6 @@ local function capture(command)
 	return output:match("(.-)\n$") or output
 end
 
-local function prompt_yn(question)
-	while true do
-		io.write(question .. " (y/n) ")
-		local input = io.read()
-		if input == "y" or input == "Y" then
-			return true
-		elseif input == "n" or input == "N" then
-			return false
-		end
-	end
-end
-
 local function append_list(list, other)
 	for _, item in ipairs(other) do
 		table.insert(list, item)
@@ -73,6 +61,18 @@ local function bsddialog(args)
 	return exit_code, output
 end
 
+-- Prompts the user for a yes/no answer to the given question using bsddialog
+-- Returns true if the user answers yes and false if the user answers no.
+local function prompt_yn(question)
+	local exit_code = bsddialog({
+		"--yesno",
+		"--disable-esc",
+		question,
+		0, 0, -- autosize
+	})
+	return exit_code == 0
+end
+
 -- Creates a dialog for component selection mirroring the
 -- traditional tarball component selection dialog.
 local function select_components(components, options)
@@ -254,7 +254,6 @@ local function pkgbase()
 
 	while not os.execute(pkg .. "update") do
 		if not prompt_yn("Updating repositories failed, try again?") then
-			print("Canceled")
 			os.exit(1)
 		end
 	end
@@ -263,7 +262,6 @@ local function pkgbase()
 
 	while not os.execute(pkg .. "install -U -F -y -r FreeBSD-base " .. packages) do
 		if not prompt_yn("Fetching packages failed, try again?") then
-			print("Canceled")
 			os.exit(1)
 		end
 	end



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505231340.54NDeVXQ011019>