# samba-pidl.spec — Fedora RPM packaging for the samba-pidl-rust workspace # # The source package produces the following binary packages: # # samba-pidl CLI IDL compiler (drop-in replacement for Perl PIDL) # samba-pidl-doc Design documentation and IDL examples # ndrdump NDR blob decoder (port of Samba's ndrdump tool) # rust-pidl-devel Rust crate sources — IDL compiler library # rust-pidl-doc Rustdoc HTML for both the pidl and samba-ndr crates # rust-samba-ndr-devel Rust crate sources — NDR wire-format runtime # # Source preparation notes # ───────────────────────── # Source0 (main tarball): # git archive --prefix=samba-pidl-%%{version}/ HEAD \ # | gzip > samba-pidl-%%{version}.tar.gz # # Source1 (vendor tarball): # Run 'make sources' from contrib/packages/ to generate both tarballs. # 'cargo vendor' stdout (the [source.*] redirect stanzas) is saved alongside # the vendor directory as vendor-config.toml; %%prep appends it to # .cargo/config.toml so offline --locked builds can find all crates in vendor/. # This tarball must be regenerated whenever Cargo.lock changes. # %global crate samba-pidl # Snapshot release identifiers. # 'make srpm' substitutes the real datetime (YYYYMMDDHHMM) and short commit hash # before invoking rpmbuild so the SRPM contains an expanded Release tag. # The placeholder values below are only used when the spec is processed without # going through the Makefile (e.g. rpmlint, manual rpmbuild invocations). %global snapdate 202603161157 %global snapcommit 436b0dd Name: %{crate} Version: 0.1.0 Release: 1.%{snapdate}.git%{snapcommit}%{?dist} Summary: IDL compiler for Samba (Rust replacement for Perl PIDL) License: GPL-3.0-or-later URL: https://gitlab.com/samba-team/samba Source0: %{name}-%{version}.tar.gz Source1: %{name}-%{version}-vendor.tar.gz # Rust build infrastructure BuildRequires: cargo-rpm-macros >= 25 %description samba-pidl is a complete Rust rewrite of the Samba PIDL (Perl IDL) compiler. It reads Interface Definition Language (IDL) files in a format compatible with Microsoft's MIDL compiler and generates: * C type declarations (--header) * NDR wire-format pull/push marshalling code (--ndr-parser) * DCE/RPC client and server stubs (--client, --server, --server-compat) * Python C extension bindings (--python) * Wireshark dissectors (--ws-parser) * Rust type definitions with NDR implementations (--rust) * TDR, Samba3 NDR, COM/DCOM, and other output modes The samba-pidl binary is a drop-in replacement for the Perl pidl script with byte-identical output on the full Samba IDL corpus (librpc/idl/*.idl). # ────────────────────────────────────────────────────────────────────────────── # samba-pidl-doc — design documentation and IDL examples # ────────────────────────────────────────────────────────────────────────────── %package doc Summary: Design documentation and IDL examples for samba-pidl License: GPL-3.0-or-later BuildArch: noarch %description doc Design and architecture documentation for the samba-pidl Rust IDL compiler, including: * Architecture overview and pipeline description * AST type reference * Parser internals * Backend implementation guide * Rust backend design notes * IDL language format reference * Usage guide * Nine self-contained IDL example files covering all language features # ────────────────────────────────────────────────────────────────────────────── # ndrdump — NDR blob decoder # ────────────────────────────────────────────────────────────────────────────── %package -n ndrdump Summary: Decode and pretty-print NDR-encoded DCE/RPC structures License: GPL-3.0-or-later %description -n ndrdump ndrdump decodes binary NDR (Network Data Representation) blobs produced by DCE/RPC and displays them as human-readable text. It is a Rust port of the ndrdump utility bundled with Samba, supporting the same IDL-derived type descriptions. # ────────────────────────────────────────────────────────────────────────────── # rust-pidl-devel — Rust crate sources: IDL compiler library # ────────────────────────────────────────────────────────────────────────────── %package -n rust-pidl-devel Summary: Rust crate sources for pidl (Samba IDL compiler library) License: GPL-3.0-or-later BuildArch: noarch Provides: crate(pidl) = %{version} Provides: crate(pidl/dump) = %{version} %description -n rust-pidl-devel Rust crate sources for the pidl IDL compiler library, installed into the system Cargo registry so that other Rust packages can use it as a build-time or compile-time dependency. The library implements all pipeline stages of the Samba PIDL compiler: lexer, hand-written recursive-descent parser, ODL-to-IDL transformation, NDR semantic analysis, and thirteen code-generation backends. The optional crate(pidl/dump) feature enables JSON serialisation of IDL and NDR trees via serde. # ────────────────────────────────────────────────────────────────────────────── # rust-pidl-doc — Rust API documentation: pidl and samba-ndr crates # ────────────────────────────────────────────────────────────────────────────── %package -n rust-pidl-doc Summary: Rust API documentation for the pidl and samba-ndr crates License: GPL-3.0-or-later BuildArch: noarch %description -n rust-pidl-doc Rustdoc HTML documentation for the pidl and samba-ndr Rust crates. Both crates are documented together as their HTML cross-links and shares the same static.files/ asset directory. Covers all public types, traits, functions, and modules in both the IDL compiler library (pidl) and the NDR wire-format runtime (samba-ndr). # ────────────────────────────────────────────────────────────────────────────── # rust-samba-ndr-devel — Rust crate sources: NDR wire-format runtime # ────────────────────────────────────────────────────────────────────────────── %package -n rust-samba-ndr-devel Summary: Rust crate sources for samba-ndr (NDR wire-format runtime) License: GPL-3.0-or-later BuildArch: noarch Provides: crate(samba-ndr) = %{version} Requires: rust-pidl-devel = %{version}-%{release} %description -n rust-samba-ndr-devel Rust crate sources for the samba-ndr NDR wire-format runtime library, installed into the system Cargo registry. samba-ndr provides the NdrPrint trait and associated primitives used by Rust code generated by the samba-pidl --rust backend. It is a required dependency for crates that consume the pidl Rust code-generation output. # ══════════════════════════════════════════════════════════════════════════════ # PREP # ══════════════════════════════════════════════════════════════════════════════ %prep %autosetup -n %{name}-%{version} # Extract the vendor tarball into the source tree. # The tarball contains vendor/, vendor-config.toml, and Cargo.lock; extracting # it here gives the build root a lock file that is exactly consistent with the # vendored crates. tar xf %{SOURCE1} # Write .cargo/config.toml pointing all crate lookups at vendor/ so that every # subsequent cargo invocation stays fully offline inside the build root. %cargo_prep -v vendor # Append any [source."git+..."] redirect stanzas emitted by 'cargo vendor' # (saved in vendor-config.toml during 'make vendor'). For this workspace all # dependencies come from crates.io, so this is typically a no-op. awk '/^\[source\."git\+/{s=1; print; next} /^\[/{s=0} s{print} /^[[:space:]]*$/{s=0}' \ vendor-config.toml >> .cargo/config.toml || : # Re-link crates that are already installed as system packages from the system # Cargo registry into vendor/ so cargo can also find them there. for dir in %{cargo_registry}/*/; do [[ -d "$dir" ]] || continue crate="${dir##%{cargo_registry}/}"; crate="${crate%/}" [[ -e "vendor/$crate" ]] || ln -s "$dir" "vendor/$crate" done # ══════════════════════════════════════════════════════════════════════════════ # GENERATE BUILD REQUIREMENTS # ══════════════════════════════════════════════════════════════════════════════ %generate_buildrequires %cargo_generate_buildrequires # ══════════════════════════════════════════════════════════════════════════════ # BUILD # ══════════════════════════════════════════════════════════════════════════════ %build # ── 1. CLI and tool binaries ────────────────────────────────────────────────── # Builds samba-pidl and ndrdump with Fedora's release profile flags. # The ndrdump build.rs script invokes the pidl library at build # time to generate Rust NDR type definitions from the bundled IDL corpus # in the idl/ directory. export PIDL_TRACE=1 %{cargo_build} -p samba-pidl -p ndrdump # ── 2. Rust API documentation ───────────────────────────────────────────────── # Generate rustdoc HTML for the two library crates. --no-deps limits output to # workspace crates only (not their transitive dependencies). Both crates are # built together so their HTML cross-links and shares the same static.files/. %{__cargo} doc \ --no-deps \ --offline \ --locked \ -p pidl \ -p samba-ndr # ══════════════════════════════════════════════════════════════════════════════ # INSTALL # ══════════════════════════════════════════════════════════════════════════════ %install # ── 1. CLI and tool binaries ────────────────────────────────────────────────── # The binaries were compiled by %%{cargo_build} into target/rpm/. install -Dpm 755 target/rpm/samba-pidl %{buildroot}%{_bindir}/samba-pidl install -Dpm 755 target/rpm/ndrdump %{buildroot}%{_bindir}/ndrdump # ── 2. Rust crate sources → Cargo registry ─────────────────────────────────── # Install the pidl library crate. Include build.rs because the crate uses # lalrpop to generate a parser at compile time. %{__mkdir} -p %{buildroot}%{cargo_registry}/pidl-%{version} awk '/^\[((.+\.)?((dev|build)-)?dependencies|features)/{f=1;next} /^\[/{f=0}; !f' \ pidl/Cargo.toml > %{buildroot}%{cargo_registry}/pidl-%{version}/Cargo.toml cp -a pidl/src/ pidl/build.rs %{buildroot}%{cargo_registry}/pidl-%{version}/ echo '{"files":{},"package":""}' > \ %{buildroot}%{cargo_registry}/pidl-%{version}/.cargo-checksum.json # Install the samba-ndr library crate (pure Rust library, no build.rs). %{__mkdir} -p %{buildroot}%{cargo_registry}/samba-ndr-%{version} awk '/^\[((.+\.)?((dev|build)-)?dependencies|features)/{f=1;next} /^\[/{f=0}; !f' \ samba-ndr/Cargo.toml > %{buildroot}%{cargo_registry}/samba-ndr-%{version}/Cargo.toml cp -a samba-ndr/src/ %{buildroot}%{cargo_registry}/samba-ndr-%{version}/ echo '{"files":{},"package":""}' > \ %{buildroot}%{cargo_registry}/samba-ndr-%{version}/.cargo-checksum.json # ── 3. Rust API documentation ───────────────────────────────────────────────── # Install the complete target/doc/ tree; it covers both crates and their # cross-links are relative, so the whole tree must be installed together. install -d %{buildroot}%{_docdir}/rust-pidl-doc/html cp -a target/doc/. %{buildroot}%{_docdir}/rust-pidl-doc/html/ # ── 4. Design documentation and examples ───────────────────────────────────── install -d %{buildroot}%{_docdir}/%{crate}-doc/docs \ %{buildroot}%{_docdir}/%{crate}-doc/examples install -pm 644 docs/*.md %{buildroot}%{_docdir}/%{crate}-doc/docs/ install -pm 644 examples/*.idl examples/README.md \ %{buildroot}%{_docdir}/%{crate}-doc/examples/ # ══════════════════════════════════════════════════════════════════════════════ # CHECK # ══════════════════════════════════════════════════════════════════════════════ %check # Run unit tests for the library crates. # --lib restricts to library unit tests only, excluding integration tests and # the benchmark targets bundled in pidl/benches/. %cargo_test -- -p pidl -p samba-ndr --lib # ══════════════════════════════════════════════════════════════════════════════ # FILES # ══════════════════════════════════════════════════════════════════════════════ # ── samba-pidl (main package: IDL compiler binary) ──────────────────────────── %files %license COPYING %doc README.md %{_bindir}/samba-pidl # ── samba-pidl-doc ──────────────────────────────────────────────────────────── %files doc %license COPYING %{_docdir}/%{crate}-doc/docs/ %{_docdir}/%{crate}-doc/examples/ # ── ndrdump ─────────────────────────────────────────────────────────────────── %files -n ndrdump %license COPYING %{_bindir}/ndrdump # ── rust-pidl-devel ─────────────────────────────────────────────────────────── %files -n rust-pidl-devel %license COPYING %{cargo_registry}/pidl-%{version}/ # ── rust-pidl-doc ───────────────────────────────────────────────────────────── %files -n rust-pidl-doc %license COPYING %doc README.md %{_docdir}/rust-pidl-doc/html/ # ── rust-samba-ndr-devel ────────────────────────────────────────────────────── %files -n rust-samba-ndr-devel %license COPYING %{cargo_registry}/samba-ndr-%{version}/ # ══════════════════════════════════════════════════════════════════════════════ # CHANGELOG # ══════════════════════════════════════════════════════════════════════════════ %changelog * Sun Mar 15 2026 Samba Team - 0.1.0-1 - Initial Fedora package