depmod.pl: updates and fixes galore
The helper script needs updating to match latest busybox modprobe behavior in that all dependencies need to be listed, not just the immediate ones. Along the way, fix symbol prefixed ports, optimize the output, and add some more depmod compatible options. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
00ffaeab80
commit
2b6497ba84
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
# under the same terms as Perl itself.
|
# under the same terms as Perl itself.
|
||||||
use Getopt::Long;
|
use Getopt::Long qw(:config no_auto_abbrev no_ignore_case);
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@ -23,6 +23,9 @@ my $basedir="";
|
|||||||
my $kernel="";
|
my $kernel="";
|
||||||
my $kernelsyms="";
|
my $kernelsyms="";
|
||||||
my $symprefix="";
|
my $symprefix="";
|
||||||
|
my $all=0;
|
||||||
|
my $quick=0;
|
||||||
|
my $errsyms=0;
|
||||||
my $stdout=0;
|
my $stdout=0;
|
||||||
my $verbose=0;
|
my $verbose=0;
|
||||||
my $help=0;
|
my $help=0;
|
||||||
@ -44,6 +47,8 @@ $0 -b basedir { -k <vmlinux> | -F <System.map> } [options]...
|
|||||||
-n --stdout : Write to stdout instead of <basedir>/modules.dep
|
-n --stdout : Write to stdout instead of <basedir>/modules.dep
|
||||||
-v --verbose : Print out lots of debugging stuff
|
-v --verbose : Print out lots of debugging stuff
|
||||||
-P --symbol-prefix : Symbol prefix
|
-P --symbol-prefix : Symbol prefix
|
||||||
|
-a --all : Probe all modules (default/only thing supported)
|
||||||
|
-e --errsyms : Report any symbols not supplied by modules/kernel
|
||||||
TXT
|
TXT
|
||||||
|
|
||||||
# get command-line options
|
# get command-line options
|
||||||
@ -55,14 +60,23 @@ GetOptions(
|
|||||||
"stdout|n" => \$stdout,
|
"stdout|n" => \$stdout,
|
||||||
"verbose|v" => \$verbose,
|
"verbose|v" => \$verbose,
|
||||||
"symbol-prefix|P=s" => \$symprefix,
|
"symbol-prefix|P=s" => \$symprefix,
|
||||||
|
"all|a" => \$all,
|
||||||
|
# unsupported options
|
||||||
|
"quick|A" => \$quick,
|
||||||
|
# ignored options (for historical usage)
|
||||||
|
"quiet|q",
|
||||||
|
"root|r",
|
||||||
|
"unresolved-error|u"
|
||||||
);
|
);
|
||||||
|
|
||||||
die $usage if $help;
|
die $usage if $help;
|
||||||
die $usage unless $basedir && ( $kernel || $kernelsyms );
|
die $usage unless $basedir && ( $kernel || $kernelsyms );
|
||||||
die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms;
|
die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms;
|
||||||
|
die "sorry, -A/--quick is not supported" if $quick;
|
||||||
|
die "--errsyms requires --kernelsyms" if $errsyms && !$kernelsyms;
|
||||||
|
|
||||||
# Strip any trailing or multiple slashes from basedir
|
# Strip any trailing or multiple slashes from basedir
|
||||||
$basedir =~ s-(/)\1+-/-g;
|
$basedir =~ s-/+$--g;
|
||||||
|
|
||||||
# The base directory should contain /lib/modules somewhere
|
# The base directory should contain /lib/modules somewhere
|
||||||
if($basedir !~ m-/lib/modules-) {
|
if($basedir !~ m-/lib/modules-) {
|
||||||
@ -137,6 +151,35 @@ foreach my $module (keys %$dep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# build a complete dependency list for each module and make sure it
|
||||||
|
# is kept in order proper order
|
||||||
|
my $mod2 = {};
|
||||||
|
sub maybe_unshift
|
||||||
|
{
|
||||||
|
my ($array, $ele) = @_;
|
||||||
|
# chop off the leading path /lib/modules/<kver>/ as modprobe
|
||||||
|
# will handle relative paths just fine
|
||||||
|
$ele =~ s:^/lib/modules/[^/]*/::;
|
||||||
|
foreach (@{$array}) {
|
||||||
|
if ($_ eq $ele) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unshift (@{$array}, $ele);
|
||||||
|
}
|
||||||
|
foreach my $module (keys %$mod) {
|
||||||
|
warn "filling out module: $module\n" if $verbose;
|
||||||
|
@{$mod2->{$module}} = ();
|
||||||
|
foreach my $md (keys %{$mod->{$module}}) {
|
||||||
|
foreach my $md2 (keys %{$mod->{$md}}) {
|
||||||
|
warn "outputting $md2\n" if $verbose;
|
||||||
|
maybe_unshift (\@{$mod2->{$module}}, $md2);
|
||||||
|
}
|
||||||
|
warn "outputting $md\n" if $verbose;
|
||||||
|
maybe_unshift (\@{$mod2->{$module}}, $md);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# figure out where the output should go
|
# figure out where the output should go
|
||||||
if ($stdout == 0) {
|
if ($stdout == 0) {
|
||||||
open(STDOUT, ">$basedir/modules.dep")
|
open(STDOUT, ">$basedir/modules.dep")
|
||||||
@ -151,8 +194,11 @@ foreach my $module ( keys %$mod ) {
|
|||||||
print join(" \\\n\t",@sorted);
|
print join(" \\\n\t",@sorted);
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
} else {
|
} else {
|
||||||
print "$module: ";
|
my $shortmod = $module;
|
||||||
my @sorted = sort bydep keys %{$mod->{$module}};
|
$shortmod =~ s:^/lib/modules/[^/]*/::;
|
||||||
|
print "$shortmod:";
|
||||||
|
my @sorted = @{$mod2->{$module}};
|
||||||
|
printf " " if @sorted;
|
||||||
print join(" ",@sorted);
|
print join(" ",@sorted);
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
@ -163,15 +209,16 @@ sub build_ref_tables
|
|||||||
{
|
{
|
||||||
my ($name, $sym_ar, $exp, $dep) = @_;
|
my ($name, $sym_ar, $exp, $dep) = @_;
|
||||||
|
|
||||||
my $ksymtab = grep m/ __ksymtab/, @$sym_ar;
|
my $ksymtab = grep m/ ${symprefix}__ksymtab/, @$sym_ar;
|
||||||
|
|
||||||
# gather the exported symbols
|
# gather the exported symbols
|
||||||
if($ksymtab){
|
if($ksymtab){
|
||||||
# explicitly exported
|
# explicitly exported
|
||||||
foreach ( @$sym_ar ) {
|
foreach ( @$sym_ar ) {
|
||||||
/ __ksymtab_(.*)$/ and do {
|
/ ${symprefix}__ksymtab_(.*)$/ and do {
|
||||||
warn "sym = $1\n" if $verbose;
|
my $sym = ${symprefix} . $1;
|
||||||
$exp->{$1} = $name;
|
warn "sym = $sym\n" if $verbose;
|
||||||
|
$exp->{$sym} = $name;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -189,7 +236,7 @@ sub build_ref_tables
|
|||||||
|
|
||||||
# gather the unresolved symbols
|
# gather the unresolved symbols
|
||||||
foreach ( @$sym_ar ) {
|
foreach ( @$sym_ar ) {
|
||||||
!/ __this_module/ && / U (.*)$/ and do {
|
!/ ${symprefix}__this_module/ && / U (.*)$/ and do {
|
||||||
warn "und = $1\n" if $verbose;
|
warn "und = $1\n" if $verbose;
|
||||||
push @{$dep->{$name}}, $1;
|
push @{$dep->{$name}}, $1;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user