ostadmin: Make a /ostree/current symbolic link

This commit is contained in:
Colin Walters 2012-05-08 09:14:03 -04:00
parent 18b6f5fd0c
commit 9179d1b27a
1 changed files with 38 additions and 2 deletions

View File

@ -258,6 +258,38 @@ update_grub (const char *release,
return ret; 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 gboolean
ot_admin_builtin_deploy (int argc, char **argv, GError **error) ot_admin_builtin_deploy (int argc, char **argv, GError **error)
{ {
@ -298,6 +330,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GError **error)
if (!opt_checkout_only) if (!opt_checkout_only)
{ {
struct utsname utsname; struct utsname utsname;
const char *release; const char *release;
@ -319,6 +352,9 @@ ot_admin_builtin_deploy (int argc, char **argv, GError **error)
goto out; goto out;
} }
if (!update_current (last_deploy_target, cancellable, error))
goto out;
ret = TRUE; ret = TRUE;
out: out:
if (context) if (context)