vbox: add a ready-to-boot android_disk_vdi target

Change-Id: I517d2cf9b324caeee7c15d28eb1e9bf3083a3bc2
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
diff --git a/android_img_layout.conf b/android_img_layout.conf
new file mode 100644
index 0000000..0b81d83
--- /dev/null
+++ b/android_img_layout.conf
@@ -0,0 +1,62 @@
+device {
+    scheme mbr
+
+    # bytes in a disk "block", must be a power of 2!
+    sector_size 512
+
+    # What LBA should the partitions start at?
+    start_lba 2048
+
+    # Autodetect disk size if == 0
+    num_lba 800000
+
+    partitions {
+        # /dev/sdX1
+        sysloader {
+            active y
+            type linux
+            # 8 cyls in length... about 8M
+            len 8064
+        }
+
+        # /dev/sdX2
+        recovery {
+            active y
+            type linux
+            # 8 cyls in length... about 8M
+            len 8064
+        }
+
+        # /dev/sdX3
+        inst_boot {
+            active y
+            type linux
+        }
+
+        # /dev/sdX4
+        # (extended partion begins)
+
+        # /dev/sdX5
+        third_party {
+            type linux
+            len 8064
+        }
+
+        # /dev/sdX6
+        inst_system {
+            type linux
+        }
+
+        # /dev/sdX7
+        inst_data {
+            type linux
+        }
+
+        # /dev/sdX7
+        cache {
+            type linux
+            len 8064
+        }
+
+    }
+}
diff --git a/config.mk b/config.mk
index 6398b27..1a697e6 100644
--- a/config.mk
+++ b/config.mk
@@ -188,12 +188,31 @@
 					$(installer_layout)
 	@echo "Creating bootable installer image: $@"
 	@rm -f $@
-	@cat $(grub_bin) > $@
-	@$(edit_mbr) -l $(installer_layout) -i $@ \
+	$(hide) cat $(grub_bin) > $@
+	$(hide) $(edit_mbr) -l $(installer_layout) -i $@ \
 		inst_boot=$(installer_tmp_img) \
 		inst_data=$(installer_data_img)
 	@echo "Done with bootable installer image -[ $@ ]-"
 
+# Ditto for the android_disk image
+INSTALLED_ANDROIDIMAGE_TARGET := $(PRODUCT_OUT)/android_disk.img
+android_layout := $(diskinstaller_root)/android_img_layout.conf
+$(INSTALLED_ANDROIDIMAGE_TARGET): \
+					$(INSTALLED_SYSTEMIMAGE) \
+					$(INSTALLED_USERDATAIMAGE_TARGET) \
+					$(INSTALLED_BOOTIMAGE_TARGET) \
+					$(grub_bin) \
+					$(edit_mbr) \
+					$(android_layout)
+	@echo "Creating bootable android disk image: $@"
+	@rm -f $@
+	$(hide) cat $(grub_bin) > $@
+	$(hide) $(edit_mbr) -l $(android_layout) -i $@ \
+		inst_boot=$(INSTALLED_BOOTIMAGE_TARGET) \
+		inst_system=$(INSTALLED_SYSTEMIMAGE) \
+		inst_data=$(INSTALLED_USERDATAIMAGE_TARGET)
+	@echo "Done with bootable android disk image -[ $@ ]-"
+
 
 ######################################################################
 # now convert the installer_img (disk image) to a VirtualBox image
@@ -204,17 +223,32 @@
 
 $(INSTALLED_VBOXINSTALLERIMAGE_TARGET): $(INSTALLED_DISKINSTALLERIMAGE_TARGET)
 	@rm -f $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
-	@$(virtual_box_manager) $(virtual_box_manager_options) $(INSTALLED_DISKINSTALLERIMAGE_TARGET) $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
+	$(hide) $(virtual_box_manager) $(virtual_box_manager_options) $(INSTALLED_DISKINSTALLERIMAGE_TARGET) $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
 	@echo "Done with VirtualBox bootable installer image -[ $@ ]-"
 
-else  # ! TARGET_USE_DISKINSTALLER
-INSTALLED_DISKINSTALLERIMAGE_TARGET :=
-INSTALLED_VBOXINSTALLERIMAGE_TARGET :=
-endif
-endif # TARGET_ARCH == x86
+# Ditto for the android_disk image
+INSTALLED_VBOXDISKIMAGE_TARGET := $(PRODUCT_OUT)/android_disk.vdi
+$(INSTALLED_VBOXDISKIMAGE_TARGET): $(INSTALLED_ANDROIDIMAGE_TARGET)
+	@rm -f $(INSTALLED_VBOXDISKIMAGE_TARGET)
+	$(hide) $(virtual_box_manager) $(virtual_box_manager_options) $(INSTALLED_ANDROIDIMAGE_TARGET) $(INSTALLED_VBOXDISKIMAGE_TARGET)
+	@echo "Done with VirtualBox bootable disk image -[ $@ ]-"
+
 
 .PHONY: installer_img
 installer_img: $(INSTALLED_DISKINSTALLERIMAGE_TARGET)
 
 .PHONY: installer_vdi
 installer_vdi: $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
+
+.PHONY: android_disk_img
+android_disk_img: $(INSTALLED_ANDROIDIMAGE_TARGET)
+
+.PHONY: android_disk_vdi
+android_disk_vdi: $(INSTALLED_VBOXDISKIMAGE_TARGET)
+
+
+else  # ! TARGET_USE_DISKINSTALLER
+INSTALLED_DISKINSTALLERIMAGE_TARGET :=
+INSTALLED_VBOXINSTALLERIMAGE_TARGET :=
+endif
+endif # TARGET_ARCH == x86