-
Notifications
You must be signed in to change notification settings - Fork 71
feat(24.04): cargo-1.85 slices #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lczyk
wants to merge
6
commits into
canonical:ubuntu-24.04
Choose a base branch
from
lczyk:ROCKS-2271/cargo-1.85-24.04
base: ubuntu-24.04
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9b2aa5
feat: cargo 1.85
lczyk 5069ded
Squashed commit of the following:
lczyk 81e8712
feat: hello
lczyk cf1278f
feat: eza workaround
lczyk 1c1b56a
Merge branch 'ubuntu-24.04' into ROCKS-2271/cargo-1.85-24.04
lczyk 65e92ec
feat: remove note on cc symlink
lczyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package: cargo-1.85 | ||
|
|
||
| essential: | ||
| - cargo-1.85_copyright | ||
|
|
||
| slices: | ||
| # NOTE: Cargo will call rust through `rustc`, so you will need to create a | ||
| # symlink pointing to the correct version of rust: | ||
| # ln -s rustc-1.85 /usr/bin/rustc | ||
| cargo: | ||
| essential: | ||
| - libc6_libs | ||
| - libcurl3t64-gnutls_libs | ||
| - libgcc-s1_libs | ||
| - libsqlite3-0_libs | ||
| - libssh2-1t64_libs | ||
| - libssl3t64_libs | ||
| - rustc-1.85_rustc | ||
| - zlib1g_libs | ||
| contents: | ||
| # in the deb this is a bash script that sets RUSTC | ||
| # and execs the real binary | ||
| # but here we don't want needless dependency on bash | ||
| /usr/bin/cargo-1.85: | ||
| symlink: ../lib/rust-1.85/bin/cargo | ||
| /usr/lib/rust-1.85/bin/cargo: | ||
|
|
||
| copyright: | ||
| contents: | ||
| /usr/share/doc/cargo-1.85/copyright: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| summary: Integration tests for cargo-1.85 | ||
|
|
||
| variants: | ||
| - eza | ||
| - hello_crate | ||
| - hello | ||
| - help_and_version | ||
| - sudo | ||
|
|
||
| execute: bash -ex ./test_${SPREAD_VARIANT}.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| # spellchecker: ignore rootfs binutils archiver resolv | ||
|
|
||
| arch=$(uname -m) | ||
| case "${arch}" in | ||
| aarch64) chisel_arch="arm64" ;; | ||
| x86_64) chisel_arch="amd64" ;; | ||
| *) echo "Unsupported architecture: ${arch}"; exit 1 ;; | ||
| esac | ||
|
|
||
| slices=( | ||
| cargo-1.85_cargo | ||
| binutils_archiver # the zlib dependency requires ar | ||
| ca-certificates_data # for HTTPS access to crates.io | ||
| ) | ||
|
|
||
| rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" | ||
| ln -s rustc-1.85 "$rootfs/usr/bin/rustc" | ||
|
|
||
| # Create minimal /dev/null | ||
| mkdir -p "$rootfs/dev" && touch "$rootfs/dev/null" && chmod +x "$rootfs/dev/null" | ||
|
|
||
| # We need DNS to fetch crates.io dependencies | ||
| mkdir -p "$rootfs/etc" && cp /etc/resolv.conf "$rootfs/etc/resolv.conf" | ||
|
|
||
| # Enable apt source downloads | ||
| # NOTE: we need dpkg-dev to unpack the source | ||
| sed -i 's|^Types:.*|Types: deb deb-src|' /etc/apt/sources.list.d/ubuntu.sources | ||
| apt update && apt install -y dpkg-dev | ||
|
|
||
| # Download source | ||
| ( | ||
| cd "$rootfs" || exit 1 | ||
| apt source rust-eza -y | ||
| mv rust-eza-* rust-eza | ||
| ) | ||
|
|
||
| # error[E0282]: type annotations needed for `Box<_>` | ||
| # --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.30/src/format_description/parse/mod.rs:83:9 | ||
| # | | ||
| # 83 | let items = format_items | ||
| # | ^^^^^ | ||
| # ... | ||
| # 86 | Ok(items.into()) | ||
| # | ---- type must be known at this point | ||
| # | | ||
| # = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update` | ||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-eza update -p time --precise 0.3.35 | ||
|
|
||
| # Build | ||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-eza build | ||
|
|
||
| # Verify the built binary works | ||
| chroot "$rootfs" /rust-eza/target/debug/eza --help | grep -q "eza \[options\] \[files...\]" | ||
| touch "$rootfs/tmp/testfile" | ||
| chroot "$rootfs" /rust-eza/target/debug/eza /tmp | grep -q "testfile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/usr/bin/env bash | ||
| # spellchecker: ignore rootfs rustc | ||
|
|
||
| arch=$(uname -m) | ||
| case "${arch}" in | ||
| aarch64) chisel_arch="arm64" ;; | ||
| x86_64) chisel_arch="amd64" ;; | ||
| *) echo "Unsupported architecture: ${arch}"; exit 1 ;; | ||
| esac | ||
|
|
||
| rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" | ||
| ln -s rustc-1.85 "$rootfs/usr/bin/rustc" | ||
|
|
||
| # Create minimal /dev/null | ||
| mkdir -p "$rootfs/dev" | ||
| touch "$rootfs/dev/null" | ||
| chmod +x "$rootfs/dev/null" | ||
|
|
||
| # Use cargo to create, build and run a simple "Hello, world!" program | ||
| # (cargo new already creates a hello world program by default) | ||
| chroot "$rootfs" cargo-1.85 new hello --bin | ||
|
|
||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C hello build | ||
| chroot "$rootfs" ./hello/target/debug/hello | grep -q "Hello, world!" | ||
|
|
||
| # Now in release mode | ||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C hello build --release | ||
| chroot "$rootfs" ./hello/target/release/hello | grep -q "Hello, world!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env bash | ||
| # spellchecker: ignore rootfs rustc | ||
|
|
||
| arch=$(uname -m) | ||
| case "${arch}" in | ||
| aarch64) chisel_arch="arm64" ;; | ||
| x86_64) chisel_arch="amd64" ;; | ||
| *) echo "Unsupported architecture: ${arch}"; exit 1 ;; | ||
| esac | ||
|
|
||
| rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" | ||
| ln -s rustc-1.85 "$rootfs/usr/bin/rustc" | ||
|
|
||
| # Create minimal /dev/null | ||
| mkdir -p "$rootfs/dev" | ||
| touch "$rootfs/dev/null" | ||
| chmod +x "$rootfs/dev/null" | ||
|
|
||
| cp -r testfiles/hello_crate "$rootfs" | ||
|
|
||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C /hello_crate build --workspace | ||
| chroot "$rootfs" ./hello_crate/target/debug/hello | grep -q "Hello, world!" |
15 changes: 15 additions & 0 deletions
15
tests/spread/integration/cargo-1.85/test_help_and_version.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
| # spellchecker: ignore rootfs | ||
|
|
||
| arch=$(uname -m) | ||
| case "${arch}" in | ||
| aarch64) chisel_arch="arm64" ;; | ||
| x86_64) chisel_arch="amd64" ;; | ||
| *) echo "Unsupported architecture: ${arch}"; exit 1 ;; | ||
| esac | ||
|
|
||
| rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" | ||
| # ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # not needed for help/version | ||
|
|
||
| chroot "$rootfs" cargo-1.85 --help | grep -q "Rust's package manager" | ||
| chroot "$rootfs" cargo-1.85 --version | grep -q 'cargo 1.85' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env bash | ||
| # spellchecker: ignore rootfs binutils archiver resolv libpam0g | ||
|
|
||
| arch=$(uname -m) | ||
| case "${arch}" in | ||
| aarch64) chisel_arch="arm64" ;; | ||
| x86_64) chisel_arch="amd64" ;; | ||
| *) echo "Unsupported architecture: ${arch}"; exit 1 ;; | ||
| esac | ||
|
|
||
| slices=( | ||
| cargo-1.85_cargo | ||
| binutils_archiver # the zlib dependency requires ar | ||
| ca-certificates_data # for HTTPS access to crates.io | ||
| libpam0g-dev_libs # sudo-rs dependency | ||
| ) | ||
|
|
||
| rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" | ||
| ln -s rustc-1.85 "$rootfs/usr/bin/rustc" | ||
|
|
||
| # Create minimal /dev/null | ||
| mkdir -p "$rootfs/dev" && touch "$rootfs/dev/null" && chmod +x "$rootfs/dev/null" | ||
|
|
||
| # We need DNS to fetch crates.io dependencies | ||
| mkdir -p "$rootfs/etc" && cp /etc/resolv.conf "$rootfs/etc/resolv.conf" | ||
|
|
||
| # Enable apt source downloads | ||
| # NOTE: we need dpkg-dev to unpack the source | ||
| sed -i 's|^Types:.*|Types: deb deb-src|' /etc/apt/sources.list.d/ubuntu.sources | ||
| apt update && apt install -y dpkg-dev | ||
|
|
||
| # Download source | ||
| ( | ||
| cd "$rootfs" || exit 1 | ||
| apt source rust-sudo-rs -y | ||
| mv rust-sudo-rs-* rust-sudo-rs | ||
| ) | ||
|
|
||
| # Build | ||
| chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-sudo-rs build | ||
|
|
||
| # Verify the built binary works | ||
| (chroot "$rootfs" /rust-sudo-rs/target/debug/sudo --help 2>&1 || true) \ | ||
| | grep -q "sudo - run commands as another user" |
3 changes: 3 additions & 0 deletions
3
tests/spread/integration/cargo-1.85/testfiles/hello_crate/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [workspace] | ||
| members = [ "greeter", "hello" ] | ||
| resolver = "2" |
4 changes: 4 additions & 0 deletions
4
tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [package] | ||
| name = "greeter" | ||
| version = "0.1.0" | ||
| edition = "2021" |
3 changes: 3 additions & 0 deletions
3
tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/src/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pub fn greet() -> String { | ||
| "Hello, world!".to_string() | ||
| } |
6 changes: 6 additions & 0 deletions
6
tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "hello" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| [dependencies] | ||
| greeter = { path = "../greeter" } |
4 changes: 4 additions & 0 deletions
4
tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/src/main.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| use greeter::greet; | ||
| fn main() { | ||
| println!("{}", greet()); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.