summaryrefslogtreecommitdiffstats
path: root/kernel/update_kernel
blob: a32878339ae0bacde6cb820228d0e52c689bf2f5 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/perl

# this script takes kernels rpms from RPMS/ and create various files in all_kernels/
# for each rpms in RPMS, it does:
#   RPMS/kernel-VER-*.rpm -> 
#     all.kernels/VER/all_modules.tar  (used for all.rdz)
#     all.kernels/VER/*.mar            (used for other rdz)
#     all.kernels/VER/modules.cz       (used for stage2)
#     all.kernels/VER/modules.dep
#     all.kernels/VER/vmlinuz
#
# if RPMS is empty, this script tries to find kernels in $main_repository

use MDK::Common;
use list_modules;

my $main_repository = '/export/media/main';
my $rpm = 'rpm --nosignature';


my $MOVE = $ARGV[0] eq '--move' && shift;

@ARGV <= 1 or die "usage: ./update_kernel [--move] [<kernel rpm>]\n";

eval { rm_rf('all.kernels') }; #- remove old things
mkdir 'all.kernels';

my $main = chomp_(cat_('RPMS/.main'));
my $main_BOOT = chomp_(cat_('RPMS/.main-BOOT'));

if (@ARGV) {
    install_kernel($ARGV[0]);
} elsif (! -d 'RPMS') {
    update_kernel_from_repository($main_repository, '2.6', 0);
    update_kernel_from_repository($main_repository, '2.6', 1);
    install_kernel(glob("$main_repository/kernel-xbox*"), 1) if arch() =~ /i.86/;
}

extract_kernel($_) foreach glob("RPMS/*.rpm");

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";
}

sub update_kernel_from_repository {
    my ($repository, $main_ver, $is_BOOT) = @_;
    my $rpm_wildcard = 'kernel-' . ($is_BOOT ? 'BOOT-' : (arch() =~ /i.86/ ? 'i586-up-1GB-' : '')) . $main_ver . '*.rpm';
    my @kernels = glob("$repository/$rpm_wildcard");
    
    install_kernel($_, 1) foreach @kernels;
}

sub install_kernel {
    my ($kernel_rpm) = @_;
    my $basename = basename($kernel_rpm);
    warn "Installing rpm $basename in RPMS\n";
    mkdir 'RPMS';
    cp_af($kernel_rpm, "RPMS/$basename");

    if (!$main) {
	$main = rpm2version($kernel_rpm);
	output('RPMS/.main', "$main\n");
    }
    if (!$main_BOOT && $kernel_rpm =~ /BOOT/) {
	$main_BOOT = rpm2version($kernel_rpm);
	output('RPMS/.main-BOOT', "$main_BOOT\n");
    }
}

sub extract_kernel {
    my ($kernel_rpm) = @_;

    my $kern_ver = rpm2version($kernel_rpm);
    my $dir = "all.kernels/$kern_ver";

    warn "Extracting 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);
}
master as boot.iso (and factorize)
+ allow to use --boot-only for master/format/record steps
+ add optionnal boot storage type in $media->{boot} and build a custom
+ syslinux-boot.cfg for it
+ rename refresh_boot_only as boot_only
+ remove --record-boot option, this can be achieved using --boot-only
+ --record now
+ fix spacing
+ add --boot-only option to prepare for special boot images
+ use dashes instead of underscores in command line options
+ require root capabilities
+ sort storage types
+
+2005/12/29 pjetur
+
+ * share/po/is.po: Fix missing, spelling, better translations
+
+2005/12/28 Olivier Blin <oblin at mandriva.com>
+
+ * keyboard.pm, standalone/keyboarddrake: create new function and use it
+ (backport for finish-install)
+
+ * tools/draklive: install packages using urpmi --auto
+ add some minimal help in syslinux
+
+ * network/drakfirewall.pm: remove unused variable
+ don't install and configure mandi-ifw if ifw is disabled
+
+2005/12/28 Pixel <pixel at mandriva.com>
+
+ * install_steps_interactive.pm: fix titi sucks :)
+
+ * lang.pm (backport) restore behaviour broken in commit 1.371 (nb: {lang}
+ is not always set in {langs} at that time)
+
+ * common.pm: let packages using common.pm to use Locale::gettext without
+ requiring it
+
+2005/12/27 Olivier Blin <oblin at mandriva.com>
+
+ * standalone/finish-install: allow to blacklist steps in
+ /etc/sysconfig/finish-install (backport)
+ locale is now set by any::selectLanguage_standalone
+ add ask_keyboard step (backport)
+
+ * any.pm: fix for localedrake in text mode (backport of patch from Pixel)
+
+ * tools/draklive: check that abs_path doesn't fail to find (rpm/patch)
+ files
+ add missing newline characters
+ add patches config option to apply patches on the installed system
+ remove urpmi media added by drakx-in-chroot, they're unusable
+ perl_checker fix
+ add --post_install option to run post install only (rpms and patches
+ installation)
+ rename patch option as patch_install
+ fix stupid mistake
+ don't allow to go on if no device is selected (thanks to Sylvie \o/)
+
+ * Xconfig/card.pm: check for nvidia_drv.so (as well as nvidia_drv.o)
+ check for nvidia_drv.so (as well as nvidia_drv.o)
+
+ * Makefile: keep install_messages.pm for finish-install (i.e. don't break
+ finish-install in 2006.0)
+
+2005/12/26 Olivier Blin <oblin at mandriva.com>
+
+ * tools/draklive: add a copy wizard
+ umount eventually mounted usb devices before formatting or running
+ syslinux
+ move default prefix in a dedicated hash
+ make options sourced from --config overwrite previous settings
+
+2005/12/22 Thierry Vignaud <tvignaud at mandriva.com>
+
+ * standalone.pm: add support for $::no_global_argv_parsing, enabling to
+ NOT using common option
+ managemnt (eg: when using Getopt)
+
+ * raid.pm: we shouldn't rely on callers to load missing modules...
+
+ * drakxtools.spec: 10.4.7-1mdk
+
+2005/12/21 Olivier Blin <oblin at mandriva.com>
+
+ * tools/draklive: big rework to be able to record live system on multiple
+ media:
+ - make bootloader/master/record steps media-specific
+ - build bootloader files for each media (create bootloader files in
+ boot/<storage_type> directory, to ease live duplication)
+ - merge initrd step in bootloader step
+ - add extra_media configuration key, to specify alternate
+ media/storage
+ - create loopbacks files in a loopbacks sub-directory
+ - duplicate usb bootloader files at root of the usb media (for
+ syslinux to find them)
+ - create initrd mountpoints in /live and move them in the new root
+ using "mount --move" (requires /bin/mount)
+ - merge most media defaults in storage settings
+
+2005/12/20 Frederic Lepied <flepied at mandriva.com>
+
+ * share/rpmsrate: added kdegraphics-kpdf
+
+2005/12/20 Pixel <pixel at mandriva.com>
+
+ * patch/patch-2006-bad-fonts.pl: some fonts are not seen by fontconfig
+ because of a packaging pb, force a rebuild of fc cache
+
+2005/12/19 Olivier Blin <oblin at mandriva.com>
+
+ * tools/draklive: use rsync to copy files on usb media
+ disable network, authentication and users step in finish-install
+ fix mkisofs options ordering
+
+2005/12/19 Thierry Vignaud <tvignaud at mandriva.com>
+
+ * lang.pm: from Yukiko Bando:
+ - kasumi is now required by scim-anthy
+ - uim-anthy is obsolete
+
+ * share/rpmsrate: install uim-qtimmodule too for KDE (Yukiko Bando)
+ kasumi is now required by scim-anthy (Yukiko Bando)
+
+ * detect_devices.pm (getSCSI_26) add a comment
+ (getSCSI_26) be more robust (aka do not silently not detect hard disks
+ when kernel sysfs exports got changed)
+ (getSCSI_26) handle kernel-2.6.14+
+
+ * drakxtools.spec: commit 10.4.6-1mdk's changes that pixel forgot to
+ commit
+
+2005/12/18 Olivier Blin <oblin at mandriva.com>
+
+ * network/adsl.pm: don't overwrite ONBOOT setting when writing adsl
+ configuration (#20089)
+
+2005/12/18 Pixel <pixel at mandriva.com>
+
+ * standalone/net_applet: replace sprintf_fixutf8 with simple sprintf
+
+ * fsedit.pm: allow auto allocating partitions without giving a {mntpoint}
+
+ * common.pm, standalone.pm: allow common.pm and standalone.pm to be used
+ in drakxtools-backend without perl-Locale-gettext
+
+ * run_program.pm: fix bad typo
+
2005/12/05 Antoine Ginies <aginies at mandriva.com>
* docs/HACKING: add missgin requires to build GI