Skip to content

Commit

Permalink
WIP: proxy bootupd crate
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Jun 20, 2020
1 parent 0207d17 commit 9b8e1d6
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile-rpm-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rpm_ostree_SOURCES = src/app/main.c \
src/app/rpmostree-builtin-status.c \
src/app/rpmostree-builtin-ex.c \
src/app/rpmostree-builtin-coreos-rootfs.c \
src/app/rpmostree-builtin-boot-update.c \
src/app/rpmostree-builtin-testutils.c \
src/app/rpmostree-builtin-container.c \
src/app/rpmostree-ex-builtin-commit2rojig.c \
Expand Down
1 change: 1 addition & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
144 changes: 144 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ lazy_static = "1.1.0"
envsubst = "0.2.0"
chrono = { version = "0.4.11", features = ["serde"] }
libdnf-sys = { path = "libdnf-sys", version = "0.1.0" }
bootupd = { path = "../../bootupd", version = "0.1.0" }

# copied from bootupd
[patch.crates-io]
ostree = { git = "https://gitlab.com/cgwalters/ostree-rs", branch = "walters-master" }
#ostree = { path = "/var/srv/walters/src/gitlab/fkrull/ostree-rs" }


[lib]
Expand Down
19 changes: 19 additions & 0 deletions rust/src/bootupd_wrap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2020 Red Hat, Inc.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/

use glib_sys;
use libc;

use crate::ffiutil::*;

#[no_mangle]
pub extern "C" fn ror_boot_update_entrypoint(
argv: *mut *mut libc::c_char,
gerror: *mut *mut glib_sys::GError,
) -> libc::c_int {
let v: Vec<String> = unsafe { glib::translate::FromGlibPtrContainer::from_glib_none(argv) };
int_glib_error(bootupd::boot_update_main(&v), gerror)
}
2 changes: 2 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// pub(crate) utilities
mod ffiutil;

mod bootupd_wrap;
pub use bootupd_wrap::*;
mod cliwrap;
pub use cliwrap::*;
mod composepost;
Expand Down
4 changes: 4 additions & 0 deletions src/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ static RpmOstreeCommand commands[] = {
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_coreos_rootfs },
{ "ex-boot-update", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_boot_update },
{ "testutils", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD |
RPM_OSTREE_BUILTIN_FLAG_HIDDEN,
NULL, rpmostree_builtin_testutils },
Expand Down
45 changes: 45 additions & 0 deletions src/app/rpmostree-builtin-boot-update.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2020 Red Hat, Inc.
*
* 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 <gio/gio.h>

#include "rpmostree-builtins.h"
#include "rpmostree-libbuiltin.h"
#include "rpmostree-rust.h"

#include <libglnx.h>

gboolean
rpmostree_builtin_boot_update (int argc,
char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GPtrArray) args = g_ptr_array_new ();
for (int i = 0; i < argc; i++)
g_ptr_array_add (args, argv[i]);
g_ptr_array_add (args, NULL);
return ror_boot_update_entrypoint ((char**)args->pdata, error);
}
1 change: 1 addition & 0 deletions src/app/rpmostree-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ BUILTINPROTO(kargs);
BUILTINPROTO(reset);
BUILTINPROTO(start_daemon);
BUILTINPROTO(coreos_rootfs);
BUILTINPROTO(boot_update);
BUILTINPROTO(testutils);
BUILTINPROTO(ex);
BUILTINPROTO(finalize_deployment);
Expand Down

0 comments on commit 9b8e1d6

Please sign in to comment.