my $uname_r;
$uname_r||=($rpm=~m#/kernel-source-([^-]+-[^-]+)[.][^.]+[.]rpm$#)[0];
my $uname_r_base=($uname_r=~/^([^-]+)/)[0];
+ # Do not: rpm -i ...
+ # as SuSE kernels require 1.5GB of VM during later 'rpm -e' in Shrike.
+ _system "rm -rf modbin-tmp;mkdir modbin-tmp;rpm2cpio '$rpm'|(cd modbin-tmp;cpio -id)"
+ and confess "RPM extraction of $rpm";
my $dir;
- do { $dir||=$_ if -d $_; } for ("/usr/src/linux-$uname_r");
- do { $dir||=$_ if -d $_; } for ("/usr/src/linux-$uname_r_base"); # older RedHat kernels
- confess "Kernel sources already found in $dir" if $dir;
- # '--nodeps' to prevent: error: Failed dependencies: perl-base is needed by *mdk
- _system "rpm -i --nodeps '$rpm'" and confess "RPM installation of $rpm";
- do { $dir||=$_ if -d $_; } for ("/usr/src/linux-$uname_r");
- do { $dir||=$_ if -d $_; } for ("/usr/src/linux-$uname_r_base"); # older RedHat kernels
+ # Do not: -f $_
+ # as we are satisfied with symlink
+ # (such as base 'linux' used for some SuSE kernels with weird directory name).
+ do { $dir||=$_ if -e $_; } for ($ENV{"PWD"}."/modbin-tmp/usr/src/linux-$uname_r-include"); # new SuSE kernels
+ do { $dir||=$_ if -e $_; } for ($ENV{"PWD"}."/modbin-tmp/usr/src/linux-$uname_r");
+ do { $dir||=$_ if -e $_; } for ($ENV{"PWD"}."/modbin-tmp/usr/src/linux-$uname_r_base"); # older RedHat kernels
+ do { $dir||=$_ if -e $_; } for ($ENV{"PWD"}."/modbin-tmp/usr/src/linux");
$dir or confess "Kernel source tree not found in: $rpm";
+ _system "chmod -R u+w $dir" and confess "Make kernel source writable in $dir";
_system "cp -p $dir/include/linux/rhconfig.h $dir/include/linux/rhconfig.h-orig"
if -f "$dir/include/linux/rhconfig.h";
- for my $smp ("","smp") {
- my @archs=qw(i386 i586 i686 athlon);
- for my $arch (@archs) {
- my %boot=(
- "__BOOT_KERNEL_SMP"=>$smp,
- map({ ("__MODULE_KERNEL_$_"=>($arch eq $_)); } @archs),
- "__BOOT_KERNEL_BOOT"=>0,
- "__BOOT_KERNEL_BOOTSMP"=>0,
- "__BOOT_KERNEL_ENTERPRISE"=>0,
- "__BOOT_KERNEL_BIGMEM"=>0,
- "__BOOT_KERNEL_DEBUG"=>0,
- );
- if (-f "$dir/include/linux/rhconfig.h") {
- my $defines="";
- for (keys(%boot)) {
- $defines.="+#define $_ ".($boot{$_} ? 1 : 0)."\n";
- }
- _system "cp -p -f $dir/include/linux/rhconfig.h-orig $dir/include/linux/rhconfig.h";
- _writefile "| patch $dir/include/linux/rhconfig.h",<<"RHCONFIG_H_NOBOOT_EOF";
+ if (-d "$dir/default" && -d "$dir/smp") {
+ # new SuSE kernels
+ for my $arch_d (glob "$dir/*") {
+ (my $arch=$arch_d)=~s#^.*/##;
+ prebuild_kernel $arch_d,$vendor,$uname_r.".".$arch;
+ }
+ }
+ else {
+ my $built_total=0;
+ # RedHat/Mandrake/old-SuSE kernels
+ for my $smp ("","smp") {
+ my @archs=qw(i386 i586 i686 athlon);
+ for my $arch (@archs) {
+ my %boot=(
+ "__BOOT_KERNEL_SMP"=>$smp,
+ map({ ("__MODULE_KERNEL_$_"=>($arch eq $_)); } @archs),
+ "__BOOT_KERNEL_BOOT"=>0,
+ "__BOOT_KERNEL_BOOTSMP"=>0,
+ "__BOOT_KERNEL_ENTERPRISE"=>0,
+ "__BOOT_KERNEL_BIGMEM"=>0,
+ "__BOOT_KERNEL_DEBUG"=>0,
+ );
+ if (-f "$dir/include/linux/rhconfig.h") {
+ my $defines="";
+ for (keys(%boot)) {
+ $defines.="+#define $_ ".($boot{$_} ? 1 : 0)."\n";
+ }
+ _system "cp -p -f $dir/include/linux/rhconfig.h-orig $dir/include/linux/rhconfig.h";
+ _writefile "| patch $dir/include/linux/rhconfig.h",<<"RHCONFIG_H_NOBOOT_EOF";
--- ./include/linux/rhconfig.h-orig Thu Aug 21 14:50:16 2003
+++ ./include/linux/rhconfig.h Thu Aug 21 14:59:22 2003
\@\@ -10,7 +10,@{[ 7+keys(%boot) ]} \@\@
#if defined(__BOOT_KERNEL_SMP) && (__BOOT_KERNEL_SMP == 1)
#define __module__smp
RHCONFIG_H_NOBOOT_EOF
+ }
+ # Mandrake packages have no configs/ and they have just that '.config' file.
+ my $single_config=-f "$dir/.config";
+ if (!$single_config) {
+ my $spec_config="$dir/configs/kernel-$uname_r_base-$arch".($smp ? "-smp" : "").".config";
+ next if ! -f $spec_config;
+ _system "ln -s $spec_config $dir/.config";
+ }
+ prebuild_kernel $dir,$vendor,$uname_r.$smp.".".$arch;
+ $built_total++;
+ _system "rm -f $dir/.config"
+ if !$single_config;
}
- # Mandrake packages have no configs/ and they have just that '.config' file.
- my $single_config=-f "$dir/.config";
- if (!$single_config) {
- my $spec_config="$dir/configs/kernel-$uname_r_base-$arch".($smp ? "-smp" : "").".config";
- next if ! -f $spec_config;
- _system "ln -s $spec_config $dir/.config";
- }
- prebuild_kernel $dir,$vendor,$uname_r.$smp.".".$arch;
- _system "rm -f $dir/.config"
- if !$single_config;
}
+ # Old SuSE kernels have no '.config' or 'configs/'.
+ confess "Not a buildable kernel: $rpm" if !$built_total;
}
- _system "rpm -e kernel-source-$uname_r" and confess "Remove of kernel-source-$uname_r";
- _system "rm -rf $dir";
+ _system "rm -rf modbin-tmp" and confess "Remove of extracted kernel-source-$uname_r";
}
sub prebuild_dir