Multistrap w/ Mendel packages installed
Change-Id: I8a9d006e7ec51bffd4099b0a9bd1e74a1d137b89
diff --git a/Makefile b/Makefile
index dadc731..845e14b 100644
--- a/Makefile
+++ b/Makefile
@@ -45,8 +45,8 @@
include $(ROOTDIR)/build/rootfs.mk
include $(ROOTDIR)/build/docker.mk
include $(ROOTDIR)/build/packages.mk
+include $(ROOTDIR)/build/multistrap.mk
-
include $(ROOTDIR)/board/bootloader.mk
-include $(ROOTDIR)/board/sdcard.mk
-include $(ROOTDIR)/board/recovery.mk
diff --git a/multistrap.mk b/multistrap.mk
new file mode 100644
index 0000000..ab4cfb7
--- /dev/null
+++ b/multistrap.mk
@@ -0,0 +1,58 @@
+# Copyright 2018 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
+include $(ROOTDIR)/build/rootfs-packages.mk
+
+MULTISTRAP_WORK_DIR := $(PRODUCT_OUT)/multistrap/work
+
+multistrap: $(PRODUCT_OUT)/multistrap/rootfs.img $(PRODUCT_OUT)/multistrap/boot.img
+
+$(PRODUCT_OUT)/multistrap/rootfs.img: $(PRODUCT_OUT)/multistrap/boot.img $(HOST_OUT)/bin/img2simg
+ fallocate -l $(ROOTFS_SIZE_MB)M $@.wip
+ mkfs.ext4 -F -j $@.wip
+ mkfs.ext2 -F $(PRODUCT_OUT)/multistrap/boot.img
+ tune2fs -o discard $@.wip
+ mkdir -p $(MULTISTRAP_WORK_DIR)
+
+ sudo mount -o loop $@.wip $(MULTISTRAP_WORK_DIR)
+ sudo mkdir -p $(MULTISTRAP_WORK_DIR)/boot $(MULTISTRAP_WORK_DIR)/dev
+ sudo mount -o loop $(PRODUCT_OUT)/multistrap/boot.img $(MULTISTRAP_WORK_DIR)/boot
+
+ cp $(ROOTDIR)/board/multistrap.conf $(PRODUCT_OUT)/multistrap
+ sed -i -e 's/USERSPACE_ARCH/$(USERSPACE_ARCH)/g' $(PRODUCT_OUT)/multistrap/multistrap.conf
+ sed -i -e 's/MAIN_PACKAGES/$(PACKAGES_EXTRA) $(BASE_PACKAGES) $(BSP_BASE_PACKAGES)/g' $(PRODUCT_OUT)/multistrap/multistrap.conf
+ sudo multistrap -f $(PRODUCT_OUT)/multistrap/multistrap.conf -d $(MULTISTRAP_WORK_DIR)
+
+ sudo mount -o bind /dev $(MULTISTRAP_WORK_DIR)/dev
+ sudo cp /usr/bin/qemu-$(QEMU_ARCH)-static $(MULTISTRAP_WORK_DIR)/usr/bin
+ sudo chroot $(MULTISTRAP_WORK_DIR) /var/lib/dpkg/info/dash.preinst install
+ sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot $(MULTISTRAP_WORK_DIR) dpkg --configure -a
+ sudo rm -f $(MULTISTRAP_WORK_DIR)/usr/bin/qemu-$(QEMU_ARCH)-static
+
+ sudo umount -R $(MULTISTRAP_WORK_DIR)
+ rm -rf $(MULTISTRAP_WORK_DIR)
+ $(HOST_OUT)/bin/img2simg $@.wip $@
+
+$(PRODUCT_OUT)/multistrap/boot.img: $(PRODUCT_OUT)/multistrap
+ fallocate -l $(BOOT_SIZE_MB)M $@
+
+$(PRODUCT_OUT)/multistrap:
+ mkdir -p $(PRODUCT_OUT)/multistrap
+
+.PHONY:: multistrap
diff --git a/rootfs-packages.mk b/rootfs-packages.mk
new file mode 100644
index 0000000..e92c822
--- /dev/null
+++ b/rootfs-packages.mk
@@ -0,0 +1,40 @@
+# Copyright 2018 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.
+
+
+
+BASE_PACKAGES := \
+ aiy-board-gadget \
+ aiy-board-tweaks \
+ base-files \
+ bluetooth \
+ bluez \
+ libbluetooth3
+ mdt-services \
+ mendel-distro-info-data \
+ mendel-keyring \
+ runonce
+
+GUI_PACKAGES := \
+ gstreamer1.0-alsa \
+ gstreamer1.0-plugins-bad \
+ gstreamer1.0-plugins-base \
+ gstreamer1.0-plugins-base-apps \
+ gstreamer1.0-plugins-good \
+ gstreamer1.0-plugins-ugly \
+ gstreamer1.0-tools \
+ libdrm2 \
+ libgstreamer1.0-0 \
+ libgstreamer-plugins-bad1.0-0 \
+ libgstreamer-plugins-base1.0-0
diff --git a/rootfs.mk b/rootfs.mk
index 990306e..560fa58 100644
--- a/rootfs.mk
+++ b/rootfs.mk
@@ -24,31 +24,7 @@
ROOTFS_PATCHED_IMG := $(PRODUCT_OUT)/obj/ROOTFS/rootfs_$(USERSPACE_ARCH).patched.img
ROOTFS_RAW_LOCAL_CACHE_PATH := $(ROOTDIR)/cache/rootfs_$(USERSPACE).raw.img
-BASE_PACKAGES := \
- aiy-board-gadget \
- aiy-board-tweaks \
- base-files \
- bluetooth \
- bluez \
- libbluetooth3 \
- mdt-services \
- mendel-distro-info-data \
- mendel-keyring \
- runonce
-
-GUI_PACKAGES := \
- gstreamer1.0-alsa \
- gstreamer1.0-plugins-bad \
- gstreamer1.0-plugins-base \
- gstreamer1.0-plugins-base-apps \
- gstreamer1.0-plugins-good \
- gstreamer1.0-plugins-ugly \
- gstreamer1.0-tools \
- libdrm2 \
- libgstreamer1.0-0 \
- libgstreamer-plugins-bad1.0-0 \
- libgstreamer-plugins-base1.0-0
-
+include $(ROOTDIR)/build/rootfs-packages.mk
include $(ROOTDIR)/board/rootfs.mk
ifeq ($(HEADLESS_BUILD),)