From: afresh1 Date: Wed, 5 Jan 2022 16:28:19 +0000 (+0000) Subject: Add the shell based fw_update and updated man page X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f07f38fc22cec0f39a361d6200f3c721d479453c;p=openbsd Add the shell based fw_update and updated man page This allows installing firmware from the installer without having to wait to boot into a live system. commit deraadt@ --- diff --git a/usr.sbin/fw_update/fw_update.8 b/usr.sbin/fw_update/fw_update.8 new file mode 100644 index 00000000000..92c99409cad --- /dev/null +++ b/usr.sbin/fw_update/fw_update.8 @@ -0,0 +1,118 @@ +.\" $OpenBSD: fw_update.8,v 1.1 2022/01/05 16:28:19 afresh1 Exp $ +.\" +.\" Copyright (c) 2011 Alexander Hall +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 5 2022 $ +.Dt FW_UPDATE 8 +.Os +.Sh NAME +.Nm fw_update +.Nd install non-free firmware packages +.Sh SYNOPSIS +.Nm +.Op Fl adDnv +.Op Fl p Ar path +.Op Ar driver | file ... +.Sh DESCRIPTION +The +.Nm +utility installs, updates, or deletes firmware packages for +.Ar driver +from the Internet. +If no +.Ar driver +is specified, the +.Nm +utility tries to determine which firmware is needed on the system. +.Pp +Since firmware with an acceptable license is already present in +.Ox , +.Nm +exists purely to deal with firmware that may not be freely +distributed with +.Ox . +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl a +Install or update firmware for all drivers. +It is an error to specify this option with any +.Ar driver +arguments. +This is enabled by default unless drivers, files or +.Fl d +are specified. +.It Fl d +Delete firmware for +.Ar driver . +If used without parameters, delete all firmware that is not required by +a driver. +If used in conjunction with +.Fl a , +delete firmware for all drivers. +.It Fl D +Download drivers only. +By default downloads to the current directory. +Secifying a URL with +.Fl p +downloads from that URL, +specifying a path downloads to that directory. +.It Fl n +Dry run. +Do not actually install or update any firmware packages; +just report the steps that would be taken. +.It Fl p Ar path +Use the firmware found at package repository +.Ar path , +being either a local directory or a URL, +instead of the default location. +.It Fl v +Turn on verbose output. +This flag can be specified multiple times for increased verbosity. +.El +.Pp +Firmware is downloaded from release-specific directories at +.Lk http://firmware.openbsd.org/firmware/ . +The files are in the format required by +.Xr pkg_add 1 , +but direct use of pkg_add is discouraged. +.Sh ENVIRONMENT +.Bl -tag -width DESTDIRXXX +.It Ev DESTDIR +The root of the system to install into. +.El +.Sh FILES +.Bl -tag -width Ds +.It Pa ${DESTDIR}/usr/share/misc/firmware_patterns +A list of patterns used to detect needed firmware from the +.Xr dmesg 8 . +.It Pa ${DESTDIR}/etc/signify/openbsd-XX-fw.pub +Used with +.Xr signify 1 +to verify downloaded firmware files. +.El +.Sh SEE ALSO +.Xr pkg_add 1 , +.Xr dmesg 8 +.Sh AUTHORS +.An -nosplit +The +.Nm +program was designed by +.An Alexander Hall Aq Mt alexander@beard.se ; +it was then replaced with a perl version by +.An Marc Espie Aq Mt espie@openbsd.org . +It was rewritten to be able to be run from the installer by +.An Andrew Hewus Fresh Aq Mt afresh1@openbsd.org . diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh new file mode 100644 index 00000000000..aa55c102689 --- /dev/null +++ b/usr.sbin/fw_update/fw_update.sh @@ -0,0 +1,53 @@ +#! /usr/bin/perl +# ex:ts=8 sw=4: +# $OpenBSD: fw_update.sh,v 1.23 2022/01/05 16:28:19 afresh1 Exp $ +# +# Copyright (c) 2010 Marc Espie +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use strict; +use warnings; +no lib ('/usr/local/libdata/perl5/site_perl'); + +sub run +{ + my ($cmd, $m) = @_; + my $module = "OpenBSD::$m"; + eval "require $module"; + if ($@) { + die $@; + } + exit($module->parse_and_run($cmd)); +} + +my $choices = { + pkg_add => 'PkgAdd', + pkg_check => 'PkgCheck', + pkg_create => 'PkgCreate', + pkg_delete => 'PkgDelete', + pkg_info => 'PkgInfo', + pkg_sign => 'PkgSign', + fw_update => 'FwUpdate', +}; + +my @l = qw(add check create delete info sign); + +while (my ($cmd, $module) = each %$choices) { + if ($0 =~ m/\/?\Q$cmd\E$/) { + run($cmd, $module); + } +} + +# defaults to pkg_info personality but keeps the command name +run($0, 'PkgInfo');