--- ../yard-1.17/scripts/make_root_fs.in	Thu Nov 19 04:35:51 1998
+++ make_root_fs.in	Fri Mar 10 16:39:19 2000
@@ -128,7 +128,7 @@
 
 warn_about_module_dependencies($ENV{'RELEASE'});
 
-if ($CFG::disk_set !~ /^(single|double|base\+extra)$/) {
+if ($CFG::disk_set !~ /^(single|double|base\+extra|bootcd)$/) {
   error "Config variable disk_set is set to \"$CFG::disk_set\"\n",
         "which is not a valid value.\n";
 }
--- ../yard-1.17/scripts/write_rescue_disk.in	Thu Nov 19 04:35:51 1998
+++ write_rescue_disk.in	Fri Mar 10 16:40:25 2000
@@ -41,7 +41,7 @@
 start_logging_output();
 print "write_rescue_disk @yard_version@\n";
 
-if ($CFG::disk_set !~ /^(single|double|base\+extra)$/) {
+if ($CFG::disk_set !~ /^(single|double|base\+extra|bootcd)$/) {
   error "Config variable disk_set is set to \"$CFG::disk_set\"\n",
         "which is not a valid value.\n";
 }
@@ -54,8 +54,8 @@
 my($root_start);		# Where the root starts on the floppy
 my($rootfsz_blocks);		# Number of blocks required by compressed root
 my($seek_clause);		# 'Seek' clause for dd root
-
-
+my($syslinux_blocks);		# Number of blocks required by syslinux
+$syslinux_blocks = 10;		# Syslinux need about 7K plus 3K reserved space
 
 ##############################################################################
 #####  Check a few things before starting.                               #####
@@ -140,10 +140,12 @@
 #####  Major control branch here.  Transfer the kernel to the floppy
 #####  either using Lilo or not.  
 
-if ($CFG::use_lilo) {
-    setup_kernel_using_lilo();
-} else {
-    setup_kernel_raw();
+if ($CFG::disk_set ne "bootcd") {
+  if ($CFG::use_lilo) {
+      setup_kernel_using_lilo();
+  } else {
+      setup_kernel_raw();
+  }
 }
 
 #####  At this point, kernel is rdev'd with root start address and
@@ -167,7 +169,7 @@
     $root_start  = 1;
   }
 
-} else {			    ########## SINGLE DISK
+} elsif ($CFG::disk_set eq "single") {   ########## SINGLE DISK
   if ($kernel_fs_blocks + $rootfsz_blocks > $CFG::floppy_capacity) {
     info 0, "Kernel fs ($kernel_fs_blocks K) + compressed root fs ",
     "($rootfsz_blocks K) > floppy capacity ",
@@ -208,12 +210,38 @@
 		* 100),
 	    "% of floppy capacity\n";
   }
+} elsif ($CFG::disk_set eq "bootcd") {   ########## BOOTCD
+
+  my($blocks_for_kernel) = bytes_to_K(-s $CFG::kernel);
+  
+  # Check whether the is enough space or not
+  if ($blocks_for_kernel + $syslinux_blocks + $rootfsz_blocks > $CFG::floppy_capacity) {
+    info 0, "\nKernel fs ($blocks_for_kernel K) +\n",    # NOT ENOUGH SPACE
+            "compressed root fs ($rootfsz_blocks K) +\n",
+            "syslinux ($syslinux_blocks K)      > floppy capacity ",
+            "($CFG::floppy_capacity)\n\n";
+    
+    error "Your compressed root fs is too large ",
+    "($rootfsz_blocks K)\nto fit into the bootdisk image.",
+    "  Trim down your file set.\n";
+  } else {  # ENOUGH SPACE PRESET
+      
+    info 0, "\nKernel needs ", $blocks_for_kernel," blocks,\n",
+            "the root filesystem ", $rootfsz_blocks ," blocks\n",
+            "and syslinux ", $syslinux_blocks ," blocks = ",
+            int(($blocks_for_kernel + $rootfsz_blocks + $syslinux_blocks) / $CFG::floppy_capacity
+		* 100), "% of floppy capacity\n";
+
+    setup_kernel_using_syslinux();
+  }
 }
 
-info 0, "Transferring compressed root filesystem ($CFG::rootfsz) to floppy \n";
-sync();
-sys("dd if=$CFG::rootfsz of=$CFG::floppy bs=1k seek=$root_start");
-sync();
+if ($CFG::disk_set ne "bootcd") {
+  info 0, "Transferring compressed root filesystem ($CFG::rootfsz) to floppy \n";
+  sync();
+  sys("dd if=$CFG::rootfsz of=$CFG::floppy bs=1k seek=$root_start");
+  sync();
+}
 
 sleep 2;
 info 0, "\a\n\nTransfer completed successfully.\n\n";
@@ -233,6 +261,9 @@
           "This will be the first disk to load.\n",
           "The other disk, which you've already prepared,\n",
           "will be loaded second after the kernel has booted.\n";
+} elsif ($CFG::disk_set eq "bootcd") {
+  info 0, "The file ", $CFG::floppy ," will be\n",
+          "the bootimage for your bootable cd.\n";
 }
 
 exit(0);
@@ -324,6 +355,86 @@
 
 }# End of setup_kernel_raw
 
+sub setup_kernel_using_syslinux {
+  
+  info 0, "\nCreating bootimage for syslinux...\n";
+
+  my($mtools_conf); # Temporary configuration file for mtools
+
+  $mtools_conf = $CFG::yard_temp . "/mtools.cfg";
+  open(FH, "> $mtools_conf");
+  print FH "drive a:\n",
+           "    file=\"", $CFG::floppy ,"\"\n",
+           "    use_xdf=0\n",
+           "    fat_bits=12\n",
+           "    cylinders=80 heads=2 sectors=36\n",
+           "    mformat_only\n";
+  close(FH);
+
+  info 0, "\nCreating and filling $CFG::floppy with zeros...\n";
+  sys("dd if=/dev/zero of=$CFG::floppy bs=1k count=$CFG::floppy_capacity"); 
+
+  info 0, "\nCreating fs on $CFG::floppy...\n";
+  $ENV{MTOOLSRC} = $mtools_conf;
+  sys("mformat -l \"YARD BOOTCD\" a:");
+  delete $ENV{MTOOLSRC};
+  sys("rm -f $mtools_conf");
+
+  info 0,"\nMounting $CFG::floppy on $CFG::mount_point ...\n";
+  sys("mount $CFG::floppy $CFG::mount_point -o loop");
+  
+  info 0, "\nCopying kernel $CFG::kernel to fs on $CFG::floppy\n";
+  ## This is slightly bad -- we shouldn't be mucking in the CFG
+  ## package, but this var is necessary for c_f_w_s.
+  local($CFG::kernel_basename) = basename($CFG::kernel);
+  sys("cp $CFG::kernel $CFG::mount_point/linux");
+  info 0, "\nSetting up the ramdisk size and other params by rdev the kernel\n";
+  sys("rdev -r $CFG::mount_point/linux $CFG::fs_size");
+  sys("rdev -R $CFG::mount_point/linux 1");
+  sys("rdev -v $CFG::mount_point/linux -1");
+
+  info 0,"\nCreating $CFG::mount_point/syslinux.cfg\n";  
+  my($current_root);
+  $current_root=`rdev $CFG::mount_point/linux`;
+  $current_root =~ s/Root\sdevice\s(.*)/$1/i;
+  $current_root =~ s/\n//gi;
+  open(FH, "> $CFG::mount_point/syslinux.cfg");
+  print FH "DEFAULT linux\n",
+           "APPEND vga=normal load_ramdisk=1 ramdisk=$CFG::fs_size init=/linuxrc initrd=initrd.gz root=$current_root\n",
+           "TIMEOUT 50\n",
+           "DISPLAY yard.txt\n",
+           "PROMPT 1\n";
+  close(FH);
+
+  info 0,"\nCreating $CFG::mount_point/yard.txt\n";  
+  open(FH, "> $CFG::mount_point/yard.txt");
+  print FH "\n\nWelcome on the Yard-BootCD !\n",
+           "\n",
+           "Please press RETURN to continue.\n",
+           "\n";
+  close(FH);
+
+  info 0, "\nTransferring compressed root filesystem ($CFG::rootfsz) to bootimage \n";
+  sys("cp $CFG::rootfsz $CFG::mount_point/initrd.gz");
+  sync();
+
+  info 0, "\nContent of $CFG::mount_point\n";
+  sys("find $CFG::mount_point/");
+
+  info 0, "\nUnmount $CFG::mount_point\n";
+  sys("umount $CFG::mount_point");
+
+
+  info 0, "\nCheck where syslinux is located...\n";
+  if (!((-e "$CFG::yard_temp/syslinux/syslinux") && 
+        (-x "$CFG::yard_temp/syslinux/syslinux"))) {
+     info 1,"Using systems\'s syslinux...\n";
+     sys("syslinux -s $CFG::floppy");
+  } else {
+     info 1,"Using yard\'s syslinux...\n";
+     sys("$CFG::yard_temp/syslinux/syslinux -s $CFG::floppy");
+  }
+}				## End of setup_syslinux
 
     
 #  SET_RAMDISK_WORD($kernel, $kernel_blocks)
