gboolean
ot_admin_builtin_deploy (int argc, char **argv, GError **error)
{
  GOptionContext *context;
  OtAdminDeploy self_data;
  OtAdminDeploy *self = &self_data;
  gboolean ret = FALSE;
  const char *deploy_target = NULL;
  const char *revision = NULL;
  __attribute__((unused)) GCancellable *cancellable = NULL;

  if (!opt_ostree_dir)
    opt_ostree_dir = "/ostree";

  memset (self, 0, sizeof (*self));

  context = g_option_context_new ("NAME [REVISION] - Check out revision NAME (or REVISION as NAME)");
  g_option_context_add_main_entries (context, options, NULL);

  if (!g_option_context_parse (context, &argc, &argv, error))
    goto out;

  if (argc < 2)
    {
      ot_util_usage_error (context, "NAME must be specified", error);
      goto out;
    }
    
  deploy_target = argv[1];
  if (argc > 2)
    revision = argv[2];

  if (!do_checkout (self, deploy_target, revision, cancellable, error))
    goto out;

  if (!opt_no_kernel)
    {
      if (!do_update_kernel (self, deploy_target, cancellable, error))
        goto out;
    }
  
  if (!update_current (deploy_target, cancellable, error))
    goto out;

  ret = TRUE;
 out:
  if (context)
    g_option_context_free (context);
  return ret;
}
Beispiel #2
0
gboolean
ot_admin_builtin_deploy (int argc, char **argv, GError **error)
{
  GOptionContext *context;
  OtAdminDeploy self_data;
  OtAdminDeploy *self = &self_data;
  gboolean ret = FALSE;
  const char *deploy_target = NULL;
  const char *revision = NULL;
  __attribute__((unused)) GCancellable *cancellable = NULL;

  memset (self, 0, sizeof (*self));

  context = g_option_context_new ("NAME [REVISION] - Check out revision NAME (or REVISION as NAME)");
  g_option_context_add_main_entries (context, options, NULL);

  if (!g_option_context_parse (context, &argc, &argv, error))
    goto out;

  if (argc < 3)
    {
      ot_util_usage_error (context, "NAME must be specified", error);
      goto out;
    }
    
  deploy_target = argv[2];
  if (argc > 3)
    revision = argv[3];

  if (!do_checkout (self, deploy_target, revision, cancellable, error))
    goto out;

  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,
                       "Unsupported machine %s", utsname.sysname);
          goto out;
        }
      
      release = utsname.release;

      if (!update_initramfs (release, deploy_target, cancellable, error))
        goto out;

      if (!update_grub (release, cancellable, error))
        goto out;
    }

  if (!update_current (deploy_target, cancellable, error))
    goto out;

  ret = TRUE;
 out:
  if (context)
    g_option_context_free (context);
  return ret;
}