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

Commit 9449583b authored by Adrian DC's avatar Adrian DC
Browse files

init: Sort the list of flattened APEX folders to avoid variations



 * In 'ActivateFlattenedApexesFrom', the 'readdir' detects
   the APEX folders in a random way that depends on filesystems,
   built packages and order of the build chain

 * In normal cases, this is not an issue, however when building
   with Go configurations, we have a case where the package
   'com.android.tethering.inprocess' is built along the
   'com.android.tethering' overriden binary, and depending on
   the 'readdir' output, the mounts break the Tethering service

Change-Id: I8ac4a0284d8d885f732c71e846933869cf16a0bd
Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent da126420
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -115,10 +115,18 @@ static Result<void> ActivateFlattenedApexesFrom(const std::string& from_dir,
        return {};
    }
    dirent* entry;
    std::vector<std::string> entries;

    while ((entry = readdir(dir.get())) != nullptr) {
        if (entry->d_name[0] == '.') continue;
        if (entry->d_type == DT_DIR) {
            const std::string apex_path = from_dir + "/" + entry->d_name;
            entries.push_back(entry->d_name);
        }
    }

    std::sort(entries.begin(), entries.end());
    for (const auto& name : entries) {
        const std::string apex_path = from_dir + "/" + name;
        const auto apex_manifest = GetApexManifest(apex_path);
        if (!apex_manifest.ok()) {
            LOG(ERROR) << apex_path << " is not an APEX directory: " << apex_manifest.error();
@@ -130,7 +138,6 @@ static Result<void> ActivateFlattenedApexesFrom(const std::string& from_dir,
        }
        on_activate(apex_path, *apex_manifest);
    }
    }
    return {};
}