diff --git a/appmgr/build-portable.sh b/appmgr/build-portable.sh index 3f5b0ff17..5cd6cd576 100755 --- a/appmgr/build-portable.sh +++ b/appmgr/build-portable.sh @@ -8,8 +8,8 @@ if [ "$0" != "./build-portable.sh" ]; then exit 1 fi -alias 'rust-musl-builder'='docker run --rm -it -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src messense/rust-musl-cross:x86_64-musl' +alias 'rust-musl-builder'='docker run --rm -it -v "$HOME"/.cargo/registry:/root/.cargo/registry -v "$(pwd)":/home/rust/src start9/rust-musl-cross:x86_64-musl' -cd .. -rust-musl-builder sh -c "(cd appmgr && cargo build --release --target=x86_64-unknown-linux-musl --features=portable,production --no-default-features)" -cd appmgr +cd ../.. +rust-musl-builder sh -c "(cd embassy-os/appmgr && cargo +beta build --release --target=x86_64-unknown-linux-musl --no-default-features)" +cd embassy-os/appmgr diff --git a/appmgr/embassy-pages.s9pk b/appmgr/embassy-pages.s9pk new file mode 100644 index 000000000..fdef873db Binary files /dev/null and b/appmgr/embassy-pages.s9pk differ diff --git a/appmgr/src/context/rpc.rs b/appmgr/src/context/rpc.rs index a20a88eca..39837ece3 100644 --- a/appmgr/src/context/rpc.rs +++ b/appmgr/src/context/rpc.rs @@ -12,6 +12,7 @@ use serde::Deserialize; use sqlx::SqlitePool; use tokio::fs::File; +#[cfg(feature = "avahi")] use crate::net::mdns::MdnsController; use crate::net::tor::TorController; use crate::util::{from_toml_async_reader, AsyncFileExt, Container}; @@ -34,6 +35,7 @@ pub struct RpcContextSeed { pub secret_store: SqlitePool, pub docker: Docker, pub tor_controller: TorController, + #[cfg(feature = "avahi")] pub mdns_controller: MdnsController, } @@ -72,6 +74,7 @@ impl RpcContext { &mut secret_store.acquire().await?, ) .await?; + #[cfg(feature = "avahi")] let mdns_controller = MdnsController::init(&mut db_handle).await?; let seed = Arc::new(RpcContextSeed { bind_rpc: base.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()), @@ -80,6 +83,7 @@ impl RpcContext { secret_store, docker: Docker::connect_with_unix_defaults()?, tor_controller, + #[cfg(feature = "avahi")] mdns_controller, }); Ok(Self(seed)) diff --git a/appmgr/src/db/model.rs b/appmgr/src/db/model.rs index 433077fdc..f1e723938 100644 --- a/appmgr/src/db/model.rs +++ b/appmgr/src/db/model.rs @@ -87,26 +87,24 @@ impl HasModel for AllPackageData { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct StaticFiles { - license: Url, - instructions: Url, - icon: Url, + license: String, + instructions: String, + icon: String, } impl StaticFiles { - pub fn local(id: &PackageId, version: &Version, icon_type: &str) -> Result { - Ok(StaticFiles { - license: format!("/public/package-data/{}/{}/LICENSE.md", id, version).parse()?, - instructions: format!("/public/package-data/{}/{}/INSTRUCTIONS.md", id, version) - .parse()?, - icon: format!("/public/package-data/{}/{}/icon.{}", id, version, icon_type).parse()?, - }) + pub fn local(id: &PackageId, version: &Version, icon_type: &str) -> Self { + StaticFiles { + license: format!("/public/package-data/{}/{}/LICENSE.md", id, version), + instructions: format!("/public/package-data/{}/{}/INSTRUCTIONS.md", id, version), + icon: format!("/public/package-data/{}/{}/icon.{}", id, version, icon_type), + } } - pub fn remote(id: &PackageId, version: &Version, icon_type: &str) -> Result { - Ok(StaticFiles { - license: format!("/registry/packages/{}/{}/LICENSE.md", id, version).parse()?, - instructions: format!("/registry/packages/{}/{}/INSTRUCTIONS.md", id, version) - .parse()?, - icon: format!("/registry/packages/{}/{}/icon.{}", id, version, icon_type).parse()?, - }) + pub fn remote(id: &PackageId, version: &Version, icon_type: &str) -> Self { + StaticFiles { + license: format!("/registry/packages/{}/{}/LICENSE.md", id, version), + instructions: format!("/registry/packages/{}/{}/INSTRUCTIONS.md", id, version), + icon: format!("/registry/packages/{}/{}/icon.{}", id, version, icon_type), + } } } diff --git a/appmgr/src/inspect.rs b/appmgr/src/inspect.rs index 5de24ce9f..e9c63ae68 100644 --- a/appmgr/src/inspect.rs +++ b/appmgr/src/inspect.rs @@ -8,11 +8,16 @@ use crate::s9pk::reader::S9pkReader; use crate::util::{display_none, display_serializable, IoFormat}; use crate::Error; -#[command(subcommands(manifest, license, icon, instructions, docker_images))] +#[command(subcommands(hash, manifest, license, icon, instructions, docker_images))] pub fn inspect(#[context] ctx: EitherContext) -> Result<(), Error> { Ok(()) } +#[command(cli_only)] +pub async fn hash(#[arg] path: PathBuf) -> Result { + Ok(S9pkReader::open(path).await?.hash_str().to_owned()) +} + #[command(cli_only, display(display_serializable))] pub async fn manifest( #[arg] path: PathBuf, diff --git a/appmgr/src/install/mod.rs b/appmgr/src/install/mod.rs index ab57ea916..1e2ed217d 100644 --- a/appmgr/src/install/mod.rs +++ b/appmgr/src/install/mod.rs @@ -53,11 +53,11 @@ pub async fn install(#[context] ctx: EitherContext, #[arg] id: String) -> Result let reg_url = rpc_ctx.package_registry_url().await?; let (man_res, s9pk) = tokio::try_join!( reqwest::get(format!( - "{}/packages/manifest/{}?version={}", + "{}/package/manifest/{}?version={}", reg_url, pkg_id, version )), reqwest::get(format!( - "{}/packages/{}.s9pk?version={}", + "{}/package/{}.s9pk?version={}", reg_url, pkg_id, version )) ) @@ -86,7 +86,7 @@ pub async fn download_install_s9pk( let res = (|| async { let progress = InstallProgress::new(s9pk.content_length()); - let static_files = StaticFiles::remote(pkg_id, version, temp_manifest.assets.icon_type())?; + let static_files = StaticFiles::remote(pkg_id, version, temp_manifest.assets.icon_type()); let mut pde = pkg_data_entry.get_mut(&mut db).await?; match pde.take() { Some(PackageDataEntry::Installed { installed, .. }) => { @@ -381,7 +381,7 @@ pub async fn install_s9pk( log::info!("Install {}@{}: Complete", pkg_id, version); - let static_files = StaticFiles::local(pkg_id, version, manifest.assets.icon_type())?; + let static_files = StaticFiles::local(pkg_id, version, manifest.assets.icon_type()); let current_dependencies = manifest .dependencies .0 @@ -490,6 +490,7 @@ pub async fn install_s9pk( } ctx.tor_controller.sync(&mut tx, &mut sql_tx).await?; + #[cfg(feature = "avahi")] ctx.mdns_controller.sync(&mut tx).await?; tx.commit(None).await?;