Skip to content
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

Add support for Jammy tiny & static stacks #136

Merged
merged 3 commits into from
Apr 26, 2023
Merged
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ The buildpack will do the following:
* If `rust-toolchain` or `rust-toolchain.toml` exists, `rustup` will install as configured in the file. If `$BP_RUST_TOOLCHAIN` / `$BP_RUST_PROFILE` are also set to non-default values, they will also be installed.
* If `rust-toolchain` or `rust-toolchain.toml` do not exist, `rustup` will install `$BP_RUST_TOOLCHAIN` / `$BP_RUST_PROFILE`.
* If `$BP_RUST_TARGET` is set, executes `rustup target add` to install an additional Rust target.
* If `$BP_RUST_TARGET` is not set and the build is running on the Paketo Tiny stack, then the Rust Linux musl target will be automatically added.
* If `$BP_RUST_TARGET` is not set and the build is running on the Paketo Tiny or Static stacks, then the Rust Linux musl target will be automatically added.

## Configuration

| Environment Variable | Description |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$BP_RUSTUP_ENABLED` | Configure rustup to be enabled. This means that rustup will be used to install Rust. Default value is `true`. Set to false to use another Rust toolchain provider like [rust-dist](https://github.com/paketo-community/rust-dist). |
| `$BP_RUST_TOOLCHAIN` | Rust toolchain to install. Default `stable`. Other common values: `beta`, `nightly` or a specific versin number. Any [acceptable value for a toolchain](https://dev-doc.rust-lang.org/beta/edition-guide/rust-2018/rustup-for-managing-rust-versions.html) can be used here. |
| `$BP_RUST_PROFILE` | Rust profile to install. Default `minimum`. Other acceptable values: `default`, `complete`. See [Rustup docs for profile](https://rust-lang.github.io/rustup/concepts/profiles.html). |
| `$BP_RUST_TARGET` | Additional Rust target to install. Default ``, so nothing additional is installed. If there is no user-specified target and the build is running on the Paketo Tiny stack, then the Linux musl target is automatically added. Run `rustup target list` to see what valid targets exist. |
| `$BP_RUSTUP_INIT_VERSION` | Configure the version of rustup-init to install. It can be a specific version or a wildcard like `1.*`. It defaults to the latest `1.*` version. |
| `$BP_RUSTUP_INIT_LIBC` | Configure the libc implementation used by the installed toolchain. Available options: `gnu` or `musl`. Defaults to `gnu` for compatiblity. You do not need to set this option with the Paketo full/base/tiny stacks. It can be used for compatibility with more exotic or custom stacks. |
| Environment Variable | Description |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
dmikusa marked this conversation as resolved.
Show resolved Hide resolved
| `$BP_RUSTUP_ENABLED` | Configure rustup to be enabled. This means that rustup will be used to install Rust. Default value is `true`. Set to false to use another Rust toolchain provider like [rust-dist](https://github.com/paketo-community/rust-dist). |
| `$BP_RUST_TOOLCHAIN` | Rust toolchain to install. Default `stable`. Other common values: `beta`, `nightly` or a specific versin number. Any [acceptable value for a toolchain](https://dev-doc.rust-lang.org/beta/edition-guide/rust-2018/rustup-for-managing-rust-versions.html) can be used here. |
| `$BP_RUST_PROFILE` | Rust profile to install. Default `minimum`. Other acceptable values: `default`, `complete`. See [Rustup docs for profile](https://rust-lang.github.io/rustup/concepts/profiles.html). |
| `$BP_RUST_TARGET` | Additional Rust target to install. Default ``, so nothing additional is installed. If there is no user-specified target and the build is running on the Paketo Tiny or Static stack, then the Linux musl target is automatically added. Run `rustup target list` to see what valid targets exist. |
| `$BP_RUSTUP_INIT_VERSION` | Configure the version of rustup-init to install. It can be a specific version or a wildcard like `1.*`. It defaults to the latest `1.*` version. |
| `$BP_RUSTUP_INIT_LIBC` | Configure the libc implementation used by the installed toolchain. Available options: `gnu` or `musl`. Defaults to `gnu` for compatiblity. You do not need to set this option with the Paketo full/base/tiny/static stacks. It can be used for compatibility with more exotic or custom stacks. |

## License

Expand Down
6 changes: 0 additions & 6 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,5 @@ api = "0.7"
type = "MIT"
uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-MIT"

[[stacks]]
id = "io.buildpacks.stacks.bionic"

[[stacks]]
id = "io.paketo.stacks.tiny"

[[stacks]]
id = "*"
2 changes: 1 addition & 1 deletion rustup/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func AdditionalTarget(cr libpak.ConfigurationResolver, stack string) string {
}

libc := "gnu"
if stack == libpak.TinyStackID {
if libpak.IsTinyStack(stack) || libpak.IsStaticStack(stack) {
dmikusa marked this conversation as resolved.
Show resolved Hide resolved
libc = "musl"
}

Expand Down
17 changes: 15 additions & 2 deletions rustup/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,25 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
ctx.Buildpack.Metadata = map[string]interface{}{
"configurations": []map[string]interface{}{},
}
ctx.StackID = libpak.TinyStackID
ctx.StackID = libpak.BionicTinyStackID

cr, err := libpak.NewConfigurationResolver(ctx.Buildpack, nil)
Expect(err).ToNot(HaveOccurred())

target := rustup.AdditionalTarget(cr, libpak.TinyStackID)
target := rustup.AdditionalTarget(cr, libpak.BionicTinyStackID)
Expect(target).To(HaveSuffix("-unknown-linux-musl"))
})

it("picks musl for static stack", func() {
ctx.Buildpack.Metadata = map[string]interface{}{
"configurations": []map[string]interface{}{},
}
ctx.StackID = libpak.JammyStaticStackID

cr, err := libpak.NewConfigurationResolver(ctx.Buildpack, nil)
Expect(err).ToNot(HaveOccurred())

target := rustup.AdditionalTarget(cr, libpak.JammyStaticStackID)
Expect(target).To(HaveSuffix("-unknown-linux-musl"))
})
})
Expand Down