LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File ns3.spec of Package ns3 (Project home:RedDwarf)

#
# spec file for package ns3
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%define _version %(echo %{version} | sed 's/\\./_/g')

Name:           ns3
Version:        3.17
Release:        0
Summary:        Discrete-event network simulator
License:        GPL-2.0
Group:          Productivity/Scientific/Other
Url:            https://www.nsnam.org/
Source0:        ns-%{version}.tar.bz2
Patch0:         ns3-3.17-pybindgen_version.patch
# https://www.nsnam.org/bugzilla/show_bug.cgi?id=1595
Patch1:         ns3-3.17-dsr_not_implemented.patch
Patch2:         ns3-3.17-force_nsc.patch
Patch3:         ns3-3.17-pkg_config.patch
Patch4:         ns3-3.17-tests.patch
Patch5:         ns3-3.17-release_debug.patch
Patch6:         ns3-3.17-overlinking.patch
Patch7:         ns3-3.17-libexec.patch
Patch8:         ns3-3.17-no_python_build_dependencies.patch
BuildRequires:  boost-devel
BuildRequires:  c++_compiler
BuildRequires:  openmpi-devel
BuildRequires:  pkg-config
BuildRequires:  python-PyBindGen
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(python)
BuildRequires:  pkgconfig(sqlite3)

%description
A discrete-event network simulator for Internet systems, targeted primarily for
research and educational use.

%package -n libns%{_version}
Summary:        Discrete-event network simulator
Group:          Productivity/Scientific/Other
Requires(posttrans): /sbin/setcap

%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-goocanvas
Requires:       python-ns3 = %{version}
Requires:       python-pygraphviz
Recommends:     python-gnomedesktop
Recommends:     python-kiwi-gtk

%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-%{version}
%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6
%patch7
%patch8

%build
export CFLAGS="${CFLAGS:-%{optflags}}"
export CXXFLAGS="${CXXFLAGS:-%{optflags}}"
./waf configure --build-profile release \
                --prefix=%{_prefix} \
                --libdir=%{_libdir} \
                --libexecdir=%{_libdir} \
                --enable-mpi \
                --force-planetlab \
                --with-nsc=%{_libdir}/nsc/ \
                --enable-tests
./waf %{?jobs:-j%jobs} -v

%install
./waf install --destdir=%{buildroot}
# The test library is a fucking empty one!
rm %{buildroot}%{_libdir}/pkgconfig/libns%{version}-test.pc
# RPM uses Requires.private, and in this specific case it shouldn't
sed -i '/^Requires.private/d' %{buildroot}%{_libdir}/pkgconfig/libns%{version}-*.pc
# At least NetAnim Designer searchs for the unversioned pkg-config
for FILE in %{buildroot}%{_libdir}/pkgconfig/libns%{version}-*.pc; do
  UNVERSIONED=$(echo $FILE | sed 's_/libns%{version}-_/libns3-_')
  ln -s $(basename $FILE) $UNVERSIONED
done
# They don't seem very useful. And I'm tired of fixing things (ns3-test.so dependency)
rm %{buildroot}%{_bindir}/ns%{version}-bench-packets
rm %{buildroot}%{_bindir}/ns%{version}-bench-simulator
rm %{buildroot}%{_bindir}/ns%{version}-print-introspected-doxygen
# These binaries are not supposed to be run by normal users
# Moving to %%{_libdir} instead of %%{_libexecdir} to allow multiarch
mkdir -p %{buildroot}%{_libdir}/ns%{version}/
mv %{buildroot}%{_bindir}/ns%{version}-* %{buildroot}%{_libdir}/ns%{version}/

%check
%ifarch %ix86
# The "average" test fails in x86
./test.py || true
%else
./test.py
%endif

%post -n libns%{_version} -p /sbin/ldconfig

%postun -n libns%{_version} -p /sbin/ldconfig

%posttrans -n libns%{_version}
setcap cap_net_raw=ep %{_libdir}/ns%{version}/ns%{version}-emu-sock-creator \
       cap_net_raw=ep %{_libdir}/ns%{version}/ns%{version}-raw-sock-creator \
       cap_net_admin=ep %{_libdir}/ns%{version}/ns%{version}-planetlab-tap-creator \
       cap_net_admin=ep %{_libdir}/ns%{version}/ns%{version}-tap-creator \
       cap_net_admin=ep %{_libdir}/ns%{version}/ns%{version}-tap-device-creator

%files -n libns%{_version}
%defattr(0644, root, root, 0755)
%{_libdir}/libns%{version}-*.so
%exclude %{_libdir}/libns%{version}-visualizer.so
%attr(0755,-,-) %{_libdir}/ns%{version}/
# rpmbuild in 12.3 crashes when using capabilities
#%dir %{_libdir}/ns%{version}/
#%caps(cap_net_raw=ep) %attr(0755,-,-) %{_libdir}/ns%{version}/ns%{version}-emu-sock-creator
#%caps(cap_net_raw=ep) %attr(0755,-,-) %{_libdir}/ns%{version}/ns%{version}-raw-sock-creator
#%caps(cap_net_admin=ep) %attr(0755,-,-) %{_libdir}/ns%{version}/ns%{version}-planetlab-tap-creator
#%caps(cap_net_admin=ep) %attr(0755,-,-) %{_libdir}/ns%{version}/ns%{version}-tap-creator
#%caps(cap_net_admin=ep) %attr(0755,-,-) %{_libdir}/ns%{version}/ns%{version}-tap-device-creator

%files -n libns%{_version}-visualizer
%defattr(0644, root, root, 0755)
%{_libdir}/libns%{version}-visualizer.so
%{python_sitearch}/visualizer/

%files -n python-ns3
%defattr(0644, root, root, 0755)
%{python_sitearch}/ns/

%files devel
%defattr(0644, root, root, 0755)
%{_includedir}/ns%{version}/
%{_libdir}/pkgconfig/libns3-*.pc
%{_libdir}/pkgconfig/libns%{version}-*.pc

%changelog