diff --git a/docs/manual/treefile.md b/docs/manual/treefile.md index 106519de..0a4c47f4 100644 --- a/docs/manual/treefile.md +++ b/docs/manual/treefile.md @@ -204,9 +204,10 @@ It supports the following parameters: will cause systemd to execute `ConditionFirstBoot=`, which implies running `systemctl preset-all` for example. This requires booting the system with `rw` so that systemd can properly populate `/etc/machine-id` and execute - the presets at switchroot. If you enable this, avoid using the `units` - member, as it will no longer function. Instead, create a - `/usr/lib/systemd/system-presets/XX-example.preset` file. + the presets at switchroot. When this is enabled, the `units` + directive will no longer function. Instead, create a + `/usr/lib/systemd/system-presets/XX-example.preset` file as part of a package + or in the postprocess script. Experimental options -------- diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index 4b13b225..91fd7c29 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -1476,6 +1476,11 @@ rpmostree_treefile_postprocessing (int rootfs_fd, if (!rename_if_exists (rootfs_fd, "etc", rootfs_fd, "usr/etc", error)) return FALSE; + gboolean machineid_compat = TRUE; + if (!_rpmostree_jsonutil_object_get_optional_boolean_member (treefile, "machineid-compat", + &machineid_compat, error)) + return FALSE; + JsonArray *units = NULL; if (json_object_has_member (treefile, "units")) units = json_object_get_array_member (treefile, "units"); @@ -1486,6 +1491,9 @@ rpmostree_treefile_postprocessing (int rootfs_fd, else len = 0; + if (len > 0 && !machineid_compat) + return glnx_throw (error, "'units' directive is incompatible with machineid-compat = false"); + { glnx_autofd int multiuser_wants_dfd = -1; diff --git a/tests/compose-tests/test-basic.sh b/tests/compose-tests/test-basic.sh index 45e5d56e..c5fd9cfb 100755 --- a/tests/compose-tests/test-basic.sh +++ b/tests/compose-tests/test-basic.sh @@ -16,6 +16,7 @@ cat > metadata.json < preset.txt assert_file_has_content preset.txt '^enable ostree-remount.service$' +# https://github.com/projectatomic/rpm-ostree/pull/1425 +ostree --repo=${repobuild} ls ${treeref} /usr/etc > ls.txt +assert_not_file_has_content ls.txt 'machine-id' +echo "ok machine-id" + if ! rpm-ostree --version | grep -q rust; then echo "ok yaml (SKIP)" else diff --git a/tests/compose-tests/test-misc-tweaks.sh b/tests/compose-tests/test-misc-tweaks.sh index 7822f18b..ccb2c09d 100755 --- a/tests/compose-tests/test-misc-tweaks.sh +++ b/tests/compose-tests/test-misc-tweaks.sh @@ -14,7 +14,6 @@ pysetjsonmember "documentation" "False" # $ rpm -qlv systemd|grep -F 'system/default.target ' # lrwxrwxrwx 1 root root 16 May 11 06:59 /usr/lib/systemd/system/default.target -> graphical.target pysetjsonmember "default_target" '"multi-user.target"' -pysetjsonmember "machineid-compat" 'False' pysetjsonmember "units" '["tuned.service"]' # And test adding/removing files pysetjsonmember "add-files" '[["foo.txt", "/usr/etc/foo.txt"], @@ -83,8 +82,3 @@ echo "ok remove-from-packages" ostree --repo=${repobuild} ls ${treeref} /tmp > ls.txt assert_file_has_content ls.txt 'd01777 0 0 0 /tmp' echo "ok /tmp" - -# https://github.com/projectatomic/rpm-ostree/pull/1425 -ostree --repo=${repobuild} ls ${treeref} /usr/etc > ls.txt -assert_not_file_has_content ls.txt 'machine-id' -echo "ok machine-id"