diff --git a/appmgr/Cargo.lock b/appmgr/Cargo.lock index 3779e9250..0493a33dd 100644 --- a/appmgr/Cargo.lock +++ b/appmgr/Cargo.lock @@ -874,6 +874,7 @@ dependencies = [ "patch-db", "pbkdf2", "pin-project", + "platforms", "prettytable-rs", "proptest", "proptest-derive", @@ -2210,6 +2211,12 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" +[[package]] +name = "platforms" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989d43012e2ca1c4a02507c67282691a0a3207f9dc67cec596b43fe925b3d325" + [[package]] name = "ppv-lite86" version = "0.2.10" diff --git a/appmgr/Cargo.toml b/appmgr/Cargo.toml index f926b6583..a03abc465 100644 --- a/appmgr/Cargo.toml +++ b/appmgr/Cargo.toml @@ -85,6 +85,7 @@ patch-db = { version = "*", path = "../patch-db/patch-db", features = [ ] } pbkdf2 = "0.9.0" pin-project = "1.0.8" +platforms = "1.1.0" prettytable-rs = "0.8.0" proptest = "1.0.0" proptest-derive = "0.3.0" diff --git a/appmgr/src/install/mod.rs b/appmgr/src/install/mod.rs index dcf5577e7..38d731d67 100644 --- a/appmgr/src/install/mod.rs +++ b/appmgr/src/install/mod.rs @@ -37,6 +37,7 @@ use crate::s9pk::reader::S9pkReader; use crate::status::{MainStatus, Status}; use crate::util::io::copy_and_shutdown; use crate::util::{display_none, display_serializable, AsyncFileExt, Version}; +use crate::version::{Current, VersionT}; use crate::volume::asset_dir; use crate::{Error, ResultExt}; @@ -83,12 +84,20 @@ pub async fn install( let reg_url = ctx.package_registry_url().await?; let (man_res, s9pk) = tokio::try_join!( reqwest::get(format!( - "{}/package/manifest/{}?version={}", - reg_url, pkg_id, version + "{}/package/manifest/{}?version={}&eos-version={}&arch={}", + reg_url, + pkg_id, + version, + Current::new().semver(), + platforms::TARGET_ARCH, )), reqwest::get(format!( - "{}/package/{}.s9pk?version={}", - reg_url, pkg_id, version + "{}/package/{}.s9pk?version={}&eos-version={}&arch={}", + reg_url, + pkg_id, + version, + Current::new().semver(), + platforms::TARGET_ARCH, )) ) .with_kind(crate::ErrorKind::Registry)?; @@ -386,8 +395,12 @@ pub async fn install_s9pk( let reg_url = ctx.package_registry_url().await?; for (dep, info) in &manifest.dependencies.0 { let manifest: Option = match reqwest::get(format!( - "{}/package/manifest/{}?version={}", - reg_url, dep, info.version + "{}/package/manifest/{}?version={}&eos-version={}&arch={}", + reg_url, + dep, + info.version, + Current::new().semver(), + platforms::TARGET_ARCH, )) .await .with_kind(crate::ErrorKind::Registry)? @@ -412,8 +425,12 @@ pub async fn install_s9pk( if tokio::fs::metadata(&icon_path).await.is_err() { tokio::fs::create_dir_all(&dir).await?; let icon = reqwest::get(format!( - "{}/package/icon/{}?version={}", - reg_url, dep, info.version + "{}/package/icon/{}?version={}&eos-version={}&arch={}", + reg_url, + dep, + info.version, + Current::new().semver(), + platforms::TARGET_ARCH, )) .await .with_kind(crate::ErrorKind::Registry)?; diff --git a/appmgr/src/update/mod.rs b/appmgr/src/update/mod.rs index a8e36252d..655c2ff11 100644 --- a/appmgr/src/update/mod.rs +++ b/appmgr/src/update/mod.rs @@ -28,6 +28,7 @@ use crate::db::util::WithRevision; use crate::notifications::NotificationLevel; use crate::update::latest_information::LatestInformation; use crate::util::Invoke; +use crate::version::{Current, VersionT}; use crate::{Error, ErrorKind, ResultExt}; lazy_static! { @@ -177,13 +178,18 @@ lazy_static! { #[instrument(skip(ctx))] async fn maybe_do_update(ctx: RpcContext) -> Result>, Error> { let mut db = ctx.db.handle(); - let latest_version = reqwest::get(format!("{}/eos/latest", ctx.eos_registry_url().await?)) - .await - .with_kind(ErrorKind::Network)? - .json::() - .await - .with_kind(ErrorKind::Network)? - .version; + let latest_version = reqwest::get(format!( + "{}/eos/latest?eos-version={}&arch={}", + ctx.eos_registry_url().await?, + Current::new().semver(), + platforms::TARGET_ARCH, + )) + .await + .with_kind(ErrorKind::Network)? + .json::() + .await + .with_kind(ErrorKind::Network)? + .version; let current_version = crate::db::DatabaseModel::new() .server_info() .version() @@ -321,7 +327,14 @@ struct EosUrl { } impl std::fmt::Display for EosUrl { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}/eos/eos.img?version=={}", self.base, self.version) + write!( + f, + "{}/eos/eos.img?version=={}&eos-version={}&arch={}", + self.base, + self.version, + Current::new().semver(), + platforms::TARGET_ARCH, + ) } }