File trex-core.spec of Package trex-core
#
# spec file for package trex-core 2.56 (x86_64 + ARM-friendly)
#
Name: trex-core
Version: 2.56
Release: 150700.150623.1
Summary: High-performance traffic generator based on DPDK
License: Apache-2.0
URL: https://github.com/cisco-system-traffic-generator/trex-core
Source0: %{name}-%{version}.tar.gz
# Build dependencies
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: pkgconfig(libmnl)
BuildRequires: pkgconfig(zlib)
BuildRequires: python3
# IMPORTANT: Do NOT include dpdk-devel
# BuildRequires: dpdk-devel <-- removed to prevent system DPDK interference
%description
TRex is a stateful/stateless traffic generator using DPDK.
This package installs the TRex daemon and its configuration, enabling it to run as a systemd service.
%prep
%setup -q
chmod -x LICENSE* CHANGES README.asciidoc
# Ensure string.h is included in portability.h before macros
sed -i '1i#include <string.h>' external_libs/bpf/portability.h
# ARM-specific patches
%ifarch aarch64
# Disable BPF JIT
sed -i 's/^[[:space:]]*#define[[:space:]]\+TREX_USE_BPFJIT/\/\* disabled for ARM: TREX_USE_BPFJIT \*\//' src/stx/common/trex_capture.h
# Skip ibverbs check on ARM
sed -i 's/def check_ibverbs_deps(bld):/def check_ibverbs_deps(bld):\n return/' linux_dpdk/ws_main.py
# Use dummy MLX5 autoconf to avoid MLX5 check
sed -i 's/conf.configure_mlx5(/conf.configure_dummy_mlx5(/' linux_dpdk/ws_main.py
# Skip internal ibverbs library reading in build
sed -i '/bld.read_shlib( name=.ibverbs./,/)/ s/^/#/' linux_dpdk/ws_main.py
# Always add -faligned-new to all C++ builds
sed -i '/return (flags)/i \ flags += ["-faligned-new"]' linux_dpdk/ws_main.py
%endif
%build
cd linux_dpdk
# Clear system include paths to prevent interference
export C_INCLUDE_PATH=
export CPLUS_INCLUDE_PATH=
export PKG_CONFIG_PATH=
# Force TRex to use internal DPDK 18.08
export RTE_SDK=$(pwd)/src/dpdk
export RTE_TARGET=
%ifarch aarch64
export RTE_TARGET=arm64-linuxapp-gcc
# Configure TRex for ARM without MLX
./b configure --no-mlx True
%else
export RTE_TARGET=x86_64-native-linuxapp-gcc
# Configure TRex for x86_64
./b configure
%endif
# Build TRex
./b build -v
%install
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_sysconfdir}/trex
install -d %{buildroot}%{_unitdir}
install -d %{buildroot}%{_libdir}/trex
cp -a linux_dpdk/* %{buildroot}%{_libdir}/trex/
chmod 0755 %{buildroot}%{_bindir}/trex
install -m 0644 cfg/trex_cfg.yaml %{buildroot}%{_sysconfdir}/trex/trex_cfg.yaml
install -m 0644 trex.env %{buildroot}%{_sysconfdir}/trex/trex.env
install -m 0644 packaging/trex.service %{buildroot}%{_unitdir}/trex.service
%files
%license LICENSE*
%doc CHANGES README.asciidoc
%{_bindir}/trex
%{_libdir}/trex
%config(noreplace) %{_sysconfdir}/trex/trex_cfg.yaml
%config(noreplace) %{_sysconfdir}/trex/trex.env
%{_unitdir}/trex.service