From 723057186feea480714f9be08d335b6e179719ef Mon Sep 17 00:00:00 2001 From: Raboneko <119771935+raboneko@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:14:34 -0800 Subject: [PATCH] feat: build crystal from source, split out shards pkg (#7044) (#7136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 b4558238b35d96f6b6899f2d376ccabcc8aeb62a. Should not be needed, as crystal requires gcc * Packager * explict buildreqs for shards should be inferred from the crystal package (cherry picked from commit 0b4f4a79dae370fea25cd42a54d68e58daec4a94) Co-authored-by: Carl Hörberg --- anda/langs/crystal/crystal/anda.hcl | 1 - anda/langs/crystal/crystal/crystal.spec | 88 +++++++++++++------------ anda/langs/crystal/crystal/update.rhai | 10 +-- anda/langs/crystal/shards/anda.hcl | 5 ++ anda/langs/crystal/shards/shards.spec | 33 ++++++++++ anda/langs/crystal/shards/update.rhai | 1 + 6 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 anda/langs/crystal/shards/anda.hcl create mode 100644 anda/langs/crystal/shards/shards.spec create mode 100644 anda/langs/crystal/shards/update.rhai diff --git a/anda/langs/crystal/crystal/anda.hcl b/anda/langs/crystal/crystal/anda.hcl index d2a5a14455..1ce7a085d6 100644 --- a/anda/langs/crystal/crystal/anda.hcl +++ b/anda/langs/crystal/crystal/anda.hcl @@ -1,5 +1,4 @@ project pkg { - arches = ["x86_64"] rpm { spec = "crystal.spec" } diff --git a/anda/langs/crystal/crystal/crystal.spec b/anda/langs/crystal/crystal/crystal.spec index da28a9d34f..f6f567b49b 100644 --- a/anda/langs/crystal/crystal/crystal.spec +++ b/anda/langs/crystal/crystal/crystal.spec @@ -1,57 +1,63 @@ -%define debug_package %nil +%bcond bootstrap 1 +%global bootstrap_version 1.17.1 -Name: crystal -Version: 1.18.2 -Release: 1%?dist -Summary: The Crystal Programming Language -License: Apache-2.0 -URL: https://crystal-lang.org/ -Source0: https://github.com/crystal-lang/crystal/releases/download/%version/crystal-%version-1-linux-x86_64-bundled.tar.gz -ExclusiveArch: x86_64 -BuildRequires: rpm_macro(fdupes) +Name: crystal +Version: 1.18.2 +Release: 2%?dist +Summary: A general-purpose, object-oriented programming language +License: Apache-2.0 +Packager: Carl Hörberg +URL: https://crystal-lang.org/ +Source0: https://github.com/crystal-lang/crystal/archive/%version.tar.gz +%if %{with bootstrap} +Source1: https://dev.alpinelinux.org/archive/crystal/crystal-%{bootstrap_version}-%{_arch}-alpine-linux-musl.tar.gz +%else +BuildRequires: crystal +%endif +BuildRequires: gcc gcc-c++ make gc-devel llvm-devel +BuildRequires: pcre2-devel libyaml-devel libffi-devel +Requires: gcc pkgconfig gc-devel +Requires: pcre2-devel openssl-devel zlib-devel +Requires: libyaml-devel libxml2-devel gmp-devel +Suggests: shards %description -%summary. - -%package devel -Summary: Development files for the crystal package - -%description devel -%summary. +Crystal is a programming language with the following goals: +- 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 %prep -%autosetup -n crystal-%version-1 +%setup -q +%if %{with bootstrap} +%setup -q -b 1 +%endif %build +%if %{with bootstrap} +# Use bootstrap crystal binary +export PATH="%{_builddir}/crystal-%{bootstrap_version}-%{_arch}-alpine-linux-musl/bin:$PATH" +%endif +%make_build release=1 interpreter=1 LDFLAGS="%{build_ldflags}" CRYSTAL_CONFIG_LIBRARY_PATH=%{_libdir}/crystal %install -mkdir -p %buildroot/usr/bin -mkdir -p %buildroot/usr/share -mkdir -p %buildroot/usr/lib/crystal -install -Dm755 bin/* %buildroot/usr/bin/ -cp -r share/* %buildroot/usr/share/ -cp -r lib/crystal/* %buildroot/usr/lib/crystal/ - -%fdupes %buildroot%_datadir/crystal/src/lib_c/ - +%make_install PREFIX=%{_prefix} %files -%license /usr/share/licenses/crystal/LICENSE -/usr/bin/crystal -/usr/share/zsh/site-functions/_crystal -/usr/share/man/man1/crystal.1.gz -/usr/share/crystal/ -/usr/share/fish/vendor_completions.d/crystal.fish -/usr/share/bash-completion/completions/crystal - -/usr/bin/shards -/usr/share/man/man1/shards.1.gz -/usr/share/man/man5/shard.yml.5.gz - -%files devel -/usr/lib/crystal/ +%license %{_datadir}/licenses/crystal/LICENSE +%{_bindir}/crystal +%{_datadir}/crystal +%{_datadir}/zsh/site-functions/_crystal +%{_datadir}/bash-completion/completions/crystal +%{_datadir}/fish/vendor_completions.d/crystal.fish +%{_mandir}/man1/crystal.1.gz %changelog +* Mon Nov 03 2025 Carl Hörberg - 1.18.2-2 +- Build from source, support multiple architectures. + * Sat Jun 17 2023 windowsboy111 - 1.8.2-2 - Add devel package. diff --git a/anda/langs/crystal/crystal/update.rhai b/anda/langs/crystal/crystal/update.rhai index b2159a6775..8a0aa8cee3 100644 --- a/anda/langs/crystal/crystal/update.rhai +++ b/anda/langs/crystal/crystal/update.rhai @@ -1,9 +1 @@ -let v = gh("crystal-lang/crystal"); -let url = `crystal-${v}-1-linux-x86_64-bundled.tar.gz`; - -if get(`https://github.com/crystal-lang/crystal/releases/expanded_assets/${v}`).contains(url) { - rpm.version(v); -} else { - print(`crystal: ${v} (waiting for bundle)`); - terminate(); -} +rpm.version(gh_tag("crystal-lang/crystal")); diff --git a/anda/langs/crystal/shards/anda.hcl b/anda/langs/crystal/shards/anda.hcl new file mode 100644 index 0000000000..32456c8b0f --- /dev/null +++ b/anda/langs/crystal/shards/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "shards.spec" + } +} diff --git a/anda/langs/crystal/shards/shards.spec b/anda/langs/crystal/shards/shards.spec new file mode 100644 index 0000000000..eb636eef6d --- /dev/null +++ b/anda/langs/crystal/shards/shards.spec @@ -0,0 +1,33 @@ +Name: shards +Version: 0.19.1 +Release: 1%?dist +Summary: Dependency manager for the Crystal language +License: Apache-2.0 +Packager: Carl Hörberg +URL: https://crystal-lang.org/ +Source0: https://github.com/crystal-lang/shards/archive/refs/tags/v%version.tar.gz +BuildRequires: crystal make +BuildRequires: gcc gc-devel libyaml-devel pcre-devel +Suggests: git make +Supplements: crystal + +%description +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. + +%prep +%setup -q + +%build +%make_build release=1 FLAGS="--link-flags=\"%{build_ldflags}\"" + +%install +%make_install PREFIX=%{_prefix} + +%files +%{_bindir}/shards +%{_mandir}/man1/shards.1.gz +%{_mandir}/man5/shard.yml.5.gz + +%changelog +* Mon Nov 03 2025 Carl Hörberg - 0.19.1-1 +- Initial package diff --git a/anda/langs/crystal/shards/update.rhai b/anda/langs/crystal/shards/update.rhai new file mode 100644 index 0000000000..11ba9c5d21 --- /dev/null +++ b/anda/langs/crystal/shards/update.rhai @@ -0,0 +1 @@ +rpm.version(gh_tag("crystal-lang/shards"));