#!/usr/bin/perl #Name: find_centos8_needs_elrepo.pl #version: 1.0.0 #Date: 2020-03-10 #Author: David Mathog # # list any ElRepo drivers needed to install CentOS 8 on this system # # assumes wget, lspci, and access to the internet are both available # If access is not available specify one parameter to the already downloaded # file. # # use strict; use warnings; my $IDLIST="http://elrepo.org/tiki/DeviceIDs"; my %id_hash_driver; my %id_hash_type; my %pci_hash_longname; my $count=0; my $real_filename="/tmp/fcne_DeviceIDsFile"; my $num_args = $#ARGV; if ($num_args != 0) { print "Usage: find_centos8_needs_elrepo.pl DeviceIDsFile\n\n", "If internet access is available let DeviceIDsFile = \"-\" and it will be downloaded\n", "automatically. Otherwise on some machine do:\n\n", " wget -O DeviceIDsFile $IDLIST\n\n", "Then copy that file by some means to the target and specify\n", "the file name on the command line.\n"; exit; } my $filename=$ARGV[0]; if($filename eq '-'){ my $messages = `wget -q -O $real_filename $IDLIST 2>/dev/null`; if($messages){ print "Some problem running:\n\n", " wget -q -O $real_filename 2>/dev/null\n\n", "returned:\n", "$messages\n"; exit; } } else { $real_filename = $filename; } open(FH, $real_filename) or die "could not open file $real_filename"; print "Checking this machine for drivers missing from CentOS 8 but present in ElRepo\n"; print "Getting Device ID list from $IDLIST\n"; while (my $line = ){ chomp $line; if($line =~ /\skmod-/){ my ($dev_type, $dev_id, $dev_driver) = split(/\s+/,$line); $dev_id = uc $dev_id; $id_hash_driver{$dev_id}=$dev_driver; $id_hash_type{$dev_id}=$dev_type; } } close(FH); print "Getting pci IDs and long names from lspci\n"; foreach my $line (`lspci`){ chomp $line; my $starts = index($line," "); my $pci_id = uc substr($line,0,$starts); my $ln = substr($line,$starts+1); $pci_hash_longname{$pci_id}=$ln; } print "Checking pci and device IDs from lspci -n, listing only those in ElRepo\n"; foreach my $line (`lspci -n`){ chomp $line; my ($pci_id, $ignore, $dev_id)= split /\s/,$line; $dev_id = uc $dev_id; if(defined($id_hash_driver{$dev_id})){ $count++; print "$pci_id $dev_id $id_hash_driver{$dev_id} $id_hash_type{$dev_id} $pci_hash_longname{$pci_id}\n"; } } if(!$count){ print "none found\n"; } if($filename eq "-"){ unlink($real_filename); } print "Done\n";