[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: boot-floppies auto partitioning & hardware detection



On Sun, 21 Oct 2001, David Kimdon wrote:

> Cool.  It is probably best if I leave you to work through these.  At
> the moment there are other important b-f issues that I need to look
> into.  I definately like the direction you went with these.  I
> especially like that you added a lot of functionality without adding a
> lot of code.

The following patcch + scripts realizes the functionality I mentioned
earlier. This code was tested,

New parameters to pass at the syslinux prompt (I also have a patch for
debian-cd that allows the setting of these during CD generation and also
a patch for base-config that allows the use of these new variables after
the first boot of the fresh system):

copycd

Copy cd /dists dir to the root directory on the harddisk as part of the
installation. This avoids the need to reinsert the CD after removing it
for a reboot. copycd makes most sense for small images (like a credit card
cd). Installation with inserting a CD once become possible.

A "copycd" package can be included on the CD. During the configuration of
the system on the HD this package is installed which can then do arbitrary
changes to the installation. This package is then removed. If the copycd
package deposits a script /root/copycd then that script is also run
(allows commands outside of the packaging system).

batch

Do a fully unattended installation

drivers=drivername

Supply a list of drivers to be included in /etc/modules.conf

New file scripts/rootdisk/prototype/bin/pcidetect which loads drivers
mappable via the pci registers:

#!/bin/sh

# Pci Driver loading and detection for the currently running kernel
# This script has to run under ash otherwise it will not work in the
# boot-floppies environment!
#
# Christoph Lameter <christoph@lameter.com>, October 15, 2001

VERBOSE=0
MODPROBE=0

loaddriver() {
  echo $1
  if [ $MODPROBE -eq 1 ]; then
     modprobe $1
  fi
}

driver() {
  VER=`uname -r`
  LINE=`grep "0x0000${2%????} 0x0000${2#????}" /lib/modules/$VER/modules.pcimap`
  if [ $? = 0 ]; then
     loaddriver $LINE
  else
     if [ $VERBOSE -eq 1 ]; then
	echo "No driver for PCI ID=$2"
     fi
  fi
}

p() {
  while read X; do
    driver $X
  done
}

while getopts "mv", opt ; do
    case $opt in
            'v')
                VERBOSE=1
                ;;

            'm')
                MODPROBE=1
                ;;

             *)
                exit 1
                ;;
    esac
done

p </proc/bus/pci/devices

-----------------------

Patch to boot-floppies against todays CVS version:

Index: utilities/dbootstrap/baseconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/baseconfig.c,v
retrieving revision 1.84
diff -u -r1.84 baseconfig.c
--- utilities/dbootstrap/baseconfig.c	2001/10/23 19:57:59	1.84
+++ utilities/dbootstrap/baseconfig.c	2001/10/23 23:11:03
@@ -539,8 +539,24 @@
 #endif

   execlog("depmod -a", LOG_INFO);
+
+  if (bootargs.drivers) {
+    snprintf(prtbuf,sizeof(prtbuf),"/target/usr/sbin/modconf"
+                     " --exclude-section pcmcia"
+                     " --target /target"
+                     " --run-shell cdromsymlink"
+                     " --load-only %s",bootargs.drivers);
+    fullscreen_execlog(prtbuf);
+  }

-  fullscreen_execlog("/target/usr/sbin/modconf"
+  if (bootargs.batch || yesNoBox(
+    _("Hardware Autoconfiguration can load drivers for PCI devices on your system without you having to specify the drivers manually.\nHardware autoconfiguration?"),_("Hardware Autoconfig"))) {
+     extern int pciDetectDone;
+     execlog("pcidetect -m -v",LOG_INFO);
+     execlog("pcidetect >>/target/etc/modules",LOG_INFO);
+     pciDetectDone=1;
+  } else
+    fullscreen_execlog("/target/usr/sbin/modconf"
                      " --exclude-section pcmcia"
                      " --target /target"
                      " --run-shell cdromsymlink"
Index: utilities/dbootstrap/bootconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/bootconfig.c,v
retrieving revision 1.151
diff -u -r1.151 bootconfig.c
--- utilities/dbootstrap/bootconfig.c	2001/10/23 10:27:13	1.151
+++ utilities/dbootstrap/bootconfig.c	2001/10/23 23:11:09
@@ -2225,6 +2225,7 @@
   int idx, status = 0;
   int rootnum;
   char *device, *partition;
+  extern int autoPartitionDone;

   idx         = firstnumber(boot);
   device      = strdup(boot);
@@ -2232,7 +2233,7 @@
   device[idx] = '\0';
   partition   = strdup(boot + idx);
   snprintf(prtbuf, sizeof(prtbuf), _("If you want the Debian system to boot automatically from the hard disk when you turn your system on, answer \"Yes\" to the following question.\nIf you have another operating system that you'd prefer to be the one that boots automatically, answer \"No\".\nBoot the Debian system on %s as the default?"), boot);
-  if (yesNoBox(prtbuf,_("Make Linux the Default Boot Partition?")) == DLG_YES) {
+  if (autoPartitionDone || bootargs.batch || yesNoBox(prtbuf,_("Make Linux the Default Boot Partition?")) == DLG_YES) {
     INFOMSG("making linux partition '%s' the default for device '%s'",
             partition, device);
     snprintf(prtbuf, sizeof(prtbuf), BC_BOOT_DFLT, device, partition);
@@ -2259,6 +2260,7 @@
   struct d_choices opt[2];
   struct stat statbuf;
   int res;
+  extern int autoPartitionDone;

   boot = Boot->name;

@@ -2314,9 +2316,12 @@
 	  opt[1].string = _("Install LILO in the root partition's boot sector.");
       snprintf(prtbuf, sizeof(prtbuf), _("LILO can be installed either into the master boot record (MBR), or into the %s boot block. If installed into the MBR, LILO will take control of the boot process. If you choose not to install LILO into the MBR, you will have the opportunity later on to install an alternative MBR program (for bootstrapping LILO).\n"),
 	       Boot->name);
-      if ( (res = menuBox(prtbuf, _("Where should the LILO boot loader be installed?"), opt, 2, 1) == -1 ))
+      if (autoPartitionDone || bootargs.batch)
+         res=1;
+      else {
+         if ( (res = menuBox(prtbuf, _("Where should the LILO boot loader be installed?"), opt, 2, 1) == -1 ))
 	      return 0;
-
+      }
       boot = opt[res].tag;
       installed_mbr = (res == 0);
   }
Index: utilities/dbootstrap/choose_medium.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/choose_medium.c,v
retrieving revision 1.115
diff -u -r1.115 choose_medium.c
--- utilities/dbootstrap/choose_medium.c	2001/10/22 06:05:02	1.115
+++ utilities/dbootstrap/choose_medium.c	2001/10/23 23:11:14
@@ -740,7 +740,7 @@

     umount(CM_MOUNTPOINT_DIR);

-    problemBox(_("Please place the first Debian CD-ROM in the CD-ROM drive."),
+    if (!is_cdrom_image()) problemBox(_("Please place the first Debian CD-ROM in the CD-ROM drive."),
 	       _("Please insert the CD-ROM"));

     if (execlog("mount -t iso9660 -o nojoliet -r /dev/cdrom " CM_MOUNTPOINT_DIR, LOG_INFO)) {
Index: utilities/dbootstrap/dbootstrap.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/dbootstrap.h,v
retrieving revision 1.90
diff -u -r1.90 dbootstrap.h
--- utilities/dbootstrap/dbootstrap.h	2001/10/16 14:50:58	1.90
+++ utilities/dbootstrap/dbootstrap.h	2001/10/23 23:11:14
@@ -149,6 +149,10 @@
   int isdebug;
   int isverbose;
   int isquiet;
+  int batch;
+  int copycd;
+  char *drivers;
+  char *install;
 } bootargs;

 enum extract_type {
Index: utilities/dbootstrap/extract_base.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/extract_base.c,v
retrieving revision 1.59
diff -u -r1.59 extract_base.c
--- utilities/dbootstrap/extract_base.c	2001/10/22 05:10:48	1.59
+++ utilities/dbootstrap/extract_base.c	2001/10/23 23:11:15
@@ -433,7 +433,12 @@
   sprintf(prtbuf,"cp %s %s","/etc/inittab.install","/target/etc/inittab");
   execlog(prtbuf, LOG_INFO);

-  configure_base () ;
+  configure_base ();
+  if (bootargs.copycd) {
+	pleaseWaitBox("Packages from CD are being copied to the Harddisk");
+	execlog("cp -a /instmnt/dists /target", LOG_INFO);
+	execlog("cp -a /instmnt/pool /target", LOG_INFO);
+  }

   sync();
   return 0;
Index: utilities/dbootstrap/main.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/main.c,v
retrieving revision 1.126
diff -u -r1.126 main.c
--- utilities/dbootstrap/main.c	2001/10/05 02:00:00	1.126
+++ utilities/dbootstrap/main.c	2001/10/23 23:11:16
@@ -172,6 +172,10 @@
     { "verbose",   1, &bootargs.isverbose}, /* chatty mode */
     { "quiet",     1, &bootargs.isquiet  }, /* quiet mode */
     { "cdrom",     1, &bootargs.cdrom    }, /* cdrom install */
+    { "install=",  0, &bootargs.install  }, /* install task/package. Bypass tasksel stage */
+    { "drivers=",  0, &bootargs.drivers  }, /* Load indicated drivers */
+    { "batch",     1, &bootargs.batch    }, /* Unattended install */
+    { "copycd",    1, &bootargs.copycd   }, /* Copy packages on CD to HD and select HD as install source */
     { NULL,        0, NULL               }
   };

@@ -679,6 +683,8 @@
       bootargs.isquiet = 0;
     }

+    if (bootargs.batch) bootargs.isquiet=1;
+
     /* get kernel version */
     get_kver();

@@ -721,7 +727,7 @@
     boxInit();

 #ifdef USE_LANGUAGE_CHOOSER
-    if ((lang = boxChooseLanguageVariant (available_languages ())) != NULL)
+    if (!bootargs.isquiet && !bootargs.batch && (lang = boxChooseLanguageVariant (available_languages ())) != NULL)
     {
         char *msgcat = (char *)malloc (PATH_MAX);

@@ -817,7 +823,6 @@
     notCreatedBootFloppy = 1;
     notInstalledLILO = 1;
     Archive_Dir=NULL;
-
     InstallationRootDevice=block_device("/");
     if (!InstallationRootDevice) {
       /* something's borked, cannot determine where / comes from */
@@ -832,11 +837,12 @@
       exit(1); /* when not root and debugging */
 #endif
     }
-
+
+    if (!bootargs.isquiet && !bootargs.batch)
 #ifdef USE_LANGUAGE_CHOOSER
-    release_notes (lang->msgcat);
+      release_notes (lang->msgcat);
 #else
-    release_notes (NULL);
+      release_notes (NULL);
 #endif

 #if #cpu(arm)
Index: utilities/dbootstrap/main_menu.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/main_menu.c,v
retrieving revision 1.78
diff -u -r1.78 main_menu.c
--- utilities/dbootstrap/main_menu.c	2001/10/20 11:28:54	1.78
+++ utilities/dbootstrap/main_menu.c	2001/10/23 23:11:18
@@ -10,6 +10,8 @@
 #include "util.h"

 static int failedBaseInstall = 0;
+int pciDetectDone = 0;
+int autoPartitionDone =0;

 int true (void) {
 	return 0;
@@ -97,6 +99,8 @@
 #endif
 #endif //!_TESTING_

+int batch_install(void) { bootargs.batch=1;bootargs.isquiet=1;return 0; }
+
 int main_menu_extract_base ()
 {
 	return failedBaseInstall = debootstrap_extract_base ();
@@ -123,15 +127,16 @@
 #define OPT_Previous1		1005
 #define OPT_CONFIGURE_KEY	1006
 #define OPT_PARTITION_DISK	1007
-#define OPT_INITIALIZE_SWAP	1008
-#define OPT_ACTIVATE_SWAP	1009
-#define OPT_DO_WITHOUT_SWAP	1010
-#define OPT_INITIALIZE_LINUX	1011
-#define OPT_MOUNT_LINUX		1012
-#define OPT_UMOUNT_LINUX	1013
-#define OPT_INSTALL_OS		1014
-#define OPT_INSTALL_BASE	1015
-#define OPT_CONFIGURE_MODULES	1016
+#define OPT_BATCH_INSTALL	1008
+#define OPT_INITIALIZE_SWAP	1009
+#define OPT_ACTIVATE_SWAP	1010
+#define OPT_DO_WITHOUT_SWAP	1011
+#define OPT_INITIALIZE_LINUX	1012
+#define OPT_MOUNT_LINUX		1013
+#define OPT_UMOUNT_LINUX	1014
+#define OPT_INSTALL_OS		1015
+#define OPT_INSTALL_BASE	1016
+#define OPT_CONFIGURE_MODULES	1017
 #define OPT_CONFIGURE_NET	1018
 #define OPT_DISK_BOOT		1019
 #define OPT_FLOPPY_BOOT		1020
@@ -148,7 +153,7 @@
 #define OPT_PROBLEM_REPORT	1031
 #define OPT_FOREIGN_MODULES	1032
 #define OPT_ATTACH_DISK   	1033
-#define NITEMS	31
+#define NITEMS	32
 	int data, ilist[NITEMS], items, i, rs;
 	struct d_choices choices[NITEMS];
 	struct { char *string; int key; } entries[] = {
@@ -162,6 +167,7 @@
 #if (#cpu(i386))
 		{_("Preload modules from a floppy"),	OPT_LOAD_MODULES_FROM_A_FD_AFTER_BOOT},
 #endif
+		{_("Continue with default Parameters"),			OPT_BATCH_INSTALL},
 		{_("Partition a Hard Disk"),				OPT_PARTITION_DISK},
 		{_("Initialize and Activate a Swap Partition"),		OPT_INITIALIZE_SWAP},
 		{_("Activate a Previously-Initialized Swap Partition"),	OPT_ACTIVATE_SWAP},
@@ -325,7 +331,6 @@
 #endif
 		}

-
 		next_action = configure_keyboard_m;
 		bufT = _("You must indicate what sort of keyboard you have so that keys operate as expected.  Select \"Next\" from the menu to configure your keyboard.");
 		bufN = _("Configure the Keyboard");
@@ -362,7 +367,7 @@
 			bufA = _("Configure the hostname");
 		}
 	}
-	else if ((swapon_partitions == NULL)
+	else if ((fdisk_disks != NULL && Root && swapon_partitions == NULL)
 		 && (fdisk_partitions_by_type[FSTYPE_SWAP] == NULL)
 		 && (noSwap == 0)) {
 		/*
@@ -437,24 +442,36 @@
 		/*
 		 * No "Linux native" partitions have been created.
 		 */
+	        if (bootargs.batch && !autoPartitionDone) {
+	   	    partition_disk();
+	            autoPartitionDone=1;
+	            continue;
+	        }
 		next_action = partition_disk;
-		bufT = _("No Linux partitions were detected.  At least one Linux partition is required to hold the root filesystem.  Selecting \"Next\" will start the partitioning program.  Use that to create \"Linux native\" partitions on your local disk.");
+		bufT = _("No Linux partitions were detected.  Selecting \"Next\" will start the partitioning program.  Selecting \"Express\" will avoid all technical questions and install using reasonable defaults.");
 		bufN = _("Partition a Hard Disk");
+		alternate_action = batch_install;
+		bufA = _("Express install overwriting Hard Disk content");
 	}
 	else if ((swapon_partitions == NULL) && (noSwap == 0)) {
 		/*
 		 * The swap partition(s) are not initialized and
 		 * activated.
 		 */
+		if (bootargs.batch && !autoPartitionDone) {
+		   partition_disk();
+		   autoPartitionDone=1;
+		   continue;
+		}
 		next_action       = init_swap;
 		alternate_action  = activate_swap;
 		alternate1_action = no_swap;
-		previous_action   = partition_disk;
+		previous_action   = batch_install;
 		bufT = _("You have a swap partition, but it needs to be initialized and activated.  Select \"Next\" to put this swap partition to use, providing virtual memory for your system.  Select \"Alternate\" to activate a swap partition which has already been initialized for swap.\n\nIf you have not finished partitioning your disks, select \"Previous\".  If you do not want to use your swap partition, select \"Alternate1\".");
 		bufN = _("Initialize and Activate a Swap Partition");
 		bufA = _("Activate a Previously-Initialized Swap Partition");
 		bufA1 = _("Do Without a Swap Partition");
-		bufP = _("Partition a Hard Disk");
+		bufP = _("Express install overwriting Hard Disk content");
 	}
 	else if (! Root && fdisk_disks != NULL) {
 		/*
@@ -484,8 +501,12 @@
 		 * The operating system kernel and the modules have
 		 * not been installed.
 		 */
+		if (bootargs.batch) {
+		  extract_kernel_and_modules();
+		  goto done_keyboard;
+		}
 		next_action               = extract_kernel_and_modules;
-		bufT = _("You've mounted your root filesystem.  You may initialize and mount additional filesystems, or you may go on to install the operating system kernel and the modules.");
+		bufT = _("You have mounted your root filesystem.  You may initialize and mount additional filesystems, or you may go on to install the operating system kernel and the modules.");
 		bufN = _("Install Kernel and Driver Modules");
 		if (fdisk_disks != NULL) {
 			alternate_action  = init_linux;
@@ -502,6 +523,11 @@
 		/*
 		 * The modules have not been configured.
 		 */
+		if (bootargs.batch && !pciDetectDone) {
+		   configure_drivers();
+		   pciDetectDone=1;
+		   goto done_keyboard;
+		}
 		next_action              = configure_drivers;
 		bufN = _("Configure Device Driver Modules");
 #if !(#cpu(alpha) || #cpu(m68k) || #cpu(hppa) || #cpu(s390) || #cpu(mips) || #cpu(mipsel))
@@ -548,6 +574,10 @@
 		/*
 		 * The network has not been configured and made active.
 		 */
+		if (bootargs.batch) {
+		  configure_network();
+		  goto done_keyboard;
+		}
 		next_action      = configure_network;
 		if (is_network_up(0))
 		    bufT = _("Your network is active, but it has not been configured for the system to remember.  If your system is configuring itself via hardware (i.e., your system can setup its network before Linux boots through DHCP or BOOTP), you should still setup the configuration so that the network can be brought up and down after booting.  If you configured the network yourself, then you also need to perform this step.");
@@ -583,6 +613,10 @@
 		/*
 		 * The base system has not been installed.
 		 */
+		if (!failedBaseInstall && bootargs.batch) {
+		   main_menu_extract_base();
+		   continue;
+		}
 		next_action = main_menu_extract_base;
 		if (failedBaseInstall) {
 			bufT = _("The previous attempt to install the base system failed. Please select \"Next\" to retry installation of the base system.");
@@ -602,6 +636,12 @@
 		 && (strcmp(Arch2, "Mac") != 0)
 #endif
 		) {
+		/* If the user did autopartitioning (does not care about HD boot setup) then simply use defaults */
+		if (bootargs.batch || autoPartitionDone) {
+		  make_bootable();
+		  reboot_system();
+		  goto done_keyboard;
+		}
 		/*
 		 * Reboot, chroot, or create a boot floppy.
 		 */
@@ -721,7 +761,7 @@
 	    items++;
 	}

-	rs = menuBox (bufT, _("Debian GNU/Linux Installation Main Menu"), choices, items, 0);
+	rs = menuBox (bufT, _("TelemetryBox/Linux Installation Main Menu"), choices, items, 0);
 	data = ilist[rs];

 #ifndef _TESTING_
@@ -735,6 +775,7 @@
 	    case OPT_CONFIGURE_KEY:    configure_keyboard_m(); break;
 	    case OPT_LOAD_MODULES_FROM_A_FD_AFTER_BOOT: load_modules_after_boot(); break;
 	    case OPT_PARTITION_DISK:   partition_disk(); break;
+	    case OPT_BATCH_INSTALL:   batch_install();break;
 	    case OPT_INITIALIZE_SWAP:  init_swap(); break;
 	    case OPT_ACTIVATE_SWAP:    activate_swap(); break;
 	    case OPT_DO_WITHOUT_SWAP:  no_swap(); break;
Index: utilities/dbootstrap/net-fetch.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/net-fetch.c,v
retrieving revision 1.50
diff -u -r1.50 net-fetch.c
--- utilities/dbootstrap/net-fetch.c	2001/10/16 05:42:58	1.50
+++ utilities/dbootstrap/net-fetch.c	2001/10/23 23:11:20
@@ -339,11 +339,11 @@

   // http://http.us.debian.org/debian/dists/potato/main/disks-$arch/current/
   nf_state.method = strdup("http");
-  nf_state.server.hostname = strdup("http.us.debian.org");
+  nf_state.server.hostname = strdup("ftp.telemetrybox.org");
   nf_state.server.port = 80;
   nf_state.proxy.hostname = strdup("none");
   nf_state.proxy.port = 8080;
-  snprintf(prtbuf, sizeof(prtbuf) - 1, "debian/" ARCHIVE_LOCATION "/", ARCHNAME);
+  snprintf(prtbuf, sizeof(prtbuf) - 1, "tbox/local/" ARCHNAME);
   nf_state.path = strdup(prtbuf);

 #if defined (_TESTING_)
Index: utilities/dbootstrap/netconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/netconfig.c,v
retrieving revision 1.66
diff -u -r1.66 netconfig.c
--- utilities/dbootstrap/netconfig.c	2001/10/20 19:40:08	1.66
+++ utilities/dbootstrap/netconfig.c	2001/10/23 23:11:21
@@ -272,12 +272,12 @@
     if(host)
       def = host;
     else
       def = strdup("debian");

     snprintf(prtbuf, PRTBUFSIZE,
              _("Every Debian system has a name - even if it is not on a network. This name is called its \"hostname\". You should now specify a hostname for your new system.\n\nIf your system is going to be on a network, you should talk to the administrator of the network before you choose a hostname. If not, you may choose any name you like.\n\nThe hostname must not contain dots or underscores, and you must not append the domain name here.\n\nIf you can't think of a hostname for your new system, you may press <ENTER> to use the default hostname of \"%s\".\nPlease enter your Host name"), def);

-    host = inputBox(prtbuf, _("Choose the Host name"), def);
+    if (bootargs.batch) host = strdup(def); host = inputBox(prtbuf, _("Choose the Host name"), def);
     free(def);
     def = NULL;

@@ -984,7 +984,7 @@
     snprintf(prtbuf, PRTBUFSIZE,
 	     _("Configuration for %s (%s)\n\nDo you want to use DHCP or BOOTP to automatically configure this interface? You'll need a DHCP or BOOTP server in the local network for this to work."),
 	     netinterface, get_ifdsc(netinterface));
-    if (yesNoBox(prtbuf, _("Automatic Network Configuration")) == DLG_NO) {
+    if (!bootargs.batch && yesNoBox(prtbuf, _("Automatic Network Configuration")) == DLG_NO) {
       ret = configure_static_network();
     } else {
       pleaseWaitBox(_("Trying to get network configuration using DHCP/BOOTP...\n\nThis may take a few minutes, be patient."));
Index: utilities/dbootstrap/partition_config.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/partition_config.c,v
retrieving revision 1.109
diff -u -r1.109 partition_config.c
--- utilities/dbootstrap/partition_config.c	2001/10/23 19:57:59	1.109
+++ utilities/dbootstrap/partition_config.c	2001/10/23 23:11:25
@@ -137,7 +137,7 @@
     disk = disk->next;
   }
   /* #### FixMe: ID CD's. */
-  rs = menuBox(_("Select the drive to partition. SCSI drives are listed in disk ID number order. Only drives that were connected and operating when the system was started will show up in this display. CD-ROM drives may be mis-identified as writable disk drives by this menu."),
+  rs = (items ==1) ? 0 : menuBox(_("Select the drive to partition. SCSI drives are listed in disk ID number order. Only drives that were connected and operating when the system was started will show up in this display. CD-ROM drives may be mis-identified as writable disk drives by this menu."),
 	       _("Select Disk Drive"), choices, items, 1);
   if (rs != -1)
     disk = dlist[rs];
@@ -228,6 +228,9 @@
     }
     free (swaps);
   }
+  if (bootargs.batch) {
+     myfdisk="/sbin/cfdisk";
+  } else
   if (NAME_ISEXE("/sbin/parted", &statbuf)) { /* check whether we have parted */
     if(twoButtonBox( _("This set of boot floppies has various programs for partitioning "
 		       "of the harddisk. However, to partition with other programs than "
@@ -253,6 +256,46 @@
      myfdisk="/sbin/cfdisk";
   }

+ /* prompt for autopartitioning */
+  if (bootargs.batch || yesNoBox(
+       _("Autopartitioning will setup a default partition scheme on your harddisk and format all necessary partitions without any user interaction.\n\nALL EXISTING FILES WILL BE LOST\n\nIf you do not choose autopartitioning then you will be prompted for partitioning and formatting.\nDo you want to autopartition?"),
+       _("Autopartitioning?")))
+  {
+    char *dname=strdup(d->name);
+    char *boot,*swap,*root;
+    extern int autoPartitionDone;
+      /* invoke fdisk with specific arguments */
+     boxSuspend();
+     printf(CLEAR);
+#define FORMAT_STRING "d\n1\nd\n2\nd\n3\nd\n4\nn\np\n1\n\n+20M\na\n1\nn\np\n2\n\n+200M\nt\n2\n82\nn\np\n3\n\n\nw\n"
+     sprintf(prtbuf,"echo '%s' | fdisk %s >/dev/null 2>&1",FORMAT_STRING,dname);
+     status=system(prtbuf);
+     fdisk_reread();
+     d=fdisk_find_disk(dname);
+     if (d==NULL)
+      { problemBox("Owww... Cannot find disk after fdisk run",_("Weirdness"));
+        exit(1);
+      }
+      boot=part_name(d,1);
+      swap=part_name(d,2);
+      root=part_name(d,3);
+      /* format swap */
+      sprintf(prtbuf,"mkswap %s",swap);status=system(prtbuf);
+      /* Activate swap */
+      swapon(swap,0);
+      /* format ext3 partitions */
+      sprintf(prtbuf,"mkfs.ext2 -j %s",root);status=system(prtbuf);
+      sprintf(prtbuf,"mount -t ext3 %s /target",root);status=system(prtbuf);
+      Root=fdisk_find_partition_by_name(root);
+      check_pending_config();
+      status=system("mkdir /target/boot");
+      sprintf(prtbuf,"mkfs.ext2 -j %s",boot);status=system(prtbuf);
+      sprintf(prtbuf,"mount -t ext3 %s /target/boot",boot);status=system(prtbuf);
+      autoPartitionDone=1;
+      boxResume();
+      return 0;
+  }
+
 #if #cpu(i386)
   if (! bootargs.isquiet)
     wideMessageBox(_(
Index: utilities/dbootstrap/select_not_mounted.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/select_not_mounted.c,v
retrieving revision 1.17
diff -u -r1.17 select_not_mounted.c
--- utilities/dbootstrap/select_not_mounted.c	2001/06/09 09:41:28	1.17
+++ utilities/dbootstrap/select_not_mounted.c	2001/10/23 23:11:25
@@ -105,7 +105,7 @@
 			problemBox(_("No partitions that had not already been mounted were detected."),_("Problem"));
 		}
 	} else {
-		rs = menuBox(message, title, choices, items, 1);
+		rs = items ==1 ? 0 : menuBox(message, title, choices, items, 1);
 		if (rs != -1) {
 			p = plist[rs];
 #ifdef NFSROOT
Index: utilities/dbootstrap/util.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/util.c,v
retrieving revision 1.56
diff -u -r1.56 util.c
--- utilities/dbootstrap/util.c	2001/09/11 01:28:54	1.56
+++ utilities/dbootstrap/util.c	2001/10/23 23:11:27
@@ -664,6 +664,12 @@
     write_userconfig("DEBUG", "true");
   if ( bootargs.cdrom )
     write_userconfig("CDROM", "true");
+  if (bootargs.install)
+    write_userconfig("INSTALL",bootargs.install);
+  if (bootargs.copycd)
+    write_userconfig("COPYCD","true");
+  if (bootargs.batch)
+    write_userconfig("BATCH","true");

 #ifdef USE_LANGUAGE_CHOOSER
   if ( lang != NULL )
Index: utilities/libfdisk/fdisk.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/libfdisk/fdisk.c,v
retrieving revision 1.66
diff -u -r1.66 fdisk.c
--- utilities/libfdisk/fdisk.c	2001/09/10 12:39:11	1.66
+++ utilities/libfdisk/fdisk.c	2001/10/23 23:11:29
@@ -600,7 +600,7 @@


 /* part_name: return partition device name from disk and partition number */
-static char *part_name(struct fdisk_disk *disk, unsigned int part)
+char *part_name(struct fdisk_disk *disk, unsigned int part)
 {
     FILE *f;
     char *pname = NULL, *dname = disk->name + 5;
Index: utilities/libfdisk/fdisk.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/libfdisk/fdisk.h,v
retrieving revision 1.28
diff -u -r1.28 fdisk.h
--- utilities/libfdisk/fdisk.h	2001/09/10 12:39:12	1.28
+++ utilities/libfdisk/fdisk.h	2001/10/23 23:11:30
@@ -79,6 +79,8 @@
 int
 fdisk_fstype_of(unsigned int ptype);

+char *part_name(struct fdisk_disk *disk, unsigned int part);
+
 char *
 fdisk_fstype_name_of(unsigned int ptype);




Reply to: