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 | |
| 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.
| -rw-r--r-- | kernel/README | 43 | ||||
| -rwxr-xr-x | kernel/check_module_list.pl | 117 |
2 files changed, 160 insertions, 0 deletions
diff --git a/kernel/README b/kernel/README new file mode 100644 index 000000000..470d04072 --- /dev/null +++ b/kernel/README @@ -0,0 +1,43 @@ +Updating the module list contained in list_modules.pm is regrettably a +largely manual task. To find what has changed in the latest kernel, run + + ./check_module_list.pl /path/to/kernel-desktop-<version>.rpm + +This will extract information about the available kernel modules from the +RPM file and print a report to stdout. The report is in two parts. + +The first part filters the list of kernel modules to find drivers we are +interested in (pci/usb/firewire/pcmcia/dmi/acpi/hid/serio/mdio) and prints +a single line for each such module. If the module is already listed in +list_modules.pm, the line is prefixed by "#". The remainder of the line +contains the module path (relative to the root of the kernel source tree) +the module file name (excluding the .ko.xz suffix), and either the category +the module is listed under in list_modules.pm or, if the module is not already +listed, the module description. + +The second part lists each module that is already listed in list_modules.pm +and prints a single line for each such module. If the module is one of the +drivers listed in the first part of the report, the line is prefixed by "#". +If the module is a built-in module, the line is prefixed by "=". If the +module is not in the list of kernel modules obtained from the RPM, the line +is prefixed by "!". + +The upshot of this is that any lines prefixed by "#" can be ignored. Lines +prefixed by "!" represent modules listed in list_modules.pm that no longer +exist in the kernel (either because they've been renamed or because they are +obsolete). In the first part of the report, lines with no prefix represent +driver modules that could potentially be added to list_modules.pm, but this +will require some judgement on the part of the user. In the second part of +the report, lines with no prefix represent non-driver modules. These will +be modules that are included in the installer stage 1 image, but there is +no obvious way to check which ones are really needed. + +After updating the module lists in list_modules.pm, running + + perl -I. modules.pm check <kernel-version> + +will check whether there are any modules listed in pcitable.gz pr usbtable.gz +in /usr/share/ldetect-lst that are not also listed in list_modules.pm. The +specified kernel version needs to be installed on the system for this to work. +If <kernel-version> is omitted, the currently running kernel version will be +used. 'make check' will run this. 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; |
