Ejemplo n.º 1
0
gboolean
ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error)
{
    g_autoptr(GOptionContext) context = NULL;
    glnx_unref_object OstreeSysroot *sysroot = NULL;
    gboolean ret = FALSE;
    const char *osname = NULL;

    context = g_option_context_new ("OSNAME - Initialize empty state for given operating system");

    if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                            OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
                                            &sysroot, cancellable, error))
        goto out;

    if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
        goto out;

    if (argc < 2)
    {
        ot_util_usage_error (context, "OSNAME must be specified", error);
        goto out;
    }

    osname = argv[1];

    if (!ostree_sysroot_init_osname (sysroot, osname, cancellable, error))
        goto out;

    g_print ("ostree/deploy/%s initialized as OSTree root\n", osname);

    ret = TRUE;
out:
    return ret;
}
Ejemplo n.º 2
0
static gboolean
handle_create_osname (RPMOSTreeSysroot *object,
                      GDBusMethodInvocation *invocation,
                      const gchar *osname)
{
  RpmostreedSysroot *self = RPMOSTREED_SYSROOT (object);
  GError *error = NULL;
  g_autofree gchar *dbus_path = NULL;

  if (!ostree_sysroot_ensure_initialized (self->ot_sysroot,
                                          self->cancellable,
                                          &error))
    goto out;

  if (strchr (osname, '/') != 0)
    {
      g_set_error_literal (&error,
                           RPM_OSTREED_ERROR,
                           RPM_OSTREED_ERROR_FAILED,
                           "Invalid osname");
      goto out;
    }

  if (!ostree_sysroot_init_osname (self->ot_sysroot, osname, self->cancellable, &error))
    goto out;

  dbus_path = rpmostreed_generate_object_path (BASE_DBUS_PATH, osname, NULL);

  rpmostree_sysroot_complete_create_osname (RPMOSTREE_SYSROOT (self),
                                            invocation,
                                            g_strdup (dbus_path));
out:
  if (error)
    g_dbus_method_invocation_take_error (invocation, error);

  return TRUE;
}