home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / images / ramdisk2.img / usr / lib / perl / kernel < prev    next >
Text File  |  1995-10-03  |  4KB  |  175 lines

  1. # kernel selection and installation -*-perl-*-
  2.  
  3. $kernel_root = "images";
  4. $kernel_version_file = "version.idx";
  5. $kernel_index_file = "image.idx";
  6.  
  7. $kernel_version_text = "";
  8. $kernel_version_dir = "";
  9. $kernel_version = "";
  10.  
  11. sub install_kernel {
  12.  
  13.     local ( $kernel );
  14.  
  15.     $res = 0;
  16.  
  17.     # Now we always copy the kernel from the boot floppy
  18.     &mount_bootdisk();
  19.  
  20.     # the boot floppy should already be mounted
  21.     &rhs_infobox("Installing Kernel",
  22. <<EOM
  23. >
  24. Copying kernel from boot floppy.
  25. >
  26. EOM
  27.          , 60);
  28.  
  29.     $res += &invoke("cp -f /bootdisk/vmlinuz $fsmount/vmlinuz");
  30.  
  31.     $res += &invoke("rdev $fsmount/vmlinuz $root_dev");
  32.     # Standard video mode
  33.     $res += &invoke("rdev -v $fsmount/vmlinuz -1");
  34.     # Mount / read-only
  35.     $res += &invoke("rdev -R $fsmount/vmlinuz 1");
  36.     # No ramdisk
  37.     $res += &invoke("rdev -r $fsmount/vmlinuz 0");
  38.  
  39.     if ($res) {
  40.     &rhs_msgbox("Error",
  41. <<EOM
  42. >
  43. The kernel was NOT installed properly.
  44. >
  45. Are you sure the BOOT floppy is inserted?
  46. >
  47. EOM
  48.             , 60);
  49.     return 0;
  50.     } else {
  51. #    if ($dev_series_selected) {
  52. #        &install_kernel_sources;
  53. #    }
  54.     return 1;
  55.     }
  56.   
  57.     &umount_bootdisk();
  58. }
  59.  
  60. sub select_kernel_version {
  61.     local ( @version_text, %version_text_to_dir );
  62.     local ( $dir, $version, $text );
  63.     local ( $max_version_index );
  64.  
  65.     @version_text = ();
  66.     %version_text_to_dir = ();
  67.  
  68.     $max_version_index = "";
  69.  
  70.     open(FD, "$rhspath/$kernel_root/$kernel_version_file");
  71.     while (<FD>) {
  72.     chop;
  73.     ($dir, $version, $text) = split(/\s+/, $_, 3);
  74.     if ((! $max_version_index) ||
  75.         ($version_text_to_dir{$max_version_index} < $dir)) {
  76.         $max_version_index = $text;
  77.     }
  78.     $version_text_to_dir{$text} = $dir;
  79.     $version_text_to_version{$text} = $version;
  80.     $version_text[@version_text] = $text;
  81.     }
  82.     close(FD);
  83.  
  84.     if ($express_install) {
  85.     $dialog_result = $max_version_index;
  86.     } else {
  87.     if (! &rhs_menul("Kernel Version",
  88. <<EOM
  89. >
  90. Please select a kernel version.
  91. >
  92. EOM
  93.              , 70, scalar(@version_text), @version_text)) {
  94.         return 0;
  95.     }
  96.     }
  97.  
  98.     $kernel_version_text = $dialog_result;
  99.     $kernel_version_dir = $version_text_to_dir{$dialog_result};
  100.     $kernel_version = $version_text_to_version{$dialog_result};
  101.  
  102.     return 1;
  103. }
  104.  
  105. sub install_kernel_sources {
  106.  
  107.     local ( $rpp, $rhsmountpath_save );
  108.  
  109.     if (! $express_install) {
  110.     if (! &rhs_yesno("Notice",
  111. <<EOM
  112. >
  113. You have installed a kernel from your boot floppy.
  114. If this is your own custom kernel, and is a different
  115. version than is available on the Red Hat CD, you will
  116. not be able to install the kernel sources at this time.
  117. >
  118. Do you wish to install kernel sources (you will have
  119. to choose a version)?
  120. >
  121. EOM
  122.              , 50)) {
  123.         return 0;
  124.     }
  125.     }
  126.  
  127.     # select kernel version
  128.     if (! &select_kernel_version) {
  129.     return 0;
  130.     }
  131.  
  132.     &rhs_infobox("Installing Kernel Sources",
  133. <<EOM
  134. >
  135. Installing sources for Linux kernel version $kernel_version.
  136. >
  137. This may take a minute or two...
  138. >
  139. EOM
  140.          , 60);
  141.  
  142.     # install kernel
  143.  
  144.     # Move the RHS stuff filesystem to a place under the
  145.     # installation filesystem
  146.     $rhsmountpath_save = $rhsmountpath;
  147.     &_remount_rhs ("$fsmount/$install_rhs_mount_point");
  148.  
  149.     $rpp = "linux-$kernel_version-src.rpp";
  150. #    &invoke("cp -f $rhspath/$rpppath/$rpp $fsmount/tmp");
  151.  
  152.     if ($pid = fork) {
  153.     waitpid($pid, 0);
  154.     } else {
  155.     chdir $fsmount;
  156.     chroot $fsmount;
  157.     &invoke("rpp-install /$install_rhs_mount_point/$rpppath/$rpp");
  158.     exit(0);
  159.     }
  160.  
  161. #    unlink("$fsmount/tmp/$rpp");
  162.  
  163.     # make symlink
  164.     chdir("$fsmount/etc");
  165.     symlink("../usr/src/kernel/linux-$kernel_version", "linux-source");
  166.  
  167.     chdir("/");
  168.     &_remount_rhs($rhsmountpath_save);
  169.  
  170.     return 1;
  171. }
  172.  
  173. ##########################
  174. 1;
  175.