Skip to content

Commit 8410685

Browse files
authored
Automatic propolis and ovmf management (#143)
1 parent 4b90bfc commit 8410685

File tree

13 files changed

+343
-163
lines changed

13 files changed

+343
-163
lines changed

Cargo.lock

Lines changed: 46 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ slog-term = "2.7"
3030
slog-async = "2.7"
3131
slog-envlogger = "2.2"
3232
toml = "0.8"
33-
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "bdaaf207c7d7f9a6d905a3589eb8e159aa78df12" }
33+
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "02fdf06bb279fc1b1393f993b90cbe84b7e9f281" }
3434
libc = "0.2"
3535
tokio = { version = "1.44.2", features = ["full"] }
3636
tokio-tungstenite = "0.21"
@@ -45,3 +45,10 @@ oxnet = { version = "0.1.1", default-features = false }
4545
indicatif = "0.17.11"
4646
xz2 = "0.1.7"
4747
camino-tempfile = "1.1.1"
48+
cargo_toml = "0.22.1"
49+
quote = "1.0.40"
50+
prettyplease = "0.2"
51+
syn = "2.0"
52+
sha2 = "0.10.8"
53+
anstyle = "1.0.10"
54+
base16ct = { version = "0.2.0", features = ["alloc"] }

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ development environment for networked systems.
1515
recommended. While nested virt can be made to work, it often requires wizardry
1616
and is known to have flaky behaviors.
1717

18-
## Installing
19-
20-
Install `propolis-server`. The`get-propolis.sh` script can also be used to
21-
automatically install propolis-server form the current Falcon CI build.
22-
23-
Set up propolis, firmware and OS base images.
24-
```
25-
./get-propolis.sh
26-
./get-ovmf.sh
27-
./setup-base-images.sh
28-
```
29-
30-
Falcon-enabled propolis builds are kicked out by Propolis CI. See
31-
[this run](https://github.com/oxidecomputer/propolis/runs/18723647907)
32-
as an example.
33-
3418
## QuickStart
3519

3620
To get a ready-to-go Falcon project use the

get-ovmf.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

get-propolis.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

import-raw-img.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# This script is useful for importing a raw image onto your local system for
4+
# testing the construction of a new falcon image. This is not necessary for
5+
# falcon images that have been uploaded to the falcon image bucket. Those
6+
# images are automatically managed by falcon.
7+
38
set -o xtrace
49
set -o errexit
510
set -o pipefail

lib/Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name = "libfalcon"
33
version = "0.1.0"
44
edition = "2018"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
97
thiserror.workspace = true
108
anyhow.workspace = true
@@ -33,7 +31,15 @@ camino.workspace = true
3331
reqwest.workspace = true
3432
indicatif.workspace = true
3533
xz2.workspace = true
36-
anstyle = "1.0.10"
34+
anstyle.workspace = true
35+
sha2.workspace = true
36+
base16ct.workspace = true
3737

3838
[dev-dependencies]
3939
camino-tempfile.workspace = true
40+
41+
[build-dependencies]
42+
cargo_toml.workspace = true
43+
quote.workspace = true
44+
prettyplease.workspace = true
45+
syn.workspace = true

lib/build.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//! This file generates a rust file with a single constant in it,
2+
//! PROPOLIS_REV, that holds the git revision of propolis that
3+
//! this build expects. The expected revision is pulled from
4+
//! the workspace Cargo.toml. This constant is used to automatically
5+
//! download propolis from buildomat CI artifacts as a part of
6+
//! the topology preflight process, ensuring that the propolis binary
7+
//! we use matches the propolis API revision falcon was built against.
8+
9+
use cargo_toml::Manifest;
10+
use quote::quote;
11+
use std::env;
12+
use std::fs;
13+
use std::path::Path;
14+
15+
fn main() {
16+
get_propolis_version();
17+
}
18+
19+
fn get_propolis_version() {
20+
let manifest = Manifest::from_path("../Cargo.toml")
21+
.expect("read workspace Cargo.toml");
22+
23+
let workspace = manifest.workspace.expect("get workspace");
24+
25+
let propolis = workspace
26+
.dependencies
27+
.get("propolis-client")
28+
.expect("build.rs: get propolis client dependency");
29+
30+
let Some(rev) = propolis.git_rev() else {
31+
panic!("build.rs: expected git rev for propolis client");
32+
};
33+
34+
let out_dir = env::var_os("OUT_DIR").unwrap();
35+
let dest_path = Path::new(&out_dir).join("propolis_version.rs");
36+
37+
let tokens = quote! { const PROPOLIS_REV: &str = #rev; };
38+
39+
let file: syn::File =
40+
syn::parse2(tokens).expect("build.rs: parse generated code");
41+
let code = prettyplease::unparse(&file);
42+
43+
fs::write(&dest_path, code).unwrap();
44+
45+
println!("cargo::rerun-if-changed=../Cargo.toml");
46+
}

0 commit comments

Comments
 (0)