Skip to content

Commit

Permalink
Merge pull request #3 from ostreedev/update-2021-2
Browse files Browse the repository at this point in the history
Update to 2021.2
  • Loading branch information
cgwalters authored Apr 15, 2021
2 parents d1ea029 + b70a7f9 commit c39133b
Show file tree
Hide file tree
Showing 15 changed files with 1,034 additions and 640 deletions.
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ v2020_4 = ["v2020_2", "ostree-sys/v2020_4"]
v2020_7 = ["v2020_4", "ostree-sys/v2020_7"]
v2020_8 = ["v2020_7", "ostree-sys/v2020_8"]
v2021_1 = ["v2020_8", "ostree-sys/v2021_1"]
v2021_2 = ["v2020_1", "ostree-sys/v2021_2"]
2 changes: 1 addition & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIR_REPO := https://github.com/gtk-rs/gir.git
GIR_VERSION := 2d1ffab19eb5f9a2f0d7a294dbf07517dab4d989
OSTREE_REPO := https://github.com/fkrull/ostree.git
OSTREE_REPO := ../ostree
OSTREE_VERSION := patch-v2021.1
RUSTDOC_STRIPPER_VERSION := 0.1.17

Expand Down
6 changes: 5 additions & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ Cargo commands.

### Generated code
Most code is generated based on the gir files using the
[gir](https://github.com/gtk-rs/gir) tool. These parts can be regenerated using
[gir](https://github.com/gtk-rs/gir) tool.

You can update `OSTree-1.0.gir` by directly copying it from a local ostree build.

Or, these parts can be regenerated using
the included Makefile:

```ShellSession
Expand Down
2 changes: 2 additions & 0 deletions rust/conf/ostree.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ generate = [
"OSTree.AsyncProgress",
"OSTree.BootconfigParser",
"OSTree.ChecksumFlags",
"OSTree.ContentWriter",
"OSTree.CommitSizesEntry",
"OSTree.Deployment",
"OSTree.DeploymentUnlockedState",
Expand Down Expand Up @@ -71,6 +72,7 @@ manual = [
"Gio.FileQueryInfoFlags",
"Gio.FilterInputStream",
"Gio.InputStream",
"Gio.OutputStream",
"Gio.VolumeMonitor",
"GLib.Bytes",
"GLib.Checksum",
Expand Down
1,535 changes: 903 additions & 632 deletions rust/gir-files/OSTree-1.0.gir

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions rust/src/auto/content_writer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use gio;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib::GString;
use ostree_sys;
use std::fmt;
use std::ptr;

glib_wrapper! {
pub struct ContentWriter(Object<ostree_sys::OstreeContentWriter, ostree_sys::OstreeContentWriterClass, ContentWriterClass>) @extends gio::OutputStream;

match fn {
get_type => || ostree_sys::ostree_content_writer_get_type(),
}
}

pub const NONE_CONTENT_WRITER: Option<&ContentWriter> = None;

pub trait ContentWriterExt: 'static {
fn finish<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<GString, glib::Error>;
}

impl<O: IsA<ContentWriter>> ContentWriterExt for O {
fn finish<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<GString, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ostree_sys::ostree_content_writer_finish(self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
}

impl fmt::Display for ContentWriter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ContentWriter")
}
}
2 changes: 1 addition & 1 deletion rust/src/auto/gpg_verify_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl GpgVerifyResult {
}
}

//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 29 }) -> Option<glib::Variant> {
//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 31 }) -> Option<glib::Variant> {
// unsafe { TODO: call ostree_sys:ostree_gpg_verify_result_get() }
//}

Expand Down
5 changes: 5 additions & 0 deletions rust/src/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pub use self::async_progress::AsyncProgressExt;
mod bootconfig_parser;
pub use self::bootconfig_parser::{BootconfigParser, BootconfigParserClass};

mod content_writer;
pub use self::content_writer::{ContentWriter, ContentWriterClass, NONE_CONTENT_WRITER};
pub use self::content_writer::ContentWriterExt;

mod deployment;
pub use self::deployment::{Deployment, DeploymentClass};

Expand Down Expand Up @@ -179,6 +183,7 @@ pub use self::constants::TREE_GVARIANT_STRING;
#[doc(hidden)]
pub mod traits {
pub use super::AsyncProgressExt;
pub use super::ContentWriterExt;
pub use super::MutableTreeExt;
pub use super::RepoFileExt;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
Expand Down
4 changes: 2 additions & 2 deletions rust/src/auto/mutable_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub trait MutableTreeExt: 'static {

fn get_metadata_checksum(&self) -> Option<GString>;

//fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 42 };
//fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 44 };

fn lookup(&self, name: &str) -> Result<(GString, MutableTree), glib::Error>;

Expand Down Expand Up @@ -127,7 +127,7 @@ impl<O: IsA<MutableTree>> MutableTreeExt for O {
}
}

//fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 42 } {
//fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 44 } {
// unsafe { TODO: call ostree_sys:ostree_mutable_tree_get_subdirs() }
//}

Expand Down
32 changes: 31 additions & 1 deletion rust/src/auto/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use std::ptr;
use AsyncProgress;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
use CollectionRef;
#[cfg(any(feature = "v2021_2", feature = "dox"))]
use ContentWriter;
use GpgVerifyResult;
use MutableTree;
use ObjectType;
Expand Down Expand Up @@ -434,7 +436,7 @@ impl Repo {
}
}

pub fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result<glib::Variant, glib::Error> {
pub fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result<Option<glib::Variant>, glib::Error> {
unsafe {
let mut out_variant = ptr::null_mut();
let mut error = ptr::null_mut();
Expand Down Expand Up @@ -998,6 +1000,34 @@ impl Repo {
}
}

#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn write_regfile(&self, expected_checksum: Option<&str>, uid: u32, gid: u32, mode: u32, content_len: u64, xattrs: Option<&glib::Variant>) -> Result<ContentWriter, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ostree_sys::ostree_repo_write_regfile(self.to_glib_none().0, expected_checksum.to_glib_none().0, uid, gid, mode, content_len, xattrs.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}

#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn write_regfile_inline<P: IsA<gio::Cancellable>>(&self, expected_checksum: Option<&str>, uid: u32, gid: u32, mode: u32, xattrs: Option<&glib::Variant>, buf: &[u8], cancellable: Option<&P>) -> Result<GString, glib::Error> {
let len = buf.len() as usize;
unsafe {
let mut error = ptr::null_mut();
let ret = ostree_sys::ostree_repo_write_regfile_inline(self.to_glib_none().0, expected_checksum.to_glib_none().0, uid, gid, mode, xattrs.to_glib_none().0, buf.to_glib_none().0, len, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}

#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn write_symlink<P: IsA<gio::Cancellable>>(&self, expected_checksum: Option<&str>, uid: u32, gid: u32, xattrs: Option<&glib::Variant>, symlink_target: &str, cancellable: Option<&P>) -> Result<GString, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ostree_sys::ostree_repo_write_symlink(self.to_glib_none().0, expected_checksum.to_glib_none().0, uid, gid, xattrs.to_glib_none().0, symlink_target.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}

pub fn get_property_remotes_config_dir(&self) -> Option<GString> {
unsafe {
let mut value = Value::from_type(<GString as StaticType>::static_type());
Expand Down
2 changes: 1 addition & 1 deletion rust/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab)
from gir-files (https://github.com/gtk-rs/gir-files @ 9fe8b26)
from gir-files (https://github.com/gtk-rs/gir-files @ e4bcf9b+)
2 changes: 2 additions & 0 deletions rust/sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dox = []
v2020_7 = ["v2020_4"]
v2020_8 = ["v2020_7"]
v2021_1 = ["v2020_8"]
v2021_2 = ["v2021_1"]

[lib]
name = "ostree_sys"
Expand Down Expand Up @@ -115,3 +116,4 @@ v2020_4 = "2020.4"
v2020_7 = "2020.7"
v2020_8 = "2020.8"
v2021_1 = "2021.1"
v2021_2 = "2021.2"
2 changes: 1 addition & 1 deletion rust/sys/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab)
from gir-files (https://github.com/gtk-rs/gir-files @ 9fe8b26)
from gir-files (https://github.com/gtk-rs/gir-files @ e4bcf9b+)
36 changes: 36 additions & 0 deletions rust/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ impl ::std::fmt::Debug for OstreeCommitSizesEntry {
}
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct OstreeContentWriterClass {
pub parent_class: gio::GOutputStreamClass,
}

impl ::std::fmt::Debug for OstreeContentWriterClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("OstreeContentWriterClass @ {:?}", self as *const _))
.field("parent_class", &self.parent_class)
.finish()
}
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct OstreeDiffDirsOptions {
Expand Down Expand Up @@ -839,6 +853,16 @@ impl ::std::fmt::Debug for OstreeBootconfigParser {
}
}

#[repr(C)]
pub struct OstreeContentWriter(c_void);

impl ::std::fmt::Debug for OstreeContentWriter {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("OstreeContentWriter @ {:?}", self as *const _))
.finish()
}
}

#[repr(C)]
pub struct OstreeDeployment(c_void);

Expand Down Expand Up @@ -1187,6 +1211,12 @@ extern "C" {
pub fn ostree_checksum_input_stream_get_type() -> GType;
//pub fn ostree_checksum_input_stream_new(stream: *mut gio::GInputStream, checksum: *mut glib::GChecksum) -> /*Ignored*/*mut OstreeChecksumInputStream;

//=========================================================================
// OstreeContentWriter
//=========================================================================
pub fn ostree_content_writer_get_type() -> GType;
pub fn ostree_content_writer_finish(self_: *mut OstreeContentWriter, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> *mut c_char;

//=========================================================================
// OstreeDeployment
//=========================================================================
Expand Down Expand Up @@ -1445,6 +1475,12 @@ extern "C" {
pub fn ostree_repo_write_metadata_stream_trusted(self_: *mut OstreeRepo, objtype: OstreeObjectType, checksum: *const c_char, object_input: *mut gio::GInputStream, length: u64, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> gboolean;
pub fn ostree_repo_write_metadata_trusted(self_: *mut OstreeRepo, objtype: OstreeObjectType, checksum: *const c_char, variant: *mut glib::GVariant, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> gboolean;
pub fn ostree_repo_write_mtree(self_: *mut OstreeRepo, mtree: *mut OstreeMutableTree, out_file: *mut *mut gio::GFile, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> gboolean;
#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn ostree_repo_write_regfile(self_: *mut OstreeRepo, expected_checksum: *const c_char, uid: u32, gid: u32, mode: u32, content_len: u64, xattrs: *mut glib::GVariant, error: *mut *mut glib::GError) -> *mut OstreeContentWriter;
#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn ostree_repo_write_regfile_inline(self_: *mut OstreeRepo, expected_checksum: *const c_char, uid: u32, gid: u32, mode: u32, xattrs: *mut glib::GVariant, buf: *const u8, len: size_t, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> *mut c_char;
#[cfg(any(feature = "v2021_2", feature = "dox"))]
pub fn ostree_repo_write_symlink(self_: *mut OstreeRepo, expected_checksum: *const c_char, uid: u32, gid: u32, xattrs: *mut glib::GVariant, symlink_target: *const c_char, cancellable: *mut gio::GCancellable, error: *mut *mut glib::GError) -> *mut c_char;

//=========================================================================
// OstreeRepoFile
Expand Down
1 change: 1 addition & 0 deletions rust/sys/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[
("OstreeCollectionRef", Layout {size: size_of::<OstreeCollectionRef>(), alignment: align_of::<OstreeCollectionRef>()}),
("OstreeCollectionRefv", Layout {size: size_of::<OstreeCollectionRefv>(), alignment: align_of::<OstreeCollectionRefv>()}),
("OstreeCommitSizesEntry", Layout {size: size_of::<OstreeCommitSizesEntry>(), alignment: align_of::<OstreeCommitSizesEntry>()}),
("OstreeContentWriterClass", Layout {size: size_of::<OstreeContentWriterClass>(), alignment: align_of::<OstreeContentWriterClass>()}),
("OstreeDeploymentUnlockedState", Layout {size: size_of::<OstreeDeploymentUnlockedState>(), alignment: align_of::<OstreeDeploymentUnlockedState>()}),
("OstreeDiffDirsOptions", Layout {size: size_of::<OstreeDiffDirsOptions>(), alignment: align_of::<OstreeDiffDirsOptions>()}),
("OstreeDiffFlags", Layout {size: size_of::<OstreeDiffFlags>(), alignment: align_of::<OstreeDiffFlags>()}),
Expand Down

0 comments on commit c39133b

Please sign in to comment.