feat: Added wrapper crate for including ipxe binaries
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "ipxe/ipxe"]
|
||||||
|
path = ipxe/ipxe
|
||||||
|
url = git@github.com:rkubes/ipxe
|
||||||
Generated
+34
-30
@@ -169,6 +169,12 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "build-print"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d8e6738dfb11354886f890621b4a34c0b177f75538023f7100b608ab9adbd66b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.20.3"
|
version = "3.20.3"
|
||||||
@@ -304,6 +310,7 @@ dependencies = [
|
|||||||
"clap_complete",
|
"clap_complete",
|
||||||
"futures",
|
"futures",
|
||||||
"gix-discover",
|
"gix-discover",
|
||||||
|
"ipxe",
|
||||||
"minijinja",
|
"minijinja",
|
||||||
"netascii",
|
"netascii",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
@@ -1045,6 +1052,25 @@ dependencies = [
|
|||||||
"icu_properties",
|
"icu_properties",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"
|
||||||
|
dependencies = [
|
||||||
|
"include_dir_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir_macros"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.14.0"
|
version = "2.14.0"
|
||||||
@@ -1061,6 +1087,14 @@ version = "2.12.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a756c3fac73139e83f14c2d742155dd2b78d3ee56597b419a0579b7bdd6dd78"
|
checksum = "6a756c3fac73139e83f14c2d742155dd2b78d3ee56597b419a0579b7bdd6dd78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ipxe"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"build-print",
|
||||||
|
"include_dir",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is_terminal_polyfill"
|
name = "is_terminal_polyfill"
|
||||||
version = "1.70.2"
|
version = "1.70.2"
|
||||||
@@ -1587,9 +1621,7 @@ checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
@@ -1605,14 +1637,12 @@ dependencies = [
|
|||||||
"sync_wrapper",
|
"sync_wrapper",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-native-tls",
|
"tokio-native-tls",
|
||||||
"tokio-util",
|
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"wasm-streams",
|
|
||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2009,19 +2039,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tokio-util"
|
|
||||||
version = "0.7.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
"futures-core",
|
|
||||||
"futures-sink",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "1.1.1+spec-1.1.0"
|
version = "1.1.1+spec-1.1.0"
|
||||||
@@ -2265,19 +2282,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-streams"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb"
|
|
||||||
dependencies = [
|
|
||||||
"futures-util",
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.104"
|
version = "0.3.104"
|
||||||
|
|||||||
+2
-3
@@ -7,7 +7,7 @@ publish = ["infra"]
|
|||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["xtask"]
|
members = ["ipxe", "xtask"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
schemars = { version = "1.2.1", features = ["semver1"] }
|
schemars = { version = "1.2.1", features = ["semver1"] }
|
||||||
@@ -26,8 +26,6 @@ num_enum = "0.7.6"
|
|||||||
optional_struct = "0.5.2"
|
optional_struct = "0.5.2"
|
||||||
regex = "1.13.1"
|
regex = "1.13.1"
|
||||||
reqwest = { version = "0.13.2", default-features = false, features = [
|
reqwest = { version = "0.13.2", default-features = false, features = [
|
||||||
"blocking",
|
|
||||||
"stream",
|
|
||||||
"native-tls",
|
"native-tls",
|
||||||
] }
|
] }
|
||||||
schemars = { workspace = true }
|
schemars = { workspace = true }
|
||||||
@@ -37,6 +35,7 @@ serde_json = { workspace = true }
|
|||||||
serde_yaml = "0.9.34"
|
serde_yaml = "0.9.34"
|
||||||
thiserror = "2.0.18"
|
thiserror = "2.0.18"
|
||||||
tokio = { version = "1.52.1", features = ["full"] }
|
tokio = { version = "1.52.1", features = ["full"] }
|
||||||
|
ipxe = { path = "./ipxe" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
test = false
|
test = false
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "ipxe"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
build-print = "1.0.1"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
include_dir = "0.7.4"
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
|
use build_print::error;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap();
|
||||||
|
let src_dir = manifest_dir.join("ipxe").join("src");
|
||||||
|
|
||||||
|
let mut command = Command::new("make");
|
||||||
|
command
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.current_dir(&src_dir)
|
||||||
|
.env_remove("DEBUG")
|
||||||
|
.env_remove("PROFILE")
|
||||||
|
.args([
|
||||||
|
"-j",
|
||||||
|
&std::thread::available_parallelism()
|
||||||
|
.unwrap()
|
||||||
|
.get()
|
||||||
|
.to_string(),
|
||||||
|
])
|
||||||
|
.arg(format!(
|
||||||
|
"EMBED={}",
|
||||||
|
manifest_dir
|
||||||
|
.join("src")
|
||||||
|
.join("embed.ipxe")
|
||||||
|
.to_string_lossy(),
|
||||||
|
));
|
||||||
|
|
||||||
|
let files = ["bin/ipxe.pxe", "bin-x86_64-efi/ipxe.efi"].map(PathBuf::from);
|
||||||
|
for file in &files {
|
||||||
|
command.arg(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = command.output().unwrap();
|
||||||
|
if !output.status.success() {
|
||||||
|
error!("{}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
}
|
||||||
|
|
||||||
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap()
|
||||||
|
.join("ipxe");
|
||||||
|
|
||||||
|
std::fs::remove_dir_all(&out_dir).ok();
|
||||||
|
for file in &files {
|
||||||
|
let input = src_dir.join(file);
|
||||||
|
let output = out_dir.join(file.file_name().unwrap());
|
||||||
|
|
||||||
|
std::fs::create_dir_all(output.parent().unwrap()).unwrap();
|
||||||
|
std::fs::copy(input, output).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
Submodule
+1
Submodule ipxe/ipxe added at 8892af68a2
@@ -0,0 +1,5 @@
|
|||||||
|
#!ipxe
|
||||||
|
|
||||||
|
dhcp
|
||||||
|
|
||||||
|
echo "Hello, World!"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
use include_dir::{Dir, include_dir};
|
||||||
|
|
||||||
|
pub static IPXE_DIR: Dir<'_> = include_dir!("$OUT_DIR/ipxe");
|
||||||
+6
-1
@@ -11,6 +11,7 @@ use crete::tftp::ServerError;
|
|||||||
use crete::{get_configs_path, get_repo_path, set_repo_path, tftp};
|
use crete::{get_configs_path, get_repo_path, set_repo_path, tftp};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
|
use ipxe::IPXE_DIR;
|
||||||
use minijinja::context;
|
use minijinja::context;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@@ -117,7 +118,11 @@ async fn main() -> Result<(), Error> {
|
|||||||
println!("{filename}");
|
println!("{filename}");
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
if let Some(caps) = re.captures(&filename) {
|
const IPXE_PATTERN: &str = "ipxe/";
|
||||||
|
if let Some(filename) = filename.strip_prefix(IPXE_PATTERN) {
|
||||||
|
println!("Looking for iPXE binary: {filename}");
|
||||||
|
Some(IPXE_DIR.get_file(filename)?.contents().to_owned())
|
||||||
|
} else if let Some(caps) = re.captures(&filename) {
|
||||||
let cluster = &caps["cluster"];
|
let cluster = &caps["cluster"];
|
||||||
let node = &caps["node"];
|
let node = &caps["node"];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user