diff --git a/.gitattributes b/.gitattributes index eed785ce8..df74eca36 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,9 +11,8 @@ *.bat text eol=crlf # Denote all files that are truly binary and should not be modified. -tools/** binary -tools/rustup-wrapper/** -binary -tools/elf-cleaner/** -binary +/tools/keys/** binary +/tools/keys/futility binary *.jar binary *.exe binary *.apk binary diff --git a/app/build-logic/src/main/java/Setup.kt b/app/build-logic/src/main/java/Setup.kt index b78a7449e..19f3cfa10 100644 --- a/app/build-logic/src/main/java/Setup.kt +++ b/app/build-logic/src/main/java/Setup.kt @@ -104,6 +104,11 @@ const val BUSYBOX_DOWNLOAD_URL = const val BUSYBOX_ZIP_CHECKSUM = "b4d0551feabaf314e53c79316c980e8f66432e9fb91a69dbbf10a93564b40951" +const val BOOTCTL_DOWNLOAD_URL = + "https://github.com/topjohnwu/magisk-files/releases/download/files/bootctl-android-14.0.0_r1.zip" +const val BOOTCTL_ZIP_CHECKSUM = + "2cf515aeb17259e88393a1322671ebab1968925864bc04ae57dad54e53ccf15b" + private abstract class SyncWithDir : Sync() { @get:OutputDirectory abstract val outputFolder: DirectoryProperty @@ -133,8 +138,10 @@ fun Project.setupCoreLib() { } from(zipTree(downloadFile(BUSYBOX_DOWNLOAD_URL, BUSYBOX_ZIP_CHECKSUM))) include(abiList.map { "$it/libbusybox.so" }) + from(zipTree(downloadFile(BOOTCTL_DOWNLOAD_URL, BOOTCTL_ZIP_CHECKSUM))) + include(abiList.map { "$it/libbootctl.so" }) onlyIf { - if (inputs.sourceFiles.files.size != abiList.size * 6) + if (inputs.sourceFiles.files.size != abiList.size * 7) throw StopExecutionException("Please build binaries first! (./build.py binary)") true } @@ -169,7 +176,6 @@ fun Project.setupCoreLib() { include("util_functions.sh", "boot_patch.sh", "addon.d.sh", "app_functions.sh", "uninstaller.sh", "module_installer.sh") } - from(rootFile("tools/bootctl")) into("chromeos") { from(rootFile("tools/futility")) from(rootFile("tools/keys")) { diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt index ed5f4122f..b50e035dc 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt @@ -502,16 +502,8 @@ abstract class MagiskInstallImpl protected constructor( private fun flashBoot() = "direct_install $installDir $srcBoot".sh().isSuccess - private suspend fun postOTA(): Boolean { - try { - val bootctl = File.createTempFile("bootctl", null, context.cacheDir) - context.assets.open("bootctl").writeTo(bootctl) - "post_ota $bootctl".sh() - } catch (e: IOException) { - console.add("! Unable to download bootctl") - Timber.e(e) - return false - } + private fun postOTA(): Boolean { + "post_ota".sh() console.add("*************************************************************") console.add(" Next reboot will boot to second slot!") diff --git a/scripts/app_functions.sh b/scripts/app_functions.sh index b2e242e8f..3fa645dd5 100644 --- a/scripts/app_functions.sh +++ b/scripts/app_functions.sh @@ -96,11 +96,10 @@ restore_imgs() { flash_image $BACKUPDIR/boot.img.gz $1 } -# $1 = path to bootctl executable post_ota() { cd /data/adb - cp -f $1 bootctl - rm -f $1 + cp -f $MAGISKBIN/bootctl bootctl + rm -f $MAGISKBIN/bootctl chmod 755 bootctl if ! ./bootctl hal-info; then rm -f bootctl diff --git a/tools/bootctl b/tools/bootctl deleted file mode 100644 index cf5c61368..000000000 Binary files a/tools/bootctl and /dev/null differ diff --git a/tools/bootctl.patch b/tools/bootctl.patch index 17353a2a3..42e6b1f3a 100755 --- a/tools/bootctl.patch +++ b/tools/bootctl.patch @@ -1,32 +1,67 @@ -# How to build the bootctl bundled within the Magisk app: +################################################################################## +# How to build the prebuilt bootctl executable: # -# 1. Checkout and sync the AOSP tree: +# 1. Checkout and sync the AOSP tree with the tag android-14.0.0_r1: # https://source.android.com/setup/build/downloading -# 2. Build for arm64: -# lunch aosp_arm64-eng -# 3. Apply patches: -# cd system/extras; patch -p1 < bootctl.patch +# 2. Apply patches: +# `patch -p1 -d system/extras -i bootctl.patch` +# 3. Build for arm, arm64, x86, and x86_64: +# `lunch aosp_-eng` # 4. Build the executable: -# m bootctl +# `m bootctl` +# +# Despite built from the Android 14 branch, the executable is usable on API 31+. +################################################################################## diff --git a/bootctl/Android.bp b/bootctl/Android.bp -index f63871cf..8a551bbe 100644 +index 106ff863..0e139989 100644 --- a/bootctl/Android.bp +++ b/bootctl/Android.bp -@@ -26,11 +26,15 @@ cc_binary { +@@ -26,13 +26,23 @@ cc_binary { "-Werror", ], - shared_libs: [ ++ ldflags: [ ++ "-Wl,-z,max-page-size=16384", ++ ], ++ + static_libs: [ "android.hardware.boot@1.0", "android.hardware.boot@1.1", "android.hardware.boot@1.2", + "android.hardware.boot-V1-ndk", + "libboot_control_client", + ], + shared_libs: [ "libhidlbase", "libutils", ++ "libbase", + "libcutils", + "liblog", ++ "libbinder_ndk", ], } +diff --git a/bootctl/bootctl.cpp b/bootctl/bootctl.cpp +index 1bf91815..e9c2d7bb 100644 +--- a/bootctl/bootctl.cpp ++++ b/bootctl/bootctl.cpp +@@ -174,7 +174,9 @@ static int do_set_snapshot_merge_status(BootControlClient* module, BootControlVe + return handle_return(ret, "Failed to set snapshot merge status: %s\n"); + } + +-std::ostream& operator<<(std::ostream& os, MergeStatus state) { ++std::ostream& operator<<(std::ostream& os, MergeStatus state); ++#if 0 ++{ + switch (state) { + case MergeStatus::CANCELLED: + return os << "cancelled"; +@@ -190,6 +192,7 @@ std::ostream& operator<<(std::ostream& os, MergeStatus state) { + return os; + } + } ++#endif + + static int do_get_snapshot_merge_status(BootControlClient* module) { + MergeStatus ret = module->getSnapshotMergeStatus();