[ostree/wip/anaconda: 5/6] core: Add "admin instutil set-kargs"



commit b68f8f95f0c0b64891f0923a98090822585abdd0
Author: Colin Walters <walters verbum org>
Date:   Mon Mar 17 19:24:56 2014 -0400

    core: Add "admin instutil set-kargs"
    
    This will be used by Anaconda as a convenience command to set the
    bootloader arguments.

 Makefile-ostree.am                               |    1 +
 src/ostree/ot-admin-builtin-instutil.c           |    1 +
 src/ostree/ot-admin-instutil-builtin-set-kargs.c |   64 ++++++++++++++++++++++
 src/ostree/ot-admin-instutil-builtins.h          |    1 +
 4 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/Makefile-ostree.am b/Makefile-ostree.am
index d96b577..4689559 100644
--- a/Makefile-ostree.am
+++ b/Makefile-ostree.am
@@ -64,6 +64,7 @@ ostree_SOURCES += \
        src/ostree/ot-admin-builtin-upgrade.c \
        src/ostree/ot-admin-builtins.h \
        src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c \
+       src/ostree/ot-admin-instutil-builtin-set-kargs.c \
        src/ostree/ot-admin-instutil-builtins.h \
        src/ostree/ot-admin-functions.h \
        src/ostree/ot-admin-functions.c \
diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c
index aa59b7a..0a6bb31 100644
--- a/src/ostree/ot-admin-builtin-instutil.c
+++ b/src/ostree/ot-admin-builtin-instutil.c
@@ -39,6 +39,7 @@ static OstreeAdminInstUtilCommand admin_instutil_subcommands[] = {
 #ifdef HAVE_SELINUX
   { "selinux-ensure-labeled", ot_admin_instutil_builtin_selinux_ensure_labeled },
 #endif
+  { "set-kargs", ot_admin_instutil_builtin_set_kargs },
   { NULL, NULL }
 };
 
diff --git a/src/ostree/ot-admin-instutil-builtin-set-kargs.c 
b/src/ostree/ot-admin-instutil-builtin-set-kargs.c
new file mode 100644
index 0000000..5ca4021
--- /dev/null
+++ b/src/ostree/ot-admin-instutil-builtin-set-kargs.c
@@ -0,0 +1,64 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2014 Colin Walters <walters verbum org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the licence or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <glib-unix.h>
+
+#include "ot-admin-instutil-builtins.h"
+
+#include "otutil.h"
+
+gboolean
+ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable 
*cancellable, GError **error)
+{
+  gboolean ret = FALSE;
+  guint i;
+  gs_unref_ptrarray GPtrArray *deployments = NULL;
+  OstreeDeployment *first_deployment = NULL;
+  gs_unref_ptrarray GPtrArray *new_kargs = NULL;
+
+  if (!ostree_sysroot_load (sysroot, cancellable, error))
+    goto out;
+
+  deployments = ostree_sysroot_get_deployments (sysroot);
+  if (deployments->len == 0)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Unable to find a deployment in sysroot");
+      goto out;
+    }
+  first_deployment = deployments->pdata[0];
+
+  new_kargs = g_ptr_array_new ();
+  for (i = 1; i < argc; i++)
+    g_ptr_array_add (new_kargs, argv[i]);
+  g_ptr_array_add (new_kargs, NULL);
+  
+  if (!ostree_sysroot_deployment_set_kargs (sysroot, first_deployment,
+                                            (char**)new_kargs->pdata,
+                                            cancellable, error))
+    goto out;
+
+  ret = TRUE;
+ out:
+  return ret;
+}
diff --git a/src/ostree/ot-admin-instutil-builtins.h b/src/ostree/ot-admin-instutil-builtins.h
index 1fe08ee..b079dde 100644
--- a/src/ostree/ot-admin-instutil-builtins.h
+++ b/src/ostree/ot-admin-instutil-builtins.h
@@ -25,6 +25,7 @@
 G_BEGIN_DECLS
 
 gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeSysroot *sysroot, 
GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable 
*cancellable, GError **error);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]