1#!/bin/sh 2#- 3# SPDX-License-Identifier: BSD-2-Clause 4# 5# Copyright (c) 2024 The FreeBSD Foundation 6# 7# This software was developed by Björn Zeeb 8# under sponsorship from the FreeBSD Foundation. 9# 10 11BSDCFG_SHARE="/usr/share/bsdconfig" 12. $BSDCFG_SHARE/common.subr || exit 1 13 14f_dprintf "%s: loading includes..." "$0" 15f_include $BSDCFG_SHARE/dialog.subr 16f_include $BSDCFG_SHARE/mustberoot.subr 17f_include $BSDCFG_SHARE/packages/packages.subr 18 19msg_freebsd_firmware_installation="$OSNAME Firmware Installation" 20msg_freebsd_installer="$OSNAME Installer" 21msg_firmware_menu_text="This menu allows you to install firmware packages for your system" 22hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER" 23hline_ok="Press OK to continue" 24 25dialog_menu_main() 26{ 27 local title="$DIALOG_TITLE" 28 local btitle="$DIALOG_BACKTITLE" 29 local prompt="$msg_firmware_menu_text" 30 local hline 31 local check_list= # Empty; filled below 32 local fwlist _fw 33 34 fwlist=`chroot $BSDINSTALL_CHROOT fwget -q -n` 35 case "${fwlist}" in 36 "") # No firmware to install 37 # Print a dialog with OK and a 3 line timeout bar. 38 local height width rows msg 39 40 msg="No firmware to install, continuing..." 41 hline="$hline_ok" 42 43 eval f_dialog_checklist_size height width rows \ 44 \"\$title\" \ 45 \"\$btitle\" \ 46 \"\$msg\" \ 47 \"-\" \ 48 \"n\" \ 49 \"-\" \ 50 \"\$hline\" 51 52 ${DIALOG} --title "${title}" --backtitle "${btitle}" \ 53 --hline "${hline}" \ 54 --nocancel --pause "${msg}" $height $width 5 55 f_dialog_menutag_store -s "" 56 return $DIALOG_OK 57 ;; 58 *) 59 local desc status height width rows selected retval 60 hline="$hline_arrows_space_tab_enter" 61 62 for _fw in ${fwlist}; do 63 desc="${_fw}" 64 f_shell_escape "$desc" desc 65 # install each firmware package by default. 66 check_list="$check_list 67 '$_fw' '$desc' 'on' 68 " 69 done 70 71 eval f_dialog_checklist_size height width rows \ 72 \"\$title\" \ 73 \"\$btitle\" \ 74 \"\$prompt\" \ 75 \"\$hline\" \ 76 $check_list 77 78 selected=$( eval $DIALOG \ 79 --title \"\$title\" \ 80 --backtitle \"\$btitle\" \ 81 --separate-output \ 82 --hline \"\$hline\" \ 83 --ok-label \"\$msg_ok\" \ 84 --cancel-label \"\$msg_cancel\" \ 85 --checklist \"\$prompt\" \ 86 $height $width $rows \ 87 $check_list \ 88 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 89 ) 90 retval=$? 91 f_dialog_menutag_store -s "$selected" 92 return $retval 93 ;; 94 esac 95} 96 97# Initialize 98f_dialog_title "$msg_freebsd_firmware_installation" 99f_dialog_backtitle "$msg_freebsd_installer" 100 101# Gather the firmware files and present them to the user 102dialog_menu_main || f_die 103f_dialog_menutag_fetch selected 104 105# Nothing to install? 106if [ "${selected}" == "" ]; then 107 exit 0 108fi 109 110f_mustberoot_init 111 112# pkg(8) needs name servers (unless we could use a local repo in the future). 113f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/ 114 115${DIALOG} --title "$DIALOG_TITLE" --backtitle "$DIALOG_BACKTITLE" \ 116 --infobox "Installing firmware. This may take a moment." 0 0 117 118# Install each of the selected firmware packages 119for fw in ${selected}; do 120 # We install one at a time in case one is not avail. 121 # pkg-install.8 needs an option to skip unavail. 122 ASSUME_ALWAYS_YES=YES chroot $BSDINSTALL_CHROOT pkg install -qy ${fw} 123done 124 125# end 126