From 46f8a48d0a6f328fb4a879689dcdf6510a45e9cb Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 11 Jan 2018 22:04:39 +0000 Subject: [PATCH] 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@ --- usr.sbin/pkg_add/OpenBSD/FwUpdate.pm | 12 +++++++----- 1 file 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 # @@ -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 -- 2.20.1