From 5ab596451a0d4eb56f96083fc3e3c204401132e0 Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Thu, 7 Feb 2019 17:22:49 -0500 Subject: mksh: add mkshrc when using TW_USE_TOOLBOX Fixes broken shell prompt in Terminal and adb shell Before: https://del.dog/7vphlkc After: https://del.dog/vhkjgo8 Add as prebuilt with suffix "_twrp" to avoid conflict with original mkshrc and rename via POST_INSTALL_CMD Prebuilt version adjusts TMPDIR variable from "/data/local/tmp" to "/tmp" for TWRP Change-Id: I42a1b2a8c114f66dbe659c07485f1dfae8a5d314 --- etc/Android.mk | 15 +++++++++++++++ etc/init.rc | 1 + etc/init.recovery.mksh.rc | 2 ++ prebuilt/Android.mk | 12 ++++++++++++ prebuilt/mkshrc_twrp | 21 +++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100755 etc/init.recovery.mksh.rc create mode 100755 prebuilt/mkshrc_twrp diff --git a/etc/Android.mk b/etc/Android.mk index cda0f372e..4aeb251dc 100644 --- a/etc/Android.mk +++ b/etc/Android.mk @@ -88,3 +88,18 @@ ifeq ($(TWRP_INCLUDE_LOGCAT), true) include $(BUILD_PREBUILT) endif endif + +ifeq ($(TW_USE_TOOLBOX), true) + include $(CLEAR_VARS) + LOCAL_MODULE := init.recovery.mksh.rc + LOCAL_MODULE_TAGS := eng + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + + # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc + # during ramdisk creation and only allows init.recovery.*.rc files to be copied + # from TARGET_ROOT_OUT thereafter + LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) + + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) +endif diff --git a/etc/init.rc b/etc/init.rc index bcd519b03..348471d4f 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -1,4 +1,5 @@ import /init.recovery.logd.rc +import /init.recovery.mksh.rc import /init.recovery.usb.rc import /init.recovery.service.rc import /init.recovery.vold_decrypt.rc diff --git a/etc/init.recovery.mksh.rc b/etc/init.recovery.mksh.rc new file mode 100755 index 000000000..3afd946f3 --- /dev/null +++ b/etc/init.recovery.mksh.rc @@ -0,0 +1,2 @@ +on init + export ENV /etc/mkshrc diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index 235b77c86..933326292 100644 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -491,6 +491,18 @@ ifeq ($(TW_INCLUDE_DUMLOCK), true) include $(BUILD_PREBUILT) endif +ifeq ($(TW_USE_TOOLBOX), true) + include $(CLEAR_VARS) + LOCAL_MODULE := mkshrc_twrp + LOCAL_MODULE_TAGS := eng + LOCAL_MODULE_CLASS := ETC + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/etc + LOCAL_SRC_FILES := $(LOCAL_MODULE) + LOCAL_POST_INSTALL_CMD := \ + $(hide) mv $(TARGET_RECOVERY_ROOT_OUT)/etc/mkshrc_twrp $(TARGET_RECOVERY_ROOT_OUT)/etc/mkshrc + include $(BUILD_PREBUILT) +endif + #TWRP App "placeholder" include $(CLEAR_VARS) LOCAL_MODULE := me.twrp.twrpapp.apk diff --git a/prebuilt/mkshrc_twrp b/prebuilt/mkshrc_twrp new file mode 100755 index 000000000..c103d6c56 --- /dev/null +++ b/prebuilt/mkshrc_twrp @@ -0,0 +1,21 @@ +# Copyright (c) 2010, 2012, 2013, 2014 +# Thorsten Glaser +# This file is provided under the same terms as mksh. +#- +# Minimal /system/etc/mkshrc for Android +# +# Support: https://launchpad.net/mksh + +: ${HOSTNAME:=$(getprop ro.product.device)} +: ${HOSTNAME:=android} +: ${TMPDIR:=/tmp} +export HOSTNAME TMPDIR + +if (( USER_ID )); then PS1='$'; else PS1='#'; fi +PS4='[$EPOCHREALTIME] '; PS1='${| + local e=$? + + (( e )) && REPLY+="$e|" + + return $e +}$HOSTNAME:${PWD:-?} '"$PS1 " -- cgit v1.2.3