summaryrefslogtreecommitdiffstats
path: root/rescue/make_partimage_save_rest_all
blob: a7af521301f152073da0af47704d0144c798ee3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh

[ $# -lt 1 ] && { 
    echo "usage: make_partimage_save_rest_all <partimage server> [<partimage dir> <data dirs>]" ; 
    exit 1
}

server=$1 ; shift
partimage_dir=$1 ; shift
data_dir=$1 ; shift

if [ -n "$partimage_dir" ]; then
    first_data_dir="$partimage_dir$data_dir"

    [ -d "$first_data_dir" ] || {
	echo "can't find $first_data_dir"
	exit 1
    }
    [ -r "$first_data_dir/lst" ] || {
	echo "can't read $first_data_dir/*"
	exit 1
    }
fi

rm -rf .tmp
mkdir -p .tmp/isolinux
cp -f /usr/lib/syslinux/isolinux.bin ../images/isolinux/alt0/* .tmp/isolinux

DISTRIB_DESCR="partimage save/restore all" ./make_rescue_img || exit 1
mkdir -p .tmp/install/stage2
mv -f rescue.sqfs .tmp/install/stage2

common_para="rescue automatic=method:cdrom"
# hda=4864,255,63 acpi=ht

for action in save_all rest_all; do

    cat <<EOF > .tmp/isolinux/isolinux.cfg
default $action
prompt 1
timeout 150

label save_all
  kernel vmlinuz
  append initrd=all.rdz $common_para save_all pserver=$server
label rest_all
  kernel vmlinuz
  append initrd=all.rdz $common_para rest_all keepmounted BOX=$data_dir pserver=$server
label rescue
  kernel vmlinuz
  append initrd=all.rdz $common_para
EOF

    if [ $action = rest_all -a -n "$partimage_dir" ]; then
	dir=`dirname $data_dir`
	mkdir -p .tmp$dir
	ln -s $partimage_dir$data_dir .tmp$dir
    fi

    genisoimage -f -o part_$action.iso -r -J -hide-rr-moved -nobak -cache-inodes -publisher Mandriva -V 'mdk part save/rest' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .tmp    
    mkcd --addmd5 part_$action.iso
done
 
rm -rf .tmp
d='n136' href='#n136'>136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
use strict;


BEGIN {
    #- for testing purpose
    (my $f = __FILE__) =~ s|/[^/]*$||;
    push @INC, $f;
}

use MDK::Common;
use list_modules;


sub flatten_and_check {
    my ($h) = @_;
    map { 
	my $category = $_;
	my @l = @{$h->{$category}};
	if (my @bad = difference2(\@l, [ category2modules($category) ])) {
	    foreach (@bad) {
		if (my $cat = module2category($_)) {
		    warn "ERROR in modules.pl: module $_ is in category $cat, not in $category\n";
		} else {
		    warn "ERROR in modules.pl: unknown module $_\n";
		}
	    }
	    exit 1;
	}
	@l;
    } keys %$h;
}

my $images_cat = 'fs/* disk/* bus/* network/* input/* various/*'; #- ie everything except multimedia

my $verbose = $ARGV[0] eq '-v' && shift;
my ($f, @para) = @ARGV;
$::{$f}->(@para);

sub modules() {
    map { category2modules($_) } split(' ', $images_cat);
}

sub remove_unneeded_modules {
    my ($kern_ver) = @_;

    #- need creating a first time the modules.dep for all modules
    filter_modules_dep($kern_ver);
    load_dependencies("all.kernels/$kern_ver/modules.dep");

    my @all = modules();
    my @all_with_deps = map { dependencies_closure($_) } @all;
    my %wanted_modules = map { (list_modules::modname2filename($_) . ".ko.gz" => 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) = @_;

    my $dir = "all.kernels/$kern_ver/modules";

    system("cd $dir ; tar cf ../all_modules.tar *.ko.gz") == 0 or die "tar failed\n";
}

sub filter_modules_dep {
    my ($kern_ver) = @_;

    my @l = cat_("all.kernels/$kern_ver/modules.dep");

    @l = map {
	    my ($f, $d) = split ':';
	    my ($module, @deps) = map { m!.*/(.*)\.k?o(\.gz)$! && $1 } $f, split(' ', $d);
	    if (member($module, 'plip', 'ppa', 'imm')) {
		@deps = map { $_ eq 'parport' ? 'parport_pc' : $_ } @deps;
	    } elsif ($module eq 'vfat') {
		push @deps, 'nls_cp437', 'nls_iso8859-1';
	    }
	    join(' ', "$module:", @deps);
    } @l;

    output("all.kernels/$kern_ver/modules.dep", map { "$_\n" } @l);
}

sub get_main_modules() {
    my $base = dirname($0);
    my $main = chomp_(cat_("$base/RPMS/.main"));
    chomp_(`tar tf $base/all.kernels/$main/all_modules.tar`);
}

sub pci_modules4stage1 {
    my ($category) = @_;
    my @modules = difference2([ category2modules($category) ]);
    print "$_\n" foreach uniq(map { dependencies_closure($_) } @modules);
}

sub check() {
    my $error;
    my %listed;
    while (my ($t1, $l) = each %list_modules::l) {
	while (my ($t2, $l) = each %$l) {
	    ref $l or die "bad $l in $t1/$t2";
	    foreach (@$l) {
		$listed{$_} = "$t1/$t2"; 
	    }
	}
    }

    my %module2category;
    my %deprecated_modules = %listed;
    my $not_listed = sub {
	my ($msg, $verbose, @l) = @_;
	my %not_listed;
	foreach (@l) {
	    my ($mod) = m|([^/]*)\.k?o(\.gz)?$| or next;
	    delete $deprecated_modules{$mod};
	    next if $listed{$mod};
	    s|.*?mdk/||;
	    s|kernel/||; s|drivers/||; s|3rdparty/||;
	    $_ = dirname $_;
	    $_ = dirname $_ if $mod eq basename($_);
	    $module2category{$mod} = $_;
	    push @{$not_listed{$_}}, $mod;
	}
	if ($verbose) {
	    print "$msg $_: ", join(" ", @{$not_listed{$_}}), "\n" foreach sort keys %not_listed;
	}
    };
    $not_listed->('NOT LISTED', 1, get_main_modules());
    $not_listed->('not listed', $verbose, chomp_(`rpm -qpl RPMS/kernel-*2.6*`));
    if (%deprecated_modules) {
	my %per_cat;
	push @{$per_cat{$listed{$_}}}, $_ foreach keys %deprecated_modules;
	foreach my $cat (sort keys %per_cat) {
	    print "bad/old modules ($cat) : ", join(" ", sort @{$per_cat{$cat}}), "\n";
	}
    }

    {
	require '/usr/bin/merge2pcitable.pl';
	my $pcitable = read_pcitable("/usr/share/ldetect-lst/pcitable");
	my $usbtable = read_pcitable("/usr/share/ldetect-lst/usbtable");

	my @l1 = uniq grep { !/:/ && $_ ne 'unknown' } map { $_->[0] } values %$pcitable;
	if (my @l = difference2(\@l1, [ keys %listed ])) {
	    my %not_listed;
	    push @{$not_listed{$module2category{$_}}}, $_ foreach @l;
	    if (my $l = delete $not_listed{''}) {