Skip to content

Commit fd39fa7

Browse files
feat: build crystal from source, split out shards pkg (#7044) (#7133)
* Build Crystal from source, split out shards pkg Build Crystal and shards from source, building dynamically linked binaries. Separate the crystal and shards packages, they have different versions and update schedules. Remove architecture restrictions. Introduce a bootstrap problem, as Crystal is built using Crystal. * bootstrap compiler for crystal compiler * Use macros when possible in shards.spec (+ formatting) * formatting of crystal.spec * use correct path to bootstrap compiler * build require make for shards * no verbose autosetup for crystal * quiet prep/extractions * shards requires gcc * Revert "shards requires gcc" This reverts commit b455823. Should not be needed, as crystal requires gcc * Packager * explict buildreqs for shards should be inferred from the crystal package (cherry picked from commit 0b4f4a7) Co-authored-by: Carl Hörberg <carl.hoerberg@gmail.com>
1 parent 99b7ce7 commit fd39fa7

File tree

6 files changed

+88
-52
lines changed

6 files changed

+88
-52
lines changed

anda/langs/crystal/crystal/anda.hcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
project pkg {
2-
arches = ["x86_64"]
32
rpm {
43
spec = "crystal.spec"
54
}

anda/langs/crystal/crystal/crystal.spec

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,63 @@
1-
%define debug_package %nil
2-
3-
Name: crystal
4-
Version: 1.18.2
5-
Release: 1%?dist
6-
Summary: The Crystal Programming Language
7-
License: Apache-2.0
8-
URL: https://crystal-lang.org/
9-
Source0: https://github.com/crystal-lang/crystal/releases/download/%version/crystal-%version-1-linux-x86_64-bundled.tar.gz
10-
ExclusiveArch: x86_64
11-
BuildRequires: rpm_macro(fdupes)
1+
%bcond bootstrap 1
2+
%global bootstrap_version 1.17.1
123

13-
%description
14-
%summary.
15-
16-
%package devel
17-
Summary: Development files for the crystal package
4+
Name: crystal
5+
Version: 1.18.2
6+
Release: 2%?dist
7+
Summary: A general-purpose, object-oriented programming language
8+
License: Apache-2.0
9+
Packager: Carl Hörberg <carl@84codes.com>
10+
URL: https://crystal-lang.org/
11+
Source0: https://github.com/crystal-lang/crystal/archive/%version.tar.gz
12+
%if %{with bootstrap}
13+
Source1: https://dev.alpinelinux.org/archive/crystal/crystal-%{bootstrap_version}-%{_arch}-alpine-linux-musl.tar.gz
14+
%else
15+
BuildRequires: crystal
16+
%endif
17+
BuildRequires: gcc gcc-c++ make gc-devel llvm-devel
18+
BuildRequires: pcre2-devel libyaml-devel libffi-devel
19+
Requires: gcc pkgconfig gc-devel
20+
Requires: pcre2-devel openssl-devel zlib-devel
21+
Requires: libyaml-devel libxml2-devel gmp-devel
22+
Suggests: shards
1823

19-
%description devel
20-
%summary.
24+
%description
25+
Crystal is a programming language with the following goals:
26+
- Have a syntax similar to Ruby (but compatibility with it is not a goal)
27+
- Statically type-checked but without having to specify the type of variables or method arguments
28+
- Be able to call C code by writing bindings to it in Crystal
29+
- Have compile-time evaluation and generation of code, to avoid boilerplate code
30+
- Compile to efficient native code
2131

2232
%prep
23-
%autosetup -n crystal-%version-1
33+
%setup -q
34+
%if %{with bootstrap}
35+
%setup -q -b 1
36+
%endif
2437

2538
%build
39+
%if %{with bootstrap}
40+
# Use bootstrap crystal binary
41+
export PATH="%{_builddir}/crystal-%{bootstrap_version}-%{_arch}-alpine-linux-musl/bin:$PATH"
42+
%endif
43+
%make_build release=1 interpreter=1 LDFLAGS="%{build_ldflags}" CRYSTAL_CONFIG_LIBRARY_PATH=%{_libdir}/crystal
2644

2745
%install
28-
mkdir -p %buildroot/usr/bin
29-
mkdir -p %buildroot/usr/share
30-
mkdir -p %buildroot/usr/lib/crystal
31-
install -Dm755 bin/* %buildroot/usr/bin/
32-
cp -r share/* %buildroot/usr/share/
33-
cp -r lib/crystal/* %buildroot/usr/lib/crystal/
34-
35-
%fdupes %buildroot%_datadir/crystal/src/lib_c/
36-
46+
%make_install PREFIX=%{_prefix}
3747

3848
%files
39-
%license /usr/share/licenses/crystal/LICENSE
40-
/usr/bin/crystal
41-
/usr/share/zsh/site-functions/_crystal
42-
/usr/share/man/man1/crystal.1.gz
43-
/usr/share/crystal/
44-
/usr/share/fish/vendor_completions.d/crystal.fish
45-
/usr/share/bash-completion/completions/crystal
46-
47-
/usr/bin/shards
48-
/usr/share/man/man1/shards.1.gz
49-
/usr/share/man/man5/shard.yml.5.gz
50-
51-
%files devel
52-
/usr/lib/crystal/
49+
%license %{_datadir}/licenses/crystal/LICENSE
50+
%{_bindir}/crystal
51+
%{_datadir}/crystal
52+
%{_datadir}/zsh/site-functions/_crystal
53+
%{_datadir}/bash-completion/completions/crystal
54+
%{_datadir}/fish/vendor_completions.d/crystal.fish
55+
%{_mandir}/man1/crystal.1.gz
5356

5457
%changelog
58+
* Mon Nov 03 2025 Carl Hörberg <carl@84codes.com> - 1.18.2-2
59+
- Build from source, support multiple architectures.
60+
5561
* Sat Jun 17 2023 windowsboy111 <windowsboy111@fyralabs.com> - 1.8.2-2
5662
- Add devel package.
5763

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
let v = gh("crystal-lang/crystal");
2-
let url = `crystal-${v}-1-linux-x86_64-bundled.tar.gz`;
3-
4-
if get(`https://github.com/crystal-lang/crystal/releases/expanded_assets/${v}`).contains(url) {
5-
rpm.version(v);
6-
} else {
7-
print(`crystal: ${v} (waiting for bundle)`);
8-
terminate();
9-
}
1+
rpm.version(gh_tag("crystal-lang/crystal"));

anda/langs/crystal/shards/anda.hcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project pkg {
2+
rpm {
3+
spec = "shards.spec"
4+
}
5+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Name: shards
2+
Version: 0.19.1
3+
Release: 1%?dist
4+
Summary: Dependency manager for the Crystal language
5+
License: Apache-2.0
6+
Packager: Carl Hörberg <carl@84codes.com>
7+
URL: https://crystal-lang.org/
8+
Source0: https://github.com/crystal-lang/shards/archive/refs/tags/v%version.tar.gz
9+
BuildRequires: crystal make
10+
BuildRequires: gcc gc-devel libyaml-devel pcre-devel
11+
Suggests: git make
12+
Supplements: crystal
13+
14+
%description
15+
Shards is a dependency manager for the Crystal programming language. It allows you to easily manage and install external libraries (called "shards") that your Crystal projects depend on.
16+
17+
%prep
18+
%setup -q
19+
20+
%build
21+
%make_build release=1 FLAGS="--link-flags=\"%{build_ldflags}\""
22+
23+
%install
24+
%make_install PREFIX=%{_prefix}
25+
26+
%files
27+
%{_bindir}/shards
28+
%{_mandir}/man1/shards.1.gz
29+
%{_mandir}/man5/shard.yml.5.gz
30+
31+
%changelog
32+
* Mon Nov 03 2025 Carl Hörberg <carl@84codes.com> - 0.19.1-1
33+
- Initial package
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rpm.version(gh_tag("crystal-lang/shards"));

0 commit comments

Comments
 (0)