diff options
-rw-r--r-- | perl-install/detect_devices.pm | 48 | ||||
-rw-r--r-- | perl-install/install_any.pm | 9 |
2 files changed, 31 insertions, 26 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 158a212cb..165b7a6b8 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -794,34 +794,38 @@ my (@dmis, $dmidecode_already_runned); # we return a list b/c several DMIs have the same name: sub dmidecode() { - return @dmis if $dmidecode_already_runned; - - foreach (run_program::get_stdout('dmidecode')) { - if (/^\t\t(.*)/) { - $dmis[-1]{string} .= "$1\n"; - $dmis[-1]{$1} = $2 if /^\t\t(.*): (.*)$/; - } elsif (my ($s) = /^\t(.*)/) { - next if $s =~ /^DMI type /; - $s =~ s/ Information$//; - push @dmis, { name => $s }; - } + return @dmis if $dmidecode_already_runned; + + foreach (run_program::get_stdout('dmidecode')) { + if (/^\t\t(.*)/) { + $dmis[-1]{string} .= "$1\n"; + $dmis[-1]{$1} = $2 if /^\t\t(.*): (.*)$/; + } elsif (my ($s) = /^\t(.*)/) { + next if $s =~ /^DMI type /; + $s =~ s/ Information$//; + push @dmis, { name => $s }; } - $dmidecode_already_runned = 1; + } + $dmidecode_already_runned = 1; @dmis; } +sub dmidecode_category { + my ($cat) = @_; + my @l = find { $_->{name} eq $cat } dmidecode(); + wantarray() ? @l : $l[0] || {}; +} sub computer_info() { - 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"; + my $Chassis = dmidecode_category('Chassis')->{Type} =~ /(\S+)/ && $1; + + my $date = dmidecode_category('BIOS')->{'Release Date'} || ''; + my $BIOS_Year = $date =~ m!(\d{4})! && $1 || + $date =~ m!\d\d/\d\d/(\d\d)! && "20$1"; - +{ - isLaptop => member($Chassis, 'Portable', 'Laptop', 'Notebook', 'Sub Notebook', 'Docking Station'), - if_($BIOS_Year, BIOS_Year => $BIOS_Year), - }; + +{ + isLaptop => member($Chassis, 'Portable', 'Laptop', 'Notebook', 'Sub Notebook', 'Docking Station'), + if_($BIOS_Year, BIOS_Year => $BIOS_Year), + }; } #- try to detect a laptop, we assume pcmcia service is an indication of a laptop or diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index a0fe63c67..d19e61472 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -737,16 +737,17 @@ sub default_packages { push @l, "mdadm" if !is_empty_array_ref($o->{all_hds}{raids}); push @l, "lvm2" if !is_empty_array_ref($o->{all_hds}{lvms}); push @l, "alsa", "alsa-utils" if any { $o->{modules_conf}->get_alias("sound-slot-$_") =~ /^snd-/ } 0 .. 4; - my %dmi = map { $_->{name} => $_ } detect_devices::dmidecode(); - if ($dmi{System}{Manufacturer} eq "Dell Computer" && member($dmi{System}{'Product Name'}, qw(Inspiron Latitude))) { + my $dmi_System = detect_devices::dmidecode_category('System'); + my $dmi_BIOS = detect_devices::dmidecode_category('BIOS'); + if ($dmi_System->{Manufacturer} =~ /Dell Computer/ && $dmi_System->{'Product Name'} =~ /Inspiron|Latitude/) { modules::append_to_modules_loaded_at_startup_for_all_kernels('i8k'); push @l, "i8kutils"; } - if ($dmi{System}{Manufacturer} eq 'TOSHIBA' && $dmi{BIOS}{Vendor} eq 'TOSHIBA') { + if ($dmi_System->{Manufacturer} =~ /TOSHIBA/ && $dmi_BIOS->{Vendor} =~ /TOSHIBA/) { modules::append_to_modules_loaded_at_startup_for_all_kernels('toshiba'); push @l, "toshutils"; } - if ($dmi{BIOS}{Vendor} eq 'COMPAL' && $dmi{BIOS}{Characteristics} =~ /Function key-initiated network boot is supported/) { + if ($dmi_BIOS->{Vendor} eq 'COMPAL' && $dmi_BIOS->{Characteristics} =~ /Function key-initiated network boot is supported/) { modules::append_to_modules_loaded_at_startup_for_all_kernels('acerhk'); } |