Skip to main content

ostree_ext/
lib.rs

1//! # Extension APIs for ostree
2//!
3//! This crate builds on top of the core ostree C library
4//! and the Rust bindings to it, adding new functionality
5//! written in Rust.
6//!
7//! ## Key Modules
8//!
9//! - [`container`]: Bidirectional mapping between OCI container images and ostree commits.
10//!   This is the core of bootc's ability to deploy container images as bootable systems.
11//! - [`tar`]: Lossless export and import of ostree commits as tar archives.
12//! - [`sysroot`]: Extensions for managing ostree deployments.
13//! - [`chunking`]: Splitting ostree commits into layers for efficient container updates.
14
15// See https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
16#![deny(missing_docs)]
17#![deny(missing_debug_implementations)]
18#![forbid(unused_must_use)]
19#![deny(unsafe_code)]
20#![cfg_attr(feature = "dox", feature(doc_cfg))]
21#![deny(clippy::dbg_macro)]
22#![deny(clippy::todo)]
23
24// Re-export our dependencies.  See https://gtk-rs.org/blog/2021/06/22/new-release.html
25// "Dependencies are re-exported".  Users will need e.g. `gio::File`, so this avoids
26// them needing to update matching versions.
27pub use composefs_ctl::composefs;
28pub use composefs_ctl::composefs_boot;
29pub use composefs_ctl::composefs_oci;
30pub use containers_image_proxy;
31pub use containers_image_proxy::oci_spec;
32pub use ostree;
33pub use ostree::gio;
34pub use ostree::gio::glib;
35
36/// Our generic catchall fatal error, expected to be converted
37/// to a string to output to a terminal or logs.
38type Result<T> = anyhow::Result<T>;
39
40// Import global functions.
41pub mod globals;
42
43pub mod bootabletree;
44pub mod cli;
45pub mod container;
46pub mod container_utils;
47pub mod diff;
48pub(crate) mod generic_decompress;
49pub mod ima;
50pub mod keyfileext;
51pub(crate) mod logging;
52pub mod ostree_prepareroot;
53pub mod refescape;
54#[doc(hidden)]
55pub mod repair;
56pub mod repo_options;
57pub mod sysroot;
58pub mod tar;
59pub mod tokio_util;
60
61pub mod selinux;
62
63pub mod chunking;
64pub mod commit;
65pub mod objectsource;
66pub(crate) mod objgv;
67#[cfg(feature = "internal-testing-api")]
68pub mod ostree_manual;
69#[cfg(not(feature = "internal-testing-api"))]
70pub(crate) mod ostree_manual;
71
72pub(crate) mod statistics;
73
74mod utils;
75
76#[cfg(feature = "docgen")]
77mod docgen;
78pub mod fsverity;
79
80/// Prelude, intended for glob import.
81pub mod prelude {
82    #[doc(hidden)]
83    pub use ostree::prelude::*;
84}
85
86#[cfg(feature = "internal-testing-api")]
87pub mod fixture;
88#[cfg(feature = "internal-testing-api")]
89pub mod integrationtest;
90
91/// Check if the system has the soft reboot target, which signals
92/// systemd support for soft reboots.
93pub fn systemd_has_soft_reboot() -> bool {
94    const UNIT: &str = "/usr/lib/systemd/system/soft-reboot.target";
95    use std::sync::OnceLock;
96    static EXISTS: OnceLock<bool> = OnceLock::new();
97    *EXISTS.get_or_init(|| std::path::Path::new(UNIT).exists())
98}