Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/examples/depmod.pl

    r1765 r2725  
    1414# This program is free software; you can redistribute it and/or modify it
    1515# under the same terms as Perl itself.
    16 use Getopt::Long;
     16use Getopt::Long qw(:config no_auto_abbrev no_ignore_case);
    1717use File::Find;
    1818use strict;
     
    2424my $kernelsyms="";
    2525my $symprefix="";
     26my $all=0;
     27my $quick=0;
     28my $errsyms=0;
    2629my $stdout=0;
    2730my $verbose=0;
     
    4548   -v --verbose       : Print out lots of debugging stuff
    4649   -P --symbol-prefix : Symbol prefix
     50   -a --all           : Probe all modules (default/only thing supported)
     51   -e --errsyms       : Report any symbols not supplied by modules/kernel
    4752TXT
    4853
     
    5661    "verbose|v"         => \$verbose,
    5762    "symbol-prefix|P=s" => \$symprefix,
     63    "all|a"             => \$all,
     64    # unsupported options
     65    "quick|A"           => \$quick,
     66    # ignored options (for historical usage)
     67    "quiet|q",
     68    "root|r",
     69    "unresolved-error|u"
    5870);
    5971
     
    6173die $usage unless $basedir && ( $kernel || $kernelsyms );
    6274die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms;
     75die "sorry, -A/--quick is not supported" if $quick;
     76die "--errsyms requires --kernelsyms" if $errsyms && !$kernelsyms;
    6377
    6478# Strip any trailing or multiple slashes from basedir
    65 $basedir =~ s-(/)\1+-/-g;
     79$basedir =~ s-/+$--g;
    6680
    6781# The base directory should contain /lib/modules somewhere
     
    138152}
    139153
     154# build a complete dependency list for each module and make sure it
     155# is kept in order proper order
     156my $mod2 = {};
     157sub maybe_unshift
     158{
     159    my ($array, $ele) = @_;
     160    # chop off the leading path /lib/modules/<kver>/ as modprobe
     161    # will handle relative paths just fine
     162    $ele =~ s:^/lib/modules/[^/]*/::;
     163    foreach (@{$array}) {
     164        if ($_ eq $ele) {
     165            return;
     166        }
     167    }
     168    unshift (@{$array}, $ele);
     169}
     170sub add_mod_deps
     171{
     172    my ($depth, $mod, $mod2, $module, $this_module) = @_;
     173
     174    $depth .= " ";
     175    warn "${depth}loading deps of module: $this_module\n" if $verbose;
     176    if (length($depth) > 50) {
     177        die "too much recursion (circular dependencies in modules?)";
     178    }
     179
     180    foreach my $md (keys %{$mod->{$this_module}}) {
     181        add_mod_deps ($depth, $mod, $mod2, $module, $md);
     182        warn "${depth} outputting $md\n" if $verbose;
     183        maybe_unshift (\@{$$mod2->{$module}}, $md);
     184    }
     185
     186    if (!%{$mod->{$this_module}}) {
     187        warn "${depth} no deps\n" if $verbose;
     188    }
     189}
     190foreach my $module (keys %$mod) {
     191    warn "filling out module: $module\n" if $verbose;
     192    @{$mod2->{$module}} = ();
     193    add_mod_deps ("", $mod, \$mod2, $module, $module);
     194}
     195
    140196# figure out where the output should go
    141197if ($stdout == 0) {
     198    warn "writing $basedir/modules.dep\n" if $verbose;
    142199    open(STDOUT, ">$basedir/modules.dep")
    143200                             or die "cannot open $basedir/modules.dep: $!";
     
    152209        print "\n\n";
    153210    } else {
    154         print "$module: ";
    155         my @sorted = sort bydep keys %{$mod->{$module}};
     211        my $shortmod = $module;
     212        $shortmod =~ s:^/lib/modules/[^/]*/::;
     213        print "$shortmod:";
     214        my @sorted = @{$mod2->{$module}};
     215        printf " " if @sorted;
    156216        print join(" ",@sorted);
    157217        print "\n";
     
    164224    my ($name, $sym_ar, $exp, $dep) = @_;
    165225
    166     my $ksymtab = grep m/ __ksymtab/, @$sym_ar;
     226    my $ksymtab = grep m/ ${symprefix}__ksymtab/, @$sym_ar;
    167227
    168228    # gather the exported symbols
     
    170230        # explicitly exported
    171231        foreach ( @$sym_ar ) {
    172             / __ksymtab_(.*)$/ and do {
    173                 warn "sym = $1\n" if $verbose;
    174                 $exp->{$1} = $name;
     232            / ${symprefix}__ksymtab_(.*)$/ and do {
     233                my $sym = ${symprefix} . $1;
     234                warn "sym = $sym\n" if $verbose;
     235                $exp->{$sym} = $name;
    175236            };
    176237        }
     
    178239        # exporting all symbols
    179240        foreach ( @$sym_ar ) {
    180             / [ABCDGRST] (.*)$/ and do {
     241            / [ABCDGRSTW] (.*)$/ and do {
    181242                warn "syma = $1\n" if $verbose;
    182243                $exp->{$1} = $name;
     
    190251    # gather the unresolved symbols
    191252    foreach ( @$sym_ar ) {
    192         !/ __this_module/ && / U (.*)$/ and do {
     253        !/ ${symprefix}__this_module/ && / U (.*)$/ and do {
    193254            warn "und = $1\n" if $verbose;
    194255            push @{$dep->{$name}}, $1;
Note: See TracChangeset for help on using the changeset viewer.