diff --git a/src/app/libmain.cxx b/src/app/libmain.cxx index fee4c6f77e..e9eb11d744 100644 --- a/src/app/libmain.cxx +++ b/src/app/libmain.cxx @@ -273,6 +273,8 @@ rpmostree_option_context_parse (GOptionContext *context, const GOptionEntry *mai bool container_capable = (flags & RPM_OSTREE_BUILTIN_FLAG_CONTAINER_CAPABLE) > 0; if (use_daemon && !(is_ostree_container && container_capable)) { + if (out_sysroot_proxy == NULL) + return glnx_throw (error, "This command can only run in an OSTree container."); /* More gracefully handle the case where * no --sysroot option was specified and we're not booted via ostree * https://github.com/projectatomic/rpm-ostree/issues/1537 diff --git a/src/app/rpmostree-builtin-rebuild.cxx b/src/app/rpmostree-builtin-rebuild.cxx index 108d419643..123a2284f0 100644 --- a/src/app/rpmostree-builtin-rebuild.cxx +++ b/src/app/rpmostree-builtin-rebuild.cxx @@ -41,39 +41,19 @@ rpmostree_ex_builtin_rebuild (int argc, char **argv, RpmOstreeCommandInvocation NULL, NULL, error)) return FALSE; - bool in_container = false; - if (rpmostreecxx::running_in_container ()) - { - CXX_TRY_VAR (is_ostree_container, rpmostreecxx::is_ostree_container (), error); - if (!is_ostree_container) - return glnx_throw (error, "This command can only run in an OSTree container."); - in_container = true; - } - auto basearch = rpmostreecxx::get_rpm_basearch (); CXX_TRY_VAR (treefile, rpmostreecxx::treefile_new_client_from_etc (basearch), error); - /* This is the big switch: we support running this command in two modes: - * "client containers", where the effect takes place in the active rootfs, and - * possibly eventually "client host systems", where the effect takes place in - * a new deployment. */ - if (in_container) - { - if (!rpmostree_container_rebuild (*treefile, cancellable, error)) - return FALSE; + /* Right now we only support running this in a container */ + if (!rpmostree_container_rebuild (*treefile, cancellable, error)) + return FALSE; - /* In the container flow, we effectively "consume" the treefiles after - * modifying the rootfs. */ - CXX_TRY_VAR (n, rpmostreecxx::treefile_delete_client_etc (), error); - if (n == 0) - { - g_print ("No changes to apply.\n"); - } - } - else + /* In the container flow, we effectively "consume" the treefiles after + * modifying the rootfs. */ + CXX_TRY_VAR (n, rpmostreecxx::treefile_delete_client_etc (), error); + if (n == 0) { - return glnx_throw (error, "This command is not yet supported on host systems. " - "See https://github.com/coreos/rpm-ostree/issues/2326."); + g_print ("No changes to apply.\n"); } return TRUE; diff --git a/tests/kolainst/nondestructive/misc.sh b/tests/kolainst/nondestructive/misc.sh index 6d5b87e971..f4415641d8 100755 --- a/tests/kolainst/nondestructive/misc.sh +++ b/tests/kolainst/nondestructive/misc.sh @@ -56,6 +56,11 @@ fi assert_file_has_content_literal err.txt 'error: Argument is invalid UTF-8' echo "ok error on non UTF-8" +if rpm-ostree ex rebuild 2>err.txt; then + fatal "ex rebuild on host" +fi +assert_file_has_content_literal err.txt 'error: This command can only run in an OSTree container' + rpm-ostree status --jsonpath '$.deployments[0].booted' > jsonpath.txt assert_file_has_content_literal jsonpath.txt 'true' echo "ok jsonpath"