Skip to content

Commit

Permalink
libpriv/core: log repo info when downloading rpmmd
Browse files Browse the repository at this point in the history
Move the logging of yum repo information from `prepare` to
`download_metadata`, since the latter could be called without
necessarily calling the former, as is the case with `makecache`.

Closes: #1035
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Oct 6, 2017
1 parent a2862f5 commit 7930c06
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/libpriv/rpmostree-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,45 @@ rpmostree_context_download_metadata (RpmOstreeContext *self,
rpmostree_output_percent_progress_end ();
}

/* A lot of code to simply log a message to the systemd journal with the state
* of the rpm-md repos. This is intended to aid system admins with determining
* system ""up-to-dateness"".
*/
{ g_autoptr(GPtrArray) repos = get_enabled_rpmmd_repos (self->hifctx, DNF_REPO_ENABLED_PACKAGES);
g_autoptr(GString) enabled_repos = g_string_new ("");
g_autoptr(GString) enabled_repos_solvables = g_string_new ("");
g_autoptr(GString) enabled_repos_timestamps = g_string_new ("");
guint total_solvables = 0;
gboolean first = TRUE;

for (guint i = 0; i < repos->len; i++)
{
DnfRepo *repo = repos->pdata[i];

if (first)
first = FALSE;
else
{
g_string_append (enabled_repos, ", ");
g_string_append (enabled_repos_solvables, ", ");
g_string_append (enabled_repos_timestamps, ", ");
}
g_autofree char *quoted = g_shell_quote (dnf_repo_get_id (repo));
g_string_append (enabled_repos, quoted);
total_solvables += dnf_repo_get_n_solvables (repo);
g_string_append_printf (enabled_repos_solvables, "%u", dnf_repo_get_n_solvables (repo));
g_string_append_printf (enabled_repos_timestamps, "%" G_GUINT64_FORMAT, dnf_repo_get_timestamp_generated (repo));
}

sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PKG_REPOS),
"MESSAGE=Preparing pkg txn; enabled repos: [%s] solvables: %u", enabled_repos->str, total_solvables,
"SACK_N_SOLVABLES=%i", dnf_sack_count (dnf_context_get_sack (self->hifctx)),
"ENABLED_REPOS=[%s]", enabled_repos->str,
"ENABLED_REPOS_SOLVABLES=[%s]", enabled_repos_solvables->str,
"ENABLED_REPOS_TIMESTAMPS=[%s]", enabled_repos_timestamps->str,
NULL);
}

return TRUE;
}

Expand Down Expand Up @@ -1558,45 +1597,6 @@ rpmostree_context_prepare (RpmOstreeContext *self,
return FALSE;
}

/* A lot of code to simply log a message to the systemd journal with the state
* of the rpm-md repos. This is intended to aid system admins with determining
* system ""up-to-dateness"".
*/
{ g_autoptr(GPtrArray) repos = get_enabled_rpmmd_repos (hifctx, DNF_REPO_ENABLED_PACKAGES);
g_autoptr(GString) enabled_repos = g_string_new ("");
g_autoptr(GString) enabled_repos_solvables = g_string_new ("");
g_autoptr(GString) enabled_repos_timestamps = g_string_new ("");
guint total_solvables = 0;
gboolean first = TRUE;

for (guint i = 0; i < repos->len; i++)
{
DnfRepo *repo = repos->pdata[i];

if (first)
first = FALSE;
else
{
g_string_append (enabled_repos, ", ");
g_string_append (enabled_repos_solvables, ", ");
g_string_append (enabled_repos_timestamps, ", ");
}
g_autofree char *quoted = g_shell_quote (dnf_repo_get_id (repo));
g_string_append (enabled_repos, quoted);
total_solvables += dnf_repo_get_n_solvables (repo);
g_string_append_printf (enabled_repos_solvables, "%u", dnf_repo_get_n_solvables (repo));
g_string_append_printf (enabled_repos_timestamps, "%" G_GUINT64_FORMAT, dnf_repo_get_timestamp_generated (repo));
}

sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PKG_REPOS),
"MESSAGE=Preparing pkg txn; enabled repos: [%s] solvables: %u", enabled_repos->str, total_solvables,
"SACK_N_SOLVABLES=%i", dnf_sack_count (dnf_context_get_sack (hifctx)),
"ENABLED_REPOS=[%s]", enabled_repos->str,
"ENABLED_REPOS_SOLVABLES=[%s]", enabled_repos_solvables->str,
"ENABLED_REPOS_TIMESTAMPS=[%s]", enabled_repos_timestamps->str,
NULL);
}

rpmostree_output_task_begin ("Resolving dependencies");

/* XXX: consider a --allow-uninstall switch? */
Expand Down

0 comments on commit 7930c06

Please sign in to comment.