Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnf: Run subscription-manager sync before refreshing metadata #285

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions backends/dnf/pk-backend-dnf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,39 @@ pk_backend_refresh_repo (PkBackendJob *job,
return dnf_state_done (state, error);
}

static void
pk_backend_refresh_subman (PkBackendJob *job)
{
PkBackend *backend = pk_backend_job_get_backend (job);
PkBackendDnfJobData *job_data = pk_backend_job_get_user_data (job);
DnfRepoLoader *repo_loader = dnf_context_get_repo_loader (job_data->context);
const gchar *argv[] = { "/usr/sbin/subscription-manager", "sync", NULL };
g_autofree gchar *err = NULL;
g_autofree gchar *out = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GPtrArray) repos = NULL;

if (!g_file_test (argv[0], G_FILE_TEST_EXISTS))
return;
if (!g_spawn_sync (NULL, (gchar **) argv, NULL, G_SPAWN_DEFAULT,
NULL, NULL,
&out, &err, NULL,
&error_local)) {
g_autofree gchar *cmd = g_strjoinv (" ", (gchar **) argv);
g_warning ("failed to run '%s': %s [stdout:%s, stderr:%s]",
cmd, error_local->message, out, err);
return;
}

/* ask the context's repo loader for new repos, forcing it to reload them */
repos = dnf_repo_loader_get_repos (repo_loader, &error_local);
if (repos == NULL)
g_warning ("failed to reload repos: %s", error_local->message);

pk_backend_sack_cache_invalidate (backend, "subscription-manager ran");
pk_backend_repo_list_changed (backend);
}

static void
pk_backend_refresh_cache_thread (PkBackendJob *job,
GVariant *params,
Expand Down Expand Up @@ -1549,6 +1582,9 @@ pk_backend_refresh_cache_thread (PkBackendJob *job,

g_variant_get (params, "(b)", &force);

/* kick subscription-manager if it exists */
pk_backend_refresh_subman (job);

/* count the enabled repos */
repos = dnf_context_get_repos (job_data->context);
for (i = 0; i < repos->len; i++) {
Expand Down