|
|
985467 |
commit f0d7217508131a006d19128c2988a43e44107418
|
|
|
985467 |
Author: Richard Hughes <richard@hughsie.com>
|
|
|
985467 |
Date: Mon Jul 13 12:02:12 2015 +0100
|
|
|
985467 |
|
|
|
985467 |
Support enrollment engines such as subscription-manager
|
|
|
985467 |
|
|
|
985467 |
This is perhaps non-optimal as we have to parse the list of repos twice, but
|
|
|
985467 |
does allow the enrollment engine to add and remove sources as required.
|
|
|
985467 |
|
|
|
985467 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1223417
|
|
|
985467 |
|
|
|
985467 |
diff --git a/libhif/hif-context.c b/libhif/hif-context.c
|
|
|
985467 |
index 57bda46..454af8a 100644
|
|
|
985467 |
--- a/libhif/hif-context.c
|
|
|
985467 |
+++ b/libhif/hif-context.c
|
|
|
985467 |
@@ -66,6 +66,7 @@ struct _HifContextPrivate
|
|
|
985467 |
gboolean only_trusted;
|
|
|
985467 |
gboolean enable_yumdb;
|
|
|
985467 |
gboolean keep_cache;
|
|
|
985467 |
+ gboolean enrollment_valid;
|
|
|
985467 |
HifLock *lock;
|
|
|
985467 |
HifTransaction *transaction;
|
|
|
985467 |
GThread *transaction_thread;
|
|
|
985467 |
@@ -1199,6 +1200,43 @@ hif_context_set_http_proxy (HifContext *context,
|
|
|
985467 |
#define MAX_NATIVE_ARCHES 12
|
|
|
985467 |
|
|
|
985467 |
/**
|
|
|
985467 |
+ * hif_context_setup_enrollments:
|
|
|
985467 |
+ * @context: a #HifContext instance.
|
|
|
985467 |
+ * @error: A #GError or %NULL
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * Resyncs the enrollment with the vendor system. This may change the contents
|
|
|
985467 |
+ * of files in repos.d according to subscription levels.
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * Returns: %TRUE for success, %FALSE otherwise
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * Since: 0.2.1
|
|
|
985467 |
+ **/
|
|
|
985467 |
+gboolean
|
|
|
985467 |
+hif_context_setup_enrollments (HifContext *context, GError **error)
|
|
|
985467 |
+{
|
|
|
985467 |
+ HifContextPrivate *priv = GET_PRIVATE (context);
|
|
|
985467 |
+ guint i;
|
|
|
985467 |
+ const gchar *cmds[] = { "/usr/sbin/rhn-profile-sync",
|
|
|
985467 |
+ "/usr/bin/subscription-manager refresh",
|
|
|
985467 |
+ NULL };
|
|
|
985467 |
+
|
|
|
985467 |
+ /* no need to refresh */
|
|
|
985467 |
+ if (priv->enrollment_valid)
|
|
|
985467 |
+ return TRUE;
|
|
|
985467 |
+
|
|
|
985467 |
+ for (i = 0; cmds[i] != NULL; i++) {
|
|
|
985467 |
+ _cleanup_strv_free_ gchar **argv = g_strsplit (cmds[i], " ", -1);
|
|
|
985467 |
+ if (!g_file_test (argv[0], G_FILE_TEST_EXISTS))
|
|
|
985467 |
+ continue;
|
|
|
985467 |
+ g_debug ("Running: %s", cmds[i]);
|
|
|
985467 |
+ if (!g_spawn_command_line_sync (cmds[i], NULL, NULL, NULL, error))
|
|
|
985467 |
+ return FALSE;
|
|
|
985467 |
+ }
|
|
|
985467 |
+ priv->enrollment_valid = TRUE;
|
|
|
985467 |
+ return TRUE;
|
|
|
985467 |
+}
|
|
|
985467 |
+
|
|
|
985467 |
+/**
|
|
|
985467 |
* hif_context_setup:
|
|
|
985467 |
* @context: a #HifContext instance.
|
|
|
985467 |
* @cancellable: A #GCancellable or %NULL
|
|
|
985467 |
@@ -1373,6 +1411,10 @@ hif_context_setup (HifContext *context,
|
|
|
985467 |
if (!hif_context_copy_vendor_solv (context, error))
|
|
|
985467 |
return FALSE;
|
|
|
985467 |
|
|
|
985467 |
+ /* initialize external frameworks where installed */
|
|
|
985467 |
+ if (!hif_context_setup_enrollments (context, error))
|
|
|
985467 |
+ return FALSE;
|
|
|
985467 |
+
|
|
|
985467 |
return TRUE;
|
|
|
985467 |
}
|
|
|
985467 |
|
|
|
985467 |
@@ -1730,6 +1772,30 @@ hif_context_commit (HifContext *context, HifState *state, GError **error)
|
|
|
985467 |
}
|
|
|
985467 |
|
|
|
985467 |
/**
|
|
|
985467 |
+ * hif_context_invalidate_full:
|
|
|
985467 |
+ * @context: a #HifContext instance.
|
|
|
985467 |
+ * @message: the reason for invalidating
|
|
|
985467 |
+ * @flags: a #HifContextInvalidateFlags, e.g. %HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * Informs the context that the certain parts of the context may no longer be
|
|
|
985467 |
+ * in sync or valid.
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * Since: 0.2.1
|
|
|
985467 |
+ **/
|
|
|
985467 |
+void
|
|
|
985467 |
+hif_context_invalidate_full (HifContext *context,
|
|
|
985467 |
+ const gchar *message,
|
|
|
985467 |
+ HifContextInvalidateFlags flags)
|
|
|
985467 |
+{
|
|
|
985467 |
+ HifContextPrivate *priv = GET_PRIVATE (context);
|
|
|
985467 |
+ g_debug ("Msg: %s", message);
|
|
|
985467 |
+ if (flags & HIF_CONTEXT_INVALIDATE_FLAG_RPMDB)
|
|
|
985467 |
+ g_signal_emit (context, signals [SIGNAL_INVALIDATE], 0, message);
|
|
|
985467 |
+ if (flags & HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT)
|
|
|
985467 |
+ priv->enrollment_valid = FALSE;
|
|
|
985467 |
+}
|
|
|
985467 |
+
|
|
|
985467 |
+/**
|
|
|
985467 |
* hif_context_invalidate:
|
|
|
985467 |
* @context: a #HifContext instance.
|
|
|
985467 |
* @message: the reason for invalidating
|
|
|
985467 |
@@ -1741,7 +1807,8 @@ hif_context_commit (HifContext *context, HifState *state, GError **error)
|
|
|
985467 |
void
|
|
|
985467 |
hif_context_invalidate (HifContext *context, const gchar *message)
|
|
|
985467 |
{
|
|
|
985467 |
- g_signal_emit (context, signals [SIGNAL_INVALIDATE], 0, message);
|
|
|
985467 |
+ hif_context_invalidate_full (context, message,
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_RPMDB);
|
|
|
985467 |
}
|
|
|
985467 |
|
|
|
985467 |
/**
|
|
|
985467 |
diff --git a/libhif/hif-context.h b/libhif/hif-context.h
|
|
|
985467 |
index ee7a7eb..7aaa8cc 100644
|
|
|
985467 |
--- a/libhif/hif-context.h
|
|
|
985467 |
+++ b/libhif/hif-context.h
|
|
|
985467 |
@@ -65,6 +65,22 @@ struct _HifContextClass
|
|
|
985467 |
void (*_hif_reserved8) (void);
|
|
|
985467 |
};
|
|
|
985467 |
|
|
|
985467 |
+/**
|
|
|
985467 |
+ * HifContextInvalidateFlags:
|
|
|
985467 |
+ * @HIF_CONTEXT_INVALIDATE_FLAG_NONE: No caches are invalid
|
|
|
985467 |
+ * @HIF_CONTEXT_INVALIDATE_FLAG_RPMDB: The rpmdb cache is invalid
|
|
|
985467 |
+ * @HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT: Any enrollment may be invalid
|
|
|
985467 |
+ *
|
|
|
985467 |
+ * The update flags.
|
|
|
985467 |
+ **/
|
|
|
985467 |
+typedef enum {
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_NONE = 0,
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_RPMDB = 1,
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT = 2,
|
|
|
985467 |
+ /*< private >*/
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_LAST
|
|
|
985467 |
+} HifContextInvalidateFlags;
|
|
|
985467 |
+
|
|
|
985467 |
GType hif_context_get_type (void);
|
|
|
985467 |
HifContext *hif_context_new (void);
|
|
|
985467 |
|
|
|
985467 |
@@ -140,6 +156,8 @@ void hif_context_set_http_proxy (HifContext *context,
|
|
|
985467 |
gboolean hif_context_setup (HifContext *context,
|
|
|
985467 |
GCancellable *cancellable,
|
|
|
985467 |
GError **error);
|
|
|
985467 |
+gboolean hif_context_setup_enrollments (HifContext *context,
|
|
|
985467 |
+ GError **error);
|
|
|
985467 |
gboolean hif_context_setup_sack (HifContext *context,
|
|
|
985467 |
HifState *state,
|
|
|
985467 |
GError **error);
|
|
|
985467 |
@@ -148,6 +166,9 @@ gboolean hif_context_commit (HifContext *context,
|
|
|
985467 |
GError **error);
|
|
|
985467 |
void hif_context_invalidate (HifContext *context,
|
|
|
985467 |
const gchar *message);
|
|
|
985467 |
+void hif_context_invalidate_full (HifContext *context,
|
|
|
985467 |
+ const gchar *message,
|
|
|
985467 |
+ HifContextInvalidateFlags flags);
|
|
|
985467 |
gboolean hif_context_install (HifContext *context,
|
|
|
985467 |
const gchar *name,
|
|
|
985467 |
GError **error);
|
|
|
985467 |
diff --git a/libhif/hif-repos.c b/libhif/hif-repos.c
|
|
|
985467 |
index 7554289..44af677 100644
|
|
|
985467 |
--- a/libhif/hif-repos.c
|
|
|
985467 |
+++ b/libhif/hif-repos.c
|
|
|
985467 |
@@ -88,6 +88,8 @@ hif_repos_invalidate (HifRepos *repos)
|
|
|
985467 |
{
|
|
|
985467 |
HifReposPrivate *priv = GET_PRIVATE (repos);
|
|
|
985467 |
priv->loaded = FALSE;
|
|
|
985467 |
+ hif_context_invalidate_full (priv->context, "repos.d invalidated",
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT);
|
|
|
985467 |
}
|
|
|
985467 |
|
|
|
985467 |
/**
|
|
|
985467 |
@@ -424,6 +426,10 @@ hif_repos_refresh (HifRepos *repos, GError **error)
|
|
|
985467 |
hif_repos_invalidate (repos);
|
|
|
985467 |
g_ptr_array_set_size (priv->sources, 0);
|
|
|
985467 |
|
|
|
985467 |
+ /* re-populate redhat.repo */
|
|
|
985467 |
+ if (!hif_context_setup_enrollments (priv->context, error))
|
|
|
985467 |
+ return FALSE;
|
|
|
985467 |
+
|
|
|
985467 |
/* open dir */
|
|
|
985467 |
repo_path = hif_context_get_repo_dir (priv->context);
|
|
|
985467 |
dir = g_dir_open (repo_path, 0, error);
|
|
|
985467 |
diff --git a/libhif/hif-source.c b/libhif/hif-source.c
|
|
|
985467 |
index 026c919..3e46027 100644
|
|
|
985467 |
--- a/libhif/hif-source.c
|
|
|
985467 |
+++ b/libhif/hif-source.c
|
|
|
985467 |
@@ -1484,6 +1484,10 @@ hif_source_update (HifSource *source,
|
|
|
985467 |
if (!ret)
|
|
|
985467 |
goto out;
|
|
|
985467 |
|
|
|
985467 |
+ /* signal that the vendor platform data is not resyned */
|
|
|
985467 |
+ hif_context_invalidate_full (priv->context, "updated repo cache",
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT);
|
|
|
985467 |
+
|
|
|
985467 |
/* done */
|
|
|
985467 |
ret = hif_state_done (state, error);
|
|
|
985467 |
if (!ret)
|
|
|
985467 |
diff --git a/libhif/hif-transaction.c b/libhif/hif-transaction.c
|
|
|
985467 |
index f7e9b17..24a59a4 100644
|
|
|
985467 |
--- a/libhif/hif-transaction.c
|
|
|
985467 |
+++ b/libhif/hif-transaction.c
|
|
|
985467 |
@@ -1428,7 +1428,9 @@ hif_transaction_commit (HifTransaction *transaction,
|
|
|
985467 |
}
|
|
|
985467 |
|
|
|
985467 |
/* all sacks are invalid now */
|
|
|
985467 |
- hif_context_invalidate (priv->context, "transaction performed");
|
|
|
985467 |
+ hif_context_invalidate_full (priv->context, "transaction performed",
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_RPMDB |
|
|
|
985467 |
+ HIF_CONTEXT_INVALIDATE_FLAG_ENROLLMENT);
|
|
|
985467 |
|
|
|
985467 |
/* this section done */
|
|
|
985467 |
ret = hif_state_done (state, error);
|
|
|
985467 |
commit 733c14386165edb05c4d6e456778a5403f87b908
|
|
|
985467 |
Author: Colin Walters <walters@verbum.org>
|
|
|
985467 |
Date: Sat Jul 18 10:35:07 2015 -0400
|
|
|
985467 |
|
|
|
985467 |
context: Don't do entitlements for alternative install roots
|
|
|
985467 |
|
|
|
985467 |
Using rpm-ostree shouldn't try to check or update my host repo's
|
|
|
985467 |
entitlement status.
|
|
|
985467 |
|
|
|
985467 |
Conflicts:
|
|
|
985467 |
libhif/hif-context.c
|
|
|
985467 |
|
|
|
985467 |
diff --git a/libhif/hif-context.c b/libhif/hif-context.c
|
|
|
985467 |
index 454af8a..c259fa9 100644
|
|
|
985467 |
--- a/libhif/hif-context.c
|
|
|
985467 |
+++ b/libhif/hif-context.c
|
|
|
985467 |
@@ -1224,6 +1224,15 @@ hif_context_setup_enrollments (HifContext *context, GError **error)
|
|
|
985467 |
if (priv->enrollment_valid)
|
|
|
985467 |
return TRUE;
|
|
|
985467 |
|
|
|
985467 |
+ /* Let's assume that alternative installation roots don't
|
|
|
985467 |
+ * require entitlement. We only want to do system things if
|
|
|
985467 |
+ * we're actually affecting the system. A more accurate test
|
|
|
985467 |
+ * here would be checking that we're using /etc/yum.repos.d or
|
|
|
985467 |
+ * so, but that can come later.
|
|
|
985467 |
+ */
|
|
|
985467 |
+ if (g_strcmp0 (priv->install_root, "/") != 0)
|
|
|
985467 |
+ return TRUE;
|
|
|
985467 |
+
|
|
|
985467 |
for (i = 0; cmds[i] != NULL; i++) {
|
|
|
985467 |
_cleanup_strv_free_ gchar **argv = g_strsplit (cmds[i], " ", -1);
|
|
|
985467 |
if (!g_file_test (argv[0], G_FILE_TEST_EXISTS))
|