source: branches/stable/mindi-busybox/examples/depmod.pl @ 1770

Last change on this file since 1770 was 1770, checked in by Bruno Cornec, 13 years ago
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod? silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian? keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René? Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

  • Property svn:executable set to *
File size: 7.8 KB
Line 
1#!/usr/bin/perl -w
2# vi: set sw=4 ts=4:
3# Copyright (c) 2001 David Schleef <ds@schleef.org>
4# Copyright (c) 2001 Erik Andersen <andersen@codepoet.org>
5# Copyright (c) 2001 Stuart Hughes <seh@zee2.com>
6# Copyright (c) 2002 Steven J. Hill <shill@broadcom.com>
7# Copyright (c) 2006 Freescale Semiconductor, Inc <stuarth@freescale.com>
8#
9# History:
10# March 2006: Stuart Hughes <stuarth@freescale.com>.
11#             Significant updates, including implementing the '-F' option
12#             and adding support for 2.6 kernels.
13
14# This program is free software; you can redistribute it and/or modify it
15# under the same terms as Perl itself.
16use Getopt::Long;
17use File::Find;
18use strict;
19
20# Set up some default values
21my $kdir="";
22my $basedir="";
23my $kernel="";
24my $kernelsyms="";
25my $symprefix="";
26my $stdout=0;
27my $verbose=0;
28my $help=0;
29my $nm = $ENV{'NM'} || "nm";
30
31# more globals
32my (@liblist) = ();
33my $exp = {};
34my $dep = {};
35my $mod = {};
36
37my $usage = <<TXT;
38$0 -b basedir { -k <vmlinux> | -F <System.map> } [options]...
39  Where:
40   -h --help          : Show this help screen
41   -b --basedir       : Modules base directory (e.g /lib/modules/<2.x.y>)
42   -k --kernel        : Kernel binary for the target (e.g. vmlinux)
43   -F --kernelsyms    : Kernel symbol file (e.g. System.map)
44   -n --stdout        : Write to stdout instead of <basedir>/modules.dep
45   -v --verbose       : Print out lots of debugging stuff
46   -P --symbol-prefix : Symbol prefix
47TXT
48
49# get command-line options
50GetOptions(
51    "help|h"            => \$help,
52    "basedir|b=s"       => \$basedir,
53    "kernel|k=s"        => \$kernel,
54    "kernelsyms|F=s"    => \$kernelsyms,
55    "stdout|n"          => \$stdout,
56    "verbose|v"         => \$verbose,
57    "symbol-prefix|P=s" => \$symprefix,
58);
59
60die $usage if $help;
61die $usage unless $basedir && ( $kernel || $kernelsyms );
62die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms;
63
64# Strip any trailing or multiple slashes from basedir
65$basedir =~ s-(/)\1+-/-g;
66
67# The base directory should contain /lib/modules somewhere
68if($basedir !~ m-/lib/modules-) {
69    warn "WARNING: base directory does not match ..../lib/modules\n";
70}
71
72# if no kernel version is contained in the basedir, try to find one
73if($basedir !~ m-/lib/modules/\d\.\d-) {
74    opendir(BD, $basedir) or die "can't open basedir $basedir : $!\n";
75    foreach ( readdir(BD) ) {
76        next if /^\.\.?$/;
77        next unless -d "$basedir/$_";
78        warn "dir = $_\n" if $verbose;
79        if( /^\d\.\d/ ) {
80            $kdir = $_;
81            warn("Guessed module directory as $basedir/$kdir\n");
82            last;
83        }
84    }
85    closedir(BD);
86    die "Cannot find a kernel version under $basedir\n" unless $kdir;
87    $basedir = "$basedir/$kdir";
88}
89
90# Find the list of .o or .ko files living under $basedir
91warn "**** Locating all modules\n" if $verbose;
92find sub {
93    my $file;
94    if ( -f $_  && ! -d $_ ) {
95        $file = $File::Find::name;
96        if ( $file =~ /\.k?o$/ ) {
97            push(@liblist, $file);
98            warn "$file\n" if $verbose;
99        }
100    }
101}, $basedir;
102warn "**** Finished locating modules\n" if $verbose;
103
104foreach my $obj ( @liblist ){
105    # turn the input file name into a target tag name
106    my ($tgtname) = $obj =~ m-(/lib/modules/.*)$-;
107
108    warn "\nMODULE = $tgtname\n" if $verbose;
109
110    # get a list of symbols
111    my @output=`$nm $obj`;
112
113    build_ref_tables($tgtname, \@output, $exp, $dep);
114}
115
116
117# vmlinux is a special name that is only used to resolve symbols
118my $tgtname = 'vmlinux';
119my @output = $kernelsyms ? `cat $kernelsyms` : `$nm $kernel`;
120warn "\nMODULE = $tgtname\n" if $verbose;
121build_ref_tables($tgtname, \@output, $exp, $dep);
122
123# resolve the dependencies for each module
124# reduce dependencies: remove unresolvable and resolved from vmlinux/System.map
125# remove duplicates
126foreach my $module (keys %$dep) {
127    warn "reducing module: $module\n" if $verbose;
128    $mod->{$module} = {};
129    foreach (@{$dep->{$module}}) {
130        if( $exp->{$_} ) {
131            warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose;
132            next if $exp->{$_} =~ /vmlinux/;
133            $mod->{$module}{$exp->{$_}} = 1;
134        } else {
135            warn "unresolved symbol $_ in file $module\n";
136        }
137    }
138}
139
140# figure out where the output should go
141if ($stdout == 0) {
142    open(STDOUT, ">$basedir/modules.dep")
143                             or die "cannot open $basedir/modules.dep: $!";
144}
145my $kseries = $basedir =~ m,/2\.6\.[^/]*, ? '2.6' : '2.4';
146
147foreach my $module ( keys %$mod ) {
148    if($kseries eq '2.4') {
149        print "$module:\t";
150        my @sorted = sort bydep keys %{$mod->{$module}};
151        print join(" \\\n\t",@sorted);
152        print "\n\n";
153    } else {
154        print "$module: ";
155        my @sorted = sort bydep keys %{$mod->{$module}};
156        print join(" ",@sorted);
157        print "\n";
158    }
159}
160
161
162sub build_ref_tables
163{
164    my ($name, $sym_ar, $exp, $dep) = @_;
165
166    my $ksymtab = grep m/ __ksymtab/, @$sym_ar;
167
168    # gather the exported symbols
169    if($ksymtab){
170        # explicitly exported
171        foreach ( @$sym_ar ) {
172            / __ksymtab_(.*)$/ and do {
173                warn "sym = $1\n" if $verbose;
174                $exp->{$1} = $name;
175            };
176        }
177    } else {
178        # exporting all symbols
179        foreach ( @$sym_ar ) {
180            / [ABCDGRST] (.*)$/ and do {
181                warn "syma = $1\n" if $verbose;
182                $exp->{$1} = $name;
183            };
184        }
185    }
186
187    # this takes makes sure modules with no dependencies get listed
188    push @{$dep->{$name}}, $symprefix . 'printk' unless $name eq 'vmlinux';
189
190    # gather the unresolved symbols
191    foreach ( @$sym_ar ) {
192        !/ __this_module/ && / U (.*)$/ and do {
193            warn "und = $1\n" if $verbose;
194            push @{$dep->{$name}}, $1;
195        };
196    }
197}
198
199sub bydep
200{
201    foreach my $f ( keys %{$mod->{$b}} ) {
202        if($f eq $a) {
203            return 1;
204        }
205    }
206    return -1;
207}
208
209
210
211__END__
212
213=head1 NAME
214
215depmod.pl - a cross platform script to generate kernel module
216dependency lists (modules.conf) which can then be used by modprobe
217on the target platform.
218
219It supports Linux 2.4 and 2.6 styles of modules.conf (auto-detected)
220
221=head1 SYNOPSIS
222
223depmod.pl [OPTION]... [basedir]...
224
225Example:
226
227    depmod.pl -F linux/System.map -b target/lib/modules/2.6.11
228
229=head1 DESCRIPTION
230
231The purpose of this script is to automagically generate a list of of kernel
232module dependencies.  This script produces dependency lists that should be
233identical to the depmod program from the modutils package.  Unlike the depmod
234binary, however, depmod.pl is designed to be run on your host system, not
235on your target system.
236
237This script was written by David Schleef <ds@schleef.org> to be used in
238conjunction with the BusyBox modprobe applet.
239
240=head1 OPTIONS
241
242=over 4
243
244=item B<-h --help>
245
246This displays the help message.
247
248=item B<-b --basedir>
249
250The base directory uner which the target's modules will be found.  This
251defaults to the /lib/modules directory.
252
253If you don't specify the kernel version, this script will search for
254one under the specified based directory and use the first thing that
255looks like a kernel version.
256
257=item B<-k --kernel>
258
259Kernel binary for the target (vmlinux).  You must either supply a kernel binary
260or a kernel symbol file (using the -F option).
261
262=item B<-F --kernelsyms>
263
264Kernel symbol file for the target (System.map).
265
266=item B<-n --stdout>
267
268Write to stdout instead of modules.dep
269kernel binary for the target (using the -k option).
270
271=item B<--verbose>
272
273Verbose (debug) output
274
275=back
276
277=head1 COPYRIGHT AND LICENSE
278
279 Copyright (c) 2001 David Schleef <ds@schleef.org>
280 Copyright (c) 2001 Erik Andersen <andersen@codepoet.org>
281 Copyright (c) 2001 Stuart Hughes <seh@zee2.com>
282 Copyright (c) 2002 Steven J. Hill <shill@broadcom.com>
283 Copyright (c) 2006 Freescale Semiconductor, Inc <stuarth@freescale.com>
284
285This program is free software; you can redistribute it and/or modify it
286under the same terms as Perl itself.
287
288=head1 AUTHOR
289
290David Schleef <ds@schleef.org>
291
292=cut
Note: See TracBrowser for help on using the repository browser.