ramdisk: move uevent link that build creates

Add missing init.rc files for recovery.
Cleanup init symbolic links.
Comment out removing the source file in relink.sh because we need
to retain files in /system in the ramdisk.
Change-Id: Ie959024296738538f3b3161e38027a44525b0696

Change-Id: I5b1a744414b88a9a15c56bd81f37091664d5cdf1
diff --git a/Android.mk b/Android.mk
index 2134c69..b17969d 100755
--- a/Android.mk
+++ b/Android.mk
@@ -407,7 +407,9 @@
     simg2img_twrp \
     libbootloader_message_twrp \
     init.recovery.hlthchrg.rc \
-    init.recovery.service.rc
+    init.recovery.service.rc \
+    init.recovery.ldconfig.rc \
+    awk
 
 ifneq ($(TARGET_ARCH), arm64)
     ifneq ($(TARGET_ARCH), x86_64)
@@ -511,7 +513,7 @@
         ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
             LOCAL_POST_INSTALL_CMD += \
             sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths  = \/sbin\n\1 +=/' \
-                    $(TARGET_RECOVERY_ROOT_OUT)/system/etc/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
+                    $(TARGET_RECOVERY_ROOT_OUT)/system/etc/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt
         else
             LOCAL_POST_INSTALL_CMD += \
             sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths  = \/sbin\n\1 +=/' \
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index 2b3c051..5bf3cc5 100755
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -106,6 +106,7 @@
     RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libcap.so
     RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libminijail.so
     RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libunwindstack.so
+    RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libasyncio.so
     RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libinit.so
     RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libdl_android.so
     RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libprotobuf-cpp-lite.so
@@ -215,7 +216,6 @@
 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
 ifneq ($(TW_EXCLUDE_MTP), true)
     RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpmtp-ffs.so
-    RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libasyncio.so
 endif
 else
 ifneq ($(TW_EXCLUDE_MTP), true)
@@ -503,8 +503,10 @@
 LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
 RELINK_INIT := $(TARGET_RECOVERY_ROOT_OUT)/system/bin/init
-LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT) $(RELINK_INIT) && \
-    ln -sf ../init $(TARGET_RECOVERY_ROOT_OUT)/sbin/ueventd
+LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/ $(RELINK_INIT) && \
+    mv $(TARGET_RECOVERY_ROOT_OUT)/system/bin/ueventd $(TARGET_RECOVERY_ROOT_OUT)/sbin/ && \
+    ln -sf /init $(TARGET_RECOVERY_ROOT_OUT)/sbin/init && \
+    ln -sf /init $(TARGET_RECOVERY_ROOT_OUT)/system/bin/init
 LOCAL_REQUIRED_MODULES := init_second_stage.recovery
 include $(BUILD_PHONY_PACKAGE)
 
diff --git a/prebuilt/relink.sh b/prebuilt/relink.sh
index 4b29a7e..dbf44e5 100755
--- a/prebuilt/relink.sh
+++ b/prebuilt/relink.sh
@@ -17,10 +17,7 @@
     fi
 
     sed "s|/system/bin/linker64\x0|/sbin/linker64\x0\x0\x0\x0\x0\x0\x0|g" $src | sed "s|/system/bin/linker\x0|/sbin/linker\x0\x0\x0\x0\x0\x0\x0|g" | sed "s|/system/bin/sh\x0|/sbin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst
-
-    if [ $1 == $(dirname $2) ]; then
-      rm -f $src
-    fi
+    #rm -f $src
 }