daemon: Add an origin_is_rojig() helper

Suggested in another PR review, it makes the code nicer.

Closes: #1252
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-02-13 15:11:36 -05:00 committed by Atomic Bot
parent 799a809c2d
commit 528456a59f
4 changed files with 17 additions and 20 deletions

View File

@ -198,9 +198,6 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot,
if (!origin)
return FALSE;
RpmOstreeRefspecType refspectype;
rpmostree_origin_classify_refspec (origin, &refspectype, NULL);
/* Hold a ref to layered packages; actually right now this injects refs
* for *all* packages since we don't have an API to query out which
* packages are layered. But it's harmless to have nonexistent refs in the
@ -226,7 +223,7 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot,
/* In rojig mode, we need to also reference packages from the base; this
* is a different refspec format.
*/
if (refspectype == RPMOSTREE_REFSPEC_TYPE_ROJIG)
if (rpmostree_origin_is_rojig (origin))
{
const char *actual_base_commit = base_commit ?: current_checksum;
g_autoptr(RpmOstreeRefSack) base_rsack =

View File

@ -866,23 +866,14 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self,
cancellable, error))
return FALSE;
RpmOstreeRefspecType refspec_type;
const char *refspec;
rpmostree_origin_classify_refspec (self->origin, &refspec_type, &refspec);
switch (refspec_type)
if (rpmostree_origin_is_rojig (self->origin))
{
case RPMOSTREE_REFSPEC_TYPE_OSTREE:
break;
case RPMOSTREE_REFSPEC_TYPE_ROJIG:
{
/* We don't want to re-check the metadata, we already did that for the
* base. In the future we should try to re-use the DnfContext.
*/
g_autoptr(DnfState) hifstate = dnf_state_new ();
if (!dnf_context_setup_sack (rpmostree_context_get_dnf (self->ctx), hifstate, error))
return FALSE;
}
break;
/* We don't want to re-check the metadata, we already did that for the
* base. In the future we should try to re-use the DnfContext.
*/
g_autoptr(DnfState) hifstate = dnf_state_new ();
if (!dnf_context_setup_sack (rpmostree_context_get_dnf (self->ctx), hifstate, error))
return FALSE;
}
const gboolean have_packages = (self->overlay_packages->len > 0 ||

View File

@ -198,6 +198,13 @@ rpmostree_origin_get_full_refspec (RpmOstreeOrigin *origin,
return NULL;
}
/* Returns: TRUE iff the origin type is rpm-ostree jigdo */
gboolean
rpmostree_origin_is_rojig (RpmOstreeOrigin *origin)
{
return origin->refspec_type == RPMOSTREE_REFSPEC_TYPE_ROJIG;
}
void
rpmostree_origin_classify_refspec (RpmOstreeOrigin *origin,
RpmOstreeRefspecType *out_type,

View File

@ -64,6 +64,8 @@ char *
rpmostree_origin_get_full_refspec (RpmOstreeOrigin *origin,
RpmOstreeRefspecType *out_refspectype);
gboolean rpmostree_origin_is_rojig (RpmOstreeOrigin *origin);
const char *
rpmostree_origin_get_jigdo_version (RpmOstreeOrigin *origin);