%global debug_package %{nil} %global rust_channel nightly Name: fp-no-dash Version: 0.2.5 Release: %autorelease Summary: A lightweight Rust dashboard for self-hosted services License: MIT URL: https://gitlab.com/fpsys/fp-no-dash Source0: %{name}-%{version}.tar.gz Source1: %{name}.service # Toolchain: there is no BuildRequires on rust/cargo here on purpose. Fedora # ships stable Rust only, and this crate cannot build on stable -- see the # comments in %build. The nightly toolchain is bootstrapped there instead. # # The C bits that toolchain still needs: `gcc` provides `cc` for linking and # for build-std's compiler_builtins, and `glibc-devel` provides crt1.o plus # libc.so, without which the final link fails. BuildRequires: gcc BuildRequires: glibc-devel BuildRequires: ca-certificates BuildRequires: curl BuildRequires: systemd-rpm-macros BuildRequires: rpmautospec %description fp-no-dash is a lightweight Rust dashboard for self-hosted services. Everything is prepared at build time. %prep %setup -q -n %{name}-%{version} %build # Fedora's build-flag preamble exports RUSTFLAGS containing # -Copt-level=3 -Cstrip=none. Those override opt-level="z" and strip="true" # from Cargo.toml, which re-links the panic backtrace machinery (gimli, # addr2line, rustc_demangle, miniz_oxide -- ~176 KiB of .text) that this # project deliberately drops. Unset so cargo falls back to # .cargo/config.toml, i.e. the configuration the released artifacts are # actually built with. unset RUSTFLAGS # This crate needs a nightly toolchain, which Fedora does not package: # * Cargo.toml sets cargo-features = ["panic-immediate-abort"], a cargo # feature that is rejected outright on stable. # * Cargo.toml sets panic = "immediate-abort", a nightly-only panic strategy. # * .cargo/config.toml sets [unstable] build-std = ["core", "std"], which is # what lets immediate-abort take effect -- it has to rebuild core/std from # source, hence the rust-src component. # * rust-toolchain.toml pins channel = "nightly" for the same reason. # So bootstrap the same toolchain the Containerfile and local builds use. # # Scratch dirs go under $HOME, which rpmbuild points at a writable directory # inside the build tree (mock exports HOME=/builddir). Deliberately not using a # build-path macro: _vpath_builddir resolves here to a constant string rather # than a directory, so it would silently create paths relative to $PWD. # These are also rustup's and cargo's own defaults, so this mostly just makes # the location explicit rather than relying on the ambient HOME. export RUSTUP_HOME="$HOME/.rustup" export CARGO_HOME="$HOME/.cargo" export PATH="$HOME/.cargo/bin:$PATH" # The tarball carries rust-toolchain.toml, which pins nightly plus the clippy, # rustfmt and musl targets. RUSTUP_TOOLCHAIN overrides that file so rustup uses # the nightly we just installed instead of resolving (and downloading) the # extras -- only rust-src is needed here, and it is requested explicitly below. export RUSTUP_TOOLCHAIN=%{rust_channel} curl --proto '=https' --tlsv1.2 -sSf -o rustup-init.sh https://sh.rustup.rs sh rustup-init.sh -y --no-modify-path --profile minimal \ --default-toolchain %{rust_channel} \ --component rust-src cargo build --release --locked %install mkdir -p %{buildroot}%{_bindir} install -m 755 target/release/fp-no-dash %{buildroot}%{_bindir}/fp-no-dash mkdir -p %{buildroot}%{_userunitdir} install -m 644 %{SOURCE1} %{buildroot}%{_userunitdir}/fp-no-dash.service %post %systemd_user_post fp-no-dash.service %preun %systemd_user_preun fp-no-dash.service %files %{_bindir}/fp-no-dash %{_userunitdir}/fp-no-dash.service %license LICENSE %doc README.md %changelog %autochangelog