mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
better handling of arch filter
This commit is contained in:
@@ -7,6 +7,7 @@ use clap::Parser;
|
|||||||
use futures::future::{BoxFuture, ready};
|
use futures::future::{BoxFuture, ready};
|
||||||
use futures::{FutureExt, TryStreamExt};
|
use futures::{FutureExt, TryStreamExt};
|
||||||
use imbl_value::InternedString;
|
use imbl_value::InternedString;
|
||||||
|
use itertools::Itertools;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::sync::OnceCell;
|
use tokio::sync::OnceCell;
|
||||||
@@ -704,16 +705,30 @@ pub async fn pack(ctx: CliContext, params: PackParams) -> Result<(), Error> {
|
|||||||
ErrorKind::InvalidRequest,
|
ErrorKind::InvalidRequest,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
manifest.images.values_mut().for_each(|c| {
|
manifest.images.iter_mut().for_each(|(id, c)| {
|
||||||
let mut to_load = BTreeSet::new();
|
let filtered = c
|
||||||
for arch in &arches {
|
.arch
|
||||||
if c.arch.contains(arch) {
|
.intersection(&arches)
|
||||||
to_load.insert(arch.clone());
|
.cloned()
|
||||||
} else if let Some(ref emulate_as) = c.emulate_missing_as {
|
.collect::<BTreeSet<_>>();
|
||||||
to_load.insert(emulate_as.clone());
|
if filtered.is_empty() {
|
||||||
|
if let Some(arch) = &c.emulate_missing_as {
|
||||||
|
tracing::warn!(
|
||||||
|
"ImageId {} is not available for {}, emulating as {}",
|
||||||
|
id,
|
||||||
|
arches.iter().join("/"),
|
||||||
|
arch
|
||||||
|
);
|
||||||
|
c.arch = [arch.clone()].into_iter().collect();
|
||||||
|
} else {
|
||||||
|
tracing::error!(
|
||||||
|
"ImageId {} is not available for {}",
|
||||||
|
id,
|
||||||
|
arches.iter().join("/"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.arch = to_load;
|
c.arch = filtered;
|
||||||
});
|
});
|
||||||
manifest.hardware_requirements.arch = Some(arches);
|
manifest.hardware_requirements.arch = Some(arches);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ impl<'a> Invoke<'a> for ExtendedCommand<'a> {
|
|||||||
.or(Some(&res.stdout))
|
.or(Some(&res.stdout))
|
||||||
.filter(|a| !a.is_empty())
|
.filter(|a| !a.is_empty())
|
||||||
.and_then(|a| std::str::from_utf8(a).ok())
|
.and_then(|a| std::str::from_utf8(a).ok())
|
||||||
.unwrap_or(&format!("{} exited with code {}", cmd_str, res.status))
|
.unwrap_or(&format!("{} exited with {}", cmd_str, res.status))
|
||||||
);
|
);
|
||||||
Ok(res.stdout)
|
Ok(res.stdout)
|
||||||
} else {
|
} else {
|
||||||
@@ -309,7 +309,7 @@ impl<'a> Invoke<'a> for ExtendedCommand<'a> {
|
|||||||
.filter(|a| !a.is_empty())
|
.filter(|a| !a.is_empty())
|
||||||
.and_then(|a| std::str::from_utf8(a).ok())
|
.and_then(|a| std::str::from_utf8(a).ok())
|
||||||
.unwrap_or(&format!(
|
.unwrap_or(&format!(
|
||||||
"{} exited with code {}",
|
"{} exited with {}",
|
||||||
cmd.as_std().get_program().to_string_lossy(),
|
cmd.as_std().get_program().to_string_lossy(),
|
||||||
res.status
|
res.status
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ export function buildManifest<
|
|||||||
): Manifest & T.Manifest {
|
): Manifest & T.Manifest {
|
||||||
const images = Object.entries(manifest.images).reduce(
|
const images = Object.entries(manifest.images).reduce(
|
||||||
(images, [k, v]) => {
|
(images, [k, v]) => {
|
||||||
v.arch = v.arch || ["aarch64", "x86_64"]
|
v.arch = v.arch ?? ["aarch64", "x86_64", "riscv64"]
|
||||||
if (v.emulateMissingAs === undefined)
|
if (v.emulateMissingAs === undefined)
|
||||||
v.emulateMissingAs = (v.arch as string[]).includes("aarch64")
|
v.emulateMissingAs = (v.arch as string[]).includes("x86_64")
|
||||||
? "aarch64"
|
? "x86_64"
|
||||||
: v.arch[0] || null
|
: (v.arch[0] ?? null)
|
||||||
v.nvidiaContainer = !!v.nvidiaContainer
|
v.nvidiaContainer = !!v.nvidiaContainer
|
||||||
images[k] = v as ImageConfig
|
images[k] = v as ImageConfig
|
||||||
return images
|
return images
|
||||||
|
|||||||
Reference in New Issue
Block a user