1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
//! Pure-Rust, async reimplementation of the ostree repository library.
//!
//! This crate exposes the repository, transaction, reading, writing, checkout,
//! and maintenance APIs. The async runtime backend is selected behind the
//! internal `ostrya-rt` crate: `smol` by default, `tokio` under the `tokio`
//! feature. The crate is designed to hold multiple concurrent transactions
//! within a single process.
//!
//! So far the crate covers repository open/create and config parsing (Phase 4
//! of `docs/port-plan.md`), the reading path (Phase 5): loading objects,
//! commits, and file content, resolving and listing refs, and traversing a
//! commit's tree, and the runtime backend and streaming primitives (Phase 5a):
//! the [`HashingReader`]/[`HashingWriter`] streams and a [`ContentReader`] that
//! streams from `rt::File` and inflates archive objects on the fly. It also
//! covers transactions and locking (Phase 6): the owned [`Transaction`] handle,
//! boot-id-keyed staging directories, and the two-layer repository lock, and the
//! object-store write layer (Phase 7a): streaming content ingestion through
//! [`ContentWriter`], metadata and symlink writers, per-mode on-disk
//! application, dedup, free-space accounting, and publication of staged objects
//! into `objects/` at commit. It also covers in-memory tree assembly (Phase
//! 7b): the [`MutableTree`] with lazy hydration and dirty tracking, and
//! [`Transaction::write_mtree`], which serializes dirty subtrees into dirtree
//! objects. It also covers filesystem ingest (Phase 7c):
//! [`Transaction::write_dfd_to_mtree`], which walks an on-disk tree into a
//! [`MutableTree`] under a [`CommitModifier`] that shapes what is committed
//! (canonical permissions, an include/prune filter, xattr and SELinux label
//! callbacks, a [`DevInoCache`], and source consumption). It also covers commit
//! assembly and durable publication (Phase 7d): [`Transaction::write_commit`]
//! and [`CommitOptions`] (with `ostree.sizes` emission), detached commit
//! metadata on [`Repo`], the ref queue ([`Transaction::set_ref`],
//! [`Transaction::set_collection_ref`]) and immediate ref writes
//! ([`Repo::set_ref_immediate`]), and the completed transaction commit
//! sequence -- objects published, then refs written. It also covers overlay
//! changeset import (Phase 7e): [`Transaction::merge_overlay_dfd_to_mtree`],
//! which merges an overlayfs upperdir into a [`MutableTree`] holding the lower
//! layer, applying whiteouts and opaque directories as it walks. It also covers
//! path-addressed tree construction (Phase 7f): the [`StagingTree`] built over a
//! transaction, with file, symlink, directory, and hardlink operations that
//! resolve paths through symlinks, tree [`merge`](StagingTree::merge) with
//! symlink resolution, and staged-first [`read_file`](StagingTree::read_file) /
//! [`read_dir`](StagingTree::read_dir) that see objects staged in the current
//! transaction before they publish. It also covers the checkout path (Phase 8):
//! [`Repo::checkout_at`], which materializes a commit's tree onto a filesystem
//! under a [`CheckoutOptions`] -- the [`CheckoutMode`] (faithful or
//! unprivileged), the [`OverwriteMode`] over an existing destination, an
//! optional subpath, hardlink-versus-copy with a `FICLONE` reflink on the copy
//! path, Docker-style whiteouts, a populated [`DevInoCache`], and an optional
//! filter. It also covers composefs export (Phase 9d):
//! [`Repo::export_composefs`], which builds the EROFS/composefs image for a
//! commit over the [`ostrya_composefs`] writer -- the tree model comes from the
//! commit's [`RepoTree`], the five top-level directories are injected, and each
//! regular file redirects to its `.file` loose object and, under the default
//! [`ComposefsOptions`] verity policy, carries the fs-verity digest of that
//! file's content -- [`Repo::export_composefs_to`], which writes that image
//! through a file descriptor and returns its fs-verity digest without holding
//! the image, [`Repo::commit_add_composefs_metadata`],
//! which stores the image digest in a commit's `ostree.composefs.digest.v0`
//! metadata, and [`Transaction::composefs_digest`], which computes the digest
//! over a tree the transaction has staged, for a commit that carries the key in
//! its own metadata. It
//! also covers tar import and export (Phase 10): [`Repo::export_tar`], which
//! writes a commit's tree as a filesystem tar stream (numeric ownership,
//! commit-timestamp mtimes, `SCHILY.xattr.*` PAX records, content-checksum
//! hardlink coalescing), and [`Repo::import_tar`], which reads a filesystem tar
//! into a [`MutableTree`] with deferred hardlink resolution and an optional
//! `/etc` -> `/usr/etc` remap. It also covers maintenance (Phase 12):
//! [`Repo::list_objects`] and the reachability walks
//! [`Repo::traverse_commit`]/[`Repo::traverse_reachable`], [`Repo::prune`]
//! ([`PruneOptions`]/[`PruneStats`]) which deletes objects unreachable from the
//! chosen roots (refs, optionally every commit, to a depth, with an optional
//! `delete_commit`, and with the extra roots
//! [`PruneOptions::gc_root_properties`] names under an optional
//! [`PruneOptions::traverse_parent`]), [`Repo::fsck`] ([`FsckOptions`]/[`FsckReport`]) which
//! verifies object integrity and completeness and marks incomplete commits
//! partial, and [`Repo::diff_commits`] ([`DiffEntry`]/[`DiffChange`]) which
//! reports the paths that changed between two commits. It also covers
//! repository fs-verity (Phase pre13): with `[ex-integrity] fsverity` set to
//! `maybe` or `yes` (see [`RepoConfig::fsverity`] and [`Tristate`]), each loose
//! object stored as a regular file is sealed with fs-verity as it is staged,
//! through the audited `ostrya-sys` ioctl wrappers. It also covers the signing
//! framework (Phase 13a): the [`Signer`]/[`Verifier`] engine surface,
//! [`Repo::sign_commit`] and [`Repo::verify_commit`], which sign and verify a
//! commit's canonical bytes and accumulate signatures in the per-engine `aay`
//! array of the commit's detached metadata, [`Repo::delete_signatures`], which
//! removes stored blobs from an engine's array, and the test-only
//! [`DummySigner`] / [`DummyVerifier`] engine. It also covers the ed25519 engine and the sign-api
//! key store (Phase 13b): [`Ed25519Signer`] / [`Ed25519Verifier`] over
//! deterministic ed25519 signatures, and [`load_sign_keys`], which reads the
//! `trusted.<type>` / `revoked.<type>` files and `.d` directories (a verifier
//! trusts the loaded set minus the revoked set). Under the `sign-spki` feature
//! it also covers the spki engine (Phase 13c): [`SpkiSigner`] / [`SpkiVerifier`]
//! over ECDSA on NIST P-256 with SHA-256, DER-encoded signatures, and
//! SubjectPublicKeyInfo public keys, reusing the sign-api key store as
//! `trusted.spki` / `revoked.spki`. Under the `verify-gpg` feature it also
//! covers the GPG engine (Phase 13d): [`GpgVerifier`] holds binary or armored
//! keyrings, parses each into certificates as it loads it, and answers the
//! verdict in the process over the `pgp` crate (rPGP); detached OpenPGP
//! signatures accumulate under `ostree.gpgsigs` with per-signature metadata
//! read from the certificate and the signature packet. The `sign-gpg` feature
//! adds [`GpgSigner`], which runs `gpg --detach-sign` with the key resolved by
//! fingerprint, key id, or user id in an optional GnuPG home directory
//! (agent-held and hardware-token keys included), and turns on `verify-gpg`
//! with it. It also covers static deltas
//! in both directions (Phase 15): [`Repo::apply_static_delta_offline`] reads a
//! delta -- the superblock, the xz-compressed parts, and the operation stream
//! (splice, open/close, set-read-source, rollsum write, and bspatch) -- and
//! produces the target commit's objects, asserting each checksum as written,
//! while [`Repo::generate_static_delta`] writes one, choosing per object
//! between a splice, a rollsum copy-from-source stream, a bspatch stream, and
//! a loose fallback. [`Repo::sign_static_delta`] wraps a superblock in the
//! signed envelope, [`Repo::verify_static_delta`] checks those signatures with
//! the signing engines over the raw superblock bytes, and
//! [`Repo::reindex_static_deltas`] rebuilds the `delta-indexes/` cache. It also
//! covers the fetcher pull is built on (Phase 16a): [`Fetcher`] serves
//! [`FetchRequest`]s for paths under a remote's mirrors over HTTP/1.1 and
//! HTTP/2 -- ALPN picks the version, connections are pooled per origin,
//! requests carry a [`Priority`] the fetcher's admission queue honors,
//! conditional requests resolve to [`Fetched::NotModified`], retryable
//! failures are repeated across mirrors, and a response arrives as a streaming
//! [`Body`] under an optional size cap -- and [`VerifyingReader`], the stream
//! that checks a payload against its expected digest at EOF. It also covers
//! local pull (Phase 16b): [`Repo::pull_local`] imports refs, their commit
//! chains, and every object those commits reach out of another local
//! repository under a [`PullOptions`] -- an object the two repositories store
//! identically, inode included, is hardlinked where the source inode already
//! carries the ownership a write here produces; a refused link takes a metadata
//! object to a reflink-then-copy and a content object to its logical header; a
//! content object crossing modes within the bare family has its payload cloned
//! under this repository's own inode policy; one crossing the archive boundary
//! is re-ingested through the ordinary write path; [`PullFlags`] selects
//! checksum verification, commit-metadata-only pulls, copying instead of
//! linking, and the mode and binding checks; and
//! [`localcache_repos`](PullOptions::localcache_repos) adds further local
//! repositories to source objects from. It also covers HTTP pull (Phase 16c):
//! [`Repo::pull`] fetches refs, their commit chains, and every object those
//! commits reach from an archive remote named in this repository's config --
//! `summary.sig`, `summary`, and `config` first, then the objects, with a
//! content object always requested in the `.filez` form an HTTP client can read
//! and a non-archive remote refused on its config mode. Up to
//! [`max_outstanding_fetches`](PullOptions::max_outstanding_fetches) objects are
//! in flight over a plan drained commits first, then the metadata the scan is
//! blocked on, then the content; a commit object is staged where it arrives,
//! behind its own `.commitpartial` marker and ahead of its tree, and the marker
//! is removed after the transaction publishes; three write permits bound the
//! concurrent writers on the destination; every object is stored under the name
//! it was requested by, which is what verifies it;
//! [`MIRROR`](PullFlags::MIRROR) writes local refs and copies the remote's
//! summary and its signature; and [`TimestampCheck`] refuses a tip older than
//! what the ref already names. [`Repo::remote_fetch_summary`] reads a remote's
//! `summary` and `summary.sig` on their own, and [`Summary`] parses one. A pull
//! also takes a static delta where the remote publishes one (Phase 16d): the
//! delta index, or the summary's `ostree.static-deltas` map, names the delta from
//! the commit the ref holds here (or from scratch), its superblock is checked
//! against the advertised digest, its parts are fetched two at a time and applied
//! into the pull's transaction, and the objects it hands over loose are fetched as
//! ordinary content objects;
//! [`disable_static_deltas`](PullOptions::disable_static_deltas) and
//! [`require_static_deltas`](PullOptions::require_static_deltas) control it, and
//! [`Repo::regenerate_summary`] writes the map that advertises this repository's
//! own deltas. Either pull checks signatures (Phase 16e): the remote's
//! `gpg-verify`, `gpg-verify-summary`, `sign-verify`, and `sign-verify-summary`
//! keys state the policy, [`PullVerify`] overrides it, and the keys come from
//! that remote's trusted keyrings and its `verification-<engine>-*` entries.
//! It also covers the configuration write side (Phase 17e):
//! [`Repo::write_config`] replaces `config` atomically with a document edited
//! through [`KeyFile`](ostrya_core::KeyFile), which is how a remote's section is
//! added or removed, and [`Repo::remove_remote_keyring`] deletes the keyring that
//! section owns. Under the `verify-gpg` feature, `Repo::gpg_import_keys` and
//! `Repo::gpg_list_keys` add certificates to a remote's
//! `<remote>.trustedkeys.gpg` and read back the key records it holds (see the
//! [`gpg`] module). It also covers the bootable commit metadata (Phase 21):
//! [`Transaction::kernel_version`] and [`RepoTree::kernel_version`] derive the
//! value `ostree.linux` holds from a tree, staged and published respectively,
//! answering the shapes that name no kernel with a [`BootableRefusal`], and
//! [`BootableMetadata`] adds `ostree.linux` and `ostree.bootable` to a
//! [`DictBuilder`] in the order they hold on disk (see the [`bootable`]
//! module).
pub use ;
pub use ;
pub use CommitOptions;
pub use ;
pub use ;
pub use DeltaOptions;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use GpgSigner;
pub use ;
pub use ;
pub use LockKind;
pub use ;
pub use MutableTree;
pub use Image;
pub use base64;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Remove the staging directories the live transactions of this process own.
///
/// A [`Transaction`] removes its staging directory when it commits, when it
/// aborts, and when it drops, so an unwound return leaves `tmp/` clean on its
/// own. [`std::process::exit`] runs no destructor: a process that ends that way
/// with a transaction still live leaves its `tmp/staging-<boot-id>-XXXXXX`
/// directory and the sibling lock file behind, for a later transaction's
/// stale-directory reaper to collect. A caller that ends the process without
/// unwinding calls this immediately before it, and `tmp/` is left as an unwound
/// return would leave it.
///
/// Call it only when the process is about to end. It removes the staging
/// directory of every live transaction in the process, so a transaction that
/// keeps running afterward finds its staged objects gone.