-
Notifications
You must be signed in to change notification settings - Fork 1k
Snappy: Add support for snapcraft builds #1898
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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 |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ | |
| /**/target | ||
| /home | ||
| /local-rustup | ||
| /snapcraft | ||
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
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,125 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -efu | ||
|
|
||
| set -o pipefail | ||
|
|
||
| # This script encapsulates the job of preparing snapcract configuration for the | ||
| # rustup snap. We construct either an edge snap (builds on PRs or master) | ||
| # or a beta snap if built from a non-master branch. | ||
|
|
||
| # If built on master, we should publish the edge snap | ||
| # If built on stable, we should publish the beta snap | ||
|
|
||
| # To parameterise the build, the following environment variables are needed: | ||
| # DO_SNAP=1 <-- without this, we don't run | ||
| # SNAP_EDGE=1 <-- with this, we build an edge/devel snap, otherwise a release snap | ||
| # SNAP_ARCH=... <-- without this we cannot build, this is the snap architecture we're building | ||
|
|
||
| if [ -z "${DO_SNAP:-}" ]; then | ||
| echo "SNAP: Not attempting to snap" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -z "${SNAP_ARCH:-}" ]; then | ||
| echo "SNAP: Unable to generate snap, architecture unset" | ||
| exit 1 | ||
| else | ||
| echo "SNAP: Constructing snap for architecture $SNAP_ARCH" | ||
| fi | ||
|
|
||
| if [ -n "${SNAP_EDGE:-}" ]; then | ||
| echo "SNAP: Generated snap will be an grade:devel snap" | ||
| GRADE=devel | ||
| else | ||
| echo "SNAP: Generated snap will be a grade:stable snap" | ||
| GRADE=stable | ||
| fi | ||
|
|
||
|
|
||
| # This is the list of proxies which the snap will contain. This needs to match | ||
| # the set of aliases which the snap has been allocated. If we add to this | ||
| # list but don't get the aliases added, then people won't see the proxy except | ||
| # as rustup.$PROXY. If we have an alias which is not a supported proxy name | ||
| # then rustup might get sad. | ||
|
|
||
| PROXIES="cargo cargo-clippy cargo-fmt cargo-miri clippy-driver rls rustc rustdoc rustfmt" | ||
|
|
||
| # From now on, things should be automagic | ||
|
|
||
| VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d\" -f2) | ||
|
|
||
| rm -rf snapcraft | ||
|
|
||
| mkdir -p snapcraft/snap | ||
|
|
||
| cd snapcraft | ||
|
|
||
| cat > snap/snapcraft.yaml <<SNAP | ||
| name: rustup | ||
| version: $VERSION | ||
| confinement: classic | ||
| base: core18 | ||
| architectures: | ||
| - build-on: [amd64] | ||
| run-on: [$SNAP_ARCH] | ||
| description: | | ||
| Rustup is the Rust Language's installer and primary front-end. You probably | ||
| want this if you want to develop anything written in Rust. | ||
| SNAP | ||
|
|
||
| if [ -n "${SNAP_EDGE:-1}" ]; then | ||
| cat >> snap/snapcraft.yaml <<SNAP | ||
|
|
||
| Please note, this snap is experimental and functionality cannot be guaranteed | ||
| to be consistent with released snaps. | ||
| summary: "EXPERIMENTAL: The Rust Language Installer" | ||
| grade: $GRADE | ||
| SNAP | ||
| else | ||
| cat >> snap/snapcraft.yaml <<SNAP | ||
| summary: "The Rust Language Installer" | ||
| grade: $GRADE | ||
| SNAP | ||
| fi | ||
|
|
||
| cat >> snap/snapcraft.yaml <<SNAP | ||
| parts: | ||
| rustup: | ||
| plugin: nil | ||
| build-attributes: [no-patchelf] | ||
| source: inputs | ||
| override-build: | | ||
| mkdir -p \$SNAPCRAFT_PART_INSTALL/bin | ||
| cp rustup-init \$SNAPCRAFT_PART_INSTALL/bin/rustup | ||
| SNAP | ||
|
|
||
| for PROXY in $PROXIES; do | ||
| cat >> snap/snapcraft.yaml <<SNAP | ||
| ln \$SNAPCRAFT_PART_INSTALL/bin/rustup \$SNAPCRAFT_PART_INSTALL/bin/$PROXY | ||
| SNAP | ||
| done | ||
|
|
||
| cat >> snap/snapcraft.yaml << 'SNAP' | ||
| prime: | ||
| - "-rustup-init" | ||
|
|
||
| environment: | ||
| RUSTUP_HOME: "$SNAP_USER_COMMON/rustup" | ||
|
|
||
| apps: | ||
| rustup: | ||
| command: bin/rustup | ||
| SNAP | ||
|
|
||
| for PROXY in $PROXIES; do | ||
| cat >> snap/snapcraft.yaml <<SNAP | ||
| $PROXY: | ||
| command: bin/$PROXY | ||
| SNAP | ||
| done | ||
|
|
||
| mkdir inputs | ||
| cp ../target/"$TARGET"/release/rustup-init inputs/ | ||
|
|
||
| ls -l snap/snapcraft.yaml |
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.