mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
fix --arch flag to fall back to emulation when native image unavailab… (#3108)
* fix --arch flag to fall back to emulation when native image unavailable, always infer hardware requirement for arch * better handling of arch filter * dont cancel in-progress commit workflows and abstract common setup * cli improvements fix group handling * fix cli publish * alpha.19 --------- Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
@@ -7,6 +7,7 @@ use clap::Parser;
|
||||
use futures::future::{BoxFuture, ready};
|
||||
use futures::{FutureExt, TryStreamExt};
|
||||
use imbl_value::InternedString;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::process::Command;
|
||||
use tokio::sync::OnceCell;
|
||||
@@ -686,7 +687,7 @@ pub async fn pack(ctx: CliContext, params: PackParams) -> Result<(), Error> {
|
||||
let manifest = s9pk.as_manifest_mut();
|
||||
manifest.git_hash = Some(GitHash::from_path(params.path()).await?);
|
||||
if !params.arch.is_empty() {
|
||||
let arches = match manifest.hardware_requirements.arch.take() {
|
||||
let arches: BTreeSet<InternedString> = match manifest.hardware_requirements.arch.take() {
|
||||
Some(a) => params
|
||||
.arch
|
||||
.iter()
|
||||
@@ -695,10 +696,41 @@ pub async fn pack(ctx: CliContext, params: PackParams) -> Result<(), Error> {
|
||||
.collect(),
|
||||
None => params.arch.iter().cloned().collect(),
|
||||
};
|
||||
manifest
|
||||
.images
|
||||
.values_mut()
|
||||
.for_each(|c| c.arch = c.arch.intersection(&arches).cloned().collect());
|
||||
if arches.is_empty() {
|
||||
return Err(Error::new(
|
||||
eyre!(
|
||||
"none of the requested architectures ({:?}) are supported by this package",
|
||||
params.arch
|
||||
),
|
||||
ErrorKind::InvalidRequest,
|
||||
));
|
||||
}
|
||||
manifest.images.iter_mut().for_each(|(id, c)| {
|
||||
let filtered = c
|
||||
.arch
|
||||
.intersection(&arches)
|
||||
.cloned()
|
||||
.collect::<BTreeSet<_>>();
|
||||
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("/"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
c.arch = filtered;
|
||||
}
|
||||
});
|
||||
manifest.hardware_requirements.arch = Some(arches);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user