Fixes: Builds for the macs (#2397)

* Fixes: Builds for the macs

* misc: Allow the feature flags run during the build for the avahi tools
This commit is contained in:
J H
2023-08-17 16:23:33 -06:00
committed by GitHub
parent af116794c4
commit b7593fac44
8 changed files with 11 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ FRONTEND_DIAGNOSTIC_UI_SRC := $(shell find frontend/projects/diagnostic-ui)
FRONTEND_INSTALL_WIZARD_SRC := $(shell find frontend/projects/install-wizard) FRONTEND_INSTALL_WIZARD_SRC := $(shell find frontend/projects/install-wizard)
PATCH_DB_CLIENT_SRC := $(shell find patch-db/client -not -path patch-db/client/dist -and -not -path patch-db/client/node_modules) PATCH_DB_CLIENT_SRC := $(shell find patch-db/client -not -path patch-db/client/dist -and -not -path patch-db/client/node_modules)
GZIP_BIN := $(shell which pigz || which gzip) GZIP_BIN := $(shell which pigz || which gzip)
TAR_BIN := $(shell which gtar || which tar)
ALL_TARGETS := $(EMBASSY_BINS) system-images/compat/docker-images/$(ARCH).tar system-images/utils/docker-images/$(ARCH).tar system-images/binfmt/docker-images/$(ARCH).tar $(EMBASSY_SRC) $(shell if [ "$(OS_ARCH)" = "raspberrypi" ]; then echo cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep; fi) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE) ALL_TARGETS := $(EMBASSY_BINS) system-images/compat/docker-images/$(ARCH).tar system-images/utils/docker-images/$(ARCH).tar system-images/binfmt/docker-images/$(ARCH).tar $(EMBASSY_SRC) $(shell if [ "$(OS_ARCH)" = "raspberrypi" ]; then echo cargo-deps/aarch64-unknown-linux-gnu/release/pi-beep; fi) $(ENVIRONMENT_FILE) $(GIT_HASH_FILE) $(VERSION_FILE)
ifeq ($(REMOTE),) ifeq ($(REMOTE),)
@@ -26,11 +27,11 @@ ifeq ($(REMOTE),)
cp = cp -r $1 $2 cp = cp -r $1 $2
ln = ln -sf $1 $2 ln = ln -sf $1 $2
else else
mkdir = ssh $(REMOTE) 'mkdir -p $1' mkdir = ssh $(REMOTE) 'sudo mkdir -p $1'
rm = ssh $(REMOTE) 'sudo rm -rf $1' rm = ssh $(REMOTE) 'sudo rm -rf $1'
ln = ssh $(REMOTE) 'sudo ln -sf $1 $2' ln = ssh $(REMOTE) 'sudo ln -sf $1 $2'
define cp define cp
tar --transform "s|^$1|x|" -czv -f- $1 | ssh $(REMOTE) "sudo tar --transform 's|^x|$2|' -xzv -f- -C /" $(TAR_BIN) --transform "s|^$1|x|" -czv -f- $1 | ssh $(REMOTE) "sudo tar --transform 's|^x|$2|' -xzv -f- -C /"
endef endef
endif endif

View File

@@ -26,7 +26,7 @@ path = "src/main.rs"
[features] [features]
avahi = ["avahi-sys"] avahi = ["avahi-sys"]
default = ["avahi-alias", "cli", "sdk", "daemon", "js_engine"] default = ["cli", "sdk", "daemon", "js_engine"]
dev = [] dev = []
unstable = ["patch-db/unstable"] unstable = ["patch-db/unstable"]
avahi-alias = ["avahi"] avahi-alias = ["avahi"]

View File

@@ -5,6 +5,7 @@
- Recommended: [rust-analyzer](https://rust-analyzer.github.io/) - Recommended: [rust-analyzer](https://rust-analyzer.github.io/)
- [Docker](https://docs.docker.com/get-docker/) - [Docker](https://docs.docker.com/get-docker/)
- [Rust ARM64 Build Container](https://github.com/Start9Labs/rust-arm-builder) - [Rust ARM64 Build Container](https://github.com/Start9Labs/rust-arm-builder)
- Mac `brew install gnu-tar`
- Scripts (run within the `./backend` directory) - Scripts (run within the `./backend` directory)
- `build-prod.sh` - compiles a release build of the artifacts for running on - `build-prod.sh` - compiles a release build of the artifacts for running on
ARM64 ARM64
@@ -12,7 +13,7 @@
## Structure ## Structure
The StartOS backend is packed into a single binary `startbox` that is symlinked under The StartOS backend is packed into a single binary `startbox` that is symlinked under
several different names for different behaviour: several different names for different behaviour:
- startd: This is the main workhorse of StartOS - any new functionality you - startd: This is the main workhorse of StartOS - any new functionality you

View File

@@ -37,7 +37,7 @@ fi
set +e set +e
fail= fail=
if [[ "$FLAGS" = "" ]]; then if [[ "$FLAGS" = "" ]]; then
rust-gnu-builder sh -c "(cd backend && cargo build --release --locked --target=$ARCH-unknown-linux-gnu)" rust-gnu-builder sh -c "(cd backend && cargo build --release --locked --features avahi-alias, --target=$ARCH-unknown-linux-gnu)"
if test $? -ne 0; then if test $? -ne 0; then
fail=true fail=true
fi fi
@@ -50,7 +50,7 @@ if [[ "$FLAGS" = "" ]]; then
done done
else else
echo "FLAGS=$FLAGS" echo "FLAGS=$FLAGS"
rust-gnu-builder sh -c "(cd backend && cargo build --release --features $FLAGS --locked --target=$ARCH-unknown-linux-gnu)" rust-gnu-builder sh -c "(cd backend && cargo build --release --features avahi-alias,$FLAGS --locked --target=$ARCH-unknown-linux-gnu)"
if test $? -ne 0; then if test $? -ne 0; then
fail=true fail=true
fi fi

View File

@@ -19,7 +19,6 @@ async fn resolve_hostname(hostname: &str) -> Result<IpAddr, Error> {
if let Ok(addr) = hostname.parse() { if let Ok(addr) = hostname.parse() {
return Ok(addr); return Ok(addr);
} }
#[cfg(feature = "avahi")]
if hostname.ends_with(".local") { if hostname.ends_with(".local") {
return Ok(IpAddr::V4(crate::net::mdns::resolve_mdns(hostname).await?)); return Ok(IpAddr::V4(crate::net::mdns::resolve_mdns(hostname).await?));
} }

View File

@@ -10,7 +10,6 @@ pub mod dhcp;
pub mod dns; pub mod dns;
pub mod interface; pub mod interface;
pub mod keys; pub mod keys;
#[cfg(feature = "avahi")]
pub mod mdns; pub mod mdns;
pub mod net_controller; pub mod net_controller;
pub mod ssl; pub mod ssl;

View File

@@ -11,7 +11,6 @@ use crate::error::ErrorCollection;
use crate::hostname::Hostname; use crate::hostname::Hostname;
use crate::net::dns::DnsController; use crate::net::dns::DnsController;
use crate::net::keys::Key; use crate::net::keys::Key;
#[cfg(feature = "avahi")]
use crate::net::mdns::MdnsController; use crate::net::mdns::MdnsController;
use crate::net::ssl::{export_cert, export_key, SslManager}; use crate::net::ssl::{export_cert, export_key, SslManager};
use crate::net::tor::TorController; use crate::net::tor::TorController;
@@ -22,7 +21,6 @@ use crate::{Error, HOST_IP};
pub struct NetController { pub struct NetController {
pub(super) tor: TorController, pub(super) tor: TorController,
#[cfg(feature = "avahi")]
pub(super) mdns: MdnsController, pub(super) mdns: MdnsController,
pub(super) vhost: VHostController, pub(super) vhost: VHostController,
pub(super) dns: DnsController, pub(super) dns: DnsController,
@@ -43,7 +41,6 @@ impl NetController {
let ssl = Arc::new(ssl); let ssl = Arc::new(ssl);
let mut res = Self { let mut res = Self {
tor: TorController::new(tor_control, tor_socks), tor: TorController::new(tor_control, tor_socks),
#[cfg(feature = "avahi")]
mdns: MdnsController::init().await?, mdns: MdnsController::init().await?,
vhost: VHostController::new(ssl.clone()), vhost: VHostController::new(ssl.clone()),
dns: DnsController::init(dns_bind).await?, dns: DnsController::init(dns_bind).await?,
@@ -201,14 +198,12 @@ impl NetController {
) )
.await?, .await?,
); );
#[cfg(feature = "avahi")]
rcs.push(self.mdns.add(key.base_address()).await?); rcs.push(self.mdns.add(key.base_address()).await?);
Ok(rcs) Ok(rcs)
} }
async fn remove_lan(&self, key: &Key, external: u16, rcs: Vec<Arc<()>>) -> Result<(), Error> { async fn remove_lan(&self, key: &Key, external: u16, rcs: Vec<Arc<()>>) -> Result<(), Error> {
drop(rcs); drop(rcs);
#[cfg(feature = "avahi")]
self.mdns.gc(key.base_address()).await?; self.mdns.gc(key.base_address()).await?;
self.vhost.gc(Some(key.local_address()), external).await self.vhost.gc(Some(key.local_address()), external).await
} }

View File

@@ -8,9 +8,9 @@ find frontend/dist/raw -type f -not -name '*.gz' -and -not -name '*.br' | xargs
find frontend/dist/raw -type f -not -name '*.gz' -and -not -name '*.br' | xargs -n 1 -P 0 brotli -kf find frontend/dist/raw -type f -not -name '*.gz' -and -not -name '*.br' | xargs -n 1 -P 0 brotli -kf
for file in $(find frontend/dist/raw -type f -not -name '*.gz' -and -not -name '*.br'); do for file in $(find frontend/dist/raw -type f -not -name '*.gz' -and -not -name '*.br'); do
raw_size=$(du --bytes $file | awk '{print $1}') raw_size=$(du $file | awk '{print $1 * 512}')
gz_size=$(du --bytes $file.gz | awk '{print $1}') gz_size=$(du $file.gz | awk '{print $1 * 512}')
br_size=$(du --bytes $file.br | awk '{print $1}') br_size=$(du $file.br | awk '{print $1 * 512}')
if [ $((gz_size * 100 / raw_size)) -gt 70 ]; then if [ $((gz_size * 100 / raw_size)) -gt 70 ]; then
rm $file.gz rm $file.gz
fi fi