+Support for TurboLinux kernels.
[lufs.git] / kernel / Linux / prepmod.in
index b4bed7c..6cfcd11 100755 (executable)
@@ -300,7 +300,8 @@ sub prebuild_rpm
 my($rpm)=@_;
 
        my $vendor=_readfile "rpm 2>/dev/null --qf '%{VENDOR}' -qp '$rpm' |";
-       $vendor=~s/,.*//;
+       $vendor="unknown" if $vendor eq "(none)";       # TurboLinux 2.4.18-14
+       $vendor=~s/[,<].*//;
        $vendor=~tr/ //d;
        my $uname_r;
        $uname_r||=($rpm=~m#/kernel-source-([^-]+-[^-]+)[.][^.]+[.]rpm$#)[0];
@@ -321,15 +322,42 @@ my($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";
+       my $built_total=0;
        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;
+                       $built_total++;
+                       }
+               }
+       elsif (-e "$dir/SetupKernelSource.sh") {
+               # TurboLinux
+               if (! -e "$dir/include") {
+                       (my $kheaders=$rpm)=~s#/kernel-source-([^/]*)$#/kernel-headers-$1#
+                                       or confess "Invalid RPM basename of: $rpm";
+                       _system "rpm2cpio '$kheaders'|(cd modbin-tmp;cpio -id)"
+                                       and confess "RPM kheaders extraction of $rpm";
+                       }
+               for my $TYPE ("","smp","smp64G") {
+                       for my $ARCH (qw(i386 i586 i686 athlon)) {
+                               # Use even 'A-Z' for the 'release' for TurboLinux 2.4.9-3D
+                               next if !glob "$dir/configs/kernel-*-*[0-9A-Z]$TYPE-$ARCH.config";
+                               _system "set -ex; cd '$dir';"
+                                                               # Forbid 'cd /usr/src/linux' in './SetupKernelSource.sh'
+                                                               # but permit later 'cd's by make(1) subprocesses.
+                                                               # Therefore do not 'export -f cd;' but 'source ./SetupKernelSource.sh'.
+                                                               .' function cd { :; };' # Do not: 'export -f cd;'
+#                                                              .' function make {(set -ex;unset make; make "$@"; make symlinks; );}; export -f make;'
+                                                               # Permit 'errors' for 'grep smp' in TurboLinux 2.4.5-0.5
+                                                               ." set +e; source ./SetupKernelSource.sh $ARCH$TYPE;"
+                                               and confess "SetupKernelSource.sh $ARCH$TYPE in $dir";
+                               prebuild_kernel $dir,$vendor,$uname_r.".".$ARCH.$TYPE;
+                               $built_total++;
+                               }
                        }
                }
        else {
-               my $built_total=0;
                # RedHat/Mandrake/old-SuSE kernels
                for my $smp ("","smp") {
                        my @archs=qw(i386 i586 i686 athlon);
@@ -376,9 +404,9 @@ RHCONFIG_H_NOBOOT_EOF
                                                if !$single_config;
                                }
                        }
-               # Old SuSE kernels have no '.config' or 'configs/'.
-               confess "Not a buildable kernel: $rpm" if !$built_total;
                }
+       # Old SuSE kernels have no '.config' or 'configs/'.
+       confess "Not a buildable kernel: $rpm" if !$built_total;
        _system "rm -rf modbin-tmp" and confess "Remove of extracted kernel-source-$uname_r";
 }