diff --git a/core/.cargo/config.toml b/core/.cargo/config.toml new file mode 100644 index 0000000..30faaf3 --- /dev/null +++ b/core/.cargo/config.toml @@ -0,0 +1,18 @@ +[target.arm-unknown-linux-gnueabihf] +# Match Raspberry Pi Zero CPU (ARM1176JZF-S). +rustflags = [ + "-C", "target-cpu=arm1176jzf-s", + "-L", "native=/usr/lib/arm-linux-gnueabihf", + "-L", "native=/lib/arm-linux-gnueabihf", + "-C", "link-arg=-Wl,-rpath-link,/usr/lib/arm-linux-gnueabihf", + "-C", "link-arg=-Wl,-rpath-link,/lib/arm-linux-gnueabihf", +] + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" +rustflags = [ + "-L", "native=/usr/lib/aarch64-linux-gnu", + "-L", "native=/lib/aarch64-linux-gnu", + "-C", "link-arg=-Wl,-rpath-link,/usr/lib/aarch64-linux-gnu", + "-C", "link-arg=-Wl,-rpath-link,/lib/aarch64-linux-gnu", +] diff --git a/core/Cargo.lock b/core/Cargo.lock index 3cf6e97..b96c84d 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -254,9 +254,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.95" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" +dependencies = [ + "find-msvc-tools", + "shlex", +] [[package]] name = "cexpr" @@ -536,7 +540,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76dc35ce83e4e9fa089b4fabe66c757b27bd504dc2179c97a01b36d3e874fb0" dependencies = [ "clap 2.34.0", - "dbus", "xml-rs", ] @@ -774,10 +777,10 @@ dependencies = [ ] [[package]] -name = "fastrand" -version = "2.0.2" +name = "find-msvc-tools" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fnv" @@ -791,21 +794,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "futures" version = "0.3.31" @@ -1073,16 +1061,18 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "bytes", + "futures-util", + "http 0.2.12", "hyper", - "native-tls", + "rustls 0.21.12", "tokio", - "tokio-native-tls", + "tokio-rustls 0.24.1", + "webpki-roots 0.25.4", ] [[package]] @@ -1236,9 +1226,9 @@ dependencies = [ "env_logger 0.11.8", "futures-util", "hyper", - "hyper-tls", + "hyper-rustls", "log", - "rustls", + "rustls 0.23.29", "serde", "serde_json", "serde_plain", @@ -1520,24 +1510,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework 2.10.0", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nom" version = "5.1.3" @@ -1642,50 +1614,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.9.3", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -2002,6 +1930,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "ring", + "rustls-webpki 0.101.7", + "sct", +] + [[package]] name = "rustls" version = "0.23.29" @@ -2011,7 +1950,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.103.4", "subtle", "zeroize", ] @@ -2025,6 +1964,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustls-webpki" version = "0.103.4" @@ -2048,21 +1997,22 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "2.10.0" @@ -2283,18 +2233,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - [[package]] name = "term" version = "0.7.0" @@ -2434,12 +2372,12 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "native-tls", + "rustls 0.21.12", "tokio", ] @@ -2449,7 +2387,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ - "rustls", + "rustls 0.23.29", "tokio", ] @@ -2461,10 +2399,10 @@ checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.23.29", "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.26.2", "tungstenite", "webpki-roots 0.26.11", ] @@ -2560,7 +2498,7 @@ dependencies = [ "httparse", "log", "rand 0.9.1", - "rustls", + "rustls 0.23.29", "rustls-pki-types", "sha1", "thiserror 2.0.12", @@ -2764,6 +2702,12 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "webpki-roots" version = "0.26.11" diff --git a/core/Cross.toml b/core/Cross.toml new file mode 100644 index 0000000..3622cf4 --- /dev/null +++ b/core/Cross.toml @@ -0,0 +1,37 @@ +[target.arm-unknown-linux-gnueabihf] +# Raspberry Pi Zero / Zero W (ARM1176JZF-S, ARMv6 + hard-float). +# +# Several workspace crates use native libs via pkg-config (dbus, sqlite, libsecret). +# Install the ARMv6/armhf -dev packages inside the cross image so they are available +# to the target linker. +pre-build = [ + "dpkg --add-architecture armhf", + "apt-get update", + "apt-get install -y --no-install-recommends bash pkg-config libc6-dev:armhf libdbus-1-dev:armhf libsystemd-dev:armhf libsqlite3-dev:armhf libsecret-1-dev:armhf", + # `cross` doesn't reliably forward PKG_CONFIG_* env vars into the container, so install a tiny + # wrapper that selects the correct multiarch pkgconfig dir based on `$TARGET`. + "bash -lc 'if [ -x /usr/bin/pkg-config ] && [ ! -x /usr/bin/pkg-config.real ]; then mv /usr/bin/pkg-config /usr/bin/pkg-config.real; fi'", + "bash -lc 'printf \"%b\" \"#!/usr/bin/env bash\\nset -euo pipefail\\nREAL=/usr/bin/pkg-config.real\\ncase \\\"\\${TARGET:-}\\\" in\\n arm-unknown-linux-gnueabihf)\\n export PKG_CONFIG_ALLOW_CROSS=1\\n export PKG_CONFIG_SYSROOT_DIR=/\\n export PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig\\n export PKG_CONFIG_PATH=\\\"\\$PKG_CONFIG_LIBDIR\\\"\\n ;;\\n aarch64-unknown-linux-gnu)\\n export PKG_CONFIG_ALLOW_CROSS=1\\n export PKG_CONFIG_SYSROOT_DIR=/\\n export PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig\\n export PKG_CONFIG_PATH=\\\"\\$PKG_CONFIG_LIBDIR\\\"\\n ;;\\n *)\\n ;;\\nesac\\nexec \\\"\\$REAL\\\" \\\"\\$@\\\"\\n\" > /usr/bin/pkg-config && chmod +x /usr/bin/pkg-config'", + # Sanity checks (use wrapper + armhf search path). + "bash -lc 'TARGET=arm-unknown-linux-gnueabihf pkg-config --modversion dbus-1'", + "bash -lc 'TARGET=arm-unknown-linux-gnueabihf pkg-config --modversion sqlite3'", + "bash -lc 'TARGET=arm-unknown-linux-gnueabihf pkg-config --modversion libsecret-1'", +] + +[target.aarch64-unknown-linux-gnu] +# Raspberry Pi OS (64-bit) / other aarch64 Linux. +# +# Use a Debian 11 (bullseye) base so the resulting binaries are compatible with +# bullseye's glibc, and to get a system `libsqlite3` new enough for Diesel. +image = "debian:bullseye-slim" +pre-build = [ + "dpkg --add-architecture arm64", + "apt-get update", + "apt-get install -y --no-install-recommends ca-certificates bash pkg-config build-essential gcc-aarch64-linux-gnu libc6-dev:arm64 libdbus-1-dev:arm64 libsystemd-dev:arm64 libsqlite3-dev:arm64 libsecret-1-dev:arm64", + # Same wrapper as above (installed once, safe to re-run). + "bash -lc 'if [ -x /usr/bin/pkg-config ] && [ ! -x /usr/bin/pkg-config.real ]; then mv /usr/bin/pkg-config /usr/bin/pkg-config.real; fi'", + "bash -lc 'printf \"%b\" \"#!/usr/bin/env bash\\nset -euo pipefail\\nREAL=/usr/bin/pkg-config.real\\ncase \\\"\\${TARGET:-}\\\" in\\n arm-unknown-linux-gnueabihf)\\n export PKG_CONFIG_ALLOW_CROSS=1\\n export PKG_CONFIG_SYSROOT_DIR=/\\n export PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig\\n export PKG_CONFIG_PATH=\\\"\\$PKG_CONFIG_LIBDIR\\\"\\n ;;\\n aarch64-unknown-linux-gnu)\\n export PKG_CONFIG_ALLOW_CROSS=1\\n export PKG_CONFIG_SYSROOT_DIR=/\\n export PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig\\n export PKG_CONFIG_PATH=\\\"\\$PKG_CONFIG_LIBDIR\\\"\\n ;;\\n *)\\n ;;\\nesac\\nexec \\\"\\$REAL\\\" \\\"\\$@\\\"\\n\" > /usr/bin/pkg-config && chmod +x /usr/bin/pkg-config'", + "bash -lc 'TARGET=aarch64-unknown-linux-gnu pkg-config --modversion dbus-1'", + "bash -lc 'TARGET=aarch64-unknown-linux-gnu pkg-config --modversion sqlite3'", + "bash -lc 'TARGET=aarch64-unknown-linux-gnu pkg-config --modversion libsecret-1'", +] diff --git a/core/Makefile b/core/Makefile index a3936f0..9a70c16 100644 --- a/core/Makefile +++ b/core/Makefile @@ -12,5 +12,15 @@ rpm: cargo build --release --workspace strip -s target/release/kordophoned strip -s target/release/kpcli + strip -s target/release/kptui cargo generate-rpm -p kordophoned +.PHONY: pi-zero +pi-zero: + CARGO_TARGET_DIR=target/cross/arm-unknown-linux-gnueabihf \ + cross build --release --target arm-unknown-linux-gnueabihf -p kordophoned -p kpcli -p kptui + +.PHONY: pi-aarch64 +pi-aarch64: + CARGO_TARGET_DIR=target/cross/aarch64-unknown-linux-gnu \ + cross build --release --target aarch64-unknown-linux-gnu -p kordophoned -p kpcli -p kptui diff --git a/core/README.md b/core/README.md index 8027456..8ad5a13 100644 --- a/core/README.md +++ b/core/README.md @@ -29,6 +29,42 @@ cargo build -p kordophone cargo build -p kordophoned --release ``` +## Raspberry Pi Zero (cross build) + +Recommended approach is `cross` (https://github.com/cross-rs/cross), which uses a containerized toolchain. + +Prereqs: + +- Install Docker or Podman +- Install `cross`: `cargo install cross` + +Build ARMv6 (Pi Zero / Zero W): + +```bash +cd core +make pi-zero +``` + +Build aarch64 (Pi OS 64-bit / Pi 3+): + +```bash +cd core +make pi-aarch64 +``` + +Notes: + +- The aarch64 cross build uses a Debian 11 (bullseye) container base image to keep glibc compatible with bullseye. + +Artifacts: + +- `target/cross/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/release/kordophoned` +- `target/cross/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/release/kpcli` +- `target/cross/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/release/kptui` +- `target/cross/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/release/kordophoned` +- `target/cross/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/release/kpcli` +- `target/cross/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/release/kptui` + ## `kordophoned` (Client Daemon) The daemon maintains a local cache, handles update cycles, and exposes IPC for GUI apps. diff --git a/core/kordophone/Cargo.toml b/core/kordophone/Cargo.toml index 9a22dbc..95399f8 100644 --- a/core/kordophone/Cargo.toml +++ b/core/kordophone/Cargo.toml @@ -14,7 +14,7 @@ ctor = "0.2.8" env_logger = "0.11.5" futures-util = "0.3.31" hyper = { version = "0.14", features = ["full"] } -hyper-tls = "0.5.0" +hyper-rustls = { version = "0.24", default-features = false, features = ["http1", "webpki-tokio"] } log = { version = "0.4.21", features = [] } serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.91" diff --git a/core/kordophone/src/api/http_client.rs b/core/kordophone/src/api/http_client.rs index 9c25e5a..91482ab 100644 --- a/core/kordophone/src/api/http_client.rs +++ b/core/kordophone/src/api/http_client.rs @@ -7,7 +7,7 @@ use crate::api::event_socket::{EventSocket, SinkMessage, SocketEvent, SocketUpda use crate::api::AuthenticationStore; use bytes::Bytes; use hyper::{Body, Client, Method, Request, Uri}; -use hyper_tls::HttpsConnector; +use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder}; use async_trait::async_trait; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -466,7 +466,11 @@ impl APIInterface for HTTPAPIClient { impl HTTPAPIClient { pub fn new(base_url: Uri, auth_store: K) -> HTTPAPIClient { - let https = HttpsConnector::new(); + let https = HttpsConnectorBuilder::new() + .with_webpki_roots() + .https_or_http() + .enable_http1() + .build(); let client = Client::builder().build::<_, Body>(https); HTTPAPIClient { base_url, auth_store, client } diff --git a/core/kordophoned-client/Cargo.toml b/core/kordophoned-client/Cargo.toml index b5e8e83..fc25bcb 100644 --- a/core/kordophoned-client/Cargo.toml +++ b/core/kordophoned-client/Cargo.toml @@ -13,11 +13,10 @@ dbus = "0.9.7" # D-Bus codegen only on Linux [target.'cfg(target_os = "linux")'.build-dependencies] -dbus-codegen = "0.10.0" +dbus-codegen = { version = "0.10.0", default-features = false } # XPC (libxpc) interface only on macOS [target.'cfg(target_os = "macos")'.dependencies] block = "0.1.6" xpc-connection = { git = "https://github.com/dfrankland/xpc-connection-rs.git", rev = "cd4fb3d", package = "xpc-connection" } xpc-connection-sys = { git = "https://github.com/dfrankland/xpc-connection-rs.git", rev = "cd4fb3d", package = "xpc-connection-sys" } - diff --git a/core/kordophoned/Cargo.toml b/core/kordophoned/Cargo.toml index 9a15f04..aea6f4c 100644 --- a/core/kordophoned/Cargo.toml +++ b/core/kordophoned/Cargo.toml @@ -33,8 +33,7 @@ dbus-tree = "0.9.2" # D-Bus codegen only on Linux [target.'cfg(target_os = "linux")'.build-dependencies] -dbus-codegen = "0.10.0" -dbus-crossroads = "0.5.1" +dbus-codegen = { version = "0.10.0", default-features = false } # XPC (libxpc) interface for macOS IPC [target.'cfg(target_os = "macos")'.dependencies] @@ -48,5 +47,6 @@ serde = { version = "1.0", features = ["derive"] } assets = [ { source = "../target/release/kordophoned", dest = "/usr/libexec/kordophoned", mode = "755" }, { source = "../target/release/kpcli", dest = "/usr/bin/kpcli", mode = "755" }, + { source = "../target/release/kptui", dest = "/usr/bin/kptui", mode = "755" }, { source = "include/net.buzzert.kordophonecd.service", dest = "/usr/share/dbus-1/services/net.buzzert.kordophonecd.service", mode = "644" }, ] diff --git a/core/kordophoned/build.rs b/core/kordophoned/build.rs index 4db9d7e..f7e9e8a 100644 --- a/core/kordophoned/build.rs +++ b/core/kordophoned/build.rs @@ -27,3 +27,4 @@ fn main() { println!("cargo:rerun-if-changed={}", KORDOPHONE_XML); } + diff --git a/core/kpcli/Cargo.toml b/core/kpcli/Cargo.toml index da2843e..075dcf8 100644 --- a/core/kpcli/Cargo.toml +++ b/core/kpcli/Cargo.toml @@ -28,7 +28,7 @@ dbus-tree = "0.9.2" # D-Bus codegen only on Linux [target.'cfg(target_os = "linux")'.build-dependencies] -dbus-codegen = "0.10.0" +dbus-codegen = { version = "0.10.0", default-features = false } # XPC (libxpc) interface only on macOS [target.'cfg(target_os = "macos")'.dependencies]