-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial snap build support * Add output dir to snapcraft * Add banner to detect missing packages * Update readme
- Loading branch information
Brian J. Cardiff
committed
Jun 17, 2019
1 parent
a9e28e7
commit 34f76b4
Showing
5 changed files
with
137 additions
and
0 deletions.
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 |