diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06dcac0bb..26c8e513d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: - name: Lint markdown uses: docker://avtodev/markdown-lint:v1 with: - args: './README.md tools/sextant/README.md' + args: './README.md northstar-sextant/README.md' cross: name: Cross @@ -177,16 +177,16 @@ jobs: uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 - - name: Install nstar - run: cargo install --path tools/nstar - - name: Install schema - run: cargo install --path tools/schema - - name: Install sextant - run: cargo install --path tools/sextant - - name: Install stress - run: cargo install --path tools/stress - - name: Install seccomp-util - run: cargo install --path tools/seccomp-util + - name: Install northstar-nstar + run: cargo install --path northstar-nstar + - name: Install northstar-sextant + run: cargo install --path northstar-sextant + - name: Install northstar-seccomp + run: cargo install --path northstar-seccomp + - name: Install northstar-schema + run: cargo install --path northstar-schema + - name: Install northstar-stress + run: cargo install --path northstar-stress openapi: name: OpenApi @@ -209,9 +209,9 @@ jobs: ./openapi-generator-cli version - name: Generate manifest jsonschema/html run: | - cargo run --bin schema -- -m manifest -o manifest.json + cargo run --bin northstar-schema -- -m manifest -o manifest.json ./openapi-generator-cli generate -i manifest.json -g html -o manifest.html --skip-validate-spec - name: Generate api jsonschema/html run: | - cargo run --bin schema -- -m api -o api.json + cargo run --bin northstar-schema -- -m api -o api.json ./openapi-generator-cli generate -i api.json -g html -o api.html --skip-validate-spec \ No newline at end of file diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 5c82fa319..b8b725674 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -26,7 +26,7 @@ jobs: components: rustfmt, rust-src - name: Build Documentation - run: cargo doc -p northstar --all-features --no-deps + run: cargo doc -p northstar-runtime -p northstar-client --all-features --no-deps - name: Install OpenApi Generator run: | @@ -36,12 +36,12 @@ jobs: - name: Generate manifest jsonschema/html run: | - cargo run --bin schema -- -m manifest -o manifest.json + cargo run --bin northstarschema -- -m manifest -o manifest.json ./openapi-generator-cli generate -i manifest.json -g html -o target/doc/manifest - name: Generate api jsonschema/html run: | - cargo run --bin schema -- -m api -o api.json + cargo run --bin northstar-schema -- -m api -o api.json ./openapi-generator-cli generate -i api.json -g html -o target/doc/api - name: Deploy diff --git a/.markdownlint.yml b/.markdownlint.yml index a6d468842..7dd56c460 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,2 +1,4 @@ MD041: false # First line in a file should be a top-level -MD033: false # Allow inline html \ No newline at end of file +MD033: false # Allow inline html +MD013: # Line length + code_blocks: false \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9ece5444b..eb95d829b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -397,10 +397,10 @@ dependencies = [ [[package]] name = "console" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", - "northstar", + "northstar-client", "tokio", ] @@ -418,7 +418,7 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cpueater" -version = "0.1.0" +version = "0.0.1" [[package]] name = "cpufeatures" @@ -431,7 +431,7 @@ dependencies = [ [[package]] name = "crashing" -version = "0.1.0" +version = "0.0.1" [[package]] name = "crc32fast" @@ -737,7 +737,7 @@ dependencies = [ [[package]] name = "ferris" -version = "0.1.0" +version = "0.0.1" [[package]] name = "fnv" @@ -920,11 +920,11 @@ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hello-resource" -version = "0.1.0" +version = "0.0.1" [[package]] name = "hello-world" -version = "0.1.0" +version = "0.0.1" [[package]] name = "hermit-abi" @@ -1030,7 +1030,7 @@ dependencies = [ [[package]] name = "inspect" -version = "0.1.0" +version = "0.0.1" dependencies = [ "caps", "nix 0.24.1", @@ -1143,21 +1143,6 @@ dependencies = [ "libc", ] -[[package]] -name = "main" -version = "0.1.0" -dependencies = [ - "android-logd-logger", - "anyhow", - "clap 3.1.18", - "env_logger", - "log", - "nix 0.24.1", - "northstar", - "tokio", - "toml", -] - [[package]] name = "matchers" version = "0.0.1" @@ -1181,7 +1166,7 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memeater" -version = "0.1.0" +version = "0.0.1" [[package]] name = "memfd" @@ -1295,7 +1280,53 @@ dependencies = [ [[package]] name = "northstar" -version = "0.7.1-dev" +version = "0.0.1-pre" +dependencies = [ + "android-logd-logger", + "anyhow", + "clap 3.1.18", + "env_logger", + "log", + "nix 0.24.1", + "northstar-runtime", + "tokio", + "toml", +] + +[[package]] +name = "northstar-client" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "futures", + "northstar-runtime", + "thiserror", + "tokio", +] + +[[package]] +name = "northstar-nstar" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "clap 3.1.18", + "clap_complete", + "futures", + "hex", + "humantime", + "itertools", + "northstar-client", + "pin-project-lite", + "prettytable-rs", + "serde_json", + "tokio", + "tokio-util", + "url", +] + +[[package]] +name = "northstar-runtime" +version = "0.0.1-pre" dependencies = [ "anyhow", "async-stream", @@ -1353,9 +1384,69 @@ dependencies = [ "zip", ] +[[package]] +name = "northstar-schema" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "clap 3.1.18", + "northstar-runtime", + "okapi", + "schemars", + "serde_json", +] + +[[package]] +name = "northstar-seccomp" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "assert_cmd", + "clap 3.1.18", + "env_logger", + "itertools", + "northstar-runtime", + "regex", + "serde_yaml", +] + +[[package]] +name = "northstar-sextant" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "base64", + "clap 3.1.18", + "colored", + "ed25519-dalek", + "env_logger", + "log", + "northstar-runtime", + "tempfile", + "zip", +] + +[[package]] +name = "northstar-stress" +version = "0.0.1-pre" +dependencies = [ + "anyhow", + "clap 3.1.18", + "env_logger", + "futures", + "humantime", + "itertools", + "log", + "northstar-client", + "rand 0.8.5", + "tokio", + "tokio-util", + "url", +] + [[package]] name = "northstar-tests" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "env_logger", @@ -1366,7 +1457,8 @@ dependencies = [ "memfd", "nanoid", "nix 0.24.1", - "northstar", + "northstar-client", + "northstar-runtime", "northstar-tests-derive", "rayon", "regex", @@ -1377,33 +1469,13 @@ dependencies = [ [[package]] name = "northstar-tests-derive" -version = "0.1.0" +version = "0.0.1" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "nstar" -version = "0.4.2" -dependencies = [ - "anyhow", - "clap 3.1.18", - "clap_complete", - "futures", - "hex", - "humantime", - "itertools", - "northstar", - "pin-project-lite", - "prettytable-rs", - "serde_json", - "tokio", - "tokio-util", - "url", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -1506,7 +1578,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "persistence" -version = "0.1.0" +version = "0.0.1" [[package]] name = "pin-project" @@ -1781,7 +1853,7 @@ dependencies = [ [[package]] name = "redis-client" -version = "0.1.0" +version = "0.0.1" dependencies = [ "bytes", "mini-redis", @@ -1923,18 +1995,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" -[[package]] -name = "schema" -version = "0.0.1" -dependencies = [ - "anyhow", - "clap 3.1.18", - "northstar", - "okapi", - "schemars", - "serde_json", -] - [[package]] name = "schemars" version = "0.8.10" @@ -1970,20 +2030,6 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" name = "seccomp" version = "0.0.1" -[[package]] -name = "seccomp-util" -version = "0.1.0" -dependencies = [ - "anyhow", - "assert_cmd", - "clap 3.1.18", - "env_logger", - "itertools", - "northstar", - "regex", - "serde_yaml", -] - [[package]] name = "semver" version = "0.9.0" @@ -2094,22 +2140,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "sextant" -version = "0.2.1" -dependencies = [ - "anyhow", - "base64", - "clap 3.1.18", - "colored", - "ed25519-dalek", - "env_logger", - "log", - "northstar", - "tempfile", - "zip", -] - [[package]] name = "sha1" version = "0.6.1" @@ -2259,24 +2289,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -[[package]] -name = "stress" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap 3.1.18", - "env_logger", - "futures", - "humantime", - "itertools", - "log", - "northstar", - "rand 0.8.5", - "tokio", - "tokio-util", - "url", -] - [[package]] name = "strsim" version = "0.8.0" @@ -2403,7 +2415,7 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] name = "test-container" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "caps", @@ -2510,23 +2522,23 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "token-client" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "futures", "hex", - "northstar", + "northstar-client", "tokio", "tokio-util", ] [[package]] name = "token-server" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "hex", - "northstar", + "northstar-client", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index d4c5bc887..6bcccb2d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,17 @@ members = [ "examples/seccomp", "examples/token-client", "examples/token-server", - "main", "northstar", + "northstar-client", + "northstar-nstar", + "northstar-runtime", + "northstar-schema", + "northstar-seccomp", + "northstar-sextant", + "northstar-stress", "northstar-tests", "northstar-tests/northstar-tests-derive", "northstar-tests/test-container", - "tools/nstar", - "tools/schema", - "tools/seccomp-util", - "tools/sextant", - "tools/stress", ] [profile.release] diff --git a/README.md b/README.md index 290eb4f71..2f47863c8 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Northstar container contains: * Northstar manifest with process configuration and container meta information Northstar containers can be created with the Northstar utility -[sextant](tools/sextant/README.md). +[sextant](northstar-sextant/README.md). ### Processes @@ -145,24 +145,24 @@ The Northstar workspace configuration configures a cargo [runner](.cargo/runner-x86_64-unknown-linux-gnu) that invokes the runtimes example main binary with super user rights. -Use the [nstar](./tools/nstar/README.md) utility to inspect and modify the +Use the [nstar](./northstar-nstar/README.md) utility to inspect and modify the runtimes state e.g. ```sh -cargo build --release --bin nstar +cargo build --release --bin northstar-nstar ... -./target/release/nstar --help +./target/release/northstar-nstar --help ... -> ./target/release/nstar -j start hello-world +> ./target/release/northstar-nstar -j start hello-world {"Response":{"Err":{"StartContainerStarted":{"name":"hello-world","version":"0.0.1"}}}} -> ./target/release/nstar -j kill hello-world +> ./target/release/northstar-nstar -j kill hello-world {"Response":{"Ok":null}} ``` ## Configuration The example executable `northstar` reads a configuration file that represents -`northstar::runtime::config::Config`. +`northstar_runtime::runtime::config::Config`. ```toml # Directory where containers are mounted @@ -295,10 +295,10 @@ only. Northstar is tested on the architectures Northstar cannot be run on 32 bit systems! In order to verify that all needed Kernel features are available, either run the -[check_conf](./tools/check_conf.sh) script or manually compare the target's +[check_conf](./check_conf.sh) script or manually compare the target's kernel configuration with the `CONFIG_` entries in the `check_conf.sh` script. -**TODO**: List required `CONFIG_` items here. The check_confi script runs on +**TODO**: List required `CONFIG_` items here. The check_config script runs on *Android only ## Internals diff --git a/tools/check_conf.sh b/check_conf.sh similarity index 100% rename from tools/check_conf.sh rename to check_conf.sh diff --git a/examples/build_examples.sh b/examples/build_examples.sh index b935e6204..e5c67b4a7 100755 --- a/examples/build_examples.sh +++ b/examples/build_examples.sh @@ -167,7 +167,7 @@ build_example() { provision_artifact "${NAME}" "${ROOT_DIR}" fi - exe cargo run --bin sextant -- pack ${CLONES} --manifest "${MANIFEST}" --root "${ROOT_DIR}" --out "${OUTPUT_DIR}" --key "${KEY}" --compression-algorithm "${COMPRESSION_ALGORITHM}" + exe cargo run --bin northstar-sextant -- pack ${CLONES} --manifest "${MANIFEST}" --root "${ROOT_DIR}" --out "${OUTPUT_DIR}" --key "${KEY}" --compression-algorithm "${COMPRESSION_ALGORITHM}" } main() { diff --git a/examples/console/Cargo.toml b/examples/console/Cargo.toml index 296c4f4c5..818b1b18e 100644 --- a/examples/console/Cargo.toml +++ b/examples/console/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "console" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -8,4 +8,4 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.57" tokio = { version = "1.18.1", features = ["macros", "rt", "net"] } -northstar = { path = "../../northstar", features = ["api"] } +northstar-client = { path = "../../northstar-client" } diff --git a/examples/console/src/main.rs b/examples/console/src/main.rs index 2e3706b04..df678a546 100644 --- a/examples/console/src/main.rs +++ b/examples/console/src/main.rs @@ -13,14 +13,14 @@ // limitations under the License. use anyhow::Result; -use northstar::api::client; +use northstar_client::Client; use std::time::Duration; use tokio::time; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { // Instantiate client and start connect sequence - let mut client = client::Client::from_env(None, Duration::from_secs(5)).await?; + let mut client = Client::from_env(None, Duration::from_secs(5)).await?; // Request the identity of this container let ident = client.ident().await?; diff --git a/examples/cpueater/Cargo.toml b/examples/cpueater/Cargo.toml index 27be43dd6..2abd6b783 100644 --- a/examples/cpueater/Cargo.toml +++ b/examples/cpueater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cpueater" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/crashing/Cargo.toml b/examples/crashing/Cargo.toml index 9e249a511..ddbc18919 100644 --- a/examples/crashing/Cargo.toml +++ b/examples/crashing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crashing" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/ferris/Cargo.toml b/examples/ferris/Cargo.toml index 2868852ed..715c671bd 100644 --- a/examples/ferris/Cargo.toml +++ b/examples/ferris/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ferris" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/hello-resource/Cargo.toml b/examples/hello-resource/Cargo.toml index 0b053e309..80669616d 100644 --- a/examples/hello-resource/Cargo.toml +++ b/examples/hello-resource/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hello-resource" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/hello-world/Cargo.toml b/examples/hello-world/Cargo.toml index 6aa425269..c04654870 100644 --- a/examples/hello-world/Cargo.toml +++ b/examples/hello-world/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hello-world" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/inspect/Cargo.toml b/examples/inspect/Cargo.toml index bf443cee4..654b27beb 100644 --- a/examples/inspect/Cargo.toml +++ b/examples/inspect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "inspect" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/memeater/Cargo.toml b/examples/memeater/Cargo.toml index 7cf5664a8..43db2098c 100644 --- a/examples/memeater/Cargo.toml +++ b/examples/memeater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "memeater" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/persistence/Cargo.toml b/examples/persistence/Cargo.toml index da575beae..4baa3797c 100644 --- a/examples/persistence/Cargo.toml +++ b/examples/persistence/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "persistence" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/redis-client/Cargo.toml b/examples/redis-client/Cargo.toml index 7633843b0..31a2a01c6 100644 --- a/examples/redis-client/Cargo.toml +++ b/examples/redis-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redis-client" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/examples/token-client/Cargo.toml b/examples/token-client/Cargo.toml index ed6a16166..25b80418a 100644 --- a/examples/token-client/Cargo.toml +++ b/examples/token-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "token-client" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -9,6 +9,6 @@ license = "Apache-2.0" anyhow = "1.0.56" futures = { version = "0.3.21", default-features = false } hex = "0.4.3" -northstar = { path = "../../northstar", features = ["api"] } +northstar-client= { path = "../../northstar-client" } tokio = { version = "1.18.1", features = ["macros", "rt", "net"] } tokio-util = { version = "0.7.2", features = ["codec"] } diff --git a/examples/token-client/src/main.rs b/examples/token-client/src/main.rs index f37f38f37..b65986a93 100644 --- a/examples/token-client/src/main.rs +++ b/examples/token-client/src/main.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Result}; use futures::{sink::SinkExt, StreamExt}; -use northstar::api::client; +use northstar_client::Client; use tokio::{ net::TcpStream, time::{sleep, Duration}, @@ -21,7 +21,7 @@ const TEXT: &str = "yay!"; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { // Connect to the runtime via NORTHSTAR_CONSOLE... - let mut client = client::Client::from_env(None, Duration::from_secs(5)).await?; + let mut client = Client::from_env(None, Duration::from_secs(5)).await?; // Create a token that can be used to verify `shared`. Note that there's // no `user` argument here. The runtime know from which container the request diff --git a/examples/token-server/Cargo.toml b/examples/token-server/Cargo.toml index a1f9c34ef..1137004c2 100644 --- a/examples/token-server/Cargo.toml +++ b/examples/token-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "token-server" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -8,5 +8,5 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.56" hex = "0.4.3" -northstar = { path = "../../northstar", features = ["api"] } +northstar-client = { path = "../../northstar-client" } tokio = { version = "1.18.1", features = ["macros", "rt", "net"] } diff --git a/examples/token-server/src/main.rs b/examples/token-server/src/main.rs index de4bc2676..20d584d11 100644 --- a/examples/token-server/src/main.rs +++ b/examples/token-server/src/main.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Context, Result}; -use northstar::api::{ - client, +use northstar_client::{ model::{Token, VerificationResult}, + Client, }; use std::time::Duration; use tokio::{ @@ -15,7 +15,7 @@ const SHARED: &str = "hello!"; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { // Connect to the runtime via NORTHSTAR_CONSOLE... - let mut client = client::Client::from_env(None, Duration::from_secs(5)).await?; + let mut client = Client::from_env(None, Duration::from_secs(5)).await?; // Listen on some random port let listener = tokio::net::TcpListener::bind("localhost:6543").await?; diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index 1babeb360..f2e46665f 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -8,9 +8,9 @@ - [Starting containers and notifications](client/start_containers.md) - [Stopping containers](client/stop_containers.md) - [Installing and uninstalling containers](client/install_containers.md) -- [Working with NPK files](sextant/npk.md) - - [Packing an NPK](sextant/pack.md) - - [Unpacking an NPK](sextant/unpack.md) - - [Inspecting an NPK](sextant/inspect.md) - - [Generating Repository Keys](sextant/gen_repo_keys.md) - - [NPK Format Reference](sextant/npk_format_reference.md) +- [Working with NPK files](northstar-sextant/npk.md) + - [Packing an NPK](northstar-sextant/pack.md) + - [Unpacking an NPK](northstar-sextant/unpack.md) + - [Inspecting an NPK](northstar-sextant/inspect.md) + - [Generating Repository Keys](northstar-sextant/gen_repo_keys.md) + - [NPK Format Reference](northstar-sextant/npk_format_reference.md) diff --git a/guide/src/client/install_containers.md b/guide/src/client/install_containers.md index 95333c7a2..a1a3ead88 100644 --- a/guide/src/client/install_containers.md +++ b/guide/src/client/install_containers.md @@ -38,7 +38,7 @@ specified in `CONTAINER_NAME` and `CONTAINER_VERSION` correspondingly. For the following snippet, we can create a dummy container called `foo`. First, we create a directory layout for he container that looks like this: -``` +```sh foo ├── manifest.yaml └── root @@ -60,10 +60,10 @@ mounts: host: /lib64 ``` -Finally, we use `sextant` to pack the container into a `npk` file. +Finally, we use `northstar-sextant` to pack the container into a `npk` file. ```sh -sextant pack --dir foo --out . --key examples/keys/northstar.key +northstar-sextant pack --dir foo --out . --key examples/keys/northstar.key ``` This will produce a file named `foo-0.0.1.npk` in the current directory. Now we diff --git a/guide/src/sextant/gen_repo_keys.md b/guide/src/sextant/gen_repo_keys.md index cb6f7ada4..38281b3c2 100644 --- a/guide/src/sextant/gen_repo_keys.md +++ b/guide/src/sextant/gen_repo_keys.md @@ -1,11 +1,11 @@ # Generating Repository Keys -To sign NPKs using `sextant` we first have to have a suitable key pair. -This can be generated using the `sextant gen-key` command. +To sign NPKs using `northstar-sextant` we first have to have a suitable key pair. +This can be generated using the `northstar-sextant gen-key` command. The following call creates a new key pair called `repokey` in the current directory: ```bash -target/debug/sextant gen-key --name repokey --out . +target/debug/northstar-sextant gen-key --name repokey --out . ``` After the call we can see that two files were created: diff --git a/guide/src/sextant/inspect.md b/guide/src/sextant/inspect.md index cb5d3d159..71f824fac 100644 --- a/guide/src/sextant/inspect.md +++ b/guide/src/sextant/inspect.md @@ -1,6 +1,7 @@ # Inspecting an NPK -To get information about an already packed NPK `sextant` provides the `inspect` command. +To get information about an already packed NPK `northstar-sextant` provides the `inspect` +command. ## Inspecting an NPK with Default Settings @@ -9,12 +10,13 @@ Inspecting an NPK without any additional parameters will show the following info - Listing of files contained in the NPK - Contents of manifest.yaml - Contents of signature.yaml -- Listing of files contained in the compressed squashfs image (`fs.img`) within the NPK +- Listing of files contained in the compressed squashfs image (`fs.img`) within the + NPK For example, inspecting the `hello-world` example container gives the following output: ```markdown -$ sextant inspect target/northstar/repository/hello-0.0.1.npk +$ northstar-sextant inspect target/northstar/repository/hello-0.0.1.npk # inspection of 'target/northstar/repository/hello-0.0.1.npk' ## NPK Content signature.yaml @@ -44,6 +46,7 @@ mounts: ``` ## signature.yaml + ```yaml manifest.yaml: hash: ee5967e740febb3a1e018e189ed21412f8bf71d34bea7b506f709d37984e90cc @@ -57,6 +60,7 @@ signature: xK0f6gIqaarM8FTbhT/qnhSy4ROK8MsoluA2A6kpDCJaAvoea/41j3tY0c047OUL5f/wm ``` ## SquashFS listing + ```bash Parallel unsquashfs: Using 32 processors 1 inodes (11 blocks) to write @@ -72,15 +76,17 @@ dr-xr-xr-x user/user 3 2021-03-01 10:15 squashfs-root/system ## Inspecting an NPK with the `--short` parameter -To facilitate the inspection of many containers as part of scripts, the `inspect` command features the `--short` parameter. -It condenses the inspection output into a single line with the following information: +To facilitate the inspection of many containers as part of scripts, the +`inspect` command features the `--short` parameter. It condenses the inspection +output into a single line with the following information: - Container name - Container version - NPK format version - Whether or not this is a [resource container](npk_format_reference.md#resource-containers) -Inspecting the `hello-world` example container with the `--short` flag gives the following output: +Inspecting the `hello-world` example container with the `--short` flag gives the +following output: ```markdown $ sextant inspect --short target/northstar/repository/hello-world-0.0.1.npk diff --git a/guide/src/sextant/pack.md b/guide/src/sextant/pack.md index 8d315b13c..ec7bf14a9 100644 --- a/guide/src/sextant/pack.md +++ b/guide/src/sextant/pack.md @@ -8,8 +8,9 @@ The command requires the following input: ## The Manifest File -The manifest is a YAML file that references all necessary data to mount and execute the container. -An example `manifest.yaml` of the `hello-world` container (found in `examples/hello-world/manifest.yaml`) looks as follows: +The manifest is a YAML file that references all necessary data to mount and +execute the container. An example `manifest.yaml` of the `hello-world` +container (found in `examples/hello-world/manifest.yaml`) looks as follows: ```yaml name: hello-world @@ -38,10 +39,11 @@ More details on the manifest format can be found in the chapter ## The `root` Folder -The root folder contains all the container data that will be available during runtime. -This includes executable files as well as additional resources. -During packing, the contents of the folder will be copied to a squashfs image that is then added to the NPK. -This image file will be mounted by the northstar runtime when the container is run. +The root folder contains all the container data that will be available during +runtime. This includes executable files as well as additional resources. +During packing, the contents of the folder will be copied to a squashfs image +that is then added to the NPK. This image file will be mounted by the northstar +runtime when the container is run. ## Calling `sextant pack` @@ -50,7 +52,7 @@ First, we build the `hello-world` binary from the northstar directory using carg ```bash $ cargo build --release --bin hello-world -Compiling hello-world v0.1.0 (/home/nori/dev/northstar/examples/hello-world) +Compiling hello-world v0.0.1 (/home/nori/dev/northstar/examples/hello-world) Finished release [optimized] target(s) in 2.77s ``` @@ -61,18 +63,19 @@ $ ls target/release/hello-world target/release/hello-world ``` -Next, we can crate the destination directory if it does not already exist. -We will choose `target/northstar/repository` as our destination as it is the default place where northstar looks for NPKs on startup. -This default is configured in `northstar.toml`. +Next, we can crate the destination directory if it does not already exist. We +will choose `target/northstar/repository` as our destination as it is the +default place where northstar looks for NPKs on startup. This default is +configured in `northstar.toml`. ```bash -$ mkdir -p target/northstar/repository +mkdir -p target/northstar/repository ``` Finally, we are able to call `sextant` and create the NPK: ```bash -$ target/debug/sextant pack \ +$ target/debug/northstar-sextant pack \ --manifest examples/hello-world/manifest.yaml \ --root target/release/hello-world \ --out target/northstar/repository @@ -87,9 +90,10 @@ hello-world-0.0.1.npk ## Signing an NPK -NPKs can be signed using ed25519 signatures. -If your runtime is configured to check NPK signatures then containers with missing or invalid signatures will not be accepted. -To create a signed version of our container we have to specify the required private key: +NPKs can be signed using ed25519 signatures. If your runtime is configured to +check NPK signatures then containers with missing or invalid signatures will not +be accepted. To create a signed version of our container we have to specify the +required private key: ```bash $ target/debug/sextant pack \ @@ -99,4 +103,5 @@ $ target/debug/sextant pack \ --out target/northstar/repository ``` -Chapter [Generating Repository Keys](gen_repo_keys.md) describes how to generate keys suitable for signing and verifying NPKs. +Chapter [Generating Repository Keys](gen_repo_keys.md) describes how to generate +keys suitable for signing and verifying NPKs. diff --git a/main/Cargo.toml b/main/Cargo.toml deleted file mode 100644 index 49bb2c830..000000000 --- a/main/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "main" -version = "0.1.0" -authors = ["ESRLabs"] -edition = "2021" -default-run = "northstar" -license = "Apache-2.0" - -[[bin]] -name = "northstar" -path = "src/main.rs" - -[dependencies] -anyhow = "1.0.57" -clap = { version = "3.1.18", features = ["derive"] } -log = "0.4.17" -nix = { version = "0.24.1", default-features = false, features = ["sched", "mount"] } -northstar = { path = "../northstar", features = ["runtime"] } -tokio = { version = "1.18.1", features = ["rt-multi-thread", "macros", "signal"] } -toml = "0.5.9" - -[target.'cfg(not(target_os = "android"))'.dependencies] -env_logger = "0.9.0" - -[target.'cfg(target_os = "android")'.dependencies] -android-logd-logger = "0.3.1" diff --git a/northstar-client/Cargo.toml b/northstar-client/Cargo.toml new file mode 100644 index 000000000..b0bfb2c48 --- /dev/null +++ b/northstar-client/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "northstar-client" +version = "0.0.1-pre" +authors = ["ESRLabs"] +edition = "2021" +license = "Apache-2.0" + +[dependencies] +anyhow = "1.0.57" +futures = "0.3.21" +northstar-runtime = { path = "../northstar-runtime", features = ["api"] } +thiserror = "1.0.31" +tokio = "1.18.2" + diff --git a/northstar/src/api/client/error.rs b/northstar-client/src/error.rs similarity index 94% rename from northstar/src/api/client/error.rs rename to northstar-client/src/error.rs index ebe2e9bec..20e45a33d 100644 --- a/northstar/src/api/client/error.rs +++ b/northstar-client/src/error.rs @@ -5,7 +5,7 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum RequestError { #[error("runtime error: {0:?}")] - Runtime(crate::api::model::Error), + Runtime(northstar_runtime::api::model::Error), #[error("notification consumer lagged")] LaggedNotifications, #[error(transparent)] diff --git a/northstar/src/api/client/mod.rs b/northstar-client/src/lib.rs similarity index 95% rename from northstar/src/api/client/mod.rs rename to northstar-client/src/lib.rs index e4f944cfe..e9ebeb445 100644 --- a/northstar/src/api/client/mod.rs +++ b/northstar-client/src/lib.rs @@ -10,23 +10,28 @@ use std::{ use anyhow::{anyhow, Context, Result}; use futures::{SinkExt, Stream, StreamExt}; +use northstar_runtime::{ + api::{ + codec, + model::{ + Connect, ConnectNack, Container, ContainerData, Message, MountResult, Notification, + RepositoryId, Request, Response, Token, UmountResult, VerificationResult, + }, + }, + common::non_nul_string::NonNulString, +}; use tokio::{ fs, io::{self, AsyncRead, AsyncWrite, BufWriter}, time, }; -use super::{ - codec, - model::{ - Connect, ConnectNack, Container, ContainerData, Message, MountResult, Notification, - RepositoryId, Request, Response, Token, UmountResult, VerificationResult, - }, -}; -use crate::common::non_nul_string::NonNulString; - /// Client errors pub mod error; +pub use northstar_runtime::{ + api::{model, VERSION}, + common::name::Name, +}; /// Default buffer size for installation transfers const BUFFER_SIZE: usize = 1024 * 1024; @@ -36,8 +41,8 @@ const BUFFER_SIZE: usize = 1024 * 1024; /// ```no_run /// use futures::StreamExt; /// use tokio::time::Duration; -/// use northstar::api::client::Client; -/// use northstar::common::version::Version; +/// use northstar_client::Client; +/// use northstar_client::model::Version; /// /// # #[tokio::main(flavor = "current_thread")] /// async fn main() { @@ -83,7 +88,7 @@ pub async fn connect( // Send connect message let connect = Connect::Connect { - version: super::VERSION, + version: VERSION, subscribe_notifications, }; connection @@ -182,8 +187,8 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use tokio::time::Duration; - /// # use northstar::api::client::Client; - /// # use northstar::api::model::Request::List; + /// # use northstar_client::Client; + /// # use northstar_client::model::Request::List; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -228,7 +233,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use tokio::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -250,7 +255,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use tokio::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -272,7 +277,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use tokio::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -294,7 +299,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -317,7 +322,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::collections::HashMap; /// # /// # #[tokio::main(flavor = "current_thread")] @@ -347,7 +352,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::collections::HashMap; /// # /// # #[tokio::main(flavor = "current_thread")] @@ -406,7 +411,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use tokio::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -432,7 +437,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// Install a npk from path /// /// ```no_run - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::time::Duration; /// # use std::path::Path; /// # @@ -463,7 +468,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// Install a npk /// /// ```no_run - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::time::Duration; /// # use std::path::Path; /// # use tokio::fs; @@ -538,7 +543,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// # use futures::StreamExt; /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -568,7 +573,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// Mount a container /// ```no_run - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::time::Duration; /// # use std::convert::TryInto; /// # @@ -590,9 +595,9 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// Mount a list of containers /// ```no_run - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # use std::time::Duration; - /// # use northstar::common::version::Version; + /// # use northstar_client::model::Version; /// # use std::path::Path; /// # use std::convert::TryInto; /// # @@ -629,7 +634,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// /// ```no_run /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -651,7 +656,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// /// ```no_run /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { @@ -688,7 +693,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// /// ```no_run /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -716,7 +721,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// /// ```no_run /// # use std::time::Duration; - /// # use northstar::api::client::Client; + /// # use northstar_client::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -746,8 +751,8 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// /// ```no_run /// # use std::time::Duration; - /// # use northstar::api::client::Client; - /// # use northstar::api::model::VerificationResult; + /// # use northstar_client::Client; + /// # use northstar_client::model::VerificationResult; /// # /// # #[tokio::main] /// # async fn main() { @@ -815,7 +820,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client { /// ```no_run /// use futures::StreamExt; /// use std::time::Duration; -/// use northstar::api::client::Client; +/// # use northstar_client::Client; /// /// # #[tokio::main(flavor = "current_thread")] /// async fn main() { diff --git a/tools/nstar/Cargo.toml b/northstar-nstar/Cargo.toml similarity index 80% rename from tools/nstar/Cargo.toml rename to northstar-nstar/Cargo.toml index 1057943f5..f499eae17 100644 --- a/tools/nstar/Cargo.toml +++ b/northstar-nstar/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "nstar" -version = "0.4.2" +name = "northstar-nstar" +version = "0.0.1-pre" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -13,7 +13,7 @@ futures = { version = "0.3.21", default-features = false } hex = "0.4.3" humantime = "2.1.0" itertools = "0.10.3" -northstar = { path = "../../northstar", features = ["api"], default-features = false } +northstar-client = { path = "../northstar-client" } pin-project-lite = "0.2.9" prettytable-rs = "0.8.0" serde_json = "1.0.81" diff --git a/tools/nstar/README.md b/northstar-nstar/README.md similarity index 100% rename from tools/nstar/README.md rename to northstar-nstar/README.md diff --git a/tools/nstar/src/main.rs b/northstar-nstar/src/main.rs similarity index 97% rename from tools/nstar/src/main.rs rename to northstar-nstar/src/main.rs index cabe16422..5779be0ef 100644 --- a/tools/nstar/src/main.rs +++ b/northstar-nstar/src/main.rs @@ -4,15 +4,11 @@ #![deny(missing_docs)] use anyhow::{anyhow, bail, Context, Result}; -use api::client::Client; use clap::{self, IntoApp, Parser}; use futures::StreamExt; -use northstar::{ - api::{ - self, - model::{Container, Token}, - }, - common::name::Name, +use northstar_client::{ + model::{Container, Token}, + Client, Name, VERSION, }; use std::{collections::HashMap, convert::TryFrom, path::PathBuf, process}; use tokio::{ @@ -31,12 +27,11 @@ const DEFAULT_HOST: &str = "tcp://localhost:4200"; /// About string for CLI fn about() -> &'static str { - Box::leak(Box::new(format!("Northstar API version {}", api::VERSION))) + Box::leak(Box::new(format!("Northstar API version {}", VERSION))) } /// Subcommands #[derive(Parser, Clone, PartialEq)] -#[clap(name = "nstar", author, about = about())] enum Subcommand { /// List available containers #[clap(alias = "ls")] @@ -132,8 +127,9 @@ enum Subcommand { Ident, } -/// CLI +/// Northstar console client #[derive(Parser)] +#[clap(author, version, about = about(), long_about = None)] struct Opt { /// Northstar address #[clap(short, long, default_value = DEFAULT_HOST)] diff --git a/tools/nstar/src/pretty.rs b/northstar-nstar/src/pretty.rs similarity index 98% rename from tools/nstar/src/pretty.rs rename to northstar-nstar/src/pretty.rs index f186d234e..2a53d7dc3 100644 --- a/tools/nstar/src/pretty.rs +++ b/northstar-nstar/src/pretty.rs @@ -1,7 +1,7 @@ use itertools::Itertools; -use model::ExitStatus; -use northstar::api::model::{ - self, Container, ContainerData, MountResult, Notification, RepositoryId, UmountResult, +use northstar_client::model::{ + self, Container, ContainerData, ExitStatus, MountResult, Notification, RepositoryId, + UmountResult, }; use prettytable::{format, Attr, Cell, Row, Table}; use std::collections::{HashMap, HashSet}; diff --git a/tools/nstar/src/trace.rs b/northstar-nstar/src/trace.rs similarity index 100% rename from tools/nstar/src/trace.rs rename to northstar-nstar/src/trace.rs diff --git a/northstar-runtime/Cargo.toml b/northstar-runtime/Cargo.toml new file mode 100644 index 000000000..9970fbf99 --- /dev/null +++ b/northstar-runtime/Cargo.toml @@ -0,0 +1,148 @@ +[package] +name = "northstar-runtime" +version = "0.0.1-pre" +authors = ["ESRLabs"] +build = "build.rs" +description = "Northstar is an container runtime for Linux targetting embedded systems" +edition = "2021" +license = "Apache-2.0" +readme = "../README.md" +repository = "https://github.com/esrlabs/northstar" +rust-version = "1.59.0" + +[dependencies] +anyhow = "1.0.57" +async-stream = { version = "0.3.3", optional = true } +async-trait = { version = "0.1.53", optional = true } +base64 = { version = "0.13.0", optional = true } +bincode = { version = "1.3.3", optional = true } +byteorder = { version = "1.4.3", optional = true } +bytes = { version = "1.1.0", optional = true } +bytesize = { version = "1.1.0", optional = true } +caps = { version = "0.5.3", optional = true } +cgroups-rs = { git = "https://github.com/esrlabs/cgroups-rs.git", branch = "northstar", features = ["serde"], optional = true } +devicemapper = { version = "0.32.0", optional = true } +ed25519-dalek = { version = "1.0.1", optional = true } +futures = { version = "0.3.21", default-features = true, optional = true } +hex = { version = "0.4.3", optional = true } +hmac = { version = "0.12.1", features = ["reset"], optional = true } +humanize-rs = { version = "0.1.5", optional = true } +humantime = { version = "2.1.0", optional = true } +humantime-serde = { version = "1.1.1", optional = true } +inotify = { version = "0.10.0", features = ["stream"], optional = true } +itertools = { version = "0.10.3", optional = true } +lazy_static = { version = "1.4.0", optional = true } +log = { version = "0.4.17", features = [ "serde"] } +loopdev = { version = "0.4.0", optional = true } +memchr = "2.5.0" +memfd = { version = "0.5.1", optional = true } +memoffset = { version = "0.6.5", optional = true } +nanoid = { version = "0.4.0", optional = true } +nix = { version = "0.24.1", default-features = false, features = ["fs", "sched", "mount", "term", "uio", "socket", "net", "signal", "user"], optional = true } +rand_core = { version = "0.6.3", features = ["getrandom"], optional = true } +rlimit = { version = "0.8.3", optional = true } +schemars = { version = "0.8.10", features = ["preserve_order"] } +semver = { version = "1.0.9", features = ["serde"] } +serde = { version = "1.0.137", features = ["derive", "rc"] } +serde_json = { version = "1.0.81", optional = true } +serde_plain = { version = "1.0.0", optional = true } +serde_with = { version = "1.13.0", optional = true } +serde_yaml = { version = "0.8.24", optional = true } +sha2 = { version = "0.10.2", optional = true } +strum = { version = "0.24.0", optional = true } +strum_macros = { version = "0.24.0", optional = true } +tempfile = { version = "3.3.0", optional = true } +thiserror = "1.0.31" +tokio = { version = "1.18.1", features = ["fs", "io-std", "io-util", "macros", "process", "rt-multi-thread", "sync", "time", "net"], optional = true } +tokio-eventfd = { version = "0.2.0", optional = true } +tokio-util = { version = "0.7.2", features = ["codec", "io"], optional = true } +url = { version = "2.2.2", features = ["serde"], optional = true } +uuid = { version = "1.0.0", features = ["v4"], optional = true } +validator = { version = "0.15.0", features = ["derive"], optional = true } +zeroize = { version = "1.5.5", optional = true } +zip = { version = "0.6.2", default-features = false, optional = true } + +[features] +api = [ + "bytes", + "futures", + "npk", + "serde_json", + "tokio", + "tokio-util", +] +npk = [ + "base64", + "byteorder", + "ed25519-dalek", + "hex", + "humanize-rs", + "itertools", + "rand_core", + "sha2", + "seccomp", + "serde_json", + "serde_plain", + "serde_with", + "serde_yaml", + "strum", + "strum_macros", + "tempfile", + "uuid", + "validator", + "zeroize", + "zip" +] +runtime = [ + "anyhow", + "api", + "async-stream", + "async-trait", + "bincode", + "bytesize", + "caps", + "cgroups-rs", + "devicemapper", + "ed25519-dalek", + "futures", + "hex", + "hmac", + "humantime", + "humantime-serde", + "inotify", + "itertools", + "lazy_static", + "loopdev", + "memfd", + "memoffset", + "nanoid", + "nix", + "npk", + "rlimit", + "tempfile", + "tokio", + "tokio-eventfd", + "tokio-util", + "url", +] +seccomp = [ + "anyhow", + "bindgen", + "caps", + "lazy_static", + "memoffset", + "nix", + "npk", +] + +[dev-dependencies] +anyhow = "1.0.57" +proptest = "1.0.0" +serde_json = "1.0.81" +toml = "0.5.9" +tokio = { version = "1.18.1", features = ["test-util"] } +tokio-test = "0.4.2" + +[build-dependencies] +anyhow = { version = "1.0.57", optional = true } +bindgen = { version = "0.59.2", default-features = false, features = ["runtime"], optional = true } diff --git a/northstar/build.rs b/northstar-runtime/build.rs similarity index 100% rename from northstar/build.rs rename to northstar-runtime/build.rs diff --git a/northstar/src/api/codec.rs b/northstar-runtime/src/api/codec.rs similarity index 100% rename from northstar/src/api/codec.rs rename to northstar-runtime/src/api/codec.rs diff --git a/northstar/src/api/mod.rs b/northstar-runtime/src/api/mod.rs similarity index 73% rename from northstar/src/api/mod.rs rename to northstar-runtime/src/api/mod.rs index 67add5b15..b56ce8d05 100644 --- a/northstar/src/api/mod.rs +++ b/northstar-runtime/src/api/mod.rs @@ -1,7 +1,5 @@ use crate::common::version::Version; -/// Client to interact with a runtime instance -pub mod client; /// API protocol codec pub mod codec; /// API model diff --git a/northstar/src/api/model.rs b/northstar-runtime/src/api/model.rs similarity index 100% rename from northstar/src/api/model.rs rename to northstar-runtime/src/api/model.rs diff --git a/northstar/src/common/container.rs b/northstar-runtime/src/common/container.rs similarity index 100% rename from northstar/src/common/container.rs rename to northstar-runtime/src/common/container.rs diff --git a/northstar/src/common/mod.rs b/northstar-runtime/src/common/mod.rs similarity index 100% rename from northstar/src/common/mod.rs rename to northstar-runtime/src/common/mod.rs diff --git a/northstar/src/common/name.rs b/northstar-runtime/src/common/name.rs similarity index 100% rename from northstar/src/common/name.rs rename to northstar-runtime/src/common/name.rs diff --git a/northstar/src/common/non_nul_string.rs b/northstar-runtime/src/common/non_nul_string.rs similarity index 100% rename from northstar/src/common/non_nul_string.rs rename to northstar-runtime/src/common/non_nul_string.rs diff --git a/northstar/src/common/version.rs b/northstar-runtime/src/common/version.rs similarity index 100% rename from northstar/src/common/version.rs rename to northstar-runtime/src/common/version.rs diff --git a/northstar/src/lib.rs b/northstar-runtime/src/lib.rs similarity index 100% rename from northstar/src/lib.rs rename to northstar-runtime/src/lib.rs diff --git a/northstar/src/npk/dm_verity.rs b/northstar-runtime/src/npk/dm_verity.rs similarity index 100% rename from northstar/src/npk/dm_verity.rs rename to northstar-runtime/src/npk/dm_verity.rs diff --git a/northstar/src/npk/manifest/autostart.rs b/northstar-runtime/src/npk/manifest/autostart.rs similarity index 100% rename from northstar/src/npk/manifest/autostart.rs rename to northstar-runtime/src/npk/manifest/autostart.rs diff --git a/northstar/src/npk/manifest/capabilities.rs b/northstar-runtime/src/npk/manifest/capabilities.rs similarity index 100% rename from northstar/src/npk/manifest/capabilities.rs rename to northstar-runtime/src/npk/manifest/capabilities.rs diff --git a/northstar/src/npk/manifest/cgroups.rs b/northstar-runtime/src/npk/manifest/cgroups.rs similarity index 100% rename from northstar/src/npk/manifest/cgroups.rs rename to northstar-runtime/src/npk/manifest/cgroups.rs diff --git a/northstar/src/npk/manifest/console.rs b/northstar-runtime/src/npk/manifest/console.rs similarity index 100% rename from northstar/src/npk/manifest/console.rs rename to northstar-runtime/src/npk/manifest/console.rs diff --git a/northstar/src/npk/manifest/io.rs b/northstar-runtime/src/npk/manifest/io.rs similarity index 100% rename from northstar/src/npk/manifest/io.rs rename to northstar-runtime/src/npk/manifest/io.rs diff --git a/northstar/src/npk/manifest/mod.rs b/northstar-runtime/src/npk/manifest/mod.rs similarity index 100% rename from northstar/src/npk/manifest/mod.rs rename to northstar-runtime/src/npk/manifest/mod.rs diff --git a/northstar/src/npk/manifest/mount.rs b/northstar-runtime/src/npk/manifest/mount.rs similarity index 100% rename from northstar/src/npk/manifest/mount.rs rename to northstar-runtime/src/npk/manifest/mount.rs diff --git a/northstar/src/npk/manifest/rlimit.rs b/northstar-runtime/src/npk/manifest/rlimit.rs similarity index 100% rename from northstar/src/npk/manifest/rlimit.rs rename to northstar-runtime/src/npk/manifest/rlimit.rs diff --git a/northstar/src/npk/manifest/selinux.rs b/northstar-runtime/src/npk/manifest/selinux.rs similarity index 100% rename from northstar/src/npk/manifest/selinux.rs rename to northstar-runtime/src/npk/manifest/selinux.rs diff --git a/northstar/src/npk/manifest/validation.rs b/northstar-runtime/src/npk/manifest/validation.rs similarity index 100% rename from northstar/src/npk/manifest/validation.rs rename to northstar-runtime/src/npk/manifest/validation.rs diff --git a/northstar/src/npk/mod.rs b/northstar-runtime/src/npk/mod.rs similarity index 100% rename from northstar/src/npk/mod.rs rename to northstar-runtime/src/npk/mod.rs diff --git a/northstar/src/npk/npk.rs b/northstar-runtime/src/npk/npk.rs similarity index 98% rename from northstar/src/npk/npk.rs rename to northstar-runtime/src/npk/npk.rs index 815a2bcd1..ff52d239e 100644 --- a/northstar/src/npk/npk.rs +++ b/northstar-runtime/src/npk/npk.rs @@ -393,7 +393,7 @@ impl Default for SquashfsOptions { } /// Create an NPK for the northstar runtime. -/// sextant collects the artifacts in a given container directory, creates and signs the necessary metadata +/// northstar-sextant collects the artifacts in a given container directory, creates and signs the necessary metadata /// and packs the results into a zipped NPK file. /// /// # Arguments @@ -406,7 +406,7 @@ impl Default for SquashfsOptions { /// /// To build the 'hello' example container: /// -/// sextant pack \ +/// northstar-sextant pack \ /// --manifest examples/hello/manifest.yaml \ /// --root examples/hello/root \ /// --out target/northstar/repository \ @@ -416,7 +416,7 @@ pub fn pack(manifest: &Path, root: &Path, out: &Path, key: Option<&Path>) -> Res } /// Create an NPK with special `squashfs` options -/// sextant collects the artifacts in a given container directory, creates and signs the necessary metadata +/// northstar-sextant collects the artifacts in a given container directory, creates and signs the necessary metadata /// and packs the results into a zipped NPK file. /// /// # Arguments @@ -430,7 +430,7 @@ pub fn pack(manifest: &Path, root: &Path, out: &Path, key: Option<&Path>) -> Res /// /// To build the 'hello' example container: /// -/// sextant pack \ +/// northstar-sextant pack \ /// --manifest examples/hello/manifest.yaml \ /// --root examples/hello/root \ /// --out target/northstar/repository \ diff --git a/northstar/src/runtime/cgroups.rs b/northstar-runtime/src/runtime/cgroups.rs similarity index 100% rename from northstar/src/runtime/cgroups.rs rename to northstar-runtime/src/runtime/cgroups.rs diff --git a/northstar/src/runtime/config.rs b/northstar-runtime/src/runtime/config.rs similarity index 100% rename from northstar/src/runtime/config.rs rename to northstar-runtime/src/runtime/config.rs diff --git a/northstar/src/runtime/console.rs b/northstar-runtime/src/runtime/console.rs similarity index 100% rename from northstar/src/runtime/console.rs rename to northstar-runtime/src/runtime/console.rs diff --git a/northstar/src/runtime/debug.rs b/northstar-runtime/src/runtime/debug.rs similarity index 100% rename from northstar/src/runtime/debug.rs rename to northstar-runtime/src/runtime/debug.rs diff --git a/northstar/src/runtime/error.rs b/northstar-runtime/src/runtime/error.rs similarity index 100% rename from northstar/src/runtime/error.rs rename to northstar-runtime/src/runtime/error.rs diff --git a/northstar/src/runtime/fork/forker/impl.rs b/northstar-runtime/src/runtime/fork/forker/impl.rs similarity index 100% rename from northstar/src/runtime/fork/forker/impl.rs rename to northstar-runtime/src/runtime/fork/forker/impl.rs diff --git a/northstar/src/runtime/fork/forker/messages.rs b/northstar-runtime/src/runtime/fork/forker/messages.rs similarity index 100% rename from northstar/src/runtime/fork/forker/messages.rs rename to northstar-runtime/src/runtime/fork/forker/messages.rs diff --git a/northstar/src/runtime/fork/forker/mod.rs b/northstar-runtime/src/runtime/fork/forker/mod.rs similarity index 100% rename from northstar/src/runtime/fork/forker/mod.rs rename to northstar-runtime/src/runtime/fork/forker/mod.rs diff --git a/northstar/src/runtime/fork/init/builder.rs b/northstar-runtime/src/runtime/fork/init/builder.rs similarity index 100% rename from northstar/src/runtime/fork/init/builder.rs rename to northstar-runtime/src/runtime/fork/init/builder.rs diff --git a/northstar/src/runtime/fork/init/mod.rs b/northstar-runtime/src/runtime/fork/init/mod.rs similarity index 100% rename from northstar/src/runtime/fork/init/mod.rs rename to northstar-runtime/src/runtime/fork/init/mod.rs diff --git a/northstar/src/runtime/fork/mod.rs b/northstar-runtime/src/runtime/fork/mod.rs similarity index 100% rename from northstar/src/runtime/fork/mod.rs rename to northstar-runtime/src/runtime/fork/mod.rs diff --git a/northstar/src/runtime/fork/util.rs b/northstar-runtime/src/runtime/fork/util.rs similarity index 100% rename from northstar/src/runtime/fork/util.rs rename to northstar-runtime/src/runtime/fork/util.rs diff --git a/northstar/src/runtime/io.rs b/northstar-runtime/src/runtime/io.rs similarity index 100% rename from northstar/src/runtime/io.rs rename to northstar-runtime/src/runtime/io.rs diff --git a/northstar/src/runtime/ipc/message.rs b/northstar-runtime/src/runtime/ipc/message.rs similarity index 100% rename from northstar/src/runtime/ipc/message.rs rename to northstar-runtime/src/runtime/ipc/message.rs diff --git a/northstar/src/runtime/ipc/mod.rs b/northstar-runtime/src/runtime/ipc/mod.rs similarity index 100% rename from northstar/src/runtime/ipc/mod.rs rename to northstar-runtime/src/runtime/ipc/mod.rs diff --git a/northstar/src/runtime/ipc/owned_fd.rs b/northstar-runtime/src/runtime/ipc/owned_fd.rs similarity index 100% rename from northstar/src/runtime/ipc/owned_fd.rs rename to northstar-runtime/src/runtime/ipc/owned_fd.rs diff --git a/northstar/src/runtime/ipc/raw_fd_ext.rs b/northstar-runtime/src/runtime/ipc/raw_fd_ext.rs similarity index 100% rename from northstar/src/runtime/ipc/raw_fd_ext.rs rename to northstar-runtime/src/runtime/ipc/raw_fd_ext.rs diff --git a/northstar/src/runtime/ipc/socket_pair.rs b/northstar-runtime/src/runtime/ipc/socket_pair.rs similarity index 100% rename from northstar/src/runtime/ipc/socket_pair.rs rename to northstar-runtime/src/runtime/ipc/socket_pair.rs diff --git a/northstar/src/runtime/key.rs b/northstar-runtime/src/runtime/key.rs similarity index 100% rename from northstar/src/runtime/key.rs rename to northstar-runtime/src/runtime/key.rs diff --git a/northstar/src/runtime/mod.rs b/northstar-runtime/src/runtime/mod.rs similarity index 100% rename from northstar/src/runtime/mod.rs rename to northstar-runtime/src/runtime/mod.rs diff --git a/northstar/src/runtime/mount.rs b/northstar-runtime/src/runtime/mount.rs similarity index 100% rename from northstar/src/runtime/mount.rs rename to northstar-runtime/src/runtime/mount.rs diff --git a/northstar/src/runtime/repository.rs b/northstar-runtime/src/runtime/repository.rs similarity index 100% rename from northstar/src/runtime/repository.rs rename to northstar-runtime/src/runtime/repository.rs diff --git a/northstar/src/runtime/state.rs b/northstar-runtime/src/runtime/state.rs similarity index 100% rename from northstar/src/runtime/state.rs rename to northstar-runtime/src/runtime/state.rs diff --git a/northstar/src/runtime/stats.rs b/northstar-runtime/src/runtime/stats.rs similarity index 100% rename from northstar/src/runtime/stats.rs rename to northstar-runtime/src/runtime/stats.rs diff --git a/northstar/src/runtime/token.rs b/northstar-runtime/src/runtime/token.rs similarity index 100% rename from northstar/src/runtime/token.rs rename to northstar-runtime/src/runtime/token.rs diff --git a/northstar/src/seccomp/bpf.rs b/northstar-runtime/src/seccomp/bpf.rs similarity index 100% rename from northstar/src/seccomp/bpf.rs rename to northstar-runtime/src/seccomp/bpf.rs diff --git a/northstar/src/seccomp/mod.rs b/northstar-runtime/src/seccomp/mod.rs similarity index 100% rename from northstar/src/seccomp/mod.rs rename to northstar-runtime/src/seccomp/mod.rs diff --git a/northstar/src/seccomp/profiles/default.rs b/northstar-runtime/src/seccomp/profiles/default.rs similarity index 100% rename from northstar/src/seccomp/profiles/default.rs rename to northstar-runtime/src/seccomp/profiles/default.rs diff --git a/northstar/src/seccomp/profiles/mod.rs b/northstar-runtime/src/seccomp/profiles/mod.rs similarity index 100% rename from northstar/src/seccomp/profiles/mod.rs rename to northstar-runtime/src/seccomp/profiles/mod.rs diff --git a/northstar/src/seccomp/types.rs b/northstar-runtime/src/seccomp/types.rs similarity index 100% rename from northstar/src/seccomp/types.rs rename to northstar-runtime/src/seccomp/types.rs diff --git a/tools/schema/Cargo.toml b/northstar-schema/Cargo.toml similarity index 64% rename from tools/schema/Cargo.toml rename to northstar-schema/Cargo.toml index 83a133606..b9d0cb94d 100644 --- a/tools/schema/Cargo.toml +++ b/northstar-schema/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "schema" -version = "0.0.1" +name = "northstar-schema" +version = "0.0.1-pre" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -8,7 +8,7 @@ license = "Apache-2.0" [dependencies] anyhow = "1.0.57" clap = { version = "3.1.18", features = ["derive"] } -northstar = { path = "../../northstar", features = ["api"], default-features = false } +northstar-runtime = { path = "../northstar-runtime", features = ["api"] } okapi = "0.7.0-rc.1" schemars = "0.8.10" serde_json = "1.0.81" diff --git a/tools/schema/src/main.rs b/northstar-schema/src/main.rs similarity index 91% rename from tools/schema/src/main.rs rename to northstar-schema/src/main.rs index 57c1a80d5..27d2cbb03 100644 --- a/tools/schema/src/main.rs +++ b/northstar-schema/src/main.rs @@ -5,7 +5,7 @@ use anyhow::{Context, Result}; use clap::Parser; -use northstar::{api, npk}; +use northstar_runtime::{api, npk}; use okapi::openapi3::{Components, Contact, Info}; use schemars::{gen::SchemaSettings, JsonSchema}; use std::{fs::write, path::PathBuf, str::FromStr}; @@ -20,10 +20,10 @@ fn about() -> &'static str { } #[derive(JsonSchema)] -struct Message(northstar::api::model::Message); +struct Message(northstar_runtime::api::model::Message); #[derive(JsonSchema)] -struct Manifest(northstar::npk::manifest::Manifest); +struct Manifest(northstar_runtime::npk::manifest::Manifest); enum Model { Api, @@ -42,9 +42,9 @@ impl FromStr for Model { } } -/// CLI +/// Northstar schema generator #[derive(Parser)] -#[clap(name = "schema", author, about = about())] +#[clap(author, version, about = about(), long_about = None)] struct Opt { /// Output destination. Defaults to stdout #[clap(short, long)] diff --git a/tools/seccomp-util/Cargo.toml b/northstar-seccomp/Cargo.toml similarity index 68% rename from tools/seccomp-util/Cargo.toml rename to northstar-seccomp/Cargo.toml index 7f1136974..c1f53a617 100644 --- a/tools/seccomp-util/Cargo.toml +++ b/northstar-seccomp/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "seccomp-util" -version = "0.1.0" +name = "northstar-seccomp" +version = "0.0.1-pre" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -10,7 +10,7 @@ anyhow = "1.0.57" clap = { version = "3.1.18", features = ["derive"] } env_logger = "0.9.0" itertools = "0.10.3" -northstar = { path = "../../northstar", features = ["seccomp"] } +northstar-runtime = { path = "../northstar-runtime", features = ["seccomp"] } regex = "1.5.5" serde_yaml = "0.8.24" diff --git a/tools/seccomp-util/README.md b/northstar-seccomp/README.md similarity index 62% rename from tools/seccomp-util/README.md rename to northstar-seccomp/README.md index 945e1b432..0a820dfdd 100644 --- a/tools/seccomp-util/README.md +++ b/northstar-seccomp/README.md @@ -4,18 +4,19 @@ Utility to generate seccomp profiles for Northstar containers. ## Create a seccomp manifest entry -To enable seccomp for container, a suitable `seccomp` entry is required in the container's manifest -file. -Using `seccomp-util`, such an entry can be created with the following steps: +To enable seccomp for container, a suitable `seccomp` entry is required in the +container's manifest file. Using `northstar-seccomp`, such an entry can be created +with the following steps: 1. Run the container with strace to generate a syscall log. -2. Run `seccomp-util` on the syscall log to generate a seccomp manifest entry. +2. Run `northstar-seccomp` on the syscall log to generate a seccomp manifest entry. 3. Optional: Restrict the arguments of syscalls to specific values. 4. Add the seccomp manifest entry to the container's manifest. ## Example Usage -An example strace log obtained by running a northstar container with strace could look as follows: +An example strace log obtained by running a northstar container with strace +could look as follows: ```shell $ cat ./target/northstar/logs/strace-259876-seccomp.strace @@ -31,25 +32,26 @@ $ cat ./target/northstar/logs/strace-259876-seccomp.strace [...] ``` -Running `seccomp-util` on the file gives the following output: +Running `northstar-seccomp` on the file gives the following output: ```shell -$ seccomp-util ./target/northstar/logs/strace-259876-seccomp.strace +$ northstar-seccomp ./target/northstar/logs/strace-259876-seccomp.strace profile: default seccomp: allow: delete_module: any ``` -Since all syscalls from the trace file except `delete_module` are part of the default profile, -`seccomp-util` did not explicitly add them to the `allow:` part of the entry. +Since all syscalls from the trace file except `delete_module` are part of the +default profile, `northstar-seccomp` did not explicitly add them to the `allow:` +part of the entry. -If we do not want to use the default profile, we can add the `--no-default-profile` command line -switch to disable it. -`seccomp-util` will then list all used syscalls explicitly: +If we do not want to use the default profile, we can add the +`--no-default-profile` command line switch to disable it. `northstar-seccomp` +will then list all used syscalls explicitly: ```shell -$ seccomp-util --no-default-profile ./target/northstar/logs/strace-259876-seccomp.strace +$ northstar-seccomp --no-default-profile ./target/northstar/logs/strace-259876-seccomp.strace seccomp: allow: brk: any @@ -63,11 +65,11 @@ seccomp: [...] ``` -If we want to restrict the `write` syscall to write to `stdout` only, we need to modify its -`seccomp` entry. -The target file descriptor is passed in the first argument of the `write` syscall -and according to POSIX, `stdout` always has a file descriptor value of `1`. -We can therefore modify the `seccomp` entry as follows: +If we want to restrict the `write` syscall to write to `stdout` only, we need to +modify its `seccomp` entry. The target file descriptor is passed in the first +argument of the `write` syscall and according to POSIX, `stdout` always has a +file descriptor value of `1`. We can therefore modify the `seccomp` entry as +follows: ```shell seccomp: @@ -87,8 +89,8 @@ seccomp: [...] ``` -Note that if there are multiple rules for a single syscall, then all rules are evaluated and the -syscall only fails if none of the rules allow it. +Note that if there are multiple rules for a single syscall, then all rules are +evaluated and the syscall only fails if none of the rules allow it. In particular, consider the following seccomp entry: @@ -105,9 +107,9 @@ seccomp: ] ``` -Since the default profile already allows the `write` syscall without imposing any restrictions on -the arguments, the entry for `write` in the `allow:` part of the entry is redundant. -It is therefore equivalent to the following entry: +Since the default profile already allows the `write` syscall without imposing +any restrictions on the arguments, the entry for `write` in the `allow:` part of +the entry is redundant. It is therefore equivalent to the following entry: ```shell seccomp: diff --git a/tools/seccomp-util/res/test_strace_data.txt b/northstar-seccomp/res/test_strace_data.txt similarity index 100% rename from tools/seccomp-util/res/test_strace_data.txt rename to northstar-seccomp/res/test_strace_data.txt diff --git a/tools/seccomp-util/src/main.rs b/northstar-seccomp/src/main.rs similarity index 98% rename from tools/seccomp-util/src/main.rs rename to northstar-seccomp/src/main.rs index 4a25b752c..bc6bf8f22 100644 --- a/tools/seccomp-util/src/main.rs +++ b/northstar-seccomp/src/main.rs @@ -1,6 +1,6 @@ use anyhow::{Context, Result}; use clap::Parser; -use northstar::{ +use northstar_runtime::{ common::non_nul_string::NonNulString, seccomp::{profiles::default::SYSCALLS_BASE, Profile, Seccomp, SyscallRule}, }; diff --git a/tools/seccomp-util/tests/tests.rs b/northstar-seccomp/tests/tests.rs similarity index 93% rename from tools/seccomp-util/tests/tests.rs rename to northstar-seccomp/tests/tests.rs index 1cd7acada..4eccb1911 100644 --- a/tools/seccomp-util/tests/tests.rs +++ b/northstar-seccomp/tests/tests.rs @@ -11,7 +11,7 @@ allow: "; let stdout = String::from_utf8( - Command::cargo_bin("seccomp-util")? + Command::cargo_bin("northstar-seccomp")? .arg("./res/test_strace_data.txt") .output()? .stdout, @@ -52,7 +52,7 @@ allow: "; let stdout = String::from_utf8( - Command::cargo_bin("seccomp-util")? + Command::cargo_bin("northstar-seccomp")? .arg("./res/test_strace_data.txt") .arg("--no-default-profile") .output()? diff --git a/tools/sextant/Cargo.toml b/northstar-sextant/Cargo.toml similarity index 72% rename from tools/sextant/Cargo.toml rename to northstar-sextant/Cargo.toml index 32a661215..8b3ba4c58 100644 --- a/tools/sextant/Cargo.toml +++ b/northstar-sextant/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "sextant" -version = "0.2.1" +name = "northstar-sextant" +version = "0.0.1-pre" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -13,6 +13,6 @@ colored = "2.0.0" ed25519-dalek = "1.0.1" env_logger = "0.9.0" log = "0.4.17" -northstar = { path = "../../northstar", features = ["npk"] } +northstar-runtime = { path = "../northstar-runtime", features = ["npk"] } tempfile = "3.3.0" zip = { version = "0.6.2", default-features = false } diff --git a/tools/sextant/README.md b/northstar-sextant/README.md similarity index 76% rename from tools/sextant/README.md rename to northstar-sextant/README.md index 9dc675859..c102bef56 100644 --- a/tools/sextant/README.md +++ b/northstar-sextant/README.md @@ -4,11 +4,12 @@ Northstar containers are distributed in the NPK file format. An NPK file contains both the container's application logic and the data files necessary to mount and run the container. To facilitate the creation, -inspection and modification of NPKs, northstar provides the `sextant` CLI tool. +inspection and modification of NPKs, northstar provides the `northstar-sextant` +CLI tool. ## Packing an unsigned NPK -NPKs are created (packed) using the `pack` command of `sextant`. +NPKs are created (packed) using the `pack` command of `northstar-sextant`. It requires the following input: 1. A manifest file describing the NPK. @@ -20,13 +21,13 @@ that will be mounted by the northstar runtime when the container is run. For example, the following command packs the `hello-world` example container: ```bash -$ target/debug/sextant pack \ +$ target/debug/northstar-sextant pack \ --manifest examples/container/hello-world/manifest.yaml \ --root target/release/hello-world \ --out target/northstar/repository ``` -The output of `sextant pack` is single NPK file: +The output of `northstar-sextant pack` is single NPK file: ```bash $ ls target/northstar/repository @@ -41,7 +42,7 @@ invalid signatures will be rejected. To pack a signed version of the `hello-world` example container, a private key has to be provided: ```bash -$ target/debug/sextant pack \ +$ target/debug/northstar-sextant pack \ --manifest examples/container/hello-world/manifest.yaml \ --root target/release/hello-world \ --key ./examples/keys/northstar.key \ @@ -50,12 +51,13 @@ $ target/debug/sextant pack \ ## Generating repository keys -To sign NPKs using `sextant` a suitable key pair is needed. It can be generated -using the `sextant gen-key` command. The following call creates a new key pair -(`repokey.key` and `repokey.pub`) in the current directory: +To sign NPKs using `northstar-sextant` a suitable key pair is needed. It can be +generated using the `northstar-sextant gen-key` command. The following call +creates a new key pair (`repokey.key` and `repokey.pub`) in the current +directory: ```bash -target/debug/sextant gen-key --name repokey --out . +target/debug/northstar-sextant gen-key --name repokey --out . ``` The private key `repokey.key` can be used for signing of NPKs while the public @@ -65,12 +67,13 @@ key `repokey.pub` is used by the northstar runtime to verify NPKs. NPKs are ZIP files that contain among other things a squashfs image that will be mounted at runtime. To extract both the outer ZIP and the inner image, the -`unpack` command of `sextant` can be used. +`unpack` command of `northstar-sextant` can be used. -To unpack the `hello-world` example container, the `sextant unpack` can be used: +To unpack the `hello-world` example container, the `northstar-sextant unpack` +can be used: ```sh -$ target/debug/sextant unpack \ +$ target/debug/northstar-sextant unpack \ --npk ./target/northstar/repository/hello-world-0.0.1.npk \ --out ./hello-world-container ``` @@ -95,7 +98,8 @@ in the `manifest.yaml`. ## Inspecting an NPK -To get information about an already packed NPK `sextant` provides the `inspect` command. +To get information about an already packed NPK `northstar-sextant` provides the +`inspect` command. ### Inspecting an NPK with default settings @@ -110,7 +114,7 @@ Inspecting an NPK without any additional parameters will show the following info The `hello-world` example container can be inspected with the following command: ```sh -$ sextant inspect target/northstar/repository/hello-0.0.1.npk +$ northstar-sextant inspect target/northstar/repository/hello-0.0.1.npk ... ``` @@ -129,6 +133,6 @@ Inspecting the `hello-world` example container with the `--short` flag gives the following output: ```markdown -$ sextant inspect --short target/northstar/repository/hello-world-0.0.1.npk +$ northstar-sextant inspect --short hello-world-0.0.1.npk name: hello-world, version: 0.0.1, NPK version: 0.0.2, resource container: no ``` diff --git a/tools/sextant/src/inspect.rs b/northstar-sextant/src/inspect.rs similarity index 97% rename from tools/sextant/src/inspect.rs rename to northstar-sextant/src/inspect.rs index 2e986386b..7843b94a5 100644 --- a/tools/sextant/src/inspect.rs +++ b/northstar-sextant/src/inspect.rs @@ -8,7 +8,7 @@ use std::{ use anyhow::{Context, Result}; use colored::Colorize; -use northstar::npk::npk::{Npk, FS_IMG_NAME, MANIFEST_NAME, SIGNATURE_NAME}; +use northstar_runtime::npk::npk::{Npk, FS_IMG_NAME, MANIFEST_NAME, SIGNATURE_NAME}; use zip::ZipArchive; pub(crate) fn inspect(npk: &Path, short: bool, unsquashfs: &Path) -> Result<()> { @@ -107,7 +107,7 @@ fn print_squashfs(fsimg_path: &Path, unsquashfs: &Path) -> Result<()> { #[cfg(test)] mod test { use super::inspect; - use northstar::npk::npk::{generate_key, pack}; + use northstar_runtime::npk::npk::{generate_key, pack}; use std::{ fs::File, io::Write, diff --git a/tools/sextant/src/main.rs b/northstar-sextant/src/main.rs similarity index 96% rename from tools/sextant/src/main.rs rename to northstar-sextant/src/main.rs index 4b5215bb7..d8ea69719 100644 --- a/tools/sextant/src/main.rs +++ b/northstar-sextant/src/main.rs @@ -5,7 +5,7 @@ use anyhow::Result; use clap::Parser; -use northstar::npk::{ +use northstar_runtime::npk::{ self, npk::{CompressionAlgorithm, SquashfsOptions}, }; @@ -14,8 +14,9 @@ use std::path::PathBuf; mod inspect; mod pack; +/// Northstar package tool #[derive(Debug, Parser)] -#[clap(about = "Northstar CLI")] +#[clap(author, version, about, long_about = None)] enum Opt { /// Pack Northstar containers Pack { diff --git a/tools/sextant/src/pack.rs b/northstar-sextant/src/pack.rs similarity index 98% rename from tools/sextant/src/pack.rs rename to northstar-sextant/src/pack.rs index 200dcf52a..67b695c1d 100644 --- a/tools/sextant/src/pack.rs +++ b/northstar-sextant/src/pack.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use northstar::npk::{ +use northstar_runtime::npk::{ manifest::Manifest, npk::{pack_with, SquashfsOptions}, }; diff --git a/tools/stress/Cargo.toml b/northstar-stress/Cargo.toml similarity index 82% rename from tools/stress/Cargo.toml rename to northstar-stress/Cargo.toml index 7793d7d13..66b2eb17b 100644 --- a/tools/stress/Cargo.toml +++ b/northstar-stress/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "stress" -version = "0.1.0" +name = "northstar-stress" +version = "0.0.1-pre" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -13,7 +13,7 @@ futures = { version = "0.3.21", default-features = false } humantime = "2.1.0" itertools = "0.10.3" log = "0.4.17" -northstar = { path = "../../northstar", features = ["api"] } +northstar-client = { path = "../northstar-client" } rand = "0.8.5" tokio = { version = "1.18.1", features = ["rt-multi-thread", "macros", "net", "time", "signal"] } tokio-util = "0.7.2" diff --git a/tools/stress/src/main.rs b/northstar-stress/src/main.rs similarity index 95% rename from tools/stress/src/main.rs rename to northstar-stress/src/main.rs index b21a5f4a5..795d332f7 100644 --- a/tools/stress/src/main.rs +++ b/northstar-stress/src/main.rs @@ -6,9 +6,9 @@ use futures::{ }; use humantime::parse_duration; use log::{debug, info}; -use northstar::api::{ - client::{self, Client}, +use northstar_client::{ model::{self, Container, ExitStatus, Notification}, + Client, }; use std::{path::PathBuf, str::FromStr, sync::Arc, time::Duration}; use tokio::{ @@ -45,11 +45,9 @@ impl FromStr for Mode { } } +/// Northstar stress test utility #[derive(Debug, Parser)] -#[clap( - name = "stress", - about = "Manual stress test the start and stop of Nortstar containers" -)] +#[clap(author, version, about, long_about = None)] struct Opt { /// Runtime address #[clap(short, long, default_value = "tcp://localhost:4200")] @@ -134,8 +132,7 @@ async fn main() -> Result<()> { // Get a list of installed applications debug!("Getting list of startable containers"); - let mut client = - client::Client::new(io(&opt.url).await?, None, time::Duration::from_secs(30)).await?; + let mut client = Client::new(io(&opt.url).await?, None, time::Duration::from_secs(30)).await?; let mut containers: Vec = Vec::new(); for container in client.list().await? { let data = Client::inspect(&mut client, &container).await?; @@ -151,7 +148,7 @@ async fn main() -> Result<()> { if opt.single { let stop = stop.clone(); let task = task::spawn(async move { - let mut client = client::Client::new( + let mut client = Client::new( io(&opt.url).await?, Some(containers.len() * 3), time::Duration::from_secs(30), @@ -206,8 +203,7 @@ async fn main() -> Result<()> { debug!("Spawning task for {}", container); let task = task::spawn(async move { let mut client = - client::Client::new(io(&url).await?, Some(1000), time::Duration::from_secs(30)) - .await?; + Client::new(io(&url).await?, Some(1000), time::Duration::from_secs(30)).await?; if let Some(initial_delay) = initial_random_delay { time::sleep(time::Duration::from_millis( @@ -334,7 +330,7 @@ async fn await_notification( /// Install and uninstall an npk in a loop async fn install_uninstall(opt: &Opt) -> Result<()> { let timeout = time::Duration::from_secs(30); - let mut client = client::Client::new(io(&opt.url).await?, Some(10), timeout).await?; + let mut client = Client::new(io(&opt.url).await?, Some(10), timeout).await?; let timeout = opt .duration diff --git a/northstar-tests/Cargo.toml b/northstar-tests/Cargo.toml index 9bb922ed2..3ec4c5cbd 100644 --- a/northstar-tests/Cargo.toml +++ b/northstar-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "northstar-tests" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" @@ -14,7 +14,8 @@ log = "0.4.17" memfd = "0.5.1" nanoid = "0.4.0" nix = { version = "0.24.1", default-features = false } -northstar = { path = "../northstar", features = ["api", "runtime"] } +northstar-client = { path = "../northstar-client" } +northstar-runtime = { path = "../northstar-runtime", features = ["api", "runtime"] } northstar-tests-derive = { path = "northstar-tests-derive" } regex = "1.5.5" tempfile = "3.3.0" diff --git a/northstar-tests/build.rs b/northstar-tests/build.rs index 0ff3a53c4..beacb4588 100644 --- a/northstar-tests/build.rs +++ b/northstar-tests/build.rs @@ -98,7 +98,7 @@ fn main() { fn find_or_build_sextant() -> PathBuf { if env::var(ENV_FORCE_BUILD).is_ok() { for dir in Path::new(&env::var("OUT_DIR").unwrap()).ancestors() { - let sextant = dir.join("sextant"); + let sextant = dir.join("northstar-sextant"); if sextant.is_file() { println!("cargo:warning=Using sextant binary {}", sextant.display()); return sextant; @@ -107,8 +107,8 @@ fn find_or_build_sextant() -> PathBuf { } CargoBuild::new() - .manifest_path("../tools/sextant/Cargo.toml") - .bin("sextant") + .manifest_path("../northstar-sextant/Cargo.toml") + .bin("northstar-sextant") .current_release() .target_dir(Path::new("..").join("target").join("northstar-tests")) // Cannot reuse target because it's in use .run() diff --git a/northstar-tests/northstar-tests-derive/Cargo.toml b/northstar-tests/northstar-tests-derive/Cargo.toml index 11c8be671..e520816b9 100644 --- a/northstar-tests/northstar-tests-derive/Cargo.toml +++ b/northstar-tests/northstar-tests-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "northstar-tests-derive" -version = "0.1.0" +version = "0.0.1" edition = "2021" license = "Apache-2.0" diff --git a/northstar-tests/src/lib.rs b/northstar-tests/src/lib.rs index cfa40a804..d5f5f20ca 100644 --- a/northstar-tests/src/lib.rs +++ b/northstar-tests/src/lib.rs @@ -8,7 +8,7 @@ pub mod runtime; /// /// ```rust /// # use anyhow::Result; -/// # use northstar::api::model::{ExitStatus, Notification}; +/// # use northstar_client::model::{ExitStatus, Notification}; /// # use northstar_tests::{containers::*, logger::assume, runtime::client, runtime_test}; /// #[runtime_test] /// fn console() -> Result<()> { diff --git a/northstar-tests/src/runtime.rs b/northstar-tests/src/runtime.rs index 9f29509ba..4e877d2c1 100644 --- a/northstar-tests/src/runtime.rs +++ b/northstar-tests/src/runtime.rs @@ -4,11 +4,8 @@ use super::{containers::*, logger}; use anyhow::{anyhow, Context, Result}; use futures::StreamExt; use nanoid::nanoid; -use northstar::{ - api::{ - client, - model::{Container, ExitStatus, Notification}, - }, +use northstar_runtime::{ + api::model::{Container, ExitStatus, Notification}, common::non_nul_string::NonNulString, runtime::{ config::{self, ConsoleConfiguration}, @@ -133,11 +130,11 @@ impl Runtime { pub struct Client { /// Client instance - client: northstar::api::client::Client, + client: northstar_client::Client, } impl std::ops::Deref for Client { - type Target = client::Client; + type Target = northstar_client::Client; fn deref(&self) -> &Self::Target { &self.client @@ -157,7 +154,8 @@ impl Client { let io = UnixStream::connect(console_full().path()) .await .expect("failed to connect to console"); - let client = client::Client::new(io, Some(1000), time::Duration::from_secs(30)).await?; + let client = + northstar_client::Client::new(io, Some(1000), time::Duration::from_secs(30)).await?; // Wait until a successful connection logger::assume("Client .* connected", 5u64).await?; @@ -165,11 +163,11 @@ impl Client { } /// Connect a new client instance to the runtime - pub async fn client(&self) -> Result> { + pub async fn client(&self) -> Result> { let io = UnixStream::connect(console_full().path()) .await .context("failed to connect to console")?; - client::Client::new(io, Some(1000), time::Duration::from_secs(30)) + northstar_client::Client::new(io, Some(1000), time::Duration::from_secs(30)) .await .context("failed to create client") } diff --git a/northstar-tests/test-container/Cargo.toml b/northstar-tests/test-container/Cargo.toml index 384ae0f32..654cd20e5 100644 --- a/northstar-tests/test-container/Cargo.toml +++ b/northstar-tests/test-container/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-container" -version = "0.1.0" +version = "0.0.1" authors = ["ESRLabs"] edition = "2021" license = "Apache-2.0" diff --git a/northstar-tests/test-container/src/main.rs b/northstar-tests/test-container/src/main.rs index 653326b0a..104a76569 100644 --- a/northstar-tests/test-container/src/main.rs +++ b/northstar-tests/test-container/src/main.rs @@ -12,7 +12,9 @@ use std::{ thread, time, }; +/// Northstar test container #[derive(Debug, Parser)] +#[clap(author, version, about, long_about = None)] struct Opt { #[clap(subcommand)] command: Option, @@ -47,7 +49,7 @@ enum Command { Inspect, Print { message: String, - #[structopt(short, long, parse(from_str), default_value = "stdout")] + #[clap(short, long, parse(from_str), default_value = "stdout")] io: Io, }, Touch { diff --git a/northstar-tests/tests/console.rs b/northstar-tests/tests/console.rs index 23201521e..fe9ca32e2 100644 --- a/northstar-tests/tests/console.rs +++ b/northstar-tests/tests/console.rs @@ -3,18 +3,18 @@ use std::{iter, path::Path}; use anyhow::{Context, Result}; use api::model::Error as ModelError; use futures::SinkExt; -use northstar::api::{ +use northstar_client::error::RequestError; +use northstar_runtime::api::{ self, - client::error::RequestError, model::{self, ConnectNack, Container}, }; use northstar_tests::runtime_test; use tokio::{net::UnixStream, time::Duration}; /// Connect a client to the runtime console without any permission configured. -async fn connect_none() -> Result> { +async fn connect_none() -> Result> { let io = UnixStream::connect(&northstar_tests::runtime::console_none().path()).await?; - api::client::Client::new(io, None, Duration::from_secs(10)) + northstar_client::Client::new(io, None, Duration::from_secs(10)) .await .context("failed to connect to the runtime") } @@ -57,7 +57,7 @@ async fn api_version() -> Result<()> { async fn too_long_line() -> Result<()> { let timeout = Duration::from_secs(10); let io = UnixStream::connect(&northstar_tests::runtime::console_full().path()).await?; - let mut client = api::client::Client::new(io, None, timeout).await?; + let mut client = northstar_client::Client::new(io, None, timeout).await?; // The default json line limit is 512K let container = Container::try_from("hello-world:0.0.1").unwrap(); @@ -74,7 +74,7 @@ async fn too_long_line() -> Result<()> { async fn npk_size_limit_violation() -> Result<()> { let timeout = Duration::from_secs(10); let io = UnixStream::connect(&northstar_tests::runtime::console_full().path()).await?; - let mut client = api::client::Client::new(io, None, timeout).await?; + let mut client = northstar_client::Client::new(io, None, timeout).await?; match client .request(model::Request::Install("mem".into(), 999999999)) @@ -107,7 +107,7 @@ async fn npk_size_limit_violation() -> Result<()> { async fn notifications() -> Result<()> { let io = UnixStream::connect(&northstar_tests::runtime::console_none().path()).await?; assert!( - api::client::Client::new(io, Some(10), Duration::from_secs(10)) + northstar_client::Client::new(io, Some(10), Duration::from_secs(10)) .await .is_err() ); diff --git a/northstar-tests/tests/examples.rs b/northstar-tests/tests/examples.rs index 6f71c024a..0e9f1302f 100644 --- a/northstar-tests/tests/examples.rs +++ b/northstar-tests/tests/examples.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use northstar::api::model::{ExitStatus, Notification}; +use northstar_runtime::api::model::{ExitStatus, Notification}; use northstar_tests::{containers::*, logger::assume, runtime::client, runtime_test}; // Start crashing example diff --git a/northstar-tests/tests/npk.rs b/northstar-tests/tests/npk.rs index b737e93fa..b778121a8 100644 --- a/northstar-tests/tests/npk.rs +++ b/northstar-tests/tests/npk.rs @@ -1,4 +1,4 @@ -use northstar::npk::npk; +use northstar_runtime::npk::npk; use std::{ fs::{self, File}, io::Write, diff --git a/northstar-tests/tests/tests.rs b/northstar-tests/tests/tests.rs index a52abff89..88f620065 100644 --- a/northstar-tests/tests/tests.rs +++ b/northstar-tests/tests/tests.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use anyhow::Result; use log::debug; -use northstar::api::{ +use northstar_runtime::api::{ self, model::{self, ExitStatus, Notification}, }; @@ -48,10 +48,10 @@ async fn install_duplicate_other_repository() -> Result<()> { // Try to a container into a repository that does not exist #[runtime_test] async fn install_invalid_repository() -> Result<()> { - let client: &mut api::client::Client<_> = &mut *client(); + let client: &mut northstar_client::Client<_> = &mut *client(); let size = TEST_CONTAINER_NPK.len() as u64; match client.install(TEST_CONTAINER_NPK, size, "whooha").await { - Err(api::client::error::RequestError::Runtime(model::Error::InvalidRepository { + Err(northstar_client::error::RequestError::Runtime(model::Error::InvalidRepository { .. })) => Ok(()), e => panic!("Unexpected response: {:?}", e), diff --git a/northstar/Cargo.toml b/northstar/Cargo.toml index b798d20c7..baf9dc92c 100644 --- a/northstar/Cargo.toml +++ b/northstar/Cargo.toml @@ -1,148 +1,22 @@ [package] name = "northstar" -version = "0.7.1-dev" +version = "0.0.1-pre" authors = ["ESRLabs"] -build = "build.rs" -description = "Northstar is an container runtime for Linux targetting embedded systems" edition = "2021" license = "Apache-2.0" -readme = "../README.md" -repository = "https://github.com/esrlabs/northstar" -rust-version = "1.59.0" +default-run = "northstar" [dependencies] anyhow = "1.0.57" -async-stream = { version = "0.3.3", optional = true } -async-trait = { version = "0.1.53", optional = true } -base64 = { version = "0.13.0", optional = true } -bincode = { version = "1.3.3", optional = true } -byteorder = { version = "1.4.3", optional = true } -bytes = { version = "1.1.0", optional = true } -bytesize = { version = "1.1.0", optional = true } -caps = { version = "0.5.3", optional = true } -cgroups-rs = { git = "https://github.com/esrlabs/cgroups-rs.git", branch = "northstar", features = ["serde"], optional = true } -devicemapper = { version = "0.32.0", optional = true } -ed25519-dalek = { version = "1.0.1", optional = true } -futures = { version = "0.3.21", default-features = true, optional = true } -hex = { version = "0.4.3", optional = true } -hmac = { version = "0.12.1", features = ["reset"], optional = true } -humanize-rs = { version = "0.1.5", optional = true } -humantime = { version = "2.1.0", optional = true } -humantime-serde = { version = "1.1.1", optional = true } -inotify = { version = "0.10.0", features = ["stream"], optional = true } -itertools = { version = "0.10.3", optional = true } -lazy_static = { version = "1.4.0", optional = true } -log = { version = "0.4.17", features = [ "serde"] } -loopdev = { version = "0.4.0", optional = true } -memchr = "2.5.0" -memfd = { version = "0.5.1", optional = true } -memoffset = { version = "0.6.5", optional = true } -nanoid = { version = "0.4.0", optional = true } -nix = { version = "0.24.1", default-features = false, features = ["fs", "sched", "mount", "term", "uio", "socket", "net", "signal", "user"], optional = true } -rand_core = { version = "0.6.3", features = ["getrandom"], optional = true } -rlimit = { version = "0.8.3", optional = true } -schemars = { version = "0.8.10", features = ["preserve_order"] } -semver = { version = "1.0.9", features = ["serde"] } -serde = { version = "1.0.137", features = ["derive", "rc"] } -serde_json = { version = "1.0.81", optional = true } -serde_plain = { version = "1.0.0", optional = true } -serde_with = { version = "1.13.0", optional = true } -serde_yaml = { version = "0.8.24", optional = true } -sha2 = { version = "0.10.2", optional = true } -strum = { version = "0.24.0", optional = true } -strum_macros = { version = "0.24.0", optional = true } -tempfile = { version = "3.3.0", optional = true } -thiserror = "1.0.31" -tokio = { version = "1.18.1", features = ["fs", "io-std", "io-util", "macros", "process", "rt-multi-thread", "sync", "time", "net"], optional = true } -tokio-eventfd = { version = "0.2.0", optional = true } -tokio-util = { version = "0.7.2", features = ["codec", "io"], optional = true } -url = { version = "2.2.2", features = ["serde"], optional = true } -uuid = { version = "1.0.0", features = ["v4"], optional = true } -validator = { version = "0.15.0", features = ["derive"], optional = true } -zeroize = { version = "1.5.5", optional = true } -zip = { version = "0.6.2", default-features = false, optional = true } - -[features] -api = [ - "bytes", - "futures", - "npk", - "serde_json", - "tokio", - "tokio-util", -] -npk = [ - "base64", - "byteorder", - "ed25519-dalek", - "hex", - "humanize-rs", - "itertools", - "rand_core", - "sha2", - "seccomp", - "serde_json", - "serde_plain", - "serde_with", - "serde_yaml", - "strum", - "strum_macros", - "tempfile", - "uuid", - "validator", - "zeroize", - "zip" -] -runtime = [ - "anyhow", - "api", - "async-stream", - "async-trait", - "bincode", - "bytesize", - "caps", - "cgroups-rs", - "devicemapper", - "ed25519-dalek", - "futures", - "hex", - "hmac", - "humantime", - "humantime-serde", - "inotify", - "itertools", - "lazy_static", - "loopdev", - "memfd", - "memoffset", - "nanoid", - "nix", - "npk", - "rlimit", - "tempfile", - "tokio", - "tokio-eventfd", - "tokio-util", - "url", -] -seccomp = [ - "anyhow", - "bindgen", - "caps", - "lazy_static", - "memoffset", - "nix", - "npk", -] - -[dev-dependencies] -anyhow = "1.0.57" -proptest = "1.0.0" -serde_json = "1.0.81" +clap = { version = "3.1.18", features = ["derive"] } +log = "0.4.17" +nix = { version = "0.24.1", default-features = false, features = ["sched", "mount"] } +northstar-runtime = { path = "../northstar-runtime", features = ["runtime"] } +tokio = { version = "1.18.1", features = ["rt-multi-thread", "macros", "signal"] } toml = "0.5.9" -tokio = { version = "1.18.1", features = ["test-util"] } -tokio-test = "0.4.2" -[build-dependencies] -anyhow = { version = "1.0.57", optional = true } -bindgen = { version = "0.59.2", default-features = false, features = ["runtime"], optional = true } +[target.'cfg(not(target_os = "android"))'.dependencies] +env_logger = "0.9.0" + +[target.'cfg(target_os = "android")'.dependencies] +android-logd-logger = "0.3.1" diff --git a/main/src/logger.rs b/northstar/src/logger.rs similarity index 100% rename from main/src/logger.rs rename to northstar/src/logger.rs diff --git a/main/src/main.rs b/northstar/src/main.rs similarity index 96% rename from main/src/main.rs rename to northstar/src/main.rs index c90904c3e..c13fdb153 100644 --- a/main/src/main.rs +++ b/northstar/src/main.rs @@ -7,7 +7,7 @@ use anyhow::{anyhow, Context, Error}; use clap::Parser; use log::{debug, info, warn}; use nix::mount::MsFlags; -use northstar::{runtime, runtime::Runtime as Northstar}; +use northstar_runtime::{runtime, runtime::Runtime as Northstar}; use runtime::config::Config; use std::{ fs::{self, read_to_string}, @@ -18,8 +18,9 @@ use tokio::{select, signal::unix::SignalKind}; mod logger; +/// Northstar Runtime #[derive(Debug, Parser)] -#[clap(name = "northstar", about = "Northstar")] +#[clap(author, version, about, long_about = None)] struct Opt { /// File that contains the northstar configuration #[clap(short, long, default_value = "northstar.toml")]