core: Add "admin instutil set-kargs"

This will be used by Anaconda as a convenience command to set the
bootloader arguments.
This commit is contained in:
Colin Walters 2014-03-17 19:24:56 -04:00
parent 4309b49866
commit b68f8f95f0
4 changed files with 67 additions and 0 deletions

View File

@ -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 \

View File

@ -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 }
};

View File

@ -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;
}

View File

@ -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