diff options
| author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2026-02-01 21:45:22 +0000 |
|---|---|---|
| committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2026-02-01 21:52:13 +0000 |
| commit | e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3 (patch) | |
| tree | 6b3a9bc39feea8bf7edcc58c9ac5b5382cebf302 /kernel/check_module_list.pl | |
| parent | 5465fd0f00f1991f6f23b3650eb9927b36ddd65c (diff) | |
| download | drakx-e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3.tar drakx-e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3.tar.gz drakx-e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3.tar.bz2 drakx-e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3.tar.xz drakx-e81c05f8a0cfb51a9d637b4a6a6fa66a34b01ed3.zip | |
kernel: add a new tool to aid the updating of list_modules.pm
See the README for details.
Diffstat (limited to 'kernel/check_module_list.pl')
| -rwxr-xr-x | kernel/check_module_list.pl | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/kernel/check_module_list.pl b/kernel/check_module_list.pl new file mode 100755 index 000000000..05d28facf --- /dev/null +++ b/kernel/check_module_list.pl @@ -0,0 +1,117 @@ +#!/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-<version>.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}; + # 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; |
