Skip to content

Commit c6ca8ec

Browse files
committed
Upgrade from core(16) to core22 + arm64 target + upload
1 parent d1d8657 commit c6ca8ec

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ docs/build/
88

99
darwin/build/
1010

11-
snapcraft/snap/snapcraft.yaml
11+
snapcraft/snapcraft.yaml
1212
snapcraft/*.snap
1313
snapcraft/build/

snapcraft/Makefile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
OUTPUT_DIR = build
1+
CRYSTAL_TARBALL =
2+
ARCH =
3+
GRADE =
4+
CHANNEL =
25

36
.PHONY: all
4-
all: snap/snapcraft.yaml
5-
mkdir -p $(OUTPUT_DIR)
6-
snapcraft
7-
mv *.snap $(OUTPUT_DIR)
7+
all: snapcraft.yaml
8+
snapcraft pack --build-for=$(ARCH)
89

9-
.PHONY: snap/snapcraft.yaml
10-
snap/snapcraft.yaml:
11-
sed 's/$${CRYSTAL_RELEASE_LINUX64_TARGZ}/$(subst /,\/,$(CRYSTAL_RELEASE_LINUX64_TARGZ))/; s/$${SNAP_GRADE}/$(SNAP_GRADE)/' snap/local/snapcraft.yaml.tpl > $@
10+
.PHONY: snapcraft.yaml
11+
snapcraft.yaml:
12+
sed 's/$${CRYSTAL_TARBALL}/$(subst /,\/,$(CRYSTAL_TARBALL))/; s/$${SNAP_GRADE}/$(GRADE)/' local/snapcraft.yaml.tpl > $@
13+
14+
.PHONY: push
15+
push:
16+
for SNAPFILE in *.snap; do\
17+
sudo -E snapcraft upload --quiet --release=$(CHANNEL) $$SNAPFILE;\
18+
done
1219

1320
clean:
14-
rm snap/snapcraft.yaml
15-
rm -Rf $(OUTPUT_DIR)
21+
snapcraft clean
22+
rm -f snapcraft.yaml *.snap

snapcraft/README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# snap for Crystal
22

3-
https://snapcraft.io/crystal
3+
<https://snapcraft.io/crystal>
44

55
## Dependencies
66

77
- [`snapcraft`](https://docs.snapcraft.io/snapcraft-overview)
88

9-
## Build the snap
9+
For example on Ubuntu:
1010

11-
Define the configuration variables and use `make` to expand the `./snap/local/snapcraft.yaml.tpl`.
11+
```console
12+
$ sudo apt-get install snapd
13+
$ snap install snapcraft --classic
14+
```
15+
16+
## Build
1217

13-
```sh
14-
$ 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
18+
Define the configuration variables and use `make` to expand the `./local/snapcraft.yaml.tpl`.
19+
20+
```console
21+
$ export SNAPCRAFT_BUILD_ENVIRONMENT=host
22+
$ make GRADE=devel ARCH=amd64 CRYSTAL_TARBALL=../linux/build/crystal-$(CRYSTAL_VERSION)-1-linux-x86_64.tar.gz
23+
$ make GRADE=devel ARCH=arm64 CRYSTAL_TARBALL=../linux/build/crystal-$(CRYSTAL_VERSION)-1-linux-aarch64.tar.gz
1524
```
1625

17-
## Snap channels usage
26+
## Channels
1827

1928
| Build | Channel | Version | Comments |
2029
|-------------------|----------------------------|-----------|------------------------------------------------------|
@@ -24,15 +33,16 @@ $ SNAP_GRADE=devel CRYSTAL_RELEASE_LINUX64_TARGZ="https://github.com/crystal-lan
2433

2534
### Configuration
2635

27-
* `CRYSTAL_RELEASE_LINUX64_TARGZ`: Url to crystal-{version}-{package}-linux-x86_64.tar.gz
28-
* `SNAP_GRADE`: Snap grande usually `devel` for nightlies and `stable` for tagged releases
36+
* `CRYSTAL_TARBALL`: path to `crystal-{version}-{package}-linux-{arch}.tar.gz`
37+
* `ARCH`: the architecture to build (`amd64` or `arm64`)
38+
* `GRADE`: Snap grade (`devel` for nightlies, `stable` for tagged releases)
2939

3040
## Install the snap
3141

3242
1. [Have snapd installed](https://snapcraft.io/docs/core/install)
3343

3444
2.
35-
```
45+
```console
3646
$ sudo snap install crystal --classic
3747
```
3848

snapcraft/snap/local/snapcraft.yaml.tpl renamed to snapcraft/local/snapcraft.yaml.tpl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: crystal
2-
base: core
2+
base: core22
33
summary: A language for humans and computers
44
description: |
55
* Have a syntax similar to Ruby (but compatibility with it is not a goal)
@@ -8,6 +8,12 @@ description: |
88
* Have compile-time evaluation and generation of code, to avoid boilerplate code. Compile to efficient native code.
99
adopt-info: crystal
1010

11+
architectures:
12+
- build-on: [amd64]
13+
build-for: [amd64]
14+
- build-on: [amd64, arm64]
15+
build-for: [arm64]
16+
1117
grade: ${SNAP_GRADE}
1218
confinement: classic
1319

@@ -24,10 +30,10 @@ apps:
2430
parts:
2531
crystal:
2632
plugin: dump
27-
source: ${CRYSTAL_RELEASE_LINUX64_TARGZ}
33+
source: ${CRYSTAL_TARBALL}
2834
override-pull: |
29-
snapcraftctl pull
30-
snapcraftctl set-version "$(cat $SNAPCRAFT_PART_SRC/share/crystal/src/VERSION | head -n 1)"
35+
craftctl default
36+
craftctl set version="$(cat $CRAFT_PART_SRC/share/crystal/src/VERSION | head -n 1)"
3137

3238
snap-wrapper:
3339
plugin: dump

0 commit comments

Comments
 (0)