brillo: Add uefi target provisioning.

Create provision-device script to create disk image located in the
ANDROID_PRODUCT_OUT directory.

BUG= 29123391
TEST= Run 'provision' command and check image manually (gnome-disks).

Change-Id: I0831140d5c6630120b42bdd2eb31d719d576fd05
diff --git a/brillo_uefi_x86_64/BoardConfig.mk b/brillo_uefi_x86_64/BoardConfig.mk
index 7844334..e552c39 100644
--- a/brillo_uefi_x86_64/BoardConfig.mk
+++ b/brillo_uefi_x86_64/BoardConfig.mk
@@ -14,7 +14,8 @@
 # limitations under the License.
 #
 
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000
+# 512 MiB - keep in sync with brillo_partitions.bpt
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 536870912
 # No ramdisk.
 BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
@@ -34,3 +35,4 @@
 
 PRODUCT_COPY_FILES += \
     device/generic/brillo/brillo_uefi_x86_64/fstab.brillo_uefi_x86_64:root/fstab.brillo_uefi_x86_64 \
+    device/generic/brillo/brillo_uefi_x86_64/provision-device:provision-device
diff --git a/brillo_uefi_x86_64/provision-device b/brillo_uefi_x86_64/provision-device
new file mode 100755
index 0000000..cfd9ab4
--- /dev/null
+++ b/brillo_uefi_x86_64/provision-device
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+OS=${ANDROID_PROVISION_OS_PARTITIONS:-${ANDROID_PRODUCT_OUT}}
+
+# TODO: Add --image parameters for EFI and misc partitions.
+bpttool make_disk_image \
+        --output ${OS}/full-disk-image.img \
+        --input ${OS}/partition-table.bpt \
+        --image boot_a:${OS}/boot.img \
+        --image boot_b:${OS}/boot.img \
+        --image system_a:${OS}/system.img \
+        --image system_b:${OS}/system.img \
+        --image userdata:${OS}/userdata.img \
+        --allow_empty_partitions
+
+# Need EFI.img combined into full-disk-image.img to use it as a boot partition
+# and to test this command.
+if [ $? -eq 0 ]
+then
+  echo "UEFI-compatible disk image created. 'full-disk-image.img' located in" \
+       "directory"
+  echo "${OS}."
+  echo "Boot this image using QEMU:"
+  echo "(e.g. '\$ qemu-system-x86_64 -enable-kvm -bios OVMF.fd" \
+       "${OS}/full-disk-image.img). "
+  echo "To obtain OVMF binary see http://www.tianocore.org/ovmf/"
+fi
\ No newline at end of file