compose: Accept NULL treefile for "use defaults" postprocessing
This is prep for split-compose. We have some options in the treefile, like `boot_location` and `tmp-is-dir` etc. While those are useful options, I don't want to force everyone using `rpm-ostree compose postprocess` to write a treefile. Change the code then to accept a `NULL` treefile to mean "use the defaults". Closes: #1070 Approved by: jlebon
This commit is contained in:
parent
5da2894823
commit
d02bc4b03c
@ -67,7 +67,8 @@ It supports the following parameters:
|
||||
* `initramfs-args`: Array of strings, optional. Passed to the
|
||||
initramfs generation program (presently `dracut`). An example use
|
||||
case for this with Dracut is `--filesystems xfs,ext4` to ensure
|
||||
specific filesystem drivers are included.
|
||||
specific filesystem drivers are included. If not specified,
|
||||
`--no-hostonly` will be used.
|
||||
|
||||
* `remove-files`: Array of files to delete from the generated tree.
|
||||
|
||||
|
@ -32,16 +32,18 @@ _rpmostree_jsonutil_object_get_optional_string_member (JsonObject *object,
|
||||
const char **out_value,
|
||||
GError **error)
|
||||
{
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
*out_value = NULL;
|
||||
|
||||
if (!object)
|
||||
return TRUE;
|
||||
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
if (node != NULL)
|
||||
{
|
||||
*out_value = json_node_get_string (node);
|
||||
if (!*out_value)
|
||||
return glnx_throw (error, "Member '%s' is not a string", member_name);
|
||||
}
|
||||
else
|
||||
*out_value = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -78,8 +80,14 @@ _rpmostree_jsonutil_object_get_optional_int_member (JsonObject *object,
|
||||
gboolean *found,
|
||||
GError **error)
|
||||
{
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
if (found)
|
||||
*found = FALSE;
|
||||
*out_value = 0;
|
||||
|
||||
if (!object)
|
||||
return TRUE;
|
||||
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
if (node != NULL)
|
||||
{
|
||||
if (!_jsonutil_node_check_int (node))
|
||||
@ -88,12 +96,6 @@ _rpmostree_jsonutil_object_get_optional_int_member (JsonObject *object,
|
||||
*found = TRUE;
|
||||
*out_value = json_node_get_int (node);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (found)
|
||||
*found = FALSE;
|
||||
*out_value = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -118,8 +120,10 @@ _rpmostree_jsonutil_object_get_optional_boolean_member (JsonObject *object,
|
||||
gboolean *out_value,
|
||||
GError **error)
|
||||
{
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
if (!object)
|
||||
return TRUE;
|
||||
|
||||
JsonNode *node = json_object_get_member (object, member_name);
|
||||
if (node != NULL)
|
||||
{
|
||||
if (json_node_get_value_type (node) != G_TYPE_BOOLEAN)
|
||||
|
@ -359,7 +359,7 @@ process_kernel_and_initramfs (int rootfs_dfd,
|
||||
|
||||
/* Run dracut with our chosen arguments (commonly at least --no-hostonly) */
|
||||
g_autoptr(GPtrArray) dracut_argv = g_ptr_array_new ();
|
||||
if (json_object_has_member (treefile, "initramfs-args"))
|
||||
if (treefile && json_object_has_member (treefile, "initramfs-args"))
|
||||
{
|
||||
JsonArray *initramfs_args = json_object_get_array_member (treefile, "initramfs-args");
|
||||
guint len = json_array_get_length (initramfs_args);
|
||||
@ -372,6 +372,11 @@ process_kernel_and_initramfs (int rootfs_dfd,
|
||||
g_ptr_array_add (dracut_argv, (char*)arg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Default to this for treecomposes */
|
||||
g_ptr_array_add (dracut_argv, (char*)"--no-hostonly");
|
||||
}
|
||||
g_ptr_array_add (dracut_argv, NULL);
|
||||
|
||||
g_auto(GLnxTmpfile) initramfs_tmpf = { 0, };
|
||||
@ -872,7 +877,7 @@ postprocess_final (int rootfs_dfd,
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(GHashTable) preserve_groups_set = NULL;
|
||||
if (json_object_has_member (treefile, "etc-group-members"))
|
||||
if (treefile && json_object_has_member (treefile, "etc-group-members"))
|
||||
{
|
||||
JsonArray *etc_group_members = json_object_get_array_member (treefile, "etc-group-members");
|
||||
preserve_groups_set = _rpmostree_jsonutil_jsarray_strings_to_set (etc_group_members);
|
||||
|
Loading…
Reference in New Issue
Block a user