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 snap target #39
Merged
Add snap target #39
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 @@ | ||
OUTPUT_DIR = build | ||
|
||
.PHONY: all | ||
all: snap/snapcraft.yaml | ||
mkdir -p $(OUTPUT_DIR) | ||
snapcraft | ||
mv *.snap $(OUTPUT_DIR) | ||
|
||
.PHONY: snap/snapcraft.yaml | ||
snap/snapcraft.yaml: | ||
sed 's/$${CRYSTAL_RELEASE_LINUX64_TARGZ}/$(subst /,\/,$(CRYSTAL_RELEASE_LINUX64_TARGZ))/; s/$${SNAP_GRADE}/$(SNAP_GRADE)/' snap/local/snapcraft.yaml.tpl > snap/snapcraft.yaml | ||
|
||
clean: | ||
rm snap/snapcraft.yaml | ||
rm -Rf $(OUTPUT_DIR) |
This file contains 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,52 @@ | ||
# snap for Crystal | ||
|
||
https://snapcraft.io/crystal | ||
|
||
## Dependencies | ||
|
||
- [`snapcraft`](https://docs.snapcraft.io/snapcraft-overview) | ||
|
||
## Build the snap | ||
|
||
Define the configuration variables and use `make` to expand the `./snap/local/snapcraft.yaml.tpl`. | ||
|
||
```sh | ||
$ SNAP_GRADE=devel CRYSTAL_RELEASE_LINUX64_TARGZ="https://github.com/crystal-lang/crystal/releases/download/0.29.0/crystal-0.29.0-1-linux-x86_64.tar.gz" make | ||
``` | ||
|
||
## Snap channels usage | ||
|
||
| Build | Channel | Version | Comments | | ||
|-------------------|----------------------------|-----------|------------------------------------------------------| | ||
| tagged release | latest/edge | M.m.p | manual set to beta, candidate, stable upon release | | ||
| nighties release | latest/edge | M.m.p-dev | | | ||
| maintenance build | latest/edge/${branch-name} | M.m.p-dev | | | ||
|
||
### Configuration | ||
|
||
* `CRYSTAL_RELEASE_LINUX64_TARGZ`: Url to crystal-{version}-{package}-linux-x86_64.tar.gz | ||
* `SNAP_GRADE`: Snap grande usually `devel` for nightlies and `stable` for tagged releases | ||
|
||
## Install the snap | ||
|
||
1. [Have snapd installed](https://snapcraft.io/docs/core/install) | ||
|
||
2. | ||
``` | ||
$ sudo snap install crystal --classic | ||
``` | ||
|
||
## Post-Install | ||
|
||
This snap ships the compiler, all required native libraries should be available on the host. | ||
|
||
The following are the suggested packages to be able to use the whole standard library capabilities. | ||
|
||
``` | ||
$ sudo apt-get install gcc pkg-config git tzdata \ | ||
libpcre3-dev libevent-dev libyaml-dev \ | ||
libgmp-dev libssl-dev libxml2-dev | ||
``` | ||
|
||
You can find more detailed information in the [Crystal reference](https://crystal-lang.org/reference/installation/on_debian_and_ubuntu.html) and in the [Crystal wiki](https://github.com/crystal-lang/crystal/wiki/All-required-libraries) if you want to be able to build the compiler itself. | ||
|
This file contains 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 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -f $SNAP_USER_COMMON/env-check-success ]; then | ||
# check if a simple program can be compiled | ||
# if something fails show a banner to the user | ||
|
||
$SNAP/bin/crystal eval 'puts "1"' >/dev/null 2>/dev/null | ||
if [ $? -eq 0 ]; then | ||
touch $SNAP_USER_COMMON/env-check-success | ||
else | ||
cat <<EOF | ||
|
||
It seems that some libraries are missing in your host. | ||
The following are the suggested packages to be able to use the whole standard library capabilities. | ||
|
||
$ sudo apt-get install gcc pkg-config git tzdata \\ | ||
libpcre3-dev libevent-dev libyaml-dev \\ | ||
libgmp-dev libssl-dev libxml2-dev | ||
|
||
You can find more detailed information in: | ||
|
||
* https://crystal-lang.org/reference/installation/on_debian_and_ubuntu.html | ||
* https://github.com/crystal-lang/crystal/wiki/All-required-libraries | ||
|
||
EOF | ||
|
||
fi | ||
fi | ||
|
||
exec $SNAP/bin/crystal "$@" |
This file contains 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,36 @@ | ||
name: crystal | ||
base: core | ||
summary: A language for humans and computers | ||
description: | | ||
* Have a syntax similar to Ruby (but compatibility with it is not a goal) | ||
* Statically type-checked but without having to specify the type of variables or method arguments. | ||
* Be able to call C code by writing bindings to it in Crystal. | ||
* Have compile-time evaluation and generation of code, to avoid boilerplate code. Compile to efficient native code. | ||
adopt-info: crystal | ||
|
||
grade: ${SNAP_GRADE} | ||
confinement: classic | ||
|
||
environment: | ||
SHARDS_CACHE_PATH: $SNAP_USER_COMMON/.cache/shards | ||
CRYSTAL_CACHE_DIR: $SNAP_USER_COMMON/.cache/crystal | ||
|
||
apps: | ||
crystal: | ||
command: crystal-snap-wrapper | ||
shards: | ||
command: bin/shards | ||
|
||
parts: | ||
crystal: | ||
plugin: dump | ||
source: ${CRYSTAL_RELEASE_LINUX64_TARGZ} | ||
override-pull: | | ||
snapcraftctl pull | ||
snapcraftctl set-version "$(cat $SNAPCRAFT_PART_SRC/share/crystal/src/VERSION | head -n 1)" | ||
|
||
snap-wrapper: | ||
plugin: dump | ||
source: . | ||
stage: | ||
- crystal-snap-wrapper |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the general wrapper which you use to run crystal in snap? Compiling even a little program would delay the actual compiler boot time and make it appear to be slow.
Can't there be a different solution to this? Maybe use the actual error code from the invoked crystal command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be another way to do it but
exec
is used to run the compiler and I don't think something can be done after that.Using
exec
to delegate is better so the wrapper is more transparent.As soon as the env is verified once the check will no longer run so is a one time delay.
Unfortunately, there is no support for post-installation messages on snap for now. I would have preferred to do it that way.