Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac33a56d authored by Alex Light's avatar Alex Light Committed by Automerger Merge Worker
Browse files

Make otapreopt_chroot setup linker am: 2b307a09 am: d2712659

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1615760

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I11d53e832d2c81db0d719b7e9f02ab5482277c79
parents e1453c16 d2712659
Loading
Loading
Loading
Loading
+34 −8
Original line number Original line Diff line number Diff line
@@ -185,6 +185,13 @@ static int otapreopt_chroot(const int argc, char **arg) {
    // want it for product APKs. Same notes as vendor above.
    // want it for product APKs. Same notes as vendor above.
    TryExtraMount("product", arg[2], "/postinstall/product");
    TryExtraMount("product", arg[2], "/postinstall/product");


    constexpr const char* kPostInstallLinkerconfig = "/postinstall/linkerconfig";
    // Try to mount /postinstall/linkerconfig. we will set it up after performing the chroot
    if (mount("tmpfs", kPostInstallLinkerconfig, "tmpfs", 0, nullptr) != 0) {
        PLOG(ERROR) << "Failed to mount a tmpfs for " << kPostInstallLinkerconfig;
        exit(215);
    }

    // Setup APEX mount point and its security context.
    // Setup APEX mount point and its security context.
    static constexpr const char* kPostinstallApexDir = "/postinstall/apex";
    static constexpr const char* kPostinstallApexDir = "/postinstall/apex";
    // The following logic is similar to the one in system/core/rootdir/init.rc:
    // The following logic is similar to the one in system/core/rootdir/init.rc:
@@ -246,15 +253,34 @@ static int otapreopt_chroot(const int argc, char **arg) {


    // Check that an ART APEX has been activated; clean up and exit
    // Check that an ART APEX has been activated; clean up and exit
    // early otherwise.
    // early otherwise.
    if (std::none_of(active_packages.begin(),
    static constexpr const std::string_view kRequiredApexs[] = {
                     active_packages.end(),
      "com.android.art",
                     [](const apex::ApexFile& package){
      "com.android.runtime",
                         return package.GetManifest().name() == "com.android.art";
    };
    for (std::string_view apex : kRequiredApexs) {
        if (std::none_of(active_packages.begin(), active_packages.end(),
                         [&](const apex::ApexFile& package) {
                             return package.GetManifest().name() == apex;
                         })) {
                         })) {
        LOG(FATAL_WITHOUT_ABORT) << "No activated com.android.art APEX package.";
            LOG(FATAL_WITHOUT_ABORT) << "No activated " << apex << " APEX package.";
            DeactivateApexPackages(active_packages);
            DeactivateApexPackages(active_packages);
            exit(217);
            exit(217);
        }
        }
    }

    // Setup /linkerconfig. Doing it after the chroot means it doesn't need its own category
    if (selinux_android_restorecon("/linkerconfig", 0) < 0) {
        PLOG(ERROR) << "Failed to restorecon /linkerconfig";
        exit(219);
    }
    std::vector<std::string> linkerconfig_cmd{"/apex/com.android.runtime/bin/linkerconfig",
                                              "--target", "/linkerconfig"};
    std::string linkerconfig_error_msg;
    bool linkerconfig_exec_result = Exec(linkerconfig_cmd, &linkerconfig_error_msg);
    if (!linkerconfig_exec_result) {
        LOG(ERROR) << "Running linkerconfig failed: " << linkerconfig_error_msg;
        exit(218);
    }


    // Now go on and run otapreopt.
    // Now go on and run otapreopt.