File ns3.spec of Package ns3
#
# spec file for package ns3
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define _version %(echo %{version} | sed 's/\\./_/g')
%bcond_with openflow
%bcond_with openmpi
Name: ns3
Version: 3.36.1
Release: 0
Summary: Discrete-event network simulator
License: GPL-2.0-only
Group: Productivity/Scientific/Other
Url: https://www.nsnam.org/
Source0: https://www.nsnam.org/releases/ns-allinone-%{version}.tar.bz2
# PATCH-FIX-OPENSUSE -- Set helper binary path to libexecdir
Patch0: 0001-Use-libexecdir-for-path-to-helper-binaries.patch
# PATCH-FIX-UPSTREAM
Patch1: 0001-Fix-CMAKE_LINUX_DISTRO-quoting.patch
# PATCH-FIX-UPSTREAM
Patch2: https://gitlab.com/nsnam/ns-3-dev/-/commit/c9cf798e5f5cc9eea94cafa3bb720108662da18b.patch#/fix_32bit_build.patch
BuildRequires: chrpath
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: gcc-c++ >= 8.0
BuildRequires: libboost_headers-devel
BuildRequires: memory-constraints
%if %{with openmpi}
BuildRequires: openmpi-devel
%endif
BuildRequires: pkg-config
BuildRequires: python3-PyBindGen >= 0.22.1
BuildRequires: python3-pygraphviz
BuildRequires: pkgconfig(gsl)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(python3)
BuildRequires: pkgconfig(sqlite3)
%if %{with openflow}
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_signals-devel
BuildRequires: libboost_system-devel
BuildRequires: openflow-devel
%endif
%description
A discrete-event network simulator for Internet systems, targeted primarily for
research and educational use.
%package helpers
Summary: Discrete-event network simulator - network helpers
Group: Productivity/Scientific/Other
%description helpers
A discrete-event network simulator for Internet systems, targeted primarily for
research and educational use.
This package contains helper binaries with elevated privileges to
setup virtual network interfaces.
%package -n libns%{_version}
Summary: Discrete-event network simulator
Group: Productivity/Scientific/Other
Recommends: %{name}-helpers = %{version}
%description -n libns%{_version}
A discrete-event network simulator for Internet systems, targeted primarily for
research and educational use.
%package -n libns%{_version}-visualizer
Summary: Discrete-event network simulator
Group: Productivity/Scientific/Other
Requires: python-ns3 = %{version}
Requires: typelib(GooCanvas)
Requires: python3-pygraphviz
%description -n libns%{_version}-visualizer
A discrete-event network simulator for Internet systems, targeted primarily for
research and educational use.
%package -n python-ns3
Summary: Python bindings for NS3
Group: Productivity/Scientific/Other
%description -n python-ns3
Python bindings for NS3.
%package devel
Summary: Files needed to create NS3 simulations
Group: Productivity/Scientific/Other
Requires: libns%{_version}
Requires: libns%{_version}-visualizer
%description devel
Files needed to create NS3 simulations.
%prep
%setup -q -n ns-allinone-%{version}
cd ns-%{version}
%autopatch -p1
%build
CFLAGS="${CFLAGS:-%{optflags}}"
CXXFLAGS="${CXXFLAGS:-%{optflags}}"
%ifarch %ix86
# Don't use x87 80-bit temporaries. To start with it breaks the test-suite.
# I could try using FLT_EVAL_METHOD, but that's C++11
CFLAGS="${CFLAGS} -ffloat-store"
CXXFLAGS="${CXXFLAGS} -ffloat-store"
%endif
cd ns-%{version}
export CFLAGS
export CXXFLAGS
%if 0%{with openmpi}
# TODO - setup MPI environment
%error
%endif
%limit_build -m 1000
%cmake \
-DCMAKE_BUILD_TYPE=default \
-DNS3_MPI:BOOL=%{?with_openmpi:ON}%{!?with_openmpi:OFF} \
-DNS3_TESTS:BOOL=ON \
-DNS3_VISUALIZER:BOOL=ON \
-DNS3_PYTHON_BINDINGS:BOOL=ON \
%{nil}
%cmake_build
%install
cd ns-%{version}
%cmake_install
# install target omits bindings: https://gitlab.com/nsnam/ns-3-dev/-/issues/733
mkdir -p %{buildroot}%{python3_sitearch}
cp -R build/bindings/python/ns %{buildroot}%{python3_sitearch}/
cp -R build/bindings/python/visualizer %{buildroot}%{python3_sitearch}/
chrpath --delete %{buildroot}%{python3_sitearch}/ns/_core.so
chrpath --replace '$ORIGIN' %{buildroot}%{python3_sitearch}/ns/[a-z]*.so
# These binaries are not supposed to be run by normal users
mkdir -p %{buildroot}%{_libexecdir}/ns3/
cp build/src/*/ns3*creator-default %{buildroot}%{_libexecdir}/ns3/
%fdupes %{buildroot}%{python3_sitearch}/visualizer/
%check
%ifnarch aarch64
# One TC fails (https://gitlab.com/nsnam/ns-3-dev/-/issues/531), but there is
# no simple method to isolate it
cd ns-%{version}
./test.py --no-build --text /tmp/test-result.txt || (cat /tmp/test-result.txt.txt ; false)
%endif
%post -n libns%{_version} -p /sbin/ldconfig
%postun -n libns%{_version} -p /sbin/ldconfig
%files -n libns%{_version}
%{_libdir}/libns%{version}-*.so
%exclude %{_libdir}/libns%{version}-visualizer-*.so
%files helpers
%dir %{_libexecdir}/ns3
%caps(cap_net_raw=ep) %attr(0755,-,-) %{_libexecdir}/ns3/ns%{version}-raw-sock-creator-default
%caps(cap_net_admin=ep) %attr(0755,-,-) %{_libexecdir}/ns3/ns%{version}-tap-creator-default
%caps(cap_net_admin=ep) %attr(0755,-,-) %{_libexecdir}/ns3/ns%{version}-tap-device-creator-default
%files -n libns%{_version}-visualizer
%{_libdir}/libns%{version}-visualizer-*.so
%{python3_sitearch}/visualizer/
%files -n python-ns3
%{python3_sitearch}/ns/
%files devel
%{_includedir}/ns3/
%{_libdir}/pkgconfig/ns3-*.pc
%{_libdir}/cmake/ns3
%changelog