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

Re: boot-floppies auto partitioning & hardware detection



Hi Christophe,

Thanks for the patch.  I've gone through and made a few little changes that I'd
like you to ok.  Once you are happy, I'm happy, and it would be great if you
just commit this to cvs.

Changes/Notes/Todo/Etc.

1. the libfdisk and the select_not_mounted.c change were more or less
standalone so I just committed them so we'd have less to talk about.

2. Size : I did some size reductions yesterday in preparation for this patch.
Taking into account the size reduction and this patch we are just 300 bytes,
uncompressed, bigger.  FYI.

3.  I changed the hardware detect in baseconfig.c since I figured people might
still want to run modconf even if they did pci autodetection.

4. I reworked the choose_medium.c patch so now we verify that it is the right
cdrom. (see choose_medium.c and util.[ch]).  I don't have a cdrom to test with, and 
I'm not sure if that is the right way to test . . . 

5. in extract_base.c I added a boxPopWindow(), plus I noticed copycd doesn't
make sense if we just did a net install.  The way I worked around that might
not be perfect,  perhaps you have a better idea?

6. partition_config.c I return status so we can detect errors. I changed a message.

7. pcidetect needs to be added to the root filesystem, presumably
rootdisk.sh needs to add it, I don't remember seeing that in the
patch.

8. I removed references to 'telemetry'.

Appendix 1 : I was going to commit it myself, and started writing up this log entry,
feel free to use it when you commit:

baseconfig.c : automatically load drivers specified by a boot argument, do pci
driver auto-detection.

bootconfig.c : If we have autopartitioned or are in batch mode then pick
defaults for the boot partition as well as location of lilo install.  NOTE:
This is i386 specific, if you want auto partitioning, and boot configuration
you should make similar changes for your arch.

choose_medium.c : If a cd 1 is already in the drive then do not prompt for one.

dbootstrap.h : 4 new boot arguments 
  batch   : fully unattended installation
  copycd  : copy cd contents to /target 
  drivers : load a list of whitespace
            delimited drivers 
  install : task/package. Bypass tasksel stage

extract_base.c : when appropriate copy the contents of the cd onto /target.
This allows us to remove a bootable CD once for the reboot and not need to
insert it again.

main.c : Add install, drivers, batch and copycd bootargs.  Don't prompt for
language or show release notes if isquiet or batch boot arguments were
specified.

netconfig.c : If we are doing a batch install set hostname to default
("debian") and configure network with dhcp.

partition_config.c : If there is only one drive, assume that is the drive we
want to partition.  FIXME: do we like this?
Ask the user if they want to auto partition the drive.  If so then take the first 
drive and divide it into 3 partitions boot 20M, swap 200M and root (rest of space).

util.c : write_userconfig() some of the new boot arguments (install, batch and
copycd) add new function get_debian_cd_num() that gets the number of a Debian cd.

main_menu.c : support batch install option


Appendix 2 :  Diff against current cvs that includes my changes.

Index: debian/changelog
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/debian/changelog,v
retrieving revision 1.739
diff -u -r1.739 changelog
--- debian/changelog	2001/10/24 18:43:52	1.739
+++ debian/changelog	2001/10/24 22:04:58
@@ -24,10 +24,14 @@
       conditionalize things properly
     - es.po update thanks to Carlos Barros <cbf@fisica.edu.uy>
   *  Christoph Lameter <christoph@lameter.com>
-    - (applied and tweaked by David Kimdon)
     - unstatic libfdisk's part_name() for auto-partitioner
     - when user wants to select an unmounted partition and there is only
       one partition to choose from, don't prompt, just select it.
+    - add new boot arguments (batch, copycd, drivers, install)
+    - pci autodetection, automatic driver loading
+    - support batch install
+    - ask fewer questions when we can figure it out on our own
+    - allow for simple automatic partitioning
   * Guido Guenther (in 3.0.15, changelog entries accidentally removed)
     - dbootstrap: let dvhtool find the mips kernel again
     - documentation/defaults.ent: fix pathnames for mips(el)
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/24 22:05:08
@@ -516,6 +516,8 @@
 
 int configure_drivers (void) {
   struct stat statbuf;
+  int do_manual_config = 1;
+  extern int pciDetectDone;
 
   if (! NAME_ISEXE("/usr/bin/whiptail", &statbuf))
       symlink("/target/usr/bin/whiptail", "/usr/bin/whiptail");
@@ -540,7 +542,30 @@
 
   execlog("depmod -a", LOG_INFO);
 
-  fullscreen_execlog("/target/usr/sbin/modconf"
+  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);
+  }
+
+  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"))) {
+     execlog("pcidetect -m -v",LOG_INFO);
+     execlog("pcidetect >>/target/etc/modules",LOG_INFO);
+     pciDetectDone=1;
+  } 
+  
+  if ( pciDetectDone && (! bootargs.batch) )
+      if ( yesNoBox( _("Some hardware (ex. ISA) cannot be automatically detected and you will need to manually configure it. \nManually configure hardware?"),_("Manual Config")) == 0)
+       {
+	   do_manual_config == 0;
+       }
+
+  if (do_manual_config)
+      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/24 22:05:22
@@ -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,15 @@
 	  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 ))
-	      return 0;
       
+      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/24 22:05:29
@@ -740,16 +740,23 @@
 
     umount(CM_MOUNTPOINT_DIR);
 
-    problemBox(_("Please place the first Debian CD-ROM in the CD-ROM drive."),
-	       _("Please insert the CD-ROM"));
+    /* If we booted off a cdrom image, check to see if we can mount it
+       and verify that it is CD 1. */
+    if (    (!is_cdrom_image()) ||
+	    execlog("mount -t iso9660 -o nojoliet -r /dev/cdrom " CM_MOUNTPOINT_DIR, LOG_INFO) ||
+	    (get_debian_cd_num (CM_MOUNTPOINT_DIR) != 1)) {
 
-    if (execlog("mount -t iso9660 -o nojoliet -r /dev/cdrom " CM_MOUNTPOINT_DIR, LOG_INFO)) {
-	problemBox(_("The CD-ROM was not mounted successfully."), _("Mount Failed"));
-	/* db_errno = DB_CANNOT_MOUNT or something */
-	status = -1;		/* #### DB_EXIT_ERROR */
-	goto cleanup_and_exit;
+	umount(CM_MOUNTPOINT_DIR);
+	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)) {
+    	    problemBox(_("The CD-ROM was not mounted successfully."), _("Mount Failed"));
+    	    /* db_errno = DB_CANNOT_MOUNT or something */
+    	    status = -1;		/* #### DB_EXIT_ERROR */
+    	    goto cleanup_and_exit;
+	}
     }
-
 
     if ((status = choose_archive_dir(
 		    _("Please choose the path inside the CD-ROM where "
Index: utilities/dbootstrap/dbootstrap.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/dbootstrap.h,v
retrieving revision 1.92
diff -u -r1.92 dbootstrap.h
--- utilities/dbootstrap/dbootstrap.h	2001/10/24 07:35:47	1.92
+++ utilities/dbootstrap/dbootstrap.h	2001/10/24 22:05:31
@@ -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/24 22:05:33
@@ -434,6 +434,13 @@
   execlog(prtbuf, LOG_INFO);
   
   configure_base () ;
+  if ( bootargs.copycd &&
+       strstr ("file:", source )) {
+      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);
+      boxPopWindow();
+  }
   
   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/24 22:05:36
@@ -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 */
@@ -833,10 +838,11 @@
 #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.79
diff -u -r1.79 main_menu.c
--- utilities/dbootstrap/main_menu.c	2001/10/24 01:52:49	1.79
+++ utilities/dbootstrap/main_menu.c	2001/10/24 22:05:41
@@ -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");
 #ifdef PCMCIA
@@ -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.
 		 */
@@ -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/netconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/netconfig.c,v
retrieving revision 1.67
diff -u -r1.67 netconfig.c
--- utilities/dbootstrap/netconfig.c	2001/10/24 01:52:49	1.67
+++ utilities/dbootstrap/netconfig.c	2001/10/24 22:05:46
@@ -277,6 +277,9 @@
     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);
 
+    if (bootargs.batch) 
+      host = strdup(def); 
+    
     host = inputBox(prtbuf, _("Choose the Host name"), def);
     free(def);
     def = NULL;
@@ -994,7 +997,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/24 22:05:53
@@ -137,8 +137,8 @@
     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."),
-	       _("Select Disk Drive"), choices, items, 1);
+  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];
   else
@@ -228,7 +228,8 @@
     }
     free (swaps);
   }
-  if (NAME_ISEXE("/sbin/parted", &statbuf)) { /* check whether we have parted */
+ 
+  if (!bootargs.batch && 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 "
 		       "cfdisk (default) is dangerous, you should not try them if you are "
@@ -251,6 +252,46 @@
   }
   else { /* no parted present, use default cfdisk */
      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(_("Cannot find disk after fdisk run"),_("Error"));
+        return 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 status;
   }
 
 #if #cpu(i386)
Index: utilities/dbootstrap/util.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/util.c,v
retrieving revision 1.57
diff -u -r1.57 util.c
--- utilities/dbootstrap/util.c	2001/10/24 01:52:49	1.57
+++ utilities/dbootstrap/util.c	2001/10/24 22:05:58
@@ -616,6 +616,29 @@
 }
 
 int
+get_debian_cd_num(char *mount_point) {
+    FILE *fp = NULL;
+    int cd_num = -1;
+    char *ptr;
+    char buf[BUFSIZ];
+    
+    snprintf (buf, sizeof buf, "%s/.disk/info", mount_point);
+    
+    if ( (fp = fopen(buf, "r")) &&
+	    fgets (buf, sizeof buf, fp) &&
+	    (ptr = strstr(buf, "Binary-"))) {
+	ptr += 7; /* strlen ("Binary-");*/
+	cd_num = atoi (ptr);
+    }
+    
+    if (fp)
+	fclose (fp);
+    
+    return cd_num;
+}
+
+
+int
 check_pending_config(void)
 {
   const char *path;
@@ -664,6 +687,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/dbootstrap/util.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/util.h,v
retrieving revision 1.23
diff -u -r1.23 util.h
--- utilities/dbootstrap/util.h	2001/10/24 01:52:49	1.23
+++ utilities/dbootstrap/util.h	2001/10/24 22:06:00
@@ -173,6 +173,19 @@
  */
 extern int is_cdrom_image(void);
 
+/*
+   Get the CD number of the CD mounted at path.
+   We look for a file .disk/info containing a string like:
+   
+   Debian GNU/Linux 1.0  "$CODENAME" - Official i386 Binary-1 (20011024)
+   
+   and pull off the number after 'Binary-'.
+   
+   if an error occors return -1, otherwise return
+   the number of the CD.
+*/
+int get_debian_cd_num(char *mount_point);
+
 /* Is the partition on an NFS mountpoint? */
 int is_nfs_partition(const char *);
 



Reply to: