ostadmin: Make a /ostree/current symbolic link
This commit is contained in:
parent
18b6f5fd0c
commit
9179d1b27a
|
|
@ -258,6 +258,38 @@ update_grub (const char *release,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_current (const char *last_deploy_target,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
ot_lfree char *tmp_symlink = NULL;
|
||||
ot_lfree char *current_name = NULL;
|
||||
|
||||
tmp_symlink = g_build_filename ("/ostree", "tmp-current", NULL);
|
||||
(void) unlink (tmp_symlink);
|
||||
|
||||
if (symlink (last_deploy_target, tmp_symlink) < 0)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
current_name = g_build_filename ("/ostree", "current", NULL);
|
||||
if (rename (tmp_symlink, current_name) < 0)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_print ("/ostree/current set to %s\n", last_deploy_target);
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_admin_builtin_deploy (int argc, char **argv, GError **error)
|
||||
{
|
||||
|
|
@ -298,11 +330,12 @@ ot_admin_builtin_deploy (int argc, char **argv, GError **error)
|
|||
|
||||
if (!opt_checkout_only)
|
||||
{
|
||||
|
||||
struct utsname utsname;
|
||||
const char *release;
|
||||
|
||||
|
||||
(void) uname (&utsname);
|
||||
|
||||
|
||||
if (strcmp (utsname.sysname, "Linux") != 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
|
|
@ -319,6 +352,9 @@ ot_admin_builtin_deploy (int argc, char **argv, GError **error)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!update_current (last_deploy_target, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
|
|
|
|||
Loading…
Reference in New Issue