File moongen.spec of Package MoonGen
#
# spec file for package moongen
#
# Copyright (c) 2025 SUSE LLC
#
Name: moongen
Version: 0
Release: 150600.10.2
Summary: High-speed packet generator based on DPDK
License: BSD-3-Clause
URL: https://github.com/emmericp/MoonGen
Source: %{name}-%{version}.tar.gz
# Build dependencies
BuildRequires: gcc >= 4.8
BuildRequires: gcc-c++
BuildRequires: make
BuildRequires: cmake
BuildRequires: libnuma-devel
BuildRequires: kernel-devel
BuildRequires: which
BuildRequires: python3
BuildRequires: python2
BuildRequires: pciutils
BuildRequires: dpdk-devel
BuildRequires: lua-devel
BuildRequires: git
# Runtime dependencies
Requires: libnuma1
Requires(post): bash
ExcludeArch: s390 s390x %{ix86}
%description
MoonGen is a high-speed packet generator built on top of DPDK.
It provides flexible Lua scripting for traffic generation and benchmarking.
This package builds MoonGen using its upstream build script but uses system DPDK headers and libraries.
%prep
%autosetup -p1
%build
chmod +x build.sh
# Use system DPDK
export MOONGEN_USE_SYSTEM_DPDK=1
# OBS-friendly: no kernel modules, no binding, no tests
export RTE_KERNEL_MODULES=0
export SKIP_BIND=1
export MOONGEN_RUN_TESTS=0
# Tell MoonGen exactly where to find system DPDK headers and libs
export RTE_SDK=/usr
export RTE_TARGET=x86_64-default-linuxapp-gcc
# Make sure the include path matches your dpdk-devel layout
mkdir -p deps/dpdk/include
ln -sf /usr/include/dpdk deps/dpdk/include
# Make sure the lib path exists
mkdir -p deps/dpdk/lib
ln -sf /usr/lib64 deps/dpdk/lib/x86_64-default-linuxapp-gcc
# Force a clean CMake reconfiguration
rm -rf build/CMakeCache.txt build/CMakeFiles
# Build MoonGen
./build.sh
# Verify binary exists
if [ ! -f build/MoonGen ]; then
echo "ERROR: build/MoonGen not found. Build failed?"
exit 1
fi
%install
# Create directories
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_libexecdir}/%{name}
install -d %{buildroot}%{_datadir}/%{name}/examples
# Install main binary
install -m 0755 build/MoonGen %{buildroot}%{_bindir}/MoonGen
# Install helper scripts (without executing them)
install -m 0755 bind-interfaces.sh %{buildroot}%{_libexecdir}/%{name}/
install -m 0755 setup-hugetlbfs.sh %{buildroot}%{_libexecdir}/%{name}/
# Install example Lua scripts
cp -a examples/* %{buildroot}%{_datadir}/%{name}/examples/
%post
cat <<EOF
MoonGen has been installed.
Note: interface binding and hugepage setup are skipped in this package.
You can manually bind interfaces and setup hugepages if needed:
sudo %{_libexecdir}/%{name}/setup-hugetlbfs.sh
sudo %{_libexecdir}/%{name}/bind-interfaces.sh
Run an example:
sudo %{_bindir}/MoonGen %{_datadir}/%{name}/examples/l3-load-latency.lua 0 1
EOF
%files
%license LICENSE
%doc README.md
%{_bindir}/MoonGen
%{_libexecdir}/%{name}/bind-interfaces.sh
%{_libexecdir}/%{name}/setup-hugetlbfs.sh
%{_datadir}/%{name}/examples
%changelog
* Fri Oct 24 2025 Kristian Zhelyazkov <kristian.zhelyazkov@suse.com>
- OBS-friendly build: use system DPDK
- Skip kernel modules, interface binding, and tests
- Ensures build/MoonGen is created and installed