%global srcname spork # A native module records the janet.h it was built against and janet refuses to # load it unless major and minor match, so every janet bound below is one # feature release wide. Derived rather than written twice: widening the ceiling # alone would admit a janet at runtime that the guard in %%build rejects, which # ships natives the user's janet then declines to load. %global janet_abi 1.42 %global janet_abi_next %{lua:local a=rpm.expand("%{janet_abi}"); local maj,min=a:match("^(%d+)%.(%d+)$"); if not maj then error("janet_abi must be MAJOR.MINOR, got "..a) end; print(maj.."."..(min+1))} Name: janet-%{srcname} Version: 1.2.0 Release: 1%{?dist} Summary: Assorted utility modules for the Janet language # spork/gfx2d compiles in deps/stb, which is dual-licensed, and glyph tables # generated from the Px437 fonts under deps/fonts, whose own name table # declares CC BY-SA 4.0. Upstream ships neither their license text nor an # attribution, so this tag is the only place the font terms are stated. License: MIT AND (MIT OR Unlicense) AND CC-BY-SA-4.0 URL: https://github.com/janet-lang/spork Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz BuildRequires: gcc # Fedora's own janet is 1.35, so the floor is what selects the COPR build. The # ceiling makes an out-of-window janet an unsatisfiable build dep rather than a # chroot that installs and then trips the %%build guard. BuildRequires: janet >= %{janet_abi}.0 BuildRequires: janet < %{janet_abi_next} BuildRequires: janet-devel >= %{janet_abi}.0 BuildRequires: janet-devel < %{janet_abi_next} Requires: janet%{?_isa} >= %{janet_abi}.0 Requires: janet%{?_isa} < %{janet_abi_next} # spork/cjanet and spork/gfx2d-shader compile C at run time, against janet.h, # so a compiler and the headers are closer to required than the rest. Recommends: gcc Recommends: janet-devel # janet-pm shells out to these to fetch a bundle; nothing else needs them. Recommends: git-core Recommends: curl Recommends: tar # MZ_VERSION in miniz.h is the zlib-compat string, not the miniz release. Provides: bundled(miniz) = 3.0.0 Provides: bundled(stb_image) = 2.30 Provides: bundled(stb_image_resize2) = 2.17 Provides: bundled(stb_image_write) = 1.16 # deps/fonts carries no version; upstream tracks the Px437 set by name only. Provides: bundled(px437-fonts) %description Spork is the official grab bag of Janet functionality that does not belong in the core library: argument parsing, JSON, HTTP, HTML templates, a source formatter, a cron expression parser, path handling, CRC, base64, UTF-8, zip, typed arrays and 2D graphics. It also ships the janet-pm package manager, the janet-format source formatter and the janet-netrepl networked REPL. %package devel Summary: Development files for Janet Spork # Only the tarray header lands here, none of the bundled code the base # package's compound tag covers. License: MIT Requires: %{name}%{?_isa} = %{version}-%{release} # The header opens with #include . Requires: janet-devel%{?_isa} >= %{janet_abi}.0 Requires: janet-devel%{?_isa} < %{janet_abi_next} %description devel The tarray header, needed to build a native Janet module against the C API of spork/tarray. %prep %autosetup -n %{srcname}-%{version} # %%license flattens its files into one directory and both are named LICENSE, # so shipping miniz's as-is replaces spork's own rather than joining it. cp -p deps/miniz/LICENSE LICENSE.miniz # CC BY-SA 4.0 wants creator and license conveyed with the adaptation, and the # glyph tables ship inside gfx2d.so. Upstream carries no notice, so write one # from what the fonts' own name tables declare. cat > LICENSE.fonts <<'FONTS' The bitmap glyph tables in spork/gfx2d (deps/default_font.h, deps/tall_font.h, deps/olive_font.h) are generated from the Px437 fonts in deps/fonts, outline versions by VileR, 2020, from The Ultimate Oldschool PC Font Pack. Licensed under Creative Commons Attribution-ShareAlike 4.0 International: https://creativecommons.org/licenses/by-sa/4.0/ FONTS %build # deps/*_font.h are generated artifacts kept as upstream ships them: regenerating # from deps/fonts needs tools/make-font.janet, which drives the cjanet JIT through # a spork that is not built yet. # Stop here rather than ship natives the Requires bounds above no longer match. janet -e '(assert (string/has-prefix? "%{janet_abi}." janet/version) "janet ABI moved, update janet_abi")' # spork's build takes its flags from janet dynamic bindings rather than from # the environment, and spork/gfx2d overrides the one for cflags, so shadowing # the compiler is the only hook that reaches every module. mkdir -p toolchain cat > toolchain/cc <<'EOF' #!/bin/sh exec %{__cc} %{build_cflags} %{build_ldflags} "$@" EOF chmod +x toolchain/cc export PATH="$PWD/toolchain:$PATH" export JANET_TOOLCHAIN=cc export JANET_BUILD_TYPE=release export JANET_PREFIX=%{_prefix} # use-rpath would bake the module path it builds against into every native. # The job count has to come through the same dynamic binding: spork's WORKERS # variable lands in a module environment the build closure never reads, so the # env-var route silently leaves it at one worker per host core. janet -e '(setdyn :workers %{_smp_build_ncpus}) (setdyn :use-rpath false)' \ -l ./bundle -e '(build)' %install export PATH="$PWD/toolchain:$PATH" export JANET_TOOLCHAIN=cc export JANET_BUILD_TYPE=release export JANET_PREFIX=%{_prefix} export JANET_PATH=%{buildroot}%{_libdir}/janet mkdir -p $JANET_PATH janet -e '(setdyn :workers %{_smp_build_ncpus}) (setdyn :use-rpath false)' \ -l ./bundle -e '(install @{})' # The scripts are generated with the module path they were installed under # spliced in. It is still the buildroot at this point, which makes this the one # moment they can be run: after the rewrite below they resolve their imports # against a path that exists only once the package is installed. %{buildroot}%{_libdir}/janet/bin/janet-format --help > /dev/null %{buildroot}%{_libdir}/janet/bin/janet-netrepl --help > /dev/null %{buildroot}%{_libdir}/janet/bin/janet-pm show-config > /dev/null sed -i 's|%{buildroot}||' %{buildroot}%{_libdir}/janet/bin/* # spork installs both below its module path; move them where a shell and man # look for them. mkdir -p %{buildroot}%{_bindir} %{buildroot}%{_mandir}/man1 mv %{buildroot}%{_libdir}/janet/bin/* %{buildroot}%{_bindir}/ rmdir %{buildroot}%{_libdir}/janet/bin mv %{buildroot}%{_libdir}/janet/man/man1/* %{buildroot}%{_mandir}/man1/ # rmdir, not rm -r: spork can also install under man//, and that would # be deleted here unshipped rather than failing the build. rmdir %{buildroot}%{_libdir}/janet/man/man1 %{buildroot}%{_libdir}/janet/man # The archives and their metadata serve only declare-executable, which links # libjanet.a -- our janet is shared-only, so nothing can consume them. rm %{buildroot}%{_libdir}/janet/%{srcname}/*.a rm %{buildroot}%{_libdir}/janet/%{srcname}/*.meta.janet %check export JANET_PATH=%{buildroot}%{_libdir}/janet for suite in test/suite-*.janet; do # suite-pm installs a bundle declaring an executable, so it needs the # libjanet.a our janet does not ship. case "$suite" in test/suite-pm.janet) continue ;; esac # suite-pmfull runs zero assertions unless SPORK_TEST_ALL_PACKAGES is set, # which would fetch bundles over the network. It is left as the no-op. janet -- "$suite" done # The suites reach the natives through JANET_PATH but import everything else # relative to the source tree, so load the staged tree from a directory that # cannot shadow it. spork/init.janet reaches every native and every module # except date, gfx2d-shader and gfx2d-codegen. (cd %{buildroot} && janet -e '(import spork) (import spork/date) (import spork/gfx2d-shader)') # gfx2d-codegen is a cjanet prelude, not an importable module -- load it the # way shader-begin does, which still resolves its cjanet dependency out of the # staged tree. Compiling it writes the generated C to stdout. (cd %{buildroot} && janet -e '(dofile (string (dyn *syspath*) "/spork/gfx2d-codegen.janet") :env (make-env))' > /dev/null) %files # miniz is the one bundled dep shipping its own license text; stb states its # terms inline in the headers and the Px437 fonts carry none. %license LICENSE LICENSE.miniz LICENSE.fonts %doc README.md CHANGELOG.md examples/ %{_bindir}/janet-format %{_bindir}/janet-netrepl %{_bindir}/janet-pm %{_libdir}/janet/%{srcname}/ %{_mandir}/man1/janet-pm.1* %files devel %{_libdir}/janet/tarray.h %changelog * Tue Sep 15 2026 Bahtiar `kalkin-` Gadimov - 1.2.0-1 - Initial package - Drop the static archives, unusable against a shared-only janet - Declare the CC BY-SA glyph tables spork/gfx2d compiles in