From nobody Thu Nov 21 00:05:29 2024 X-Original-To: dev-commits-src-all@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 4Xtz5P46bKz5dw44; Thu, 21 Nov 2024 00:05:29 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xtz5P2dF6z4DXF; Thu, 21 Nov 2024 00:05:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732147529; 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=OsZU/oSvIJjPFScRjAUDfEJvF5CsT52NYTVzyItALds=; b=ua7dER6CE2O3b3X0ocN9g8OcZMYO5j1az3s86BUO7RQBQTvUz1qvg9gYoKT7SLRORMd8NY adA7+PlB4ikGLsETIol+WD+p2tDxuifv58tsBALQ4k5NzWE5AkrHOuNT+WtJN/M+rFULeW QsI/ffh5jI02sIWCKAtreYH0RADxRxZ725+6skHXPTcY1n9PyhloKo62fzLIJx9/s9pFNX 8TG3hloe+v6XaCplSlqjYgqQaTgkRF/fbQ1/Sv9SQ3BzdnZ3kbC8GCqxZUmeBUZC3oQGzc gbL7+mMH07Cb8AjboN1ypqhFncE5HF5zCkhAd68Sc+cQ3xDxCCpxuBPJa0/sEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732147529; 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=OsZU/oSvIJjPFScRjAUDfEJvF5CsT52NYTVzyItALds=; b=v8FC4UQ+M+bLVdbI7tOt4nsAIr4a4DGxJXAsSazOVW5LsFAGF83dwrCPIw6aknlRIVhUqA 8PpICGkyi9hfPBTsRGL4Q169Wje29PMYm7ONNCsIpHyDLu6ESyylZVKO0mJBN3z+VDWlWu xu6ZB2U0esNXD6+llXpm1LS/xxlPR8EsldhDLUURdvXnE3xScpubsRi412nTgcfPYIZtED hCFT2RSixNUB1Qpe4HIWVsxrPigAtR3r4TO0hApdvNgP9LgPgalo2bWnB+gENIMZJk8IG/ PCcu5lHyuBls9CO0kMr5Z8EV04PSUQyEiZOT9eEHNL0E6dss1QOYuUTUQrlBBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732147529; a=rsa-sha256; cv=none; b=rGsyoIKO1VVIOF1P6mi6DIrM5A5wHFCOyt7RInWQNOOLvW1T+jaFBqP2ibAzICD9NmAm3I uE/nTUrdUsopuFDXuRft7RbKfJuybAoK52GmwFai3ELaUEcRkkGYGxtYzdCZhf58cSIJRe avowF9btJC/9jxsLbz5NPIvgh+asV7yPFPfPCCdMsEBDn3is0XKDNeYVh5/VijIqe/AJPa oC7pAplocnfBXUdGY5i2co3WT2zVsB52SQrfDo6huBiw1Q/DlyV0K8GGAMT6arAoEUlNoP GLcjwF5ervPW3+pjQv1BHsX+9oG2jF0n8PUYguDSxYxE5wLIx4zjcGBlQAVuvg== 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 4Xtz5P1R1PzG60; Thu, 21 Nov 2024 00:05:29 +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 4AL05TgI087700; Thu, 21 Nov 2024 00:05:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AL05Tjg087697; Thu, 21 Nov 2024 00:05:29 GMT (envelope-from git) Date: Thu, 21 Nov 2024 00:05:29 GMT Message-Id: <202411210005.4AL05Tjg087697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 15f6edf20e4e - stable/14 - bsdinstall: add menu to install firmware List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 15f6edf20e4e1542f2385a9cbd6e996e23252858 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=15f6edf20e4e1542f2385a9cbd6e996e23252858 commit 15f6edf20e4e1542f2385a9cbd6e996e23252858 Author: Bjoern A. Zeeb AuthorDate: 2024-11-09 01:10:33 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-11-21 00:04:57 +0000 bsdinstall: add menu to install firmware Add a menu to the installer to run fwget(8) inside the newly installed system to install firmware known to be needed. This requires working netowrking. This is needed at least for wireless currently for when we entirely stop shipping new firmware in src.git to have working networking on the installed system (we already do need this for at least rtw89). Sponsored by: The FreeBSD Foundation Tested with: 4 different iwlwifi chipsets in a system (earlier version) Suggested improvments by: jrtc27 Differential Revision: https://reviews.freebsd.org/D47491 (cherry picked from commit bbe2a1da2df639c616869aa838244c8094779bd4) --- usr.sbin/bsdinstall/bsdinstall.8 | 19 +++++- usr.sbin/bsdinstall/scripts/Makefile | 1 + usr.sbin/bsdinstall/scripts/auto | 1 + usr.sbin/bsdinstall/scripts/firmware | 125 +++++++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8 index c8bf143322ae..50c8948a7989 100644 --- a/usr.sbin/bsdinstall/bsdinstall.8 +++ b/usr.sbin/bsdinstall/bsdinstall.8 @@ -1,6 +1,10 @@ .\"- .\" Copyright (c) 2011-2013 Nathan Whitehorn All rights reserved. .\" Copyright (c) 2018 Roberto Fernandez Cueto +.\" Copyright (c) 2024 The FreeBSD Foundation +.\" +.\" Portions of this documentation were written by Björn Zeeb +.\" under sponsorship from the FreeBSD Foundation. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -23,7 +27,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd November 18, 2023 +.Dd November 4, 2024 .Dt BSDINSTALL 8 .Os .Sh NAME @@ -240,6 +244,12 @@ Extracts the distributions listed in .Ev DISTRIBUTIONS into .Ev BSDINSTALL_CHROOT . +.It Cm firmware +executes +.Xr fwget 8 +inside the +.Ev BSDINSTALL_CHROOT +to install any needed and available firmware for the new system. .It Cm rootpass Interactively invokes .Xr passwd 1 @@ -323,6 +333,13 @@ Default: Path to a log file for the installation. Default: .Dq Pa $TMPDIR/bsdinstall_log +.It Ev BSDINSTALL_SKIP_FIRMWARE +If not empty, the +.Cm auto +target +will not invoke the +.Cm firmware +target. .It Ev BSDINSTALL_SKIP_HARDENING If not empty, the .Cm auto diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile index 2d226f418783..cbe190d85f12 100644 --- a/usr.sbin/bsdinstall/scripts/Makefile +++ b/usr.sbin/bsdinstall/scripts/Makefile @@ -7,6 +7,7 @@ SCRIPTS=auto \ docsinstall \ entropy \ fetchmissingdists \ + firmware \ hardening \ hostname \ jail \ diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index fd5b634696ae..6a89b3dfdd81 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -364,6 +364,7 @@ fi [ -z "$BSDINSTALL_SKIP_TIME" ] && bsdinstall time [ -z "$BSDINSTALL_SKIP_SERVICES" ] && bsdinstall services [ -z "$BSDINSTALL_SKIP_HARDENING" ] && bsdinstall hardening +[ -z "$BSDINSTALL_SKIP_FIRMWARE" ] && bsdinstall firmware [ -z "$BSDINSTALL_SKIP_USERS" ] && dialog --backtitle "$OSNAME Installer" \ --title "Add User Accounts" --yesno \ diff --git a/usr.sbin/bsdinstall/scripts/firmware b/usr.sbin/bsdinstall/scripts/firmware new file mode 100644 index 000000000000..a563f0e578e4 --- /dev/null +++ b/usr.sbin/bsdinstall/scripts/firmware @@ -0,0 +1,125 @@ +#!/bin/sh +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 The FreeBSD Foundation +# +# This software was developed by Björn Zeeb +# under sponsorship from the FreeBSD Foundation. +# + +BSDCFG_SHARE="/usr/share/bsdconfig" +. $BSDCFG_SHARE/common.subr || exit 1 + +f_dprintf "%s: loading includes..." "$0" +f_include $BSDCFG_SHARE/dialog.subr +f_include $BSDCFG_SHARE/mustberoot.subr +f_include $BSDCFG_SHARE/packages/packages.subr + +msg_freebsd_firmware_installation="$OSNAME Firmware Installation" +msg_freebsd_installer="$OSNAME Installer" +msg_firmware_menu_text="This menu allows you to install firmware packages for your system" +hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER" +hline_ok="Press OK to continue" + +dialog_menu_main() +{ + local title="$DIALOG_TITLE" + local btitle="$DIALOG_BACKTITLE" + local prompt="$msg_firmware_menu_text" + local hline + local check_list= # Empty; filled below + local fwlist _fw + + fwlist=`chroot $BSDINSTALL_CHROOT fwget -q -n` + case "${fwlist}" in + "") # No firmware to install + # Print a dialog with OK and a 3 line timeout bar. + local height width rows msg + + msg="No firmware to install, continuing..." + hline="$hline_ok" + + eval f_dialog_checklist_size height width rows \ + \"\$title\" \ + \"\$btitle\" \ + \"\$msg\" \ + \"-\" \ + \"n\" \ + \"-\" \ + \"\$hline\" + + ${DIALOG} --title "${title}" --backtitle "${btitle}" \ + --hline "${hline}" \ + --nocancel --pause "${msg}" $height $width 5 + f_dialog_menutag_store -s "" + return $DIALOG_OK + ;; + *) + local desc status height width rows selected retval + hline="$hline_arrows_space_tab_enter" + + for _fw in ${fwlist}; do + desc="${_fw}" + f_shell_escape "$desc" desc + # install each firmware package by default. + check_list="$check_list + '$_fw' '$desc' 'on' + " + done + + eval f_dialog_checklist_size height width rows \ + \"\$title\" \ + \"\$btitle\" \ + \"\$prompt\" \ + \"\$hline\" \ + $check_list + + selected=$( eval $DIALOG \ + --title \"\$title\" \ + --backtitle \"\$btitle\" \ + --separate-output \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --checklist \"\$prompt\" \ + $height $width $rows \ + $check_list \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD + ) + retval=$? + f_dialog_menutag_store -s "$selected" + return $retval + ;; + esac +} + +# Initialize +f_dialog_title "$msg_freebsd_firmware_installation" +f_dialog_backtitle "$msg_freebsd_installer" + +# Gather the firmware files and present them to the user +dialog_menu_main || f_die +f_dialog_menutag_fetch selected + +# Nothing to install? +if [ "${selected}" == "" ]; then + exit 0 +fi + +f_mustberoot_init + +# pkg(8) needs name servers (unless we could use a local repo in the future). +f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/ + +${DIALOG} --title "$DIALOG_TITLE" --backtitle "$DIALOG_BACKTITLE" \ + --infobox "Installing firmware. This may take a moment." 0 0 + +# Install each of the selected firmware packages +for fw in ${selected}; do + # We install one at a time in case one is not avail. + # pkg-install.8 needs an option to skip unavail. + ASSUME_ALWAYS_YES=YES chroot $BSDINSTALL_CHROOT pkg install -qy ${fw} +done + +# end