From c12e205ec52bc03b907bfeb3adc64f6745f6e556 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Wed, 5 Dec 2018 14:54:26 -0800 Subject: [PATCH] Fix /init -> /system/bin/init symlink creation race A symlink for TARGET_ROOT_OUT as a post install command of a package that is also installed to TARGET_ROOT_OUT. We hijack init.rc which satisfies this requirement for this symlink. Bug: 120402274 Bug: 120460755 Bug: 120509320 Bug: 120554662 Test: symlink is created Test: make bootimage && ls -la $OUT/root/init Change-Id: I6f1ac06ef152c36d7d7db4618d49a008338da39b --- init/Android.mk | 1 - rootdir/Android.mk | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/init/Android.mk b/init/Android.mk index 0e6ee0b59..bdd03018a 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -104,7 +104,6 @@ LOCAL_MODULE := init_system LOCAL_REQUIRED_MODULES := \ init_second_stage \ -LOCAL_POST_INSTALL_CMD := ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init include $(BUILD_PHONY_PACKAGE) include $(CLEAR_VARS) diff --git a/rootdir/Android.mk b/rootdir/Android.mk index aad00ad30..f88f6b945 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -9,6 +9,10 @@ LOCAL_SRC_FILES := $(LOCAL_MODULE) LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT. +# Since init.rc is required for init and satisfies that requirement, we hijack it to create the symlink. +LOCAL_POST_INSTALL_CMD := ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init + include $(BUILD_PREBUILT) #######################################