Skip to content

Commit

Permalink
fixup! deployment: add _ostree_deployment_get_version API
Browse files Browse the repository at this point in the history
  • Loading branch information
r4f4 committed Aug 2, 2021
1 parent 39be4f8 commit 2ab65af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/libostree/ostree-deployment-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct _OstreeDeployment
};

void _ostree_deployment_set_bootcsum (OstreeDeployment *self, const char *bootcsum);
char *_ostree_deployment_get_version (OstreeDeployment *self, OstreeRepo *repo, GError **error);
const char *_ostree_deployment_get_version (OstreeDeployment *self, OstreeRepo *repo);

void _ostree_deployment_set_overlay_initrds (OstreeDeployment *self,
char **overlay_initrds);
Expand Down
29 changes: 14 additions & 15 deletions src/libostree/ostree-deployment.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,27 @@ ostree_deployment_get_bootserial (OstreeDeployment *self)
return self->bootserial;
}

char *
const char *
_ostree_deployment_get_version (OstreeDeployment *self,
OstreeRepo *repo,
GError **error)
OstreeRepo *repo)
{
g_return_val_if_fail (repo != NULL, NULL);

if (self->version_is_cached)
return self->version;

/* Try extracting a version for this deployment. */
const gchar *csum = ostree_deployment_get_csum (self);
if (!self->version_is_cached)
{
/* Try extracting a version for this deployment. */
const gchar *csum = ostree_deployment_get_csum (self);

g_autoptr(GVariant) variant = NULL;
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, csum,
&variant, error))
return NULL;
g_autoptr(GVariant) variant = NULL;
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, csum,
&variant, NULL))
return NULL;

g_autoptr(GVariant) metadata = g_variant_get_child_value (variant, 0);
g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", &self->version);
g_autoptr(GVariant) metadata = g_variant_get_child_value (variant, 0);
g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", &self->version);

self->version_is_cached = TRUE;
self->version_is_cached = TRUE;
}

return self->version;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,

const gchar *deployment_version = NULL;
if (repo)
deployment_version = _ostree_deployment_get_version (deployment, repo, error);
deployment_version = _ostree_deployment_get_version (deployment, repo);

/* XXX The SYSLINUX bootloader backend actually parses the title string
* (specifically, it looks for the substring "(ostree"), so further
Expand Down

0 comments on commit 2ab65af

Please sign in to comment.