selinux_relabel_var_if_needed (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, int os_deploy_dfd,
GCancellable *cancellable, GError **error)
{
+ GLNX_AUTO_PREFIX_ERROR ("Relabeling /var", error);
/* This is a bit of a hack; we should change the code at some
* point in the distant future to only create (and label) /var
* when doing a deployment.
return TRUE;
}
+static gboolean
+require_stateroot (OstreeSysroot *self, const char *stateroot, GError **error)
+{
+ const char *osdeploypath = glnx_strjoina ("ostree/deploy/", stateroot);
+ if (!glnx_fstatat_allow_noent (self->sysroot_fd, osdeploypath, NULL, 0, error))
+ return FALSE;
+ if (errno == ENOENT)
+ return glnx_throw (error, "No such stateroot: %s", stateroot);
+ return TRUE;
+}
+
/* The first part of writing a deployment. This primarily means doing the
* hardlink farm checkout, but we also compute some initial state.
*/
if (osname == NULL)
osname = ostree_deployment_get_osname (self->booted_deployment);
+ if (!require_stateroot (self, osname, error))
+ return FALSE;
+
OstreeRepo *repo = ostree_sysroot_repo (self);
gint new_deployserial;
static gboolean
sysroot_finalize_selinux_policy (int deployment_dfd, GError **error)
{
+ GLNX_AUTO_PREFIX_ERROR ("Finalizing SELinux policy", error);
struct stat stbuf;
gint exit_status;
g_autofree gchar *stdout = NULL;
OstreeDeployment *merge_deployment, GCancellable *cancellable,
GError **error)
{
+ GLNX_AUTO_PREFIX_ERROR ("Finalizing deployment", error);
g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
glnx_autofd int deployment_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &deployment_dfd, error))
set -euo pipefail
-echo "1..$((29 + ${extra_admin_tests:-0}))"
+echo "1..$((30 + ${extra_admin_tests:-0}))"
mkdir sysrootmin
${CMD_PREFIX} ostree admin init-fs --modern sysrootmin
echo "ok --print-current-dir"
+if ${CMD_PREFIX} ostree admin deploy --stateroot=nosuchroot testos:testos/buildmain/x86_64-runtime 2>err.txt; then
+ fatal "deployed to nonexistent root"
+fi
+assert_file_has_content err.txt "error:.*No such stateroot: nosuchroot"
+
+echo "ok nice error for deploy with no stateroot"
+
# Test layout of bootloader config and refs
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1