split first stage init into a separate executable
In the future, systems with dm-linear will require a ramdisk to set up
the mount for system. In this world, first stage init will be a part
of this ramdisk and handle setting up dm-linear, mounting the
necessary partitions, then pivoting to the system image, which will
become the root partition.
This also enables previous devices without system-as-root, to be
unified with system-as-root devices for all aspects of boot after the
pivot_root.
Bug: 79758715
Test: boot hikey
Test: boot sailfish, boot sailfish into recovery
Change-Id: Iefa88a3ec5994e7989aa9f26f2de0351ffa5468b
diff --git a/init/Android.mk b/init/Android.mk
index 9d9d368..d20509b 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -41,35 +41,35 @@
include $(CLEAR_VARS)
LOCAL_CPPFLAGS := $(init_cflags)
-LOCAL_SRC_FILES := main.cpp
+LOCAL_SRC_FILES := \
+ devices.cpp \
+ first_stage_mount.cpp \
+ init_first_stage.cpp \
+ reboot_utils.cpp \
+ selinux.cpp \
+ uevent_listener.cpp \
+ util.cpp \
-LOCAL_MODULE:= init
+LOCAL_MODULE := init
+
+LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := \
- libinit \
- libbootloader_message \
libfs_mgr \
libfec \
libfec_rs \
- libhidl-gen-utils \
libsquashfs_utils \
liblogwrap \
libext4_utils \
libseccomp_policy \
libcrypto_utils \
libsparse \
- libprocessgroup \
libavb \
libkeyutils \
- libprotobuf-cpp-lite \
- libpropertyinfoserializer \
- libpropertyinfoparser \
liblp \
-
-shared_libs := \
libcutils \
libbase \
liblog \
@@ -77,27 +77,11 @@
libdl \
libz \
libselinux \
-
-ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
-# init is static executable for non-system-as-root devices, because the dynamic linker
-# and shared libs are not available before /system is mounted, but init has to run
-# before the partition is mounted.
-LOCAL_STATIC_LIBRARIES += $(shared_libs) libc++_static
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-else
-LOCAL_SHARED_LIBRARIES := $(shared_libs) libc++
-endif
-shared_libs :=
+ libcap \
LOCAL_REQUIRED_MODULES := \
- e2fsdroid \
- mke2fs \
- sload_f2fs \
- make_f2fs \
-
-# Create symlinks.
-LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \
- ln -sf ../init $(TARGET_ROOT_OUT)/sbin/ueventd; \
+ init_second_stage \
+ init_second_stage.recovery \
LOCAL_SANITIZE := signed-integer-overflow
include $(BUILD_EXECUTABLE)