From 66a8d421d8325c862284e02dc72baeef138dfa8e Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 2 Nov 2004 11:02:00 +0000 Subject: (dmidecode) handle multiple devices with same name (computer_info) split it out of dmidecode() --- perl-install/detect_devices.pm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'perl-install/detect_devices.pm') diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index e78de8480..a3566739c 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -783,29 +783,34 @@ sub hasSMP() { sub hasPCMCIA() { $::o->{pcmcia} } #- because /proc/pcmcia seems not to be present on 2.4 at least (or use /var/run/stab) sub dmidecode() { - my (%l, $cat); + my @l; - my $dmidecode_infos if 0; - - if (!$dmidecode_infos) { foreach (run_program::get_stdout('dmidecode')) { if (/^\t\t(.*)/) { - $l{$cat} .= "$1\n"; + $l[-1]->{string} .= "$1\n"; } elsif (my ($s) = /^\t(.*)/) { next if $s =~ /^DMI type /; $s =~ s/ Information$//; - $cat = $s; + push @l, { name => $s }; } } - my $Chassis = $l{Chassis} =~ /^Type:\s*(\S+)/m && $1; - my $BIOS_Year = $l{BIOS} =~ m!^Release Date:.*?(\d{4})!m && $1 || - $l{BIOS} =~ m!^Release Date:.*?\d\d/\d\d/(\d\d)!m && "20$1"; + @l; +} + +sub computer_info() { + my $dmidecode_infos; + my @l = dmidecode(); + my $chassis = (find { $_->{name} eq 'Chassis' } @l) || { string => '' }; + my $Chassis = $chassis->{string} =~ /^Type:\s*(\S+)/m && $1; + my $BIOS = (find { $_->{name} eq 'BIOS' } @l) || { string => '' }; + my $BIOS_Year = $BIOS->{string} =~ m!^Release Date:.*?(\d{4})!m && $1 || + $BIOS->{string} =~ m!^Release Date:.*?\d\d/\d\d/(\d\d)!m && "20$1"; $dmidecode_infos = { isLaptop => member($Chassis, 'Portable', 'Laptop', 'Notebook', 'Sub Notebook', 'Docking Station'), if_($BIOS_Year, BIOS_Year => $BIOS_Year), }; - } + $dmidecode_infos; } -- cgit v1.2.1