compose: Have first-one-wins semantics for rojig parsing

The core bug here is that previously if we had multiple YAML files
in include, we ended up overwriting self->treefile_rs for the
last one. Handling inheritance worked, but it broke rojig since
we generate the specfile Rust side.

Let's have first-one-wins semantics for now.  I have a bigger
fix incoming in https://github.com/projectatomic/rpm-ostree/pull/1574

Closes: #1576
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-09-23 18:37:37 +00:00 committed by Atomic Bot
parent 65bdc08917
commit 2e567840ca

View File

@ -519,19 +519,25 @@ parse_treefile_to_json (RpmOstreeTreeComposeContext *self,
g_str_has_suffix (treefile_path, ".yml")) g_str_has_suffix (treefile_path, ".yml"))
{ {
const char *arch = self ? dnf_context_get_base_arch (rpmostree_context_get_dnf (self->corectx)) : NULL; const char *arch = self ? dnf_context_get_base_arch (rpmostree_context_get_dnf (self->corectx)) : NULL;
self->treefile_rs = ror_treefile_new (treefile_path, arch, g_autoptr(RORTreefile) tf = ror_treefile_new (treefile_path, arch,
self->workdir_dfd, self->workdir_dfd,
error); error);
if (!self->treefile_rs) if (!tf)
return glnx_prefix_error (error, "Failed to load YAML treefile"); return glnx_prefix_error (error, "Failed to load YAML treefile");
glnx_fd_close int json_fd = ror_treefile_to_json (self->treefile_rs, error); glnx_fd_close int json_fd = ror_treefile_to_json (tf, error);
if (json_fd < 0) if (json_fd < 0)
return FALSE; return FALSE;
g_autoptr(GInputStream) json_s = g_unix_input_stream_new (json_fd, FALSE); g_autoptr(GInputStream) json_s = g_unix_input_stream_new (json_fd, FALSE);
if (!json_parser_load_from_stream (parser, json_s, NULL, error)) if (!json_parser_load_from_stream (parser, json_s, NULL, error))
return FALSE; return FALSE;
/* We have first-one-wins semantics for this until we move all of the
* parsing into Rust.
*/
if (!self->treefile_rs)
self->treefile_rs = g_steal_pointer (&tf);
} }
else else
{ {