%bcond check 1 # CREATE EXTENSION jsonschema; pgrx names every artifact after the crate, so the # .so/.control/.sql ship as jsonschema.* regardless of the RPM name. %global extname jsonschema # Target the chroot's stock PostgreSQL major (Fedora >= 44 ships pg18); pgrx # stages its package tree under target/release/%%{extname}-pg%%{pgmajor}. %global pgmajor 18 Name: pg-jsonschema-boon Version: 0.1.9 Release: 1%{?dist} Summary: JSON Schema validation functions for PostgreSQL # jsonschema is MIT; the rest is the cumulative SPDX over pgrx, boon, serde_json # and every other crate statically linked into the pg18 extension (cargo metadata). License: ((Apache-2.0 OR MIT) AND BSD-3-Clause) AND ((MIT OR Apache-2.0) AND Unicode-3.0) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT) AND (Apache-2.0 OR BSD-2-Clause OR MIT) AND (Apache-2.0 OR LGPL-2.1-or-later OR MIT) AND (Apache-2.0 OR MIT) AND BSD-3-Clause AND ISC AND MIT AND (MIT OR Unlicense) AND MIT-0 AND Unicode-3.0 AND Zlib URL: https://github.com/theory/pg-jsonschema-boon Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Source1: %{name}-%{version}-vendor.tar.xz ExclusiveArch: %{rust_arches} BuildRequires: cargo-rpm-macros >= 24 # pgrx builds the extension through `cargo pgrx package`; the toolchain version # must match the crate's pinned `pgrx = "=0.18.0"`. BuildRequires: cargo-pgrx = 0.18.0 # pgrx-pg-sys runs bindgen against the server headers, so clang/libclang and the # stock (never PGDG-versioned) server-devel are required; gcc links the cdylib; # pgrx-bindgen formats its generated bindings with rustfmt. BuildRequires: clang BuildRequires: gcc BuildRequires: postgresql-server-devel BuildRequires: rustfmt Requires: postgresql-server %description pg-jsonschema-boon is a PostgreSQL extension, written in Rust with pgrx and the boon validator, that adds JSON Schema validation functions: jsonschema_is_valid() checks a schema against the JSON Schema meta-schemas, and jsonschema_validates() validates a JSON value against a schema. It supports drafts 2020-12, 2019-09, draft-7, draft-6 and draft-4, including multi-file schema composition. %prep %autosetup -n %{name}-%{version} -p1 tar -xJf %{SOURCE1} %cargo_prep -v vendor %build %{cargo_vendor_manifest} # `cargo pgrx package` reads its pg_config registry from $PGRX_HOME/config.toml. # Write it directly instead of `cargo pgrx init`, which also runs initdb to build # a data dir — needed only for `cargo pgrx run/test`, absent in the chroot. export PGRX_HOME="$PWD/.pgrx" mkdir -p "$PGRX_HOME" cat > "$PGRX_HOME/config.toml" <. cargo pgrx package --pg-config %{_bindir}/pg_config %install # pgrx already lays the staged tree out at the pg_config-derived absolute paths # (%%{_libdir}/pgsql, %%{_datadir}/pgsql), so copy it wholesale into the buildroot. cp -a target/release/%{extname}-pg%{pgmajor}/* %{buildroot}/ %check %if %{with check} # No running server in the offline chroot: smoke-check the built artifacts and # that pgrx substituted @CARGO_VERSION@ in the control file. test -f %{buildroot}%{_libdir}/pgsql/%{extname}.so test -f %{buildroot}%{_datadir}/pgsql/extension/%{extname}--%{version}.sql grep -q "default_version = '%{version}'" \ %{buildroot}%{_datadir}/pgsql/extension/%{extname}.control %endif %files %license LICENSE.md %license cargo-vendor.txt %doc README.md %{_libdir}/pgsql/%{extname}.so %{_datadir}/pgsql/extension/%{extname}.control %{_datadir}/pgsql/extension/%{extname}--*.sql %changelog * Tue Jun 30 2026 Bahtiar `kalkin-` Gadimov - 0.1.9-1 - Initial package