mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
Bugfix/protocol consistency (#846)
* fix eos <-> registry protocol * fix ui <-> eos protocol * redoes the embassyd api to accept an optional version spec argument, still allowing for CLI @ syntax * redo the front end in accordance with the new api * Update appmgr/src/install/mod.rs Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> * fix more query params Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
committed by
Aiden McClelland
parent
198635da50
commit
aea5dfe04a
@@ -84,27 +84,27 @@ pub async fn list(#[context] ctx: RpcContext) -> Result<Vec<(PackageId, Version)
|
||||
pub async fn install(
|
||||
#[context] ctx: RpcContext,
|
||||
#[arg] id: String,
|
||||
#[arg(rename = "version-spec")] version_spec: Option<String>,
|
||||
) -> Result<WithRevision<()>, Error> {
|
||||
let (pkg_id, version_str) = if let Some(split) = id.split_once("@") {
|
||||
split
|
||||
} else {
|
||||
(id.as_str(), "*")
|
||||
let version_str = match &version_spec {
|
||||
None => "*",
|
||||
Some(v) => &*v,
|
||||
};
|
||||
let version: VersionRange = version_str.parse()?;
|
||||
let reg_url = ctx.package_registry_url().await?;
|
||||
let (man_res, s9pk) = tokio::try_join!(
|
||||
reqwest::get(format!(
|
||||
"{}/package/manifest/{}?version={}&eos-version-compat={}&arch={}",
|
||||
"{}/package/manifest/{}?spec={}&eos-version-compat={}&arch={}",
|
||||
reg_url,
|
||||
pkg_id,
|
||||
id,
|
||||
version,
|
||||
Current::new().compat(),
|
||||
platforms::TARGET_ARCH,
|
||||
)),
|
||||
reqwest::get(format!(
|
||||
"{}/package/{}.s9pk?version={}&eos-version-compat={}&arch={}",
|
||||
"{}/package/{}.s9pk?spec={}&eos-version-compat={}&arch={}",
|
||||
reg_url,
|
||||
pkg_id,
|
||||
id,
|
||||
version,
|
||||
Current::new().compat(),
|
||||
platforms::TARGET_ARCH,
|
||||
@@ -319,7 +319,11 @@ pub async fn sideload(
|
||||
}
|
||||
|
||||
#[instrument(skip(ctx))]
|
||||
async fn cli_install(ctx: CliContext, target: String) -> Result<(), RpcError> {
|
||||
async fn cli_install(
|
||||
ctx: CliContext,
|
||||
target: String,
|
||||
version_spec: Option<String>,
|
||||
) -> Result<(), RpcError> {
|
||||
if target.ends_with(".s9pk") {
|
||||
let path = PathBuf::from(target);
|
||||
|
||||
@@ -360,11 +364,23 @@ async fn cli_install(ctx: CliContext, target: String) -> Result<(), RpcError> {
|
||||
tracing::info!("Package Upload failed: {}", res.text().await?)
|
||||
}
|
||||
} else {
|
||||
let params = match (target.split_once("@"), version_spec) {
|
||||
(Some((pkg, v)), None) => serde_json::json!({ "id": pkg, "version-spec": v }),
|
||||
(Some((pkg, v)), Some(_)) => {
|
||||
return Err(crate::Error::new(
|
||||
eyre!("Invalid package id {}", target),
|
||||
ErrorKind::InvalidRequest,
|
||||
)
|
||||
.into())
|
||||
}
|
||||
(None, Some(v)) => serde_json::json!({ "id": target, "version-spec": v }),
|
||||
(None, None) => serde_json::json!({ "id": target }),
|
||||
};
|
||||
tracing::debug!("calling package.install");
|
||||
rpc_toolkit::command_helpers::call_remote(
|
||||
ctx,
|
||||
"package.install",
|
||||
serde_json::json!({ "id": target }),
|
||||
params,
|
||||
PhantomData::<()>,
|
||||
)
|
||||
.await?
|
||||
@@ -580,7 +596,7 @@ 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={}&eos-version-compat={}&arch={}",
|
||||
"{}/package/manifest/{}?spec={}&eos-version-compat={}&arch={}",
|
||||
reg_url,
|
||||
dep,
|
||||
info.version,
|
||||
@@ -610,7 +626,7 @@ 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={}&eos-version-compat={}&arch={}",
|
||||
"{}/package/icon/{}?spec={}&eos-version-compat={}&arch={}",
|
||||
reg_url,
|
||||
dep,
|
||||
info.version,
|
||||
|
||||
@@ -329,7 +329,7 @@ impl std::fmt::Display for EosUrl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}/eos/eos.img?version=={}&eos-version={}&arch={}",
|
||||
"{}/eos/eos.img?spec=={}&eos-version={}&arch={}",
|
||||
self.base,
|
||||
self.version,
|
||||
Current::new().semver(),
|
||||
|
||||
Reference in New Issue
Block a user