Skip to content

Commit

Permalink
compose: Add and use treefile API to get automatic version suffix
Browse files Browse the repository at this point in the history
Instead of parsing JSON, prep for dropping our JSON C parsing.
  • Loading branch information
cgwalters committed Jun 6, 2022
1 parent bf188ae commit f0a28fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions rust/src/lib.rs
Expand Up @@ -534,6 +534,7 @@ pub mod ffi {
fn get_recommends(&self) -> bool;
fn get_selinux(&self) -> bool;
fn get_gpg_key(&self) -> String;
fn get_automatic_version_suffix(&self) -> String;
fn get_container(&self) -> bool;
fn get_machineid_compat(&self) -> bool;
fn get_etc_group_members(&self) -> Vec<String>;
Expand Down
8 changes: 8 additions & 0 deletions rust/src/treefile.rs
Expand Up @@ -1279,6 +1279,14 @@ impl Treefile {
self.parsed.base.gpg_key.clone().unwrap_or_default()
}

pub(crate) fn get_automatic_version_suffix(&self) -> String {
self.parsed
.base
.automatic_version_suffix
.clone()
.unwrap_or_default()
}

pub(crate) fn get_container(&self) -> bool {
self.parsed.base.container.unwrap_or(false)
}
Expand Down
7 changes: 2 additions & 5 deletions src/app/rpmostree-compose-builtin-tree.cxx
Expand Up @@ -922,10 +922,7 @@ impl_install_tree (RpmOstreeTreeComposeContext *self, gboolean *out_changed,
!g_hash_table_contains (self->metadata, OSTREE_COMMIT_META_KEY_VERSION))
{
CXX_TRY_VAR (ver_prefix, (*self->treefile_rs)->require_automatic_version_prefix (), error);
const char *ver_suffix = NULL;
if (!_rpmostree_jsonutil_object_get_optional_string_member (
self->treefile, "automatic-version-suffix", &ver_suffix, error))
return FALSE;
auto ver_suffix = (*self->treefile_rs)->get_automatic_version_suffix ();

g_autofree char *last_version = NULL;
if (self->previous_checksum)
Expand All @@ -941,7 +938,7 @@ impl_install_tree (RpmOstreeTreeComposeContext *self, gboolean *out_changed,
}

CXX_TRY_VAR (next_versionv,
rpmostreecxx::util_next_version (ver_prefix.c_str (), ver_suffix ?: "",
rpmostreecxx::util_next_version (ver_prefix.c_str (), ver_suffix.c_str (),
last_version ?: ""),
error);
next_version = std::move (next_versionv);
Expand Down

0 comments on commit f0a28fc

Please sign in to comment.