diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/depmod.pl | 227 | ||||
| -rw-r--r-- | scripts/inittab | 91 | ||||
| -rwxr-xr-x | scripts/mk2knr.pl | 84 | ||||
| -rw-r--r-- | scripts/undeb | 53 | ||||
| -rw-r--r-- | scripts/unrpm | 48 |
5 files changed, 503 insertions, 0 deletions
diff --git a/scripts/depmod.pl b/scripts/depmod.pl new file mode 100755 index 000000000..bd7767f19 --- /dev/null +++ b/scripts/depmod.pl @@ -0,0 +1,227 @@ +#!/usr/bin/perl -w +# vi: set ts=4: +# Copyright (c) 2001 David Schleef <ds@schleef.org> +# Copyright (c) 2001 Erik Andersen <andersen@codepoet.org> +# Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com> +# This program is free software; you can redistribute it and/or modify it +# under the same terms as Perl itself. + +# TODO -- use strict mode... +#use strict; + +use Getopt::Long; +use File::Find; + + +# Set up some default values + +my $basedir=""; +my $kernel; +my $kernelsyms; +my $stdout=1; +my $verbose=0; + + +# get command-line options + +my %opt; + +GetOptions( + \%opt, + "help|h", + "basedir|b=s" => \$basedir, + "kernel|k=s" => \$kernel, + "kernelsyms|F=s" => \$kernelsyms, + "stdout|n" => \$stdout, + "verbose|v" => \$verbose, +); + +if (defined $opt{help}) { + print + "$0 [OPTION]... [basedir]\n", + "\t-h --help\t\tShow this help screen\n", + "\t-b --basedir\t\tModules base directory (defaults to /lib/modules)\n", + "\t-k --kernel\t\tKernel binary for the target\n", + "\t-F --kernelsyms\t\tKernel symbol file\n", + "\t-n --stdout\t\tWrite to stdout instead of modules.dep\n", + "\t-v --verbose\t\tPrint out lots of debugging stuff\n", + ; + exit 1; +} + +if($basedir !~ m-/lib/modules-) { + warn "WARNING: base directory does not match ..../lib/modules\n"; +} + +# Find the list of .o files living under $basedir +#if ($verbose) { printf "Locating all modules\n"; } +my($file) = ""; +my(@liblist) = (); +find sub { + if ( -f $_ && ! -d $_ ) { + $file = $File::Find::name; + if ( $file =~ /.o$/ ) { + push(@liblist, $file); + if ($verbose) { printf "$file\n"; } + } + } +}, $basedir; +if ($verbose) { printf "Finished locating modules\n"; } + +foreach $obj ( @liblist, $kernel ){ + # turn the input file name into a target tag name + # vmlinux is a special that is only used to resolve symbols + if($obj =~ /vmlinux/) { + $tgtname = "vmlinux"; + } else { + ($tgtname) = $obj =~ m-(/lib/modules/.*)$-; + } + + warn "MODULE = $tgtname\n" if $verbose; + + # get a list of symbols + @output=`nm $obj`; + $ksymtab=grep m/ __ksymtab/, @output; + + # gather the exported symbols + if($ksymtab){ + # explicitly exported + foreach ( @output ) { + / __ksymtab_(.*)$/ and do { + warn "sym = $1\n" if $verbose; + $exp->{$1} = $tgtname; + }; + } + } else { + # exporting all symbols + foreach ( @output) { + / [ABCDGRST] (.*)$/ and do { + warn "syma = $1\n" if $verbose; + $exp->{$1} = $tgtname; + }; + } + } + # gather the unresolved symbols + foreach ( @output ) { + !/ __this_module/ && / U (.*)$/ and do { + warn "und = $1\n" if $verbose; + push @{$dep->{$tgtname}}, $1; + }; + } +} + + +# reduce dependancies: remove unresolvable and resolved from vmlinux +# remove duplicates +foreach $module (keys %$dep) { + $mod->{$module} = {}; + foreach (@{$dep->{$module}}) { + if( $exp->{$_} ) { + warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose; + next if $exp->{$_} =~ /vmlinux/; + $mod->{$module}{$exp->{$_}} = 1; + } else { + warn "unresolved symbol $_ in file $module\n"; + } + } +} + +# resolve the dependancies for each module +foreach $module ( keys %$mod ) { + print "$module:\t"; + @sorted = sort bydep keys %{$mod->{$module}}; + print join(" \\\n\t",@sorted); +# foreach $m (@sorted ) { +# print "\t$m\n"; +# } + print "\n\n"; +} + +sub bydep +{ + foreach my $f ( keys %{$mod->{$b}} ) { + if($f eq $a) { + return 1; + } + } + return -1; +} + + + +__END__ + +=head1 NAME + +depmod.pl - a cross platform script to generate kernel module dependency + lists which can then be used by modprobe. + +=head1 SYNOPSIS + +depmod.pl [OPTION]... [FILE]... + +Example: + + depmod.pl -F linux/System.map target/lib/modules + +=head1 DESCRIPTION + +The purpose of this script is to automagically generate a list of of kernel +module dependancies. This script produces dependancy lists that should be +identical to the depmod program from the modutils package. Unlike the depmod +binary, however, depmod.pl is designed to be run on your host system, not +on your target system. + +This script was written by David Schleef <ds@schleef.org> to be used in +conjunction with the BusyBox modprobe applet. + +=head1 OPTIONS + +=over 4 + +=item B<-h --help> + +This displays the help message. + +=item B<-b --basedir> + +The base directory uner which the target's modules will be found. This +defaults to the /lib/modules directory. + +=item B<-k --kernel> + +Kernel binary for the target. You must either supply a kernel binary +or a kernel symbol file (using the -F option). + +=item B<-F --kernelsyms> + +Kernel symbol file for the target. You must supply either a kernel symbol file +kernel binary for the target (using the -k option). + +=item B<-n --stdout> + +Write to stdout instead of modules.dep. This is currently hard coded... +kernel binary for the target (using the -k option). + +=item B<--verbose> + +Be verbose (not implemented) + +=back + +=head1 COPYRIGHT + +Copyright (c) 2001 David Schleef <ds@schleef.org> +Copyright (c) 2001 Erik Andersen <andersen@codepoet.org> +Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com> +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=head1 AUTHOR + +David Schleef <ds@schleef.org> + +=cut + +# $Id: depmod.pl,v 1.2 2001/11/19 23:57:54 andersen Exp $ + diff --git a/scripts/inittab b/scripts/inittab new file mode 100644 index 000000000..5716045b8 --- /dev/null +++ b/scripts/inittab @@ -0,0 +1,91 @@ +# /etc/inittab init(8) configuration for BusyBox +# +# Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen +# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> +# +# +# Note, BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use sysvinit. +# +# +# Format for each entry: <id>:<runlevels>:<action>:<process> +# +# <id>: WARNING: This field has a non-traditional meaning for BusyBox init! +# +# The id field is used by BusyBox init to specify the controlling tty for +# the specified process to run on. The contents of this field are +# appended to "/dev/" and used as-is. There is no need for this field to +# be unique, although if it isn't you may have strange results. If this +# field is left blank, it is completely ignored. Also note that if +# BusyBox detects that a serial console is in use, then all entries +# containing non-empty id fields will _not_ be run. BusyBox init does +# nothing with utmp. We don't need no stinkin' utmp. +# +# <runlevels>: The runlevels field is completely ignored. +# +# <action>: Valid actions include: sysinit, respawn, askfirst, wait, once, +# restart, ctrlaltdel, and shutdown. +# +# Note: askfirst acts just like respawn, but before running the specified +# process it displays the line "Please press Enter to activate this +# console." and then waits for the user to press enter before starting +# the specified process. +# +# Note: unrecognised actions (like initdefault) will cause init to emit +# an error message, and then go along with its business. +# +# <process>: Specifies the process to be executed and it's command line. +# +# Note: BusyBox init works just fine without an inittab. If no inittab is +# found, it has the following default behavior: +# ::sysinit:/etc/init.d/rcS +# ::askfirst:/bin/sh +# ::ctrlaltdel:/sbin/reboot +# ::shutdown:/sbin/swapoff -a +# ::shutdown:/bin/umount -a -r +# ::restart:/sbin/init +# +# if it detects that /dev/console is _not_ a serial console, it will +# also run: +# tty2::askfirst:/bin/sh +# tty3::askfirst:/bin/sh +# tty4::askfirst:/bin/sh +# +# Boot-time system configuration/initialization script. +# This is run first except when booting in single-user mode. +# +::sysinit:/etc/init.d/rcS + +# /bin/sh invocations on selected ttys +# +# Note below that we prefix the shell commands with a "-" to indicate to the +# shell that it is supposed to be a login shell. Normally this is handled by +# login, but since we are bypassing login in this case, BusyBox lets you do +# this yourself... +# +# Start an "askfirst" shell on the console (whatever that may be) +::askfirst:-/bin/sh +# Start an "askfirst" shell on /dev/tty2-4 +tty2::askfirst:-/bin/sh +tty3::askfirst:-/bin/sh +tty4::askfirst:-/bin/sh + +# /sbin/getty invocations for selected ttys +tty4::respawn:/sbin/getty 38400 tty5 +tty5::respawn:/sbin/getty 38400 tty6 + +# Example of how to put a getty on a serial line (for a terminal) +#::respawn:/sbin/getty -L ttyS0 9600 vt100 +#::respawn:/sbin/getty -L ttyS1 9600 vt100 +# +# Example how to put a getty on a modem line. +#::respawn:/sbin/getty 57600 ttyS2 + +# Stuff to do when restarting the init process +::restart:/sbin/init + +# Stuff to do before rebooting +::ctrlaltdel:/sbin/reboot +::shutdown:/bin/umount -a -r +::shutdown:/sbin/swapoff -a + diff --git a/scripts/mk2knr.pl b/scripts/mk2knr.pl new file mode 100755 index 000000000..aaf4963b1 --- /dev/null +++ b/scripts/mk2knr.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w +# +# @(#) mk2knr.pl - generates a perl script that converts lexemes to K&R-style +# +# How to use this script: +# - In the busybox directory type 'scripts/mk2knr.pl files-you-want-to-convert' +# - Review the 'convertme.pl' script generated and remove / edit any of the +# substitutions in there (please especially check for false positives) +# - Type './convertme.pl same-files-as-before' +# - Compile and see if it works +# +# BUGS: This script does not ignore strings inside comments or strings inside +# quotes (it probably should). + +# set this to something else if you want +$convertme = 'convertme.pl'; + +# internal-use variables (don't touch) +$convert = 0; +%converted = (); + +# if no files were specified, print usage +die "usage: $0 file.c | file.h\n" if scalar(@ARGV) == 0; + +# prepare the "convert me" file +open(CM, ">$convertme") or die "convertme.pl $!"; +print CM "#!/usr/bin/perl -p -i\n\n"; + +# process each file passed on the cmd line +while (<>) { + + # if the line says "getopt" in it anywhere, we don't want to muck with it + # because option lists tend to include strings like "cxtzvOf:" which get + # matched by the "check for mixed case" regexps below + next if /getopt/; + + # tokenize the string into just the variables + while (/([a-zA-Z_][a-zA-Z0-9_]*)/g) { + $var = $1; + + # ignore the word "BusyBox" + next if ($var =~ /BusyBox/); + + # this checks for javaStyle or szHungarianNotation + $convert++ if ($var =~ /^[a-z]+[A-Z][a-z]+/); + + # this checks for PascalStyle + $convert++ if ($var =~ /^[A-Z][a-z]+[A-Z][a-z]+/); + + # if we want to add more checks, we can add 'em here, but the above + # checks catch "just enough" and not too much, so prolly not. + + if ($convert) { + $convert = 0; + + # skip ahead if we've already dealt with this one + next if ($converted{$var}); + + # record that we've dealt with this var + $converted{$var} = 1; + + print CM "s/\\b$var\\b/"; # more to come in just a minute + + # change the first letter to lower-case + $var = lcfirst($var); + + # put underscores before all remaining upper-case letters + $var =~ s/([A-Z])/_$1/g; + + # now change the remaining characters to lower-case + $var = lc($var); + + print CM "$var/g;\n"; + } + } +} + +# tidy up and make the $convertme script executable +close(CM); +chmod 0755, $convertme; + +# print a helpful help message +print "Done. Scheduled name changes are in $convertme.\n"; +print "Please review/modify it and then type ./$convertme to do the search & replace.\n"; diff --git a/scripts/undeb b/scripts/undeb new file mode 100644 index 000000000..a72e1e2ba --- /dev/null +++ b/scripts/undeb @@ -0,0 +1,53 @@ +#!/bin/sh +# +# This should work with the GNU version of tar and gzip! +# This should work with the bash or ash shell! +# Requires the programs (ar, tar, gzip, and the pager more or less). +# +usage() { +echo "Usage: undeb -c package.deb <Print control file info>" +echo " undeb -l package.deb <List contents of deb package>" +echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," +echo " put . for current directory>" +exit +} + +deb=$2 + +exist() { +if [ "$deb" = "" ]; then +usage +elif [ ! -s "$deb" ]; then +echo "Can't find $deb!" +exit +fi +} + +if [ "$1" = "" ]; then +usage +elif [ "$1" = "-l" ]; then +exist +type more >/dev/null 2>&1 && pager=more +type less >/dev/null 2>&1 && pager=less +[ "$pager" = "" ] && echo "No pager found!" && exit +(ar -p $deb control.tar.gz | tar -xzO *control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | tar -tzv) | $pager +exit +elif [ "$1" = "-c" ]; then +exist +ar -p $deb control.tar.gz | tar -xzO *control +exit +elif [ "$1" = "-x" ]; then +exist +if [ "$3" = "" ]; then +usage +elif [ ! -d "$3" ]; then +echo "No such directory $3!" +exit +fi +ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit +echo +echo "Extracted $deb to $3!" +exit +else +usage +fi diff --git a/scripts/unrpm b/scripts/unrpm new file mode 100644 index 000000000..376286a6f --- /dev/null +++ b/scripts/unrpm @@ -0,0 +1,48 @@ +#!/bin/sh +# +# This should work with the GNU version of cpio and gzip! +# This should work with the bash or ash shell! +# Requires the programs (cpio, gzip, and the pager more or less). +# +usage() { +echo "Usage: unrpm -l package.rpm <List contents of rpm package>" +echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory," +echo " put . for current directory>" +exit +} + +rpm=$2 + +exist() { +if [ "$rpm" = "" ]; then +usage +elif [ ! -s "$rpm" ]; then +echo "Can't find $rpm!" +exit +fi +} + +if [ "$1" = "" ]; then +usage +elif [ "$1" = "-l" ]; then +exist +type more >/dev/null 2>&1 && pager=more +type less >/dev/null 2>&1 && pager=less +[ "$pager" = "" ] && echo "No pager found!" && exit +(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager +exit +elif [ "$1" = "-x" ]; then +exist +if [ "$3" = "" ]; then +usage +elif [ ! -d "$3" ]; then +echo "No such directory $3!" +exit +fi +rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit +echo +echo "Extracted $rpm to $3!" +exit +else +usage +fi |
