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