build: Create a home partition image
u-boot's fastboot implementation is unfortunately stupid enough that we can't
simply use "fastboot format:ext4" to create the filesystem for the home
partition.
Instead, we create the partition using Mendel's build system and use img2simg to
create a super tiny sparse image.
Change-Id: If53562b0aab6e448715dc02b128c6abeb158593a
diff --git a/Makefile b/Makefile
index f53324f..84c3019 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@
@mkdir -p $(PRODUCT_OUT)/obj
@mkdir -p $(ROOTDIR)/cache
-all: rootfs bootloader partition-table
+all: rootfs home bootloader partition-table
lintian: packages
lintian $(PRODUCT_OUT)/packages/core/*.deb $(PRODUCT_OUT)/packages/bsp/*.deb
@@ -46,6 +46,7 @@
include $(ROOTDIR)/build/img2simg.mk
include $(ROOTDIR)/build/busybox.mk
include $(ROOTDIR)/build/prereqs.mk
+include $(ROOTDIR)/build/home.mk
include $(ROOTDIR)/build/rootfs.mk
include $(ROOTDIR)/build/docker.mk
include $(ROOTDIR)/build/packages.mk
diff --git a/home.mk b/home.mk
new file mode 100644
index 0000000..c75e542
--- /dev/null
+++ b/home.mk
@@ -0,0 +1,50 @@
+# Copyright 2019 Google LLC
+#
+# 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
+#
+# https://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.
+
+ifeq ($(ROOTDIR),)
+$(error $$ROOTDIR IS NOT DEFINED -- don\'t forget to source setup.sh)
+endif
+
+include $(ROOTDIR)/build/preamble.mk
+
+HOME_DIR := $(PRODUCT_OUT)/obj/HOME
+HOME_RAW_IMG := $(PRODUCT_OUT)/obj/HOME/home.raw.img
+HOME_IMG := $(PRODUCT_OUT)/home.img
+
+$(HOME_DIR):
+ mkdir -p $(HOME_DIR)
+
+home: $(HOME_IMG)
+ $(LOG) home finished
+
+home_raw: $(HOME_RAW_IMG)
+
+$(HOME_RAW_IMG): $(HOME_DIR)
+ $(LOG) home raw-build
+ fallocate -l $(HOME_SIZE_MB)M $(HOME_RAW_IMG)
+ mkfs.ext4 -F -j $(HOME_RAW_IMG)
+ $(LOG) home raw-build finished
+
+$(HOME_IMG): $(HOST_OUT)/bin/img2simg $(HOME_RAW_IMG)
+ $(LOG) home img2simg
+ $(HOST_OUT)/bin/img2simg $(HOME_RAW_IMG) $(HOME_IMG)
+ $(LOG) rootfs img2simg finished
+
+clean::
+ rm -rf $(HOME_RAW_IMG) $(HOME_IMG) $(HOME_DIR)
+
+targets::
+ @echo "home - creates the home partition image"
+
+.PHONY:: home home_raw