Skip to content

Commit

Permalink
repack: move sbin to /system ramdisk and update repacking
Browse files Browse the repository at this point in the history
for android-10

This will support updating the ramdisk to a different
compression format and co-exist with magisk.

We are also cleaning up and removing non android-10
api makefile actions.

We are also moving twrp repacking to its own class. We
check the new ramdisk format and if it's different
we have magisk compress using the new ramdisk format.

Change-Id: I770030aae7797e75817178b2f0fccd9f39dc23af
  • Loading branch information
bigbiff committed Sep 8, 2020
1 parent 3db1ffc commit ad58e1b
Show file tree
Hide file tree
Showing 127 changed files with 959 additions and 17,485 deletions.
441 changes: 96 additions & 345 deletions Android.mk

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion adbbu/Android.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ LOCAL_MODULE:= twrpbu
LOCAL_MODULE_STEM := bu
LOCAL_MODULE_TAGS:= optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
include $(BUILD_EXECUTABLE)

8 changes: 4 additions & 4 deletions attr/Android.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ LOCAL_CFLAGS := -c -W
LOCAL_MODULE := listxattr
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_PACK_MODULE_RELOCATIONS := false

ifneq ($(TARGET_ARCH), arm64)
ifneq ($(TARGET_ARCH), x86_64)
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker
else
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
endif
else
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
endif

include $(BUILD_EXECUTABLE)
4 changes: 2 additions & 2 deletions bmlutils/bmlutils.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ int format_rfs_device (const char *device, const char *path) {
// dump 10KB of zeros to partition before format due to fat.format bug
char cmd[PATH_MAX];

sprintf(cmd, "/sbin/dd if=/dev/zero of=%s bs=4096 count=10", device);
sprintf(cmd, "/system/bin/dd if=/dev/zero of=%s bs=4096 count=10", device);
if(__system(cmd)) {
printf("failure while zeroing rfs partition.\n");
return -1;
}

// Run fat.format
sprintf(cmd, "/sbin/fat.format -F %s -S 4096 -s %s %s", fatsize, sectorsize, device);
sprintf(cmd, "/system/bin/fat.format -F %s -S 4096 -s %s %s", fatsize, sectorsize, device);
if(__system(cmd)) {
printf("failure while running fat.format\n");
return -1;
Expand Down
11 changes: 5 additions & 6 deletions crypto/ext4crypt/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,36 @@ include $(CLEAR_VARS)
LOCAL_MODULE := twrpfbe
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_SRC_FILES := main.cpp
LOCAL_SHARED_LIBRARIES := libe4crypt
#LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
LOCAL_MODULE := e4policyget
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_SRC_FILES := e4policyget.cpp
LOCAL_SHARED_LIBRARIES := libe4crypt
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
LOCAL_MODULE := keystore_auth
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_SRC_FILES := keystore_auth.cpp
LOCAL_SHARED_LIBRARIES := libc libkeystore_binder libutils libbinder liblog
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
#9.0
LOCAL_CFLAGS += -DUSE_SECURITY_NAMESPACE
LOCAL_SHARED_LIBRARIES += libkeystore_aidl
endif
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64

include $(BUILD_EXECUTABLE)

Expand Down
4 changes: 2 additions & 2 deletions crypto/ext4crypt/Decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st
if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) {
printf("error during keymaster_auth service\n");
/* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc
* service keystore_auth /sbin/keystore_auth
* service keystore_auth /system/bin/keystore_auth
* disabled
* oneshot
* user system
Expand Down Expand Up @@ -804,7 +804,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st
if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) {
printf("error during keymaster_auth service\n");
/* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc
* service keystore_auth /sbin/keystore_auth
* service keystore_auth /system/bin/keystore_auth
* disabled
* oneshot
* user system
Expand Down
2 changes: 1 addition & 1 deletion crypto/fde/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := twrpdec
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_SRC_FILES := main.cpp cryptfs.cpp
LOCAL_SHARED_LIBRARIES := libcrypto libhardware libcutils libc libstdc++
LOCAL_C_INCLUDES := external/openssl/include $(commands_recovery_local_path)/crypto/scrypt/lib/crypto
Expand Down
8 changes: 3 additions & 5 deletions crypto/fscrypt/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := twrpfbe
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
LOCAL_SRC_FILES := main.cpp
LOCAL_SHARED_LIBRARIES := libtwrpfscrypt

Expand All @@ -59,23 +59,21 @@ include $(CLEAR_VARS)
LOCAL_MODULE := fscryptpolicyget
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
LOCAL_SRC_FILES := fscryptpolicyget.cpp
LOCAL_SHARED_LIBRARIES := libtwrpfscrypt
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
LOCAL_MODULE := keystore_auth
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
LOCAL_SRC_FILES := keystore_auth.cpp
LOCAL_SHARED_LIBRARIES := libc libkeystore_binder libutils libbinder liblog
LOCAL_CFLAGS += -DUSE_SECURITY_NAMESPACE
LOCAL_SHARED_LIBRARIES += libkeystore_aidl
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64

include $(BUILD_EXECUTABLE)

Expand Down
2 changes: 1 addition & 1 deletion crypto/fscrypt/Decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st
if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) {
printf("error during keymaster_auth service\n");
/* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc
* service keystore_auth /sbin/keystore_auth
* service keystore_auth /system/bin/keystore_auth
* disabled
* oneshot
* user system
Expand Down
2 changes: 1 addition & 1 deletion crypto/fscrypt/FsCrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const std::string device_key_temp = device_key_dir + "/temp";

const std::string user_key_dir = std::string() + DATA_MNT_POINT + "/misc/vold/user_keys";
const std::string user_key_temp = user_key_dir + "/temp";
const std::string prepare_subdirs_path = "/sbin/vold_prepare_subdirs";
const std::string prepare_subdirs_path = "/system/bin/vold_prepare_subdirs";

const std::string systemwide_volume_key_dir =
std::string() + DATA_MNT_POINT + "/misc/vold/volume_keys";
Expand Down
8 changes: 4 additions & 4 deletions crypto/vold_decrypt/Android.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ifeq ($(TW_INCLUDE_CRYPTO), true)
LOCAL_SRC_FILES := vdc_pie.cpp
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
LOCAL_CLANG := true
LOCAL_TIDY := true
LOCAL_TIDY_FLAGS := -warnings-as-errors=clang-analyzer-security*,cert-*
Expand All @@ -141,12 +141,12 @@ ifeq ($(TW_INCLUDE_CRYPTO), true)
endif
ifneq ($(TARGET_ARCH), arm64)
ifneq ($(TARGET_ARCH), x86_64)
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker
else
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
endif
else
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
endif

include $(BUILD_EXECUTABLE)
Expand Down
10 changes: 5 additions & 5 deletions crypto/vold_decrypt/vold_decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int sdkver = 20;
#ifdef TW_CRYPTO_SYSTEM_VOLD_DEBUG

#ifndef VD_STRACE_BIN
#define VD_STRACE_BIN "/sbin/strace"
#define VD_STRACE_BIN "/system/bin/strace"
#endif

bool has_strace = false;
Expand Down Expand Up @@ -399,7 +399,7 @@ void Symlink_Firmware_Files(bool is_vendor_symlinked, bool is_firmware_symlinked
LOGINFO("%d file(s) symlinked.\n", (int)FirmwareFiles.size());
}

// Android 8.0 fs_mgr checks for "/sbin/recovery", in which case it will
// Android 8.0 fs_mgr checks for "/system/bin/recovery", in which case it will
// use /etc/recovery.fstab -> symlink it temporarily. Reference:
// https://android.googlesource.com/platform/system/core/+/android-8.0.0_r17/fs_mgr/fs_mgr_fstab.cpp#693
bool Symlink_Recovery_Fstab(void) {
Expand Down Expand Up @@ -716,8 +716,8 @@ vector<AdditionalService> Get_List_Of_Additional_Services(void) {

if (Service_Exists(services[j].Service_Name))
services[j].TWRP_Service_Name = services[j].Service_Name;
else if (Service_Exists("sbin" + services[j].Service_Name))
services[j].TWRP_Service_Name = "sbin" + services[j].Service_Name;
else if (Service_Exists("system/bin" + services[j].Service_Name))
services[j].TWRP_Service_Name = "system/bin" + services[j].Service_Name;
else
services[j].TWRP_Service_Name.clear();

Expand Down Expand Up @@ -995,7 +995,7 @@ int Exec_vdc_cryptfs(const string& command, const string& argument, vdc_ReturnVa
}

// getpwtype and checkpw commands are removed from Pie vdc, using modified vdc_pie
const char *cmd[] = { "/sbin/vdc_pie", "cryptfs" };
const char *cmd[] = { "/system/bin/vdc_pie", "cryptfs" };
if (sdkver < 28)
cmd[0] = "/system/bin/vdc";
const char *env[] = { "LD_LIBRARY_PATH=/system/lib64:/system/lib", NULL };
Expand Down
2 changes: 1 addition & 1 deletion data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ void DataManager::SetDefaultValues()

mData.SetValue("tw_enable_adb_backup", "0");

if (TWFunc::Path_Exists("/sbin/magiskboot"))
if (TWFunc::Path_Exists("/system/bin/magiskboot"))
mConst.SetValue("tw_has_repack_tools", "1");
else
mConst.SetValue("tw_has_repack_tools", "0");
Expand Down
6 changes: 3 additions & 3 deletions dosfstools/Android.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LOCAL_CFLAGS += -Wno-sign-compare
LOCAL_MODULE = fsck.fat
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
Expand All @@ -40,7 +40,7 @@ LOCAL_CFLAGS += -Wno-sign-compare
LOCAL_MODULE = fatlabel
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
Expand All @@ -52,7 +52,7 @@ LOCAL_CFLAGS += -Wno-sign-compare
LOCAL_MODULE = mkfs.fat
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
include $(BUILD_EXECUTABLE)

endif
64 changes: 21 additions & 43 deletions etc/Android.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,54 +31,32 @@ include $(BUILD_PREBUILT)

endif

ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 22; echo $$?),0)
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.service.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)

LOCAL_SRC_FILES := init.recovery.service22.rc
include $(BUILD_PREBUILT)
else
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.service.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)

LOCAL_SRC_FILES := init.recovery.service21.rc
include $(BUILD_PREBUILT)
endif
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.service.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)

ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.hlthchrg.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_SRC_FILES := init.recovery.service22.rc
include $(BUILD_PREBUILT)

LOCAL_SRC_FILES := init.recovery.hlthchrg26.rc
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.hlthchrg.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)

include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.ldconfig.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_SRC_FILES := init.recovery.hlthchrg26.rc
include $(BUILD_PREBUILT)

LOCAL_SRC_FILES := init.recovery.ldconfig.rc
include $(BUILD_PREBUILT)
else
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.hlthchrg.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.ldconfig.rc
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)

LOCAL_SRC_FILES := init.recovery.hlthchrg25.rc
include $(BUILD_PREBUILT)
endif
LOCAL_SRC_FILES := init.recovery.ldconfig.rc
include $(BUILD_PREBUILT)

ifeq ($(TWRP_INCLUDE_LOGCAT), true)
ifeq ($(TARGET_USES_LOGD), true)
Expand Down
8 changes: 4 additions & 4 deletions etc/init.rc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on early-init

on init
export PATH /sbin:/system/bin
export LD_LIBRARY_PATH /sbin
export LD_LIBRARY_PATH /system/lib64

export ANDROID_ROOT /system
export ANDROID_DATA /data
Expand Down Expand Up @@ -103,11 +103,11 @@ on late-init
on property:sys.powerctl=*
powerctl ${sys.powerctl}

service ueventd /sbin/ueventd
service ueventd /system/bin/ueventd
critical
seclabel u:r:ueventd:s0

service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
Expand All @@ -118,7 +118,7 @@ on property:ro.debuggable=1
#start adbd
setprop service.adb.root 1

service fastbootd /sbin/fastbootd
service fastbootd /system/bin/fastbootd
disabled
group system
seclabel u:r:fastbootd:s0
Expand Down
2 changes: 1 addition & 1 deletion etc/init.recovery.hlthchrg25.rc
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# healthd for pre Android 8.0

service healthd /sbin/healthd -r
service healthd /system/bin/healthd -r
critical
seclabel u:r:healthd:s0
2 changes: 1 addition & 1 deletion etc/init.recovery.ldconfig.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
on fs
export LD_CONFIG_FILE /sbin/ld.config.txt
export LD_CONFIG_FILE /system/etc/ld.config.txt
2 changes: 1 addition & 1 deletion etc/init.recovery.logd.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
service logd /sbin/logd
service logd /system/bin/logd
class core
socket logdr seqpacket 0666 root root
socket logdw dgram+passcred 0222 root root
Expand Down
4 changes: 0 additions & 4 deletions etc/init.recovery.service21.rc

This file was deleted.

Loading

0 comments on commit ad58e1b

Please sign in to comment.