Skip to content

Commit 2477cbd

Browse files
authored
Merge pull request #537 from cbgbt/compress-twoliter-tools
twoliter: compress included tool archives
2 parents 7b6731d + 48ed3b5 commit 2477cbd

File tree

33 files changed

+686
-93
lines changed

33 files changed

+686
-93
lines changed

Cargo.lock

Lines changed: 128 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[workspace]
22
resolver = "2"
33

4+
default-members = ["twoliter"]
45
members = [
56
"tools/amispec",
67
"tools/bottlerocket-variant",
78
"tools/buildsys",
89
"tools/buildsys-config",
10+
"tools/include-env-compressed",
11+
"tools/include-env-compressed/include-env-compressed-macro",
912
"tools/oci-cli-wrapper",
1013
"tools/parse-datetime",
1114
"tools/pipesys",
@@ -18,7 +21,9 @@ members = [
1821
"tools/testsys-config",
1922
"tools/unplug",
2023
"tools/update-metadata",
24+
2125
"twoliter",
26+
"twoliter/src/tool-crates/*",
2227

2328
"tests/integration-tests",
2429
]
@@ -37,6 +42,7 @@ ci = ["github"]
3742
installers = []
3843
# Target platforms to build apps for (Rust target-triple syntax)
3944
targets = ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl"]
45+
features = ["pubsys", "testsys"]
4046

4147
[workspace.metadata.cross.build]
4248
pre-build = [
@@ -54,6 +60,8 @@ bottlerocket-types = { version = "0.0.16", git = "https://github.com/bottlerocke
5460
bottlerocket-variant = { version = "0.1", path = "tools/bottlerocket-variant" }
5561
buildsys = { version = "0.1", path = "tools/buildsys", lib = true, artifact = [ "bin:buildsys" ] }
5662
buildsys-config = { version = "0.1", path = "tools/buildsys-config" }
63+
include-env-compressed = { version = "0.1", path = "tools/include-env-compressed" }
64+
include-env-compressed-macro = { version = "0.1", path = "tools/include-env-compressed/include-env-compressed-macro" }
5765
krane-bundle = { version = "0.1", path = "tools/krane" }
5866
oci-cli-wrapper = { version = "0.1", path = "tools/oci-cli-wrapper" }
5967
parse-datetime = { version = "0.1", path = "tools/parse-datetime" }
@@ -67,7 +75,17 @@ serde-templated-derive = { version = "0.1", path = "tools/serde-templated-derive
6775
testsys = { version = "0.1", path = "tools/testsys", artifact = [ "bin:testsys" ] }
6876
testsys-config = { version = "0.1", path = "tools/testsys-config" }
6977
testsys-model = { version = "0.0.16", git = "https://github.com/bottlerocket-os/bottlerocket-test-system", tag = "v0.0.16" }
78+
7079
twoliter = { version = "0.10.1", path = "twoliter", artifact = [ "bin:twoliter" ] }
80+
twoliter-tool-buildsys = { version = "0.1", path = "twoliter/src/tool-crates/buildsys" }
81+
twoliter-tool-embedded-bundle = { version = "0.1", path = "twoliter/src/tool-crates/embedded-bundle" }
82+
twoliter-tool-pipesys = { version = "0.1", path = "twoliter/src/tool-crates/pipesys" }
83+
twoliter-tool-pubsys = { version = "0.1", path = "twoliter/src/tool-crates/pubsys" }
84+
twoliter-tool-pubsys-setup = { version = "0.1", path = "twoliter/src/tool-crates/pubsys-setup" }
85+
twoliter-tool-testsys = { version = "0.1", path = "twoliter/src/tool-crates/testsys" }
86+
twoliter-tool-tuftool = { version = "0.1", path = "twoliter/src/tool-crates/tuftool" }
87+
twoliter-tool-unplug = { version = "0.1", path = "twoliter/src/tool-crates/unplug" }
88+
7189
unplug = { version = "0.1", path = "tools/unplug", artifact = [ "bin:unplug" ] }
7290
update-metadata = { version = "0.1", path = "tools/update-metadata" }
7391

@@ -156,6 +174,7 @@ url = "2"
156174
uuid = "1"
157175
walkdir = "2"
158176
which = "6"
177+
zstd = "0.13"
159178

160179
# The profile that 'cargo dist' will build with
161180
[profile.dist]

clarify.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,24 @@ license-files = [
7474
{ path = "LICENSE-MIT", hash = 0xb9f15462 },
7575
{ path = "LICENSE", hash = 0xa4618a29 },
7676
]
77+
78+
[clarify.zstd-safe]
79+
expression = "MIT OR Apache-2.0"
80+
license-files = [
81+
{ path = "LICENSE.Apache-2.0", hash = 0x7b466be4 },
82+
{ path = "LICENSE.Mit", hash = 0xa237d234 },
83+
{ path = "LICENSE", hash = 0x742401ae },
84+
]
85+
86+
[clarify.zstd-sys]
87+
# The zstd-sys rust crate is MIT OR Apache-2.0
88+
# zstd itself is BSD-3-Clause or GPL-2.0 (we choose BSD-3-Clause)
89+
expression = "(MIT OR Apache-2.0) AND BSD-3-Clause"
90+
license-files = [
91+
{ path = "LICENSE", hash = 0x742401ae },
92+
{ path = "LICENSE.Apache-2.0", hash = 0x7b466be4 },
93+
{ path = "LICENSE.BSD-3-Clause", hash = 0xc9f5c4f6 },
94+
{ path = "LICENSE.Mit", hash = 0xa237d234 },
95+
{ path = "zstd/COPYING", hash = 0x96841aa4 },
96+
{ path = "zstd/LICENSE", hash = 0x3bfe1fb1 },
97+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "include-env-compressed"
3+
version = "0.1.0"
4+
authors = ["Sean P. Kelly <[email protected]>"]
5+
license = "Apache-2.0 OR MIT"
6+
edition = "2024"
7+
8+
[dependencies]
9+
include-env-compressed-macro.workspace = true
10+
zstd.workspace = true
11+
12+
[lints]
13+
workspace = true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## `include-env-compressed`
2+
3+
Like `include-bytes!`, but adds `zstd` compression for release builds.
4+
5+
This macro is intended to be used alongside [cargo artifact-dependencies].
6+
As such, the input must be an environment variable which is set at compile time to a path to the
7+
target asset.
8+
9+
Use the macro like so:
10+
11+
```rust
12+
use include_env_compressed: {Archive, include_archive_from_env};
13+
14+
const MY_ARCHIVE: Archive = include_archive_from_env!("ENV_VAR");
15+
16+
// Returns a `Box<dyn std::io::Read + Send + Sync + 'static>`
17+
let reader = MY_ARCHIVE.reader();
18+
```
19+
20+
You may optionally specify a zstd compression level as the second argument.
21+
22+
```rust
23+
const VERY_COMPRESSED_ARCHIVE: Archive = include_archive_from_env!("ENV_VAR", 22);
24+
```
25+
26+
Uses zstd's default compression level if no level is provided.
27+
28+
Note: Due to limitations, does not compose with the `env!()` macro in the same way that
29+
`include_bytes!` does.
30+
31+
[cargo artifact-dependencies]: https://doc.rust-lang.org/beta/cargo/reference/unstable.html#artifact-dependencies
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::path::PathBuf;
2+
3+
fn main() {
4+
// Set an environment variable to be used during integration tests
5+
let manifest = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("build.rs");
6+
println!("cargo:rustc-env=MY_BUILD_SCRIPT={}", manifest.display())
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "include-env-compressed-macro"
3+
version = "0.1.0"
4+
authors = ["Sean P. Kelly <[email protected]>"]
5+
license = "Apache-2.0 OR MIT"
6+
edition = "2024"
7+
8+
[lib]
9+
proc-macro = true
10+
11+
[dependencies]
12+
proc-macro2.workspace = true
13+
quote.workspace = true
14+
snafu.workspace = true
15+
syn = { workspace = true, features = ["full"] }
16+
zstd.workspace = true
17+
18+
[lints]
19+
workspace = true

0 commit comments

Comments
 (0)