use hardware requirements to display conflicts and prevent install (#2700)

* use hardware requirements to display conflicts and prevent install

* better messaging and also consider OS compatibility

* wip: backend hw requirements

* update backend components

* migration

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
Matt Hill
2024-10-29 13:48:03 -06:00
committed by GitHub
parent e1a91a7e53
commit 1be9cdae67
35 changed files with 725 additions and 500 deletions

View File

@@ -25,8 +25,9 @@ mod v0_3_6_alpha_3;
mod v0_3_6_alpha_4;
mod v0_3_6_alpha_5;
mod v0_3_6_alpha_6;
mod v0_3_6_alpha_7;
pub type Current = v0_3_6_alpha_6::Version; // VERSION_BUMP
pub type Current = v0_3_6_alpha_7::Version; // VERSION_BUMP
impl Current {
#[instrument(skip(self, db))]
@@ -102,6 +103,7 @@ enum Version {
V0_3_6_alpha_4(Wrapper<v0_3_6_alpha_4::Version>),
V0_3_6_alpha_5(Wrapper<v0_3_6_alpha_5::Version>),
V0_3_6_alpha_6(Wrapper<v0_3_6_alpha_6::Version>),
V0_3_6_alpha_7(Wrapper<v0_3_6_alpha_7::Version>),
Other(exver::Version),
}
@@ -132,6 +134,7 @@ impl Version {
Self::V0_3_6_alpha_4(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_5(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_6(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_7(v) => DynVersion(Box::new(v.0)),
Self::Other(v) => {
return Err(Error::new(
eyre!("unknown version {v}"),
@@ -154,6 +157,7 @@ impl Version {
Version::V0_3_6_alpha_4(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_5(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_6(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_7(Wrapper(x)) => x.semver(),
Version::Other(x) => x.clone(),
}
}
@@ -172,15 +176,19 @@ fn version_accessor(db: &mut Value) -> Option<&mut Value> {
fn version_compat_accessor(db: &mut Value) -> Option<&mut Value> {
if db.get("public").is_some() {
let server_info = db.get_mut("public")?.get_mut("serverInfo")?;
if server_info.get("versionCompat").is_some() {
server_info.get_mut("versionCompat")
if server_info.get("packageVersionCompat").is_some() {
server_info.get_mut("packageVersionCompat")
} else {
if let Some(prev) = server_info.get("eosVersionCompat").cloned() {
server_info
.as_object_mut()?
.insert("versionCompat".into(), prev);
.insert("packageVersionCompat".into(), prev);
} else if let Some(prev) = server_info.get("versionCompat").cloned() {
server_info
.as_object_mut()?
.insert("packageVersionCompat".into(), prev);
}
server_info.get_mut("versionCompat")
server_info.get_mut("packageVersionCompat")
}
} else {
db.get_mut("server-info")?.get_mut("eos-version-compat")

View File

@@ -0,0 +1,50 @@
use exver::{PreReleaseSegment, VersionRange};
use imbl_value::{json, InOMap};
use super::v0_3_5::V0_3_0_COMPAT;
use super::{v0_3_6_alpha_6, VersionT};
use crate::prelude::*;
lazy_static::lazy_static! {
static ref V0_3_6_alpha_7: exver::Version = exver::Version::new(
[0, 3, 6],
[PreReleaseSegment::String("alpha".into()), 7.into()]
);
}
#[derive(Clone, Copy, Debug, Default)]
pub struct Version;
impl VersionT for Version {
type Previous = v0_3_6_alpha_6::Version;
type PreUpRes = ();
async fn pre_up(self) -> Result<Self::PreUpRes, Error> {
Ok(())
}
fn semver(self) -> exver::Version {
V0_3_6_alpha_7.clone()
}
fn compat(self) -> &'static VersionRange {
&V0_3_0_COMPAT
}
fn up(self, db: &mut Value, _: Self::PreUpRes) -> Result<(), Error> {
let server_info = db["public"]["serverInfo"]
.as_object_mut()
.or_not_found("public.serverInfo")?;
server_info.insert("ram".into(), json!(0));
server_info.insert("devices".into(), json!([]));
let package_data = db["public"]["packageData"]
.as_object_mut()
.or_not_found("public.packageData")?;
for (_, pde) in package_data.iter_mut() {
if let Some(manifest) = pde["stateInfo"].get_mut("manifest") {
manifest["hardwareRequirements"]["device"] = json!([]);
}
}
Ok(())
}
fn down(self, _db: &mut Value) -> Result<(), Error> {
Ok(())
}
}