package modalias; # TODO: # - be faster (Elapsed time: lspcidrake.pl ~ 0.28s instead of 0.12s for old lspcidrake use strict; use MDK::Common; use c; my @config_groups = ( [ "/lib/module-init-tools/modprobe.default", "/etc/modprobe.conf", "/etc/modprobe.d", ], ); my @system_groups = ( [ "/lib/module-init-tools/ldetect-lst-modules.alias", ], [ "/lib/modules/" . c::kernel_version() . "/modules.alias", ], ); my @classes = qw(ide ieee1394 input pci pcmcia pnp serio usb); my @alias_groups; my $alias_re = qr/^\s*alias\s+(([^:]+):\S+)\s+(\S+)$/; sub alias_to_ids { my ($alias) = @_; my ($vendor, $device); # returns (vendor, device) if (($vendor, $device) = $alias =~ /:v([0-9A-F]{4})[dp]([0-9A-F]{4})/) { return ($vendor, $device); } elsif (($vendor, $device) = $alias =~ /:v0{4}([0-9A-F]{4})[dp]0{4}([0-9A-F]{4})/) { return ($vendor, $device); } } sub parse_path { my ($group, $path) = @_; if (-d $path) { parse_path($group, "$path/$_") foreach all($path); } elsif (-f $path) { foreach (cat_($path)) { if (my ($alias, $class, $module) = $_ =~ $alias_re) { if (member($class, @classes)) { my ($vendor, $device) = alias_to_ids($alias); if ($vendor) { $group->{$class} ||= {}; $group->{$class}{$vendor} ||= {}; $group->{$class}{$vendor}{$device} ||= []; push @{$group->{$class}{$vendor}{$device}}, $alias, $module; } else { push @{$group->{$class}{other}}, $alias, $module; } } } } } } sub parse_file_modules { my ($path) = @_; my %modules; foreach (cat_($path)) { if (my ($alias, undef, $module) = $_ =~ $alias_re) { push @{$modules{$module}}, $alias; } } \%modules; } sub get_alias_groups { my ($o_skip_config) = @_; #- FIXME: only o_skip_config from the first call is considered @alias_groups = map { my $group = {}; parse_path($group, $_) foreach @$_; $group; } if_(!$o_skip_config, @config_groups), @system_groups unless @alias_groups; @alias_groups; } sub get_modules { my ($modalias, $o_skip_config) = @_; my ($class) = $modalias =~ /^([^:]+):\S+$/; my ($vendor, $device) = alias_to_ids($modalias); $class && member($class, @classes) or return; require File::FnMatch; foreach my $group (get_alias_groups($o_skip_config)) { my @aliases; foreach my $subgroup ($group->{$class}{$vendor}{$device}, $group->{$class}{other}) { foreach (group_by2(@$subgroup)) { File::FnMatch::fnmatch($_->[0], $modalias) and push @aliases, $_->[1]; } } return uniq(@aliases) if @aliases; } } 1; firewall'>topic/firewall Mageia Installer and base platform for many utilitiesThierry Vignaud [tv]
summaryrefslogtreecommitdiffstats
path: root/perl-install/share
Commit message (Expand)AuthorAgeFilesLines
* updated pot filePablo Saratxaga2003-07-141-138/+418
* changed "Country" . " / Region" to "Country / Region" and fixed Chinese po'sPablo Saratxaga2003-07-121-12/+7
* updated pot filePablo Saratxaga2003-07-101-95/+129
* updated pot filePablo Saratxaga2003-07-092-10998/+11474
* install netprofile on laptopsFrederic Lepied2003-07-081-0/+1
* iAdded various new keyboard layoutsPablo Saratxaga2003-07-011-0/+0
* Moved Bokmaal file to nb.poPablo Saratxaga2003-06-281-21449/+0
* Fixed typos; updated Ukrainian po filePablo Saratxaga2003-06-272-33/+33
* updated pot filePablo Saratxaga2003-06-272-498/+721
* use the mkswap commandPascal Rigaux2003-06-181-0/+1
* updated pot filePablo Saratxaga2003-06-162-458/+572
* change a bit how strings are passed to advertising systemGuillaume Cottenceau2003-06-1216-1252/+1632
* cookerGuillaume Cottenceau2003-06-061-0/+0
* updated Estonien, Japanese, Albanian and Vietnamese po filesPablo Saratxaga2003-06-033-3301/+3539
* UpdateArkadiusz Lipiec2003-06-021-195/+308
* updated Spanish translationsFabián Mandelbaum2003-06-021-154/+271
* changed the name of the russian phonetic layoutPablo Saratxaga2003-05-3147-6454/+11245
* updated Vietnamese filePablo Saratxaga2003-05-302-67/+68
* updated Albanian filePablo Saratxaga2003-05-281-5/+46
* updated pot filePablo Saratxaga2003-05-261-3/+43
* updated pot filePablo Saratxaga2003-05-222-75/+134
* updated pot filePablo Saratxaga2003-05-202-98/+147
* updated German, Estonian and Finnish filesPablo Saratxaga2003-05-203-1420/+1964
* update french translationThierry Vignaud2003-05-201-67/+54
* updated Spanish translationsFabián Mandelbaum2003-05-191-221/+176
* updated pot filePablo Saratxaga2003-05-16