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;
28pub use composefs_boot;
29pub use 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
43mod isolation;
44
45pub mod bootabletree;
46pub mod cli;
47pub mod container;
48pub mod container_utils;
49pub mod diff;
50pub(crate) mod generic_decompress;
51pub mod ima;
52pub mod keyfileext;
53pub(crate) mod logging;
54pub mod ostree_prepareroot;
55pub mod refescape;
56#[doc(hidden)]
57pub mod repair;
58pub mod repo_options;
59pub mod sysroot;
60pub mod tar;
61pub mod tokio_util;
62
63pub mod selinux;
64
65pub mod chunking;
66pub mod commit;
67pub mod objectsource;
68pub(crate) mod objgv;
69#[cfg(feature = "internal-testing-api")]
70pub mod ostree_manual;
71#[cfg(not(feature = "internal-testing-api"))]
72pub(crate) mod ostree_manual;
73
74pub(crate) mod statistics;
75
76mod utils;
77
78#[cfg(feature = "docgen")]
79mod docgen;
80pub mod fsverity;
81
82/// Prelude, intended for glob import.
83pub mod prelude {
84    #[doc(hidden)]
85    pub use ostree::prelude::*;
86}
87
88#[cfg(feature = "internal-testing-api")]
89pub mod fixture;
90#[cfg(feature = "internal-testing-api")]
91pub mod integrationtest;
92
93/// Check if the system has the soft reboot target, which signals
94/// systemd support for soft reboots.
95pub fn systemd_has_soft_reboot() -> bool {
96    const UNIT: &str = "/usr/lib/systemd/system/soft-reboot.target";
97    use std::sync::OnceLock;
98    static EXISTS: OnceLock<bool> = OnceLock::new();
99    *EXISTS.get_or_init(|| std::path::Path::new(UNIT).exists())
100}