Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions slices/cargo-1.85.yaml
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:
10 changes: 10 additions & 0 deletions tests/spread/integration/cargo-1.85/task.yaml
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
56 changes: 56 additions & 0 deletions tests/spread/integration/cargo-1.85/test_eza.sh
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"
28 changes: 28 additions & 0 deletions tests/spread/integration/cargo-1.85/test_hello.sh
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!"
22 changes: 22 additions & 0 deletions tests/spread/integration/cargo-1.85/test_hello_crate.sh
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 tests/spread/integration/cargo-1.85/test_help_and_version.sh
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'
44 changes: 44 additions & 0 deletions tests/spread/integration/cargo-1.85/test_sudo.sh
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
members = [ "greeter", "hello" ]
resolver = "2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "greeter"
version = "0.1.0"
edition = "2021"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn greet() -> String {
"Hello, world!".to_string()
}
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" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use greeter::greet;
fn main() {
println!("{}", greet());
}
Loading