diff --git a/Makefile-ostree.am b/Makefile-ostree.am index d96b577b..46895597 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 aa59b7ab..0a6bb315 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 00000000..5ca40212 --- /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 + * + * 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 +#include + +#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 1fe08ee3..b079ddea 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