fix feature flag for avahi

This commit is contained in:
Aiden McClelland
2021-07-08 10:28:32 -06:00
parent 8035fb285c
commit a2188be4cd
6 changed files with 34 additions and 26 deletions

View File

@@ -8,8 +8,8 @@ if [ "$0" != "./build-portable.sh" ]; then
exit 1 exit 1
fi 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 .. cd ../..
rust-musl-builder sh -c "(cd appmgr && cargo build --release --target=x86_64-unknown-linux-musl --features=portable,production --no-default-features)" rust-musl-builder sh -c "(cd embassy-os/appmgr && cargo +beta build --release --target=x86_64-unknown-linux-musl --no-default-features)"
cd appmgr cd embassy-os/appmgr

BIN
appmgr/embassy-pages.s9pk Normal file

Binary file not shown.

View File

@@ -12,6 +12,7 @@ use serde::Deserialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;
use tokio::fs::File; use tokio::fs::File;
#[cfg(feature = "avahi")]
use crate::net::mdns::MdnsController; use crate::net::mdns::MdnsController;
use crate::net::tor::TorController; use crate::net::tor::TorController;
use crate::util::{from_toml_async_reader, AsyncFileExt, Container}; use crate::util::{from_toml_async_reader, AsyncFileExt, Container};
@@ -34,6 +35,7 @@ pub struct RpcContextSeed {
pub secret_store: SqlitePool, pub secret_store: SqlitePool,
pub docker: Docker, pub docker: Docker,
pub tor_controller: TorController, pub tor_controller: TorController,
#[cfg(feature = "avahi")]
pub mdns_controller: MdnsController, pub mdns_controller: MdnsController,
} }
@@ -72,6 +74,7 @@ impl RpcContext {
&mut secret_store.acquire().await?, &mut secret_store.acquire().await?,
) )
.await?; .await?;
#[cfg(feature = "avahi")]
let mdns_controller = MdnsController::init(&mut db_handle).await?; let mdns_controller = MdnsController::init(&mut db_handle).await?;
let seed = Arc::new(RpcContextSeed { let seed = Arc::new(RpcContextSeed {
bind_rpc: base.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()), bind_rpc: base.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()),
@@ -80,6 +83,7 @@ impl RpcContext {
secret_store, secret_store,
docker: Docker::connect_with_unix_defaults()?, docker: Docker::connect_with_unix_defaults()?,
tor_controller, tor_controller,
#[cfg(feature = "avahi")]
mdns_controller, mdns_controller,
}); });
Ok(Self(seed)) Ok(Self(seed))

View File

@@ -87,26 +87,24 @@ impl HasModel for AllPackageData {
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct StaticFiles { pub struct StaticFiles {
license: Url, license: String,
instructions: Url, instructions: String,
icon: Url, icon: String,
} }
impl StaticFiles { impl StaticFiles {
pub fn local(id: &PackageId, version: &Version, icon_type: &str) -> Result<Self, Error> { pub fn local(id: &PackageId, version: &Version, icon_type: &str) -> Self {
Ok(StaticFiles { StaticFiles {
license: format!("/public/package-data/{}/{}/LICENSE.md", id, version).parse()?, license: format!("/public/package-data/{}/{}/LICENSE.md", id, version),
instructions: format!("/public/package-data/{}/{}/INSTRUCTIONS.md", id, version) instructions: format!("/public/package-data/{}/{}/INSTRUCTIONS.md", id, version),
.parse()?, icon: format!("/public/package-data/{}/{}/icon.{}", id, version, icon_type),
icon: format!("/public/package-data/{}/{}/icon.{}", id, version, icon_type).parse()?, }
})
} }
pub fn remote(id: &PackageId, version: &Version, icon_type: &str) -> Result<Self, Error> { pub fn remote(id: &PackageId, version: &Version, icon_type: &str) -> Self {
Ok(StaticFiles { StaticFiles {
license: format!("/registry/packages/{}/{}/LICENSE.md", id, version).parse()?, license: format!("/registry/packages/{}/{}/LICENSE.md", id, version),
instructions: format!("/registry/packages/{}/{}/INSTRUCTIONS.md", id, version) instructions: format!("/registry/packages/{}/{}/INSTRUCTIONS.md", id, version),
.parse()?, icon: format!("/registry/packages/{}/{}/icon.{}", id, version, icon_type),
icon: format!("/registry/packages/{}/{}/icon.{}", id, version, icon_type).parse()?, }
})
} }
} }

View File

@@ -8,11 +8,16 @@ use crate::s9pk::reader::S9pkReader;
use crate::util::{display_none, display_serializable, IoFormat}; use crate::util::{display_none, display_serializable, IoFormat};
use crate::Error; 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> { pub fn inspect(#[context] ctx: EitherContext) -> Result<(), Error> {
Ok(()) Ok(())
} }
#[command(cli_only)]
pub async fn hash(#[arg] path: PathBuf) -> Result<String, Error> {
Ok(S9pkReader::open(path).await?.hash_str().to_owned())
}
#[command(cli_only, display(display_serializable))] #[command(cli_only, display(display_serializable))]
pub async fn manifest( pub async fn manifest(
#[arg] path: PathBuf, #[arg] path: PathBuf,

View File

@@ -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 reg_url = rpc_ctx.package_registry_url().await?;
let (man_res, s9pk) = tokio::try_join!( let (man_res, s9pk) = tokio::try_join!(
reqwest::get(format!( reqwest::get(format!(
"{}/packages/manifest/{}?version={}", "{}/package/manifest/{}?version={}",
reg_url, pkg_id, version reg_url, pkg_id, version
)), )),
reqwest::get(format!( reqwest::get(format!(
"{}/packages/{}.s9pk?version={}", "{}/package/{}.s9pk?version={}",
reg_url, pkg_id, version reg_url, pkg_id, version
)) ))
) )
@@ -86,7 +86,7 @@ pub async fn download_install_s9pk(
let res = (|| async { let res = (|| async {
let progress = InstallProgress::new(s9pk.content_length()); 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?; let mut pde = pkg_data_entry.get_mut(&mut db).await?;
match pde.take() { match pde.take() {
Some(PackageDataEntry::Installed { installed, .. }) => { Some(PackageDataEntry::Installed { installed, .. }) => {
@@ -381,7 +381,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
log::info!("Install {}@{}: Complete", pkg_id, version); 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 let current_dependencies = manifest
.dependencies .dependencies
.0 .0
@@ -490,6 +490,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
} }
ctx.tor_controller.sync(&mut tx, &mut sql_tx).await?; ctx.tor_controller.sync(&mut tx, &mut sql_tx).await?;
#[cfg(feature = "avahi")]
ctx.mdns_controller.sync(&mut tx).await?; ctx.mdns_controller.sync(&mut tx).await?;
tx.commit(None).await?; tx.commit(None).await?;