Skip to content

Commit

Permalink
postprocess: Allow add-files into /etc
Browse files Browse the repository at this point in the history
Even though it's really `/usr/etc`. This is for greater consistency with
`postprocess-script` where it appears as `/etc`.

Closes: #997
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Sep 28, 2017
1 parent 4528782 commit 2e59a27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/libpriv/rpmostree-postprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,17 @@ rpmostree_copy_additional_files (int rootfs_dfd,
dest += strspn (dest, "/");
if (!*dest)
return glnx_throw (error, "Invalid destination in add-files");
/* At this point on the filesystem level, the /etc content is already in
* /usr/etc. But let's be nice and allow people to use add-files into /etc
* and have it appear in /usr/etc; in most cases we want /usr/etc to just
* be a libostree implementation detail.
*/
g_autofree char *dest_owned = NULL;
if (g_str_has_prefix (dest, "etc/"))
{
dest_owned = g_strconcat ("usr/", dest, NULL);
dest = dest_owned;
}

g_print ("Adding file '%s'\n", dest);

Expand Down
10 changes: 9 additions & 1 deletion tests/compose-tests/test-misc-tweaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ pysetjsonmember "default_target" '"multi-user.target"'
pyappendjsonmember "packages" '["tuned"]'
pysetjsonmember "units" '["tuned.service"]'
# And test adding/removing files
pysetjsonmember "add-files" '[["foo.txt", "/usr/etc/foo.txt"]]'
pysetjsonmember "add-files" '[["foo.txt", "/usr/etc/foo.txt"],
["baz.txt", "/usr/share/baz.txt"],
["bar.txt", "/etc/bar.txt"]]'
pysetjsonmember "remove-files" '["etc/hosts"]'
pysetjsonmember "remove-from-packages" '[["setup", "/etc/hosts\..*"]]'
rnd=$RANDOM
echo $rnd > composedata/foo.txt
echo bar > composedata/bar.txt
echo baz > composedata/baz.txt
# Test tmp-is-dir
pysetjsonmember "tmp-is-dir" 'True'

Expand All @@ -44,6 +48,10 @@ echo "ok enable units"
# Tests for files
ostree --repo=${repobuild} cat ${treeref} /usr/etc/foo.txt > out.txt
assert_file_has_content out.txt $rnd
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
echo "ok add-files"

ostree --repo=${repobuild} ls ${treeref} /usr/etc > out.txt
Expand Down

0 comments on commit 2e59a27

Please sign in to comment.