This commit is contained in:
Aiden McClelland
2021-11-08 16:35:13 -07:00
committed by Aiden McClelland
parent 6eb2dfbb5e
commit d55586755d
4 changed files with 54 additions and 16 deletions

7
appmgr/Cargo.lock generated
View File

@@ -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"

View File

@@ -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"

View File

@@ -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<R: AsyncRead + AsyncSeek + Unpin>(
let reg_url = ctx.package_registry_url().await?;
for (dep, info) in &manifest.dependencies.0 {
let manifest: Option<Manifest> = 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<R: AsyncRead + AsyncSeek + Unpin>(
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)?;

View File

@@ -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<Option<Arc<Revision>>, 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::<LatestInformation>()
.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::<LatestInformation>()
.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,
)
}
}