summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-11-22 14:15:24 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-11-22 14:15:24 +0000
commitc879294087d1f55b5992ff194bae9d0ded78c31a (patch)
treee54ee940894d61a91f93ee69fc66b3e0d08e58ed /kernel
parent0a60319a0b805bf9c7dfe191ab2bd64fb0fa60e6 (diff)
downloaddrakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.gz
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.bz2
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.tar.xz
drakx-c879294087d1f55b5992ff194bae9d0ded78c31a.zip
- no more kernel/all.modules, things are in kernel/all.kernels
- cleanup what we keep in kernel/all.kernels: only vmlinuz, modules.dep, *.mar, all_modules.tar, modules.cz - replace all_modules.list + modules with all_modules.tar - kernel/all.modules/modules.cz-VERSION are now in kernel/all.kernels/VERSION/modules.cz - allow having a normal in isolinux, but don't use it for floppy images (for this, add kernel/all.kernels/.main-BOOT) - add many modules kernel/list_modules.pm in unused categories since we don't take all modules from kernel, only those listed (needed to have a not too big modules.cz for normal kernel) - complete rewrite of update_kernel (now written in perl)
Diffstat (limited to 'kernel')
-rw-r--r--kernel/.cvsignore1
-rw-r--r--kernel/Makefile6
-rw-r--r--kernel/dependencies.pl13
-rw-r--r--kernel/list_modules.pm17
-rw-r--r--kernel/modules.pl119
-rwxr-xr-xkernel/update_kernel267
6 files changed, 216 insertions, 207 deletions
diff --git a/kernel/.cvsignore b/kernel/.cvsignore
index 827e0ba13..66624465e 100644
--- a/kernel/.cvsignore
+++ b/kernel/.cvsignore
@@ -1,3 +1,2 @@
modules.description
-all.modules
all.kernels
diff --git a/kernel/Makefile b/kernel/Makefile
index 9e4dd9bb5..585d85d7b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,13 +1,13 @@
-all: all.modules
+all: all.kernels
-all.modules: ../mdk-stage1/mar/mar update_kernel list_modules.pm
+all.kernels: ../mdk-stage1/mar/mar update_kernel list_modules.pm
./update_kernel
../mdk-stage1/mar/mar:
make -C `dirname $@` mar
clean:
- rm -rf *~ modules.description all.modules all.modules64
+ rm -rf *~ modules.description all.kernels
check:
perl modules.pl check > /dev/null
diff --git a/kernel/dependencies.pl b/kernel/dependencies.pl
deleted file mode 100644
index e3be14212..000000000
--- a/kernel/dependencies.pl
+++ /dev/null
@@ -1,13 +0,0 @@
-use strict;
-
-use MDK::Common;
-use list_modules;
-
-my $version = shift @ARGV;
-my $depfile = shift @ARGV;
-load_dependencies($depfile);
-print STDERR "Loaded dependencies from $depfile\n";
-
-my @modules = uniq(map { dependencies_closure($_) } @ARGV);
-print join " ", map { $_ . ($version == 24 ? '.o' : '.ko') } @modules;
-print "\n";
diff --git a/kernel/list_modules.pm b/kernel/list_modules.pm
index 99edf778d..798f87ff0 100644
--- a/kernel/list_modules.pm
+++ b/kernel/list_modules.pm
@@ -39,7 +39,7 @@ our %l = (
],
raw => [
- qw(ppp_generic ppp_async),
+ qw(ppp_generic ppp_async ppp_deflate bsd_comp),
],
pcmcia => [
qw(3c574_cs 3c589_cs axnet_cs fmvj18x_cs),
@@ -132,7 +132,7 @@ our %l = (
if_(arch() =~ /^ppc/, qw(hfs)),
qw(reiserfs),
],
- various => [ qw(smbfs romfs ext3 xfs) ],
+ various => [ qw(smbfs romfs ext3 xfs jfs ufs) ],
},
@@ -170,10 +170,12 @@ our %l = (
# just here for classification, unused categories (nor auto-detect, nor load_thiskind)
{
raid => [
- qw(linear raid0 raid1 raid5 lvm-mod multipath),
+ qw(linear raid0 raid1 raid5 lvm-mod multipath dm-mod),
],
mouse => [
qw(busmouse msbusmouse logibusmouse serial qpmouse atixlmouse),
+ if_(arch() =~ /ppc/, 'macserial'),
+ qw(hid mousedev usbhid usbmouse),
],
char => [
if_(arch() =~ /ia64/, qw(efivars)),
@@ -185,6 +187,11 @@ our %l = (
qw(parport_pc parport_serial),
qw(btaudio),
+ arch() =~ /i.86/ ? 'aes-i586' : 'aes',
+ if_(arch() =~ /sparc/, 'openprom'),
+
+ qw(wacom evdev), qw(usblp printer),
+
#- these need checking
qw(tmspci rrunner meye),
],
@@ -226,6 +233,10 @@ sub category2modules {
} split(' ', $_[0]);
}
+sub all_modules() {
+ map { @$_ } map { values %$_ } values %l;
+}
+
sub module2category {
my ($module) = @_;
foreach my $t1 (keys %l) {
diff --git a/kernel/modules.pl b/kernel/modules.pl
index 587674e8f..b8207087a 100644
--- a/kernel/modules.pl
+++ b/kernel/modules.pl
@@ -105,28 +105,117 @@ my %images = (
all => 'fs/cdrom disk/cdrom|raw bus/usb|usb_keyboard disk/usb|scsi fs/loopback|local bus/pcmcia disk/pcmcia|hardware_raid fs/network network/main|pcmcia|usb|raw|gigabit bus/firewire disk/firewire',
);
-my $verbose = "@ARGV" =~ /-v/;
-images() if "@ARGV" =~ /images/;
-check() if "@ARGV" =~ /check/;
-pci_modules4stage1($1) if "@ARGV" =~ /pci_modules4stage1:(.*)/;
-
-sub images() {
- while (my ($image, $l) = each %images) {
- my @modules = if_($image !~ /drivers/, @modules_always_on_stage1);
- push @modules, map { category2modules($_) } split(' ', $l);
+my $verbose = $ARGV[0] eq '-v' && shift;
+my ($f, @para) = @ARGV;
+$::{$f}->(@para);
+
+sub image2modules {
+ my ($image) = @_;
+ my $l = $images{$image};
+
+ my @modules = if_($image !~ /drivers/, @modules_always_on_stage1);
+ push @modules, map { category2modules($_) } split(' ', $l);
- @modules = difference2(\@modules, \@modules_removed_from_stage1);
+ @modules = difference2(\@modules, \@modules_removed_from_stage1);
+
+ if ($image !~ /all/) {
+ @modules = difference2(\@modules, \@modules_only_for_all_img);
+ }
+
+ @modules;
+}
+
+sub remove_unneeded_modules {
+ my ($kern_ver) = @_;
+
+ #- need creating a first time the modules.dep for all modules
+ #- it will be redone in make_modules_dep when unneeded modules are removed
+ make_modules_dep($kern_ver);
+ load_dependencies("all.kernels/$kern_ver/modules.dep");
+
+ my $ext = module_extension($kern_ver);
+
+ my @all = list_modules::all_modules();
+ my @all_with_deps = map { dependencies_closure($_) } @all;
+ my %wanted_modules = map {; "$_.$ext" => 1 } @all_with_deps;
+ foreach (all("all.kernels/$kern_ver/modules")) {
+ $wanted_modules{$_} or unlink "all.kernels/$kern_ver/modules/$_";
+ }
+}
+
+sub make_modules_per_image {
+ my ($kern_ver) = @_;
+
+ make_modules_dep($kern_ver);
+ load_dependencies("all.kernels/$kern_ver/modules.dep");
- if ($image !~ /all/) {
- @modules = difference2(\@modules, \@modules_only_for_all_img);
+ my $ext = module_extension($kern_ver);
+
+ foreach my $image (keys %images) {
+ my @modules_with_deps = uniq(map { dependencies_closure($_) } image2modules($image));
+ my @l = map { "$_.$ext" } @modules_with_deps;
+
+ my $dir = "all.kernels/$kern_ver/modules";
+ @l = grep { -e "$dir/$_" } @l;
+
+ if ($image =~ /all/) {
+ system("cd $dir ; tar cf ../${image}_modules.tar @l") == 0 or die "tar failed\n";
+ } else {
+ my $gi_base_dir = chomp_(`pwd`) . '/..';
+ system("cd $dir ; $gi_base_dir/mdk-stage1/mar/mar -c ../${image}_modules.mar @l") == 0 or die "mar failed\n";
+ }
+ }
+}
+
+sub make_modules_dep {
+ my ($kern_ver) = @_;
+
+ my @l =
+ kernel_is_26($kern_ver) ?
+ cat_("all.kernels/$kern_ver/lib/modules/$kern_ver/modules.dep") :
+ `/sbin/depmod-24 -F all.kernels/$kern_ver/boot/System.map-$kern_ver -e *.o | perl -pe 's/\\\n//'`;
+
+ @l = map {
+ if (/(\S+):\s+(.*)/) {
+ my ($module, @deps) = map { m!.*/(.*)\.k?o(\.gz)$! && $1 } $1, split(' ', $2);
+ if (member($module, 'plip', 'ppa', 'imm')) {
+ @deps = map { $_ eq 'parport' ? 'parport_pc' : $_ } @deps;
+ } elsif ($module eq 'vfat') {
+ push @deps, 'nls_cp437', 'nls_iso8859-1';
+ }
+ if_(@deps, join(' ', "$module:", @deps));
+ } else {
+ ();
}
- printf qq(%s_modules_raw="%s"\n), $image, join ' ', @modules;
+ } @l;
+
+ output("all.kernels/$kern_ver/modules.dep", map { "$_\n" } @l);
+}
+
+sub make_modules_description {
+ my ($kern_ver) = @_;
+ my $ext = module_extension($kern_ver);
+ my $dir = "all.kernels/$kern_ver/modules";
+
+ my @l;
+ if (kernel_is_26(`uname -r`)) { #- modinfo behaves differently depending on the build kernel used
+ my $name;
+ @l = map {
+ $name = $1 if m!^filename:\s*(.*)\.$ext!;
+ if_($name && /^description:\s*(.*)/, "$name\t$1");
+ } `cd $dir ; /sbin/modinfo *.$ext`;
+ } else {
+ @l = map {
+ if_(/(.*?)\.$ext "(.*)"/, "$1\t$2\n");
+ } `cd $dir ; /sbin/modinfo-24 -f '%{filename} %{description}\n' *.$ext`;
}
- printf qq(images="%s"\n), join(' ', keys %images);
+ output("modules.description", @l);
}
sub pci_modules4stage1 {
- print "$_\n" foreach uniq(map { dependencies_closure($_) } difference2([ category2modules($_[0]) ], \@modules_removed_from_stage1));
+ my ($category) = @_;
+ my @modules = difference2([ category2modules($category) ], \@modules_removed_from_stage1);
+ print "$_\n" foreach uniq(map { dependencies_closure($_) } @modules);
}
sub check() {
diff --git a/kernel/update_kernel b/kernel/update_kernel
index 4e0924efa..13a9b3203 100755
--- a/kernel/update_kernel
+++ b/kernel/update_kernel
@@ -1,187 +1,110 @@
-#!/bin/bash
+#!/usr/bin/perl
-ALL_KERNELS="all.kernels"
-RPMS=/export/media/main
+use MDK::Common;
+use list_modules;
-ARCH=`uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/'`
+my $RPMS = '/export/media/main';
+my $rpm = 'rpm --nosignature';
-# move stuff to this new "kernel" directory
-if [ ! -d all.kernels ]; then
- if [ -d ../all.kernels ]; then
- mv ../all.kernels .
- rm -rf ../all.modules
- else
- # make sure "all.kernels" directory exists
- mkdir all.kernels
- fi
-fi
+my $MOVE = $ARGV[0] eq '--move' && shift;
-function create_marfile() {
- marfile=$1
- shift
- $GIBASEDIR/mdk-stage1/mar/mar -c $marfile $*
-}
+@ARGV <= 1 or die "usage: ./update_kernel [--move] [<kernel rpm>]\n";
-function build_kernel_is_26() {
- uname -r | grep -q '^2\.6'
-}
-function kern_version() {
- if echo $1 | grep -q ^2.4; then
- version=24
- objects="*.o"
- else
- version=25
- objects="*.ko"
- fi
-}
-
-function create_modules() {
- kernel_path=$1
- kern=$2
- echo "Updating modules in '`pwd`' for kernel '$kern'"
- kern_version $kern
- find $kernel_path/lib/modules/ -name "$objects" -exec cp -f {} . \;
- if [ $version -eq 24 ]; then
- /sbin/depmod-24 -F $kernel_path/boot/System.map* -e *.o | perl -pe 's/\\\n//' \
- | perl -ne 's/\.o//g; s/[ \t]+/ /g; print if /: /' > modules.dep
- else
- cp $kernel_path/lib/modules/*/modules.dep .
- perl -ni -e 's|/\S+/([^/]+)\.k?o(\.gz)|$1|g; print if /: /' modules.dep
- fi
- perl -pi -e 's/((plip|ppa|imm): parport)/$1 parport_pc/' modules.dep
- perl -pi -e 's/(vfat: fat)/$1 nls_cp437 nls_iso8859-1/' modules.dep
-
- if build_kernel_is_26; then
- /sbin/modinfo $objects | perl -lne 'print "$name\t$1" if $name && /^description:\s*(.*)/; $name = $1 if m!^filename:\s*(.*)\.k?o!' > modules.description
- else
- /sbin/modinfo-$version -f '%{filename} %{description}\n' $objects | perl -lne 'print "$1\t$2" if /(.*?)\.k?o "(.*)"/' > modules.description
- fi
-}
+mkdir 'all.kernels'; # make sure "all.kernels" directory exists
+eval { rm_rf('all.modules') }; #- not used anymore
+
+my $main = chomp_(cat_('all.kernels/.main'));
+my $main_BOOT = chomp_(cat_('all.kernels/.main-BOOT'));
-function create_modules_mar() {
- kern_version $kern
-
- if [ $version -eq 24 ]; then
- echo -n "stripping $kern: "
- $GIBASEDIR/kernel/strip_modules *.o 2>/dev/null
- echo "done"
- else
- echo "don't strip on 2.6 since it breaks modules"
- fi
-
- if [ -z "$MOVE" ]; then
- echo -n "packdrake $kern: "
- ls $objects | packdrake -b9s "modules.cz" 400000
- echo "done"
- mv modules.cz ../modules.cz-$kern
- fi
- for i in $images; do
- eval "modules=\$${i}_modules_raw"
- modules_with_deps=`perl -I $GIBASEDIR/kernel $GIBASEDIR/kernel/dependencies.pl $version modules.dep $modules`
- if [ $i = "all" ]; then
- echo $modules_with_deps > "${i}_modules.list"
- else
- eval "create_marfile ${i}_modules.mar $modules_with_deps"
- fi
- done
- echo
+if (@ARGV) {
+ install_kernel($ARGV[0]);
+} else {
+ update_kernel_from_repository($RPMS, '2.6', 0);
+ update_kernel_from_repository($RPMS, '2.6', 1);
+ update_kernel_from_repository($RPMS, '2.4', 1);
}
-function install_kernel() {
- rpm=$1
-
- ver=$(rpm --nosignature -qpl $rpm | sed -n 's!/boot/vmlinuz-!!p')
- [ -n "$ver" ] || return
-
- if [ -n "$2" ]; then
- [ -d $ALL_KERNELS/$ver ] && return
- main_ver=$2
- echo Removing previous kernel $ALL_KERNELS/$main_ver*
- rm -rf $ALL_KERNELS/$main_ver*
- fi
-
- rm -rf $ALL_KERNELS/$ver
- echo "Installing kernel $ver"
- mkdir -p $ALL_KERNELS/$ver
- rpm2cpio $rpm | (cd $ALL_KERNELS/$ver ; cpio -id)
-
- find $ALL_KERNELS/$ver -type f -name "*.o.gz" -o -name "*.ko.gz" | xargs gunzip
-
- # remove those files during update_kernel, they will get back when make_boot_img is called
- for dir in /tftpboot /var/lib/tftpboot; do
- rm -f $dir/{vmlinuz,network.rdz,all.rdz}
- done
+
+sub system_verbose { print join(' ', @_), "\n"; system(@_) }
+sub sys { &system_verbose; $? and die }
+
+sub rpm2version {
+ my ($kernel_rpm) = @_;
+ `$rpm -qpl $kernel_rpm` =~ m!/boot/vmlinuz-(.*)! && $1 or die "can't find vmlinuz in $kernel_rpm\n";
}
-[ -e $ALL_KERNELS/.main ] && main=$(cat $ALL_KERNELS/.main)
-
-if [ "$1" = "--move" ]; then
- MOVE=1
- shift
-fi
-
-if [ "$ARCH" == "ia64" ] || [ "$ARCH" == "ppc" ]; then
- name=kernel
-else
- name=kernel-BOOT
-fi
-
-if [ -n "$1" ]; then
- #- allow specifying a kernel file on commandline (./update_kernel /RPMS/kernel-2.4.22.10mdk-1-1mdk.i586.rpm)
- install_kernel $1
-else
-# install_kernel $RPMS/kernel-BOOT-2.4*.rpm 2.4
- install_kernel $RPMS/kernel-BOOT-2.6*.rpm 2.6
-fi
-
-[ -n "$main" -a -e $ALL_KERNELS/$main ] || {
- cd $ALL_KERNELS
- main=$(echo 2.6* | sed 's/.* //')
- [ -e "$main" ] || main=$(echo 2.4* | sed 's/.* //')
- [ -e "$main" ] || { echo "no kernel installed in $ALL_KERNELS"; exit 1; }
- echo "Choosing $main"
- echo $main > .main
- cd ..
+sub update_kernel_from_repository {
+ my ($RPMS, $main_ver, $is_BOOT) = @_;
+ my $rpm_wildcard = 'kernel-' . ($is_BOOT ? 'BOOT-' : '') . $main_ver . '*.rpm';
+ my ($kernel_rpm) = my @kernels = glob("$RPMS/$rpm_wildcard");
+ @kernels <= 1 or die "more than one kernel match $rpm_wildcard";
+ @kernels >= 1 or die "no kernel match $rpm_wildcard";
+
+ install_kernel($kernel_rpm, 1);
}
+sub install_kernel {
+ my ($kernel_rpm, $o_update) = @_;
+
+ my $kern_ver = rpm2version($kernel_rpm);
+ my $dir = "all.kernels/$kern_ver";
+
+ -d $dir and return if $o_update;
+
+ my $is_BOOT = $kern_ver =~ /BOOT/;
+ my ($main_ver) = $kern_ver =~ /^(2\.\d)/;
+ if (my @previous = grep { ($is_BOOT xor !/BOOT/) && /^\Q$main_ver/ } all('all.kernels')) {
+ warn "Removing previous kernels ", join(' ', @previous), "\n";
+ rm_rf("all.kernels/$_") foreach @previous;
+ }
+
+ if (!$main || !-d "all.kernels/$main") {
+ $main = $kern_ver;
+ output('all.kernels/.main', "$main\n");
+ }
+ if ($is_BOOT && (!$main_BOOT || !-d "all.kernels/$main_BOOT")) {
+ $main_BOOT = $kern_ver;
+ output('all.kernels/.main-BOOT', "$main_BOOT\n");
+ }
-if [ "$ARCH" == "i386" ]; then
- for i in $ALL_KERNELS/*/boot/vmlinuz*; do
- #disable any existing resolution!!!
- /usr/sbin/rdev -v $i 65535 #788 #785
- done
-fi
-
-
-GIBASEDIR=`pwd`/..
-
-rm -rf all.modules ; mkdir all.modules
-for i in $ALL_KERNELS/*; do
- kern=`basename $i`
- (
- mkdir all.modules/$kern
- cd all.modules/$kern
-
- create_modules ../../$i $kern
- ) || exit 1
-done
-cp -f all.modules/$main/modules.description .
-
-l=`MOVE=$MOVE perl modules.pl images` || exit 1
-eval $l
-
-for i in $ALL_KERNELS/*; do
- kern=`basename $i`
- (
- cd all.modules/$kern
-
- if [ "$kern" = "$main" ]; then
- create_modules_mar ../../$i $kern
- else
- echo "$kern ($main)"
- create_modules_mar ../../$i $kern 2>/dev/null
- fi
- ) || exit 1
-done
+ warn "Installing kernel $kern_ver\n";
+
+ eval { rm_rf($dir) };
+ mkdir_p("$dir/modules");
+ sys("rpm2cpio $kernel_rpm | (cd $dir ; cpio -id)");
+
+ rename "$dir/boot/vmlinuz-$kern_ver", "$dir/vmlinuz" or die "can't find vmlinuz\n";
+
+ sys("find $dir -name '*.gz' | xargs gunzip");
+
+ my $ext = module_extension($kern_ver);
+
+ open(my $F, "find $dir -name '*.$ext' |");
+ my $file; while ($file = <$F>) {
+ chomp($file);
+ rename $file, "$dir/modules/" . basename($file) or warn "conflict for $file\n";
+ }
+
+ if (kernel_is_26($kern_ver)) {
+ warn "no stripping on 2.6 since it breaks modules\n";
+ } else {
+ print STDERR "stripping $kern_ver: ";
+ sys("./strip_modules $dir/modules/*.$ext");
+ print STDERR "done\n";
+ }
+
+ sys('perl', 'modules.pl', 'remove_unneeded_modules', $kern_ver) if $kern_ver !~ /BOOT/;
+
+ sys('perl', 'modules.pl', 'make_modules_per_image', $kern_ver);
+ sys('perl', 'modules.pl', 'make_modules_description', $kern_ver) if $kern_ver eq $main;
+
+ if (!$MOVE) {
+ print STDERR "packdrake $kern_ver: ";
+ sys("cd $dir/modules ; ls *.$ext | packdrake -b9s ../modules.cz 400000");
+ print STDERR "done\n";
+ }
+
+ eval { rm_rf("$dir$_") } foreach qw(/boot /lib /usr /modules);
+}