#!/usr/bin/perl use lib './'; # use the local version of list_modules.pm use strict; use MDK::Common; use File::Basename; use list_modules; if (@ARGV != 1) { print "Usage: check_module_list.pl kernel-desktop-.rpm\n"; exit(1); } my $rpm = $ARGV[0]; -f $rpm or die "Could not find RPM file '$rpm'\n"; my $kernel_version; if ($rpm =~ /^kernel-(\w+)-(\d+\.\d+\.\d+)-(\d+\.mga\d+)/) { $kernel_version = "$2-$1-$3"; } else { die "Failed to extract kernel version from RPM file name\n"; } print "* kernel version : $kernel_version\n"; my $cmd1 = "rpm2cpio $rpm | cpio --extract --to-stdout --quiet ./lib/modules/$kernel_version/modules.dep | sort"; open(my $pipe1, '-|', $cmd1) or die "Failed to execute '$cmd1: $!'\n"; my @module_list; while (<$pipe1>) { my ($module, $discard) = split(':', $_); push @module_list, $module; } my $cmd2 = "rpm2cpio $rpm | cpio --extract --to-stdout --quiet ./lib/modules/$kernel_version/modules.alias"; open(my $pipe2, '-|', $cmd2) or die "Failed to execute '$cmd2': $!\n"; my %module_types; while (<$pipe2>) { if ($_ =~ /alias\s+([a-z*]+):(\S+) (\S+)/) { $module_types{$3} = $1 if $1 eq 'pci' || $1 eq 'usb' || $1 eq 'firewire' || $1 eq 'pcmcia' || $1 eq 'dmi' || $1 eq 'acpi' || $1 eq 'hid' || $1 eq 'serio' || $1 eq 'mdio'; } } my $cmd3 = "rpm2cpio $rpm | cpio --extract --to-stdout --quiet ./lib/modules/$kernel_version/modules.description"; open(my $pipe3, '-|', $cmd3) or die "Failed to execute '$cmd3': $!\n"; my %module_descriptions; while (<$pipe3>) { if ($_ =~ /^(\S+)\s+(.*)$/) { $module_descriptions{$1} = $2; } } my $cmd4 = "rpm2cpio $rpm | cpio --extract --to-stdout --quiet ./lib/modules/$kernel_version/modules.builtin"; open(my $pipe4, '-|', $cmd4) or die "Failed to execute '$cmd4: $!'\n"; my %builtin_modules; while (<$pipe4>) { chomp($_); my $path = dirname($_); my $name = basename($_, '.ko'); $builtin_modules{$name} = $path; } print "**********************************************\n"; print "* Listing driver modules found in the RPM file\n"; print "**********************************************\n"; my %listed_in_rpm; my %listed_in_drakx; foreach (@module_list) { my $path = dirname($_); my $name = basename($_, ".ko.xz"); $listed_in_rpm{$name} = 1; my $module_name = $name =~ s/-/_/gr; my $type = $module_types{$module_name}; $type ||= 'snd-sof' if $path =~ m|sound/soc/sof|; $type ||= 'platform' if $path =~ m|drivers/platform/x86|; # skip if this is not a recognised driver type next if !defined($type); my $category = list_modules::module2category($name); if ($category) { print("# $path $name $type $category\n"); $listed_in_drakx{$name} = 1; } else { my $description = $module_descriptions{$name}; print(" $path $name $type '$description'\n"); } } print "******************************************\n"; print "* Listing modules found in list_modules.pm\n"; print "******************************************\n"; my @mk = sort(keys %list_modules::l); foreach my $mc (@mk) { my $ml = $list_modules::l{$mc}; my @sk = sort(keys %{$ml}); foreach my $sc (@sk) { my $sl = ${$ml}{$sc}; foreach my $name (@$sl) { if ($listed_in_drakx{$name}) { print '# '; } elsif ($listed_in_rpm{$name}) { print ' '; } elsif ($builtin_modules{$name}) { print '= '; } else { print '! '; } print "$mc/$sc $name\n" } } } 1;