4280 AI tries to open nonexistent /.cdrom/.image_info file
authorJan Damborsky <jan.damborsky@sun.com>
Wed, 17 Dec 2008 09:08:04 +0100
changeset 389 f9a7dbcea5b5
parent 388 078beaed6ea6
child 390 0f08a15005d5
4280 AI tries to open nonexistent /.cdrom/.image_info file
usr/src/lib/liborchestrator/orchestrator_private.h
usr/src/lib/liborchestrator/perform_slim_install.c
--- a/usr/src/lib/liborchestrator/orchestrator_private.h	Tue Dec 16 14:52:16 2008 -0700
+++ b/usr/src/lib/liborchestrator/orchestrator_private.h	Wed Dec 17 09:08:04 2008 +0100
@@ -177,6 +177,9 @@
 #define	IMAGE_INFO_COMPRESSION_TYPE	"COMPRESSION_TYPE"
 #define	IMAGE_INFO_LINE_MAXLN		1000
 
+/* If following file exists, we are in Automated Installer environment */
+#define	AUTOMATED_INSTALLER_MARK	"/.autoinstall"
+
 /*
  * Debugging levels
  */
--- a/usr/src/lib/liborchestrator/perform_slim_install.c	Tue Dec 16 14:52:16 2008 -0700
+++ b/usr/src/lib/liborchestrator/perform_slim_install.c	Wed Dec 17 09:08:04 2008 +0100
@@ -186,6 +186,7 @@
 static uint32_t	get_mem_size(void);
 static uint64_t	calc_swap_size(uint64_t available_swap_space);
 static uint64_t	calc_dump_size(uint64_t available_dump_space);
+static boolean_t	is_automated_installation(void);
 
 void 		*do_transfer(void *arg);
 void		*do_ti(void *args);
@@ -1586,9 +1587,12 @@
 {
 	/*
 	 * Size in MB that is the minimum device size we will allow
-	 * for installing Slim.
+	 * for installing.
 	 *
 	 * Get uncompressed size of image and add 20% reserve.
+	 * For Slim installer, information about size of bits to be installed
+	 * is generated by Distro Constructor and stored in /.image_info file.
+	 * In this case, we just parse that file and load required data.
 	 *
 	 * If system has not enough physical memory for installation,
 	 * swap is required and minimum size will account for it.
@@ -1598,12 +1602,21 @@
 	 *
 	 * Dump is always optional.
 	 *
-	 * If information about image size is not available,
-	 * default is used (4GiB).
+	 * If information about image size is not available, default
+	 * is used (4GiB).
+	 * This is the case of Automated Installation, as the size needs to be
+	 * dynamically calculated, since list of packages to be installed is
+	 * provided in AI manifest and thus can be customized.
+	 * Until there is a mechanism which would dynamically calculate total
+	 * size of packages to be installed, we keep image_size set to the
+	 * default value for now (4GiB). Initialization of image_info variable
+	 * is part of its definition.
 	 */
 
-	if (obtain_image_info(&image_info) != OM_SUCCESS)
-		om_log_print("Couldn't read image info file\n");
+	if (!is_automated_installation()) {
+		if (obtain_image_info(&image_info) != OM_SUCCESS)
+			om_log_print("Couldn't read image info file\n");
+	}
 
 	return ((uint64_t)(image_info.image_size *
 	    image_info.compress_ratio * 1.2) + calc_required_swap_size());
@@ -2804,3 +2817,18 @@
 	return ((om_get_min_size(NULL, NULL) - calc_required_swap_size()) * 2 +
 	    2048);
 }
+
+
+/*
+ * Check if we are running within Automated Installer environment
+ *
+ * Return:	B_TRUE - yes, this is Automated Installation
+ *		B_FALSE - other type of installation is running
+ * Notes:
+ */
+
+static boolean_t
+is_automated_installation(void)
+{
+	return (access(AUTOMATED_INSTALLER_MARK, F_OK) == 0 ? B_TRUE : B_FALSE);
+}