Skip to main content

rto_exec/
runtime_file_pins.rs

1// GENERATED FILE — do not edit by hand.
2//
3// Regenerate with:
4//
5//     scripts/derive-runtime-file-pins.py
6//
7// # What these are, and why they are derived rather than written
8//
9// `boxlite` downloads the runtime archive, extracts it into its own OUT_DIR and
10// `include_bytes!`s **the extracted files** into the rlib. Those files are what
11// ends up in the binary, so those are what `build.rs` verifies — one digest per
12// file per platform, checked after extraction and before anything is linked.
13//
14// The archive pins in `runtime_pins.rs` remain the source of truth. This file is
15// a mechanical function of them: the generator verifies each archive against its
16// own pin before opening it, then hashes every member. A `boxlite` bump is
17// therefore `runtime_pins.rs` + re-run the generator + review the diff, never
18// fifteen hand-typed hex strings.
19//
20// Standalone on purpose — **no `use`, no `crate::` paths** — because `build.rs`
21// pulls it in with `include!`, exactly as it does `runtime_pins.rs`.
22
23/// One file as it must appear in `boxlite`'s extracted runtime directory.
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub struct PinnedFile {
26    /// Its name in the runtime directory — the archive member with the
27    /// leading `boxlite-runtime/` component stripped, as
28    /// `tar --strip-components=1` leaves it.
29    pub name: &'static str,
30    /// Lowercase hex SHA-256 of its contents.
31    pub sha256: &'static str,
32    /// Its exact size in bytes.
33    pub bytes: u64,
34}
35
36/// One platform's extracted runtime files.
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub struct PinnedRuntimeFiles {
39    /// The platform, as the upstream release names it.
40    pub target: &'static str,
41    /// The archive these were derived from, so a bumped archive pin that
42    /// nobody re-derived is a test failure rather than a silent mismatch.
43    pub archive_sha256: &'static str,
44    /// Every file the archive contributes, sorted by name.
45    pub files: &'static [PinnedFile],
46}
47
48/// The `boxlite` release these were derived from.
49pub const RUNTIME_FILES_VERSION: &str = "0.9.7";
50
51/// Every pinned platform's extracted runtime files.
52pub const RUNTIME_FILES: &[PinnedRuntimeFiles] = &[
53    PinnedRuntimeFiles {
54        target: "darwin-arm64",
55        archive_sha256: "7f64529978cd2af420411ddfd4cc3b5799ca20234d90346c887cb596d52f8d4e",
56        files: &[
57            PinnedFile {
58                name: "boxlite-guest",
59                sha256: "f09abc03fd2d233b1e6fa31327cb30c14698d7c60ee21be241096620767ae261",
60                bytes: 14_074_296,
61            },
62            PinnedFile {
63                name: "boxlite-shim",
64                sha256: "741ced072011ee62ef3861908e4573bd2bb13c21bc0c40bca42eabea3de65a93",
65                bytes: 22_991_696,
66            },
67            PinnedFile {
68                name: "debugfs",
69                sha256: "6bf2f08e5cb6ce2d2c9c445ed4d4b2ac12721d61ad2592b0e958c4db0e2d6f87",
70                bytes: 661_800,
71            },
72            PinnedFile {
73                name: "libkrunfw.5.dylib",
74                sha256: "454efb5b04045c1b89eaa4d28e90afe92bad1b125b059168f164971a7189cf18",
75                bytes: 22_970_192,
76            },
77            PinnedFile {
78                name: "mke2fs",
79                sha256: "d82d5b85dd86ee8fc8d6d1e72b59b331cd4bd288e485f9c9fb0da81170eb5854",
80                bytes: 577_560,
81            },
82        ],
83    },
84    PinnedRuntimeFiles {
85        target: "linux-arm64-gnu",
86        archive_sha256: "78e978d6398d5a78dc76d675941cb05287e8c70b1b647e98a479058a9652be28",
87        files: &[
88            PinnedFile {
89                name: "boxlite-guest",
90                sha256: "e641807883c0c2d427e93d1fd18313fdd806593b89dbb1fafff48293e3bf8aa6",
91                bytes: 14_079_928,
92            },
93            PinnedFile {
94                name: "boxlite-shim",
95                sha256: "2ce896d88569c9164a33b4b4c36221988076d78aab02a3c97d100fef4f49c87a",
96                bytes: 26_652_536,
97            },
98            PinnedFile {
99                name: "bwrap",
100                sha256: "3e599fc36c39f220d9f0b05956c5c57720b6a83c819cc3114e3ed7e6175dbefa",
101                bytes: 307_120,
102            },
103            PinnedFile {
104                name: "debugfs",
105                sha256: "ae190ef38146ffe20cdc12a419a86d9fd7fd55316356ffd6a995e9d9391acef4",
106                bytes: 3_593_336,
107            },
108            PinnedFile {
109                name: "libkrunfw.so.5",
110                sha256: "f30112748a09cefccb9b3d98098fe2b770e785debfafea5dc9e0523f17b8d74a",
111                bytes: 22_939_240,
112            },
113            PinnedFile {
114                name: "mke2fs",
115                sha256: "c5b92faf507b95db98b78234c7c12580e7a9fd141d4ad5bdeb212e0b4b2537d0",
116                bytes: 3_052_784,
117            },
118        ],
119    },
120    PinnedRuntimeFiles {
121        target: "linux-x64-gnu",
122        archive_sha256: "9ae495f55d363e6af04640ab55025ac80b4bf4762e38fa0b8ac80c7604e3148c",
123        files: &[
124            PinnedFile {
125                name: "boxlite-guest",
126                sha256: "8d090705ae2fe424a5d2a501733029a9cadb58f158691957abecc823c638ae40",
127                bytes: 14_480_904,
128            },
129            PinnedFile {
130                name: "boxlite-shim",
131                sha256: "ee1572b212f9041b7de208540c68e6bee608386064eedf2aabbc9a1f7b058677",
132                bytes: 29_320_000,
133            },
134            PinnedFile {
135                name: "bwrap",
136                sha256: "3312ccace553fd083a00f4706c5658880113ed79f3fc1ec7bb486ec0797a7523",
137                bytes: 187_376,
138            },
139            PinnedFile {
140                name: "debugfs",
141                sha256: "cf3e94ba478311991c4dd461a983365529b612293ff82a76ed4b1c1d6adfaf89",
142                bytes: 3_374_856,
143            },
144            PinnedFile {
145                name: "libkrunfw.so.5",
146                sha256: "c29492267947a7f40218a9a181fe5aa3e9bcb96efbd0e3fab3d1839f5a0a9eff",
147                bytes: 19_203_768,
148            },
149            PinnedFile {
150                name: "mke2fs",
151                sha256: "c3bedf42c320212abeb1c6325bd2663d7507a46d0ba06c2a76af1a9222c8ebb1",
152                bytes: 2_831_648,
153            },
154        ],
155    },
156];
157
158/// The extracted-file pins for an upstream target name.
159#[must_use]
160pub fn runtime_files_for(target: &str) -> Option<&'static PinnedRuntimeFiles> {
161    let mut index = 0;
162    // A plain loop rather than an iterator, matching `runtime_pins.rs`: this file
163    // is `include!`d into a build script, where keeping to the language core is
164    // the point.
165    while index < RUNTIME_FILES.len() {
166        if RUNTIME_FILES[index].target.as_bytes() == target.as_bytes() {
167            return Some(&RUNTIME_FILES[index]);
168        }
169        index += 1;
170    }
171    None
172}