# Started from rust2rpm 28 output (rust2rpm -t fedora -V auto amdgpu_top), # then modified for this package's specific needs. See inline comments # documenting for further details on each deviation from the rust2rpm template. # # Why this is not a standard rust2rpm SPEC: # - amdgpu_top is a standalone binary application, not a Rust library, # so it is to be packaged as "amdgpu_top" (not "rust-amdgpu_top") without # the library subpackage that rust2rpm generates. # - It has a git dependency (libdrm-amdgpu-sys-rs) that requires a # manual [source] replacement in .cargo/config.toml (see %%prep). # - %%cargo_install fails due to that git dependency, so we install the # binary manually (see %%install). # - It links C libraries (libdrm, libX11, wayland) via FFI, which # rust2rpm does not detect, so those BuildRequires are added manually. %bcond check 1 # amdgpu_top is a binary, prevent library files from being installed %global cargo_install_lib 0 %global crate amdgpu_top Name: amdgpu_top Version: 0.11.5 Release: %autorelease Summary: Tool that displays AMDGPU usage gathered from performance counters # Main project: MIT # Vendored dependencies have varying licenses, see LICENSE.dependencies # SPDX expression generated from cargo_license_summary output. # To regenerate after a version update: # - Build with rpmbuild -bc, then read LICENSE.dependencies # - Or run %%cargo_license_summary and collect unique license entries # Bundled fonts: OFL-1.1 (BIZ UDGothic) # Vendored dependencies: Apache-2.0, BSL-1.0, CC0-1.0, ISC, Unicode-3.0, Zlib # # There are some files not covered by the LICENSE or LICENSE.dependencies file: # W3C # vendor/winit-0.30.13/src/keyboard.rs # # MPL-2.0 # vendor/uluru-3.1.0/LICENSE # vendor/uluru-3.1.0/src/lib.rs # # Public Domain / LicenseRef-Fedora-Public-Domain # vendor/tiff-0.11.3/tests/COPYRIGHT License: %{shrink: MIT AND Apache-2.0 AND BSL-1.0 AND CC0-1.0 AND ISC AND OFL-1.1 AND Unicode-3.0 AND Zlib AND W3C AND MPL-2.0 AND LicenseRef-Fedora-Public-Domain } URL: https://github.com/Umio-Yasuno/amdgpu_top # NOTE: Pulling Source0 from GitHub (not crates.io via %%{crates_source}) # because the crates.io tarball does not include the git dependency (libdrm-amdgpu-sys-rs) # This build expects such source layout. Source0: %{url}/archive/v%{version}/%{crate}-%{version}.tar.gz # Vendor tarball of all Rust dependencies (required for offline builds). # Generate with rust2rpm: # rust2rpm -t fedora -V auto amdgpu_top # This produces amdgpu_top-%%{version}-vendor.tar.xz automatically. # # Manual alternative if rust2rpm is unavailable: # wget %%{url}/archive/refs/tags/v%%{version}.tar.gz -O amdgpu_top-%%{version}.tar.gz # tar -xf amdgpu_top-%%{version}.tar.gz # cd amdgpu_top-%%{version} # cargo vendor # tar -cJf ../amdgpu_top-%%{version}-vendor.tar.xz vendor/ Source1: amdgpu_top-%{version}-vendor.tar.xz ExclusiveArch: x86_64 # Disable LTO to prevent rustc Internal Compiler Error in x11-dl %global _lto_cflags %{nil} BuildRequires: cargo-rpm-macros >= 24 # System C libraries linked via FFI, # therefore rust2rpm does NOT detect these because they are not Rust crate dependencies BuildRequires: libdrm-devel BuildRequires: libX11-devel BuildRequires: wayland-devel BuildRequires: gcc %global _description %{expand: Tool that displays AMDGPU usage. The tool displays information gathered from performance counters (GRBM, GRBM2), sensors, fdinfo, gpu_metrics and AMDGPU driver.} %description %{_description} %prep %autosetup -n %{crate}-%{version} -p1 -a1 %cargo_prep -v vendor # Remove pre-compiled binaries from vendored crates find vendor -type f \( -name '*.wasm' -o -name '*.so' -o -name '*.dll' -o -name '*.o' \) -delete # Clear Cargo checksums so it does not panic over the deleted binaries sed -i 's/"files":{[^}]*}/"files":{}/' vendor/*/.cargo-checksum.json # MANUAL STEP: Git dependency replacement (NOT generated by rust2rpm) # # amdgpu_top depends on libdrm-amdgpu-sys-rs via a git URL (with a pinned # revision) in Cargo.toml instead of a crates.io dependency. Cargo vendor # downloads this git source into the vendor directory, but cargo still tries # to fetch it from git during the build unless we redirect it to the # vendored copy. Offline builds have no network, so without this the build fails # # WHEN UPDATING TO A NEW VERSION: # - Find the new git revision in Cargo.lock: # grep -A5 "libdrm-amdgpu-sys-rs" Cargo.lock # - Update BOTH occurrences of the revision below (the [source] key URL # AND the rev= line) to the new revision hash. cat >> .cargo/config.toml << EOF [source."git+https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs?rev=c87eff736523054247f1192796a5f47560cd35db"] git = "https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs" rev = "c87eff736523054247f1192796a5f47560cd35db" replace-with = "vendored-sources" EOF %build # Prevent rustc stack overflow when compiling auto-generated wayland-protocol bindings export RUST_MIN_STACK=16777216 %cargo_build %{cargo_license_summary} %{cargo_license} > LICENSE.dependencies %{cargo_vendor_manifest} %install # MANUAL STEP: Binary installation (NOT %%cargo_install) # # rust2rpm generates %%cargo_install here, but it fails for this package: # the git dependency causes cargo install to attempt a git fetch even in # offline mode. We install the binary directly instead. %%cargo_build # produces the binary at target/rpm/amdgpu_top. install -Dpm 0755 target/rpm/amdgpu_top %{buildroot}%{_bindir}/amdgpu_top %if %{with check} %check %cargo_test %endif %files %license LICENSE %license LICENSE.dependencies %license cargo-vendor.txt %doc AUTHORS %doc CHANGELOG.md %doc README.md %{_bindir}/amdgpu_top %changelog %autochangelog