diff --git a/src/aklite_client_ext.cc b/src/aklite_client_ext.cc index b57237e2..ba4d11d2 100644 --- a/src/aklite_client_ext.cc +++ b/src/aklite_client_ext.cc @@ -120,15 +120,18 @@ GetTargetToInstallResult AkliteClientExt::GetTargetToInstall(const CheckInResult << " Skipping its installation."; } - if (force_apps_sync || !client_->appsInSync(Target::fromTufTarget(current))) { + auto apps_to_update = client_->appsToUpdate(Target::fromTufTarget(current)); + if (force_apps_sync || !apps_to_update.empty()) { // Force installation of apps res.selected_target = current; LOG_INFO << "The specified Target is already installed, enforcing installation to make sure it's synced and running:" << res.selected_target.Name(); + LOG_INFO << "XX " << apps_to_update.size() + << " Apps requiring update: " + boost::algorithm::join(apps_to_update, ", "); res.status = GetTargetToInstallResult::Status::UpdateSyncApps; - res.reason = "Syncing Active Target Apps"; + res.reason = "Syncing Active Target Apps\nApps requiring update: " + boost::algorithm::join(apps_to_update, ", "); } else { // No targets to install res.selected_target = TufTarget(); diff --git a/src/composeappmanager.cc b/src/composeappmanager.cc index 9e5238c7..8f6f72e7 100644 --- a/src/composeappmanager.cc +++ b/src/composeappmanager.cc @@ -237,13 +237,24 @@ ComposeAppManager::AppsContainer ComposeAppManager::getAppsToUpdate(const Uptane return apps_to_update; } -bool ComposeAppManager::checkForAppsToUpdate(const Uptane::Target& target) { +std::vector ComposeAppManager::checkForAppsToUpdate(const Uptane::Target& target) { cur_apps_to_fetch_and_update_ = getAppsToUpdate(target); if (!!cfg_.reset_apps) { cur_apps_to_fetch_ = getAppsToFetch(target); } are_apps_checked_ = true; - return cur_apps_to_fetch_and_update_.empty() && cur_apps_to_fetch_.empty(); + std::vector ret; + for (const auto& app : cur_apps_to_fetch_and_update_) { + if (std::find(ret.begin(), ret.end(), app.first) == ret.end()) { + ret.push_back(app.first); + } + } + for (const auto& app : cur_apps_to_fetch_) { + if (std::find(ret.begin(), ret.end(), app.first) == ret.end()) { + ret.push_back(app.first); + } + } + return ret; } DownloadResult ComposeAppManager::Download(const TufTarget& target) { diff --git a/src/composeappmanager.h b/src/composeappmanager.h index e7e3eb3c..a99a6e16 100644 --- a/src/composeappmanager.h +++ b/src/composeappmanager.h @@ -59,7 +59,7 @@ class ComposeAppManager : public RootfsTreeManager { // If Apps are not specified in the config then all Target's Apps are returned AppsContainer getApps(const Uptane::Target& t) const; AppsContainer getAppsToUpdate(const Uptane::Target& t) const; - bool checkForAppsToUpdate(const Uptane::Target& target); + std::vector checkForAppsToUpdate(const Uptane::Target& target); void setAppsNotChecked() { are_apps_checked_ = false; } void handleRemovedApps(const Uptane::Target& target) const; Json::Value getAppsState() const; diff --git a/src/liteclient.cc b/src/liteclient.cc index d3a47791..ecdde939 100644 --- a/src/liteclient.cc +++ b/src/liteclient.cc @@ -771,22 +771,24 @@ bool LiteClient::isTargetActive(const Uptane::Target& target) const { return target.filename() == current.filename() && target.sha256Hash() == current.sha256Hash(); } -bool LiteClient::appsInSync(const Uptane::Target& target) const { +bool LiteClient::appsInSync(const Uptane::Target& target) const { return appsToUpdate(target).empty(); } + +std::vector LiteClient::appsToUpdate(const Uptane::Target& target) const { if (package_manager_->name() == ComposeAppManager::Name) { auto* compose_pacman = dynamic_cast(package_manager_.get()); if (compose_pacman == nullptr) { LOG_ERROR << "Cannot downcast the package manager to a specific type"; - return false; + return {}; } LOG_INFO << "Checking status of Active Target (" << target.filename() << ")"; - auto no_any_app_to_update = compose_pacman->checkForAppsToUpdate(target); - if (no_any_app_to_update) { + auto apps_to_update = compose_pacman->checkForAppsToUpdate(target); + if (apps_to_update.empty()) { compose_pacman->handleRemovedApps(getCurrent()); } - return no_any_app_to_update; + return apps_to_update; } - return true; + return {}; } void LiteClient::setAppsNotChecked() { diff --git a/src/liteclient.h b/src/liteclient.h index 79bf5284..bd4dd7b9 100644 --- a/src/liteclient.h +++ b/src/liteclient.h @@ -68,6 +68,7 @@ class LiteClient { void reportAppsState(); bool isTargetActive(const Uptane::Target& target) const; bool appsInSync(const Uptane::Target& target) const; + std::vector appsToUpdate(const Uptane::Target& target) const; void setAppsNotChecked(); std::string getDeviceID() const; static void update_request_headers(std::shared_ptr& http_client, const Uptane::Target& target,