(refactor) Move pkgcache helper function to sysroot-core

Trying to drain the `util.c` file; this one lives more logically
there.

Closes: #1086
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-11-07 13:45:49 -05:00 committed by Atomic Bot
parent 8b4c5e0901
commit 7ea2a5afce
6 changed files with 35 additions and 34 deletions

View File

@ -142,6 +142,31 @@ add_package_refs_to_set (RpmOstreeRefSack *rsack,
return TRUE;
}
/* The pkgcache is in extensions/; see also
* https://github.com/projectatomic/rpm-ostree/pull/1055
*/
gboolean
rpmostree_syscore_get_pkgcache_repo (OstreeRepo *parent,
OstreeRepo **out_pkgcache,
GCancellable *cancellable,
GError **error)
{
if (!glnx_shutil_mkdir_p_at (ostree_repo_get_dfd (parent),
"extensions/rpmostree", 0755,
cancellable, error))
return FALSE;
g_autoptr(OstreeRepo) pkgcache =
ostree_repo_create_at (ostree_repo_get_dfd (parent),
"extensions/rpmostree/pkgcache",
OSTREE_REPO_MODE_BARE, NULL,
cancellable, error);
if (!pkgcache)
return FALSE;
*out_pkgcache = g_steal_pointer (&pkgcache);
return TRUE;
}
/* Loop over all deployments, gathering all referenced NEVRAs for
* layered packages. Then delete any cached pkg refs that aren't in
* that set.
@ -157,7 +182,7 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot,
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_autoptr(OstreeRepo) pkgcache_repo = NULL;
if (!rpmostree_get_pkgcache_repo (repo, &pkgcache_repo, cancellable, error))
if (!rpmostree_syscore_get_pkgcache_repo (repo, &pkgcache_repo, cancellable, error))
return FALSE;
g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);

View File

@ -41,7 +41,11 @@ OstreeDeployment *rpmostree_syscore_get_origin_merge_deployment (OstreeSysroot *
gboolean rpmostree_syscore_bump_mtime (OstreeSysroot *self, GError **error);
gboolean
rpmostree_syscore_get_pkgcache_repo (OstreeRepo *parent,
OstreeRepo **out_pkgcache,
GCancellable *cancellable,
GError **error);
#define RPMOSTREE_LIVE_INPROGRESS_XATTR "user.rpmostree-live-inprogress"
#define RPMOSTREE_LIVE_REPLACED_XATTR "user.rpmostree-live-replaced"

View File

@ -614,7 +614,7 @@ finalize_replacement_overrides (RpmOstreeSysrootUpgrader *self,
g_autoptr(GPtrArray) inactive_replacements = g_ptr_array_new ();
g_autoptr(OstreeRepo) pkgcache_repo = NULL;
if (!rpmostree_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
if (!rpmostree_syscore_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
return FALSE;
GLNX_HASH_TABLE_FOREACH_KV (local_replacements, const char*, nevra, const char*, sha256)
@ -689,7 +689,7 @@ finalize_overlays (RpmOstreeSysrootUpgrader *self,
return FALSE;
g_autoptr(OstreeRepo) pkgcache_repo = NULL;
if (!rpmostree_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
if (!rpmostree_syscore_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
return FALSE;
GLNX_HASH_TABLE_FOREACH_KV (local_pkgs, const char*, nevra, const char*, sha256)
@ -823,7 +823,7 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self,
return FALSE;
g_autoptr(OstreeRepo) pkgcache_repo = NULL;
if (!rpmostree_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
if (!rpmostree_syscore_get_pkgcache_repo (self->repo, &pkgcache_repo, cancellable, error))
return FALSE;
rpmostree_context_set_repos (self->ctx, self->repo, pkgcache_repo);

View File

@ -482,7 +482,7 @@ import_local_rpm (OstreeRepo *parent,
* need relabeling and that's OK.
* */
if (!rpmostree_get_pkgcache_repo (parent, &pkgcache_repo, cancellable, error))
if (!rpmostree_syscore_get_pkgcache_repo (parent, &pkgcache_repo, cancellable, error))
return FALSE;
/* let's just use the current sepolicy -- we'll just relabel it if the new

View File

@ -517,28 +517,6 @@ rpmostree_deployment_get_layered_info (OstreeRepo *repo,
return TRUE;
}
gboolean
rpmostree_get_pkgcache_repo (OstreeRepo *parent,
OstreeRepo **out_pkgcache,
GCancellable *cancellable,
GError **error)
{
if (!glnx_shutil_mkdir_p_at (ostree_repo_get_dfd (parent),
"extensions/rpmostree", 0755,
cancellable, error))
return FALSE;
g_autoptr(OstreeRepo) pkgcache =
ostree_repo_create_at (ostree_repo_get_dfd (parent),
"extensions/rpmostree/pkgcache",
OSTREE_REPO_MODE_BARE, NULL,
cancellable, error);
if (!pkgcache)
return FALSE;
*out_pkgcache = g_steal_pointer (&pkgcache);
return TRUE;
}
gboolean
rpmostree_decompose_sha256_nevra (const char **nevra, /* gets incremented */
char **out_sha256,

View File

@ -112,12 +112,6 @@ rpmostree_deployment_get_layered_info (OstreeRepo *repo,
GVariant **out_replaced_base_pkgs,
GError **error);
gboolean
rpmostree_get_pkgcache_repo (OstreeRepo *parent,
OstreeRepo **out_pkgcache,
GCancellable *cancellable,
GError **error);
gboolean
rpmostree_decompose_sha256_nevra (const char **nevra,
char **sha256,