compose: Copy in additional files before postprocessing
Sometimes it's useful to have access to the additional files when running the post script, so this re-orders the compose process to copy the additional files in before the post script runs Signed-off-by: Jonathan Dieter <jdieter@lesbg.com> Closes: #997 Approved by: jlebon
This commit is contained in:
parent
2e59a2748d
commit
fd6109af1d
@ -934,9 +934,6 @@ impl_compose_tree (const char *treefile_pathstr,
|
||||
cancellable, error))
|
||||
return glnx_prefix_error (error, "Preparing rootfs for commit");
|
||||
|
||||
if (!rpmostree_copy_additional_files (rootfs_fd, self->treefile_context_dirs->pdata[0], treefile, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_autoptr(GFile) treefile_dirpath = g_file_get_parent (self->treefile);
|
||||
if (!rpmostree_check_passwd (self->repo, rootfs_fd, treefile_dirpath, treefile,
|
||||
self->previous_checksum,
|
||||
|
@ -1225,18 +1225,15 @@ rpmostree_rootfs_postprocess_common (int rootfs_fd,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* rpmostree_copy_additional_files:
|
||||
*
|
||||
* Copy external files, if specified in the configuration file, from
|
||||
/* Copy external files, if specified in the configuration file, from
|
||||
* the context directory to the rootfs.
|
||||
*/
|
||||
gboolean
|
||||
rpmostree_copy_additional_files (int rootfs_dfd,
|
||||
GFile *context_directory,
|
||||
JsonObject *treefile,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
static gboolean
|
||||
copy_additional_files (int rootfs_dfd,
|
||||
GFile *context_directory,
|
||||
JsonObject *treefile,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
guint len;
|
||||
JsonArray *add = NULL;
|
||||
@ -1581,6 +1578,10 @@ rpmostree_treefile_postprocessing (int rootfs_fd,
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy in additional files before postprocessing */
|
||||
if (!copy_additional_files (rootfs_fd, context_directory, treefile, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
const char *postprocess_script = NULL;
|
||||
if (!_rpmostree_jsonutil_object_get_optional_string_member (treefile, "postprocess-script",
|
||||
&postprocess_script, error))
|
||||
|
@ -78,9 +78,3 @@ rpmostree_commit (int rootfs_dfd,
|
||||
char **out_new_revision,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean
|
||||
rpmostree_copy_additional_files (int rootfs_dfd,
|
||||
GFile *context_directory,
|
||||
JsonObject *treefile,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
@ -16,6 +16,15 @@ pysetjsonmember "units" '["tuned.service"]'
|
||||
pysetjsonmember "add-files" '[["foo.txt", "/usr/etc/foo.txt"],
|
||||
["baz.txt", "/usr/share/baz.txt"],
|
||||
["bar.txt", "/etc/bar.txt"]]'
|
||||
pysetjsonmember "postprocess-script" \"$PWD/postprocess.sh\"
|
||||
cat > postprocess.sh << EOF
|
||||
#!/bin/bash
|
||||
set -xeuo pipefail
|
||||
echo misc-tweaks-postprocess-done > /usr/share/misc-tweaks-postprocess-done.txt
|
||||
cp -a /usr/etc/foo.txt /usr/share/misc-tweaks-foo.txt
|
||||
EOF
|
||||
chmod a+x postprocess.sh
|
||||
|
||||
pysetjsonmember "remove-files" '["etc/hosts"]'
|
||||
pysetjsonmember "remove-from-packages" '[["setup", "/etc/hosts\..*"]]'
|
||||
rnd=$RANDOM
|
||||
@ -52,6 +61,9 @@ ostree --repo=${repobuild} cat ${treeref} /usr/etc/bar.txt > out.txt
|
||||
assert_file_has_content out.txt bar
|
||||
ostree --repo=${repobuild} cat ${treeref} /usr/share/baz.txt > out.txt
|
||||
assert_file_has_content out.txt baz
|
||||
# https://github.com/projectatomic/rpm-ostree/pull/997
|
||||
ostree --repo=${repobuild} cat ${treeref} /usr/share/misc-tweaks-foo.txt > out.txt
|
||||
assert_file_has_content out.txt $rnd
|
||||
echo "ok add-files"
|
||||
|
||||
ostree --repo=${repobuild} ls ${treeref} /usr/etc > out.txt
|
||||
|
Loading…
Reference in New Issue
Block a user