diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-01-11 22:04:40 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-01-11 22:04:40 +0000 |
commit | c8b71c857544a5f6ea1ba6fca06fe289a7c78c2d (patch) | |
tree | c34a3aa81389a68c268556b511ba2b408fe775ab /usr.sbin | |
parent | abd4e5c8dce4dbeb313abd47e3a55857f9902df1 (diff) |
Create a second hash that maps all possible drivers to a default regex
to match in dmesg(8). This is helpful if we want to install firmware
depending on dmesg(8) output that does not follow the typical driver
scheme.
From espie@
"do it do it" deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/FwUpdate.pm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm b/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm index 557568b1d15..e4391c57f82 100644 --- a/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm +++ b/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: FwUpdate.pm,v 1.24 2017/11/01 18:18:10 espie Exp $ +# $OpenBSD: FwUpdate.pm,v 1.25 2018/01/11 22:04:39 patrick Exp $ # # Copyright (c) 2014 Marc Espie <espie@openbsd.org> # @@ -146,10 +146,11 @@ OpenBSD::Auto::cache(updater, return OpenBSD::FwUpdate::Update->new; }); -my %possible_drivers = map {($_, 1)} +my %possible_drivers = map {($_, "$_-firmware")} (qw(acx athn bwfm bwi ipw iwi iwm iwn malo otus pgt radeondrm rsu rtwn uath upgt urtwn uvideo vmm wpi)); +my %match = map {($_, qr{^\Q$_\E\d+\s+at\s/})} (keys %possible_drivers); sub parse_dmesg { @@ -158,9 +159,9 @@ sub parse_dmesg while (<$f>) { chomp; for my $driver (keys %$search) { - next unless m/^\Q$driver\E\d+\s+at\s/; - delete $search->{$driver}; + next unless $_ =~ $match{$driver}; $found->{$driver} = 1; + delete $search->{$driver}; } } } @@ -187,7 +188,8 @@ sub find_machine_drivers sub driver2firmware { - return shift."-firmware"; + my $k = shift; + return $possible_drivers{$k}; } sub find_installed_drivers |