File coreemu.spec of Package coreemu
#
# spec file for package coreemu
#
# Copyright (c) 2016-2018, Martin Hauke <mardnh@gmx.de>
#
# 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 use_python %{primary_python}
%define pythons %{primary_python}
%define services core-daemon.service
%define __strip /bin/true
%define __debug_install_post %{nil}
%global debug_package %{nil}
Name: coreemu
Version: 9.2.0
Release: 0
Summary: Common Open Research Emulator for use with network namespaces
License: BSD-2-Clause
Group: System/Emulators/PC
Url: http://www.nrl.navy.mil/itd/ncs/products/core
Source: https://github.com/coreemu/core/archive/release-%{version}.tar.gz
Patch0: configureac-path.diff
BuildRequires: python-rpm-macros
BuildRequires: %{use_python}-pip
BuildRequires: %{use_python}-grpcio >= 1.69.0
BuildRequires: %{use_python}-grpcio-tools >= 1.69.0
BuildRequires: %{use_python}-invoke >= 2.2.0
BuildRequires: %{use_python}-poetry >= 1.2.1
# install_system
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: pkgconf-pkg-config
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: libev-devel
BuildRequires: nftables
BuildRequires: iproute2
BuildRequires: tk
BuildRequires: ethtool
BuildRequires: bash
# build_core
BuildRequires: procps
# poetry
BuildRequires: %{use_python}-Fabric >= 3.2.2
BuildRequires: %{use_python}-lxml >= 5.2.2
BuildRequires: %{use_python}-netaddr >= 0.10.1
BuildRequires: %{use_python}-protobuf >= 5.29.3
BuildRequires: %{use_python}-pyproj >= 3.6.1
BuildRequires: %{use_python}-Mako >= 1.2.3
#>= 11.1.0
BuildRequires: %{use_python}-PyYAML
# ospf-mdr
BuildRequires: libtool
BuildRequires: gawk
BuildRequires: readline-devel
#
Recommends: quagga
Requires: %{use_python}-netaddr
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
The Common Open Research Emulator provides Python modules and a GUI for
building virtual networks using Linux network namespace containers and bridging.
%prep
%autosetup -n core-release-%{version}
%build
python3 -m venv --system-site-packages venv
source ./venv/bin/activate
./bootstrap.sh
./configure --prefix=/usr
make %{?_smp_mflags}
# install poetry
cd daemon
mkdir -p ./core_venv/venv
export CORE_VENV_PATH=./core_venv/venv
python3 -m venv --system-site-packages $CORE_VENV_PATH
%pyproject_wheel
%install
cd daemon
install -d %{buildroot}%{_bindir}
TMP_FILE=$(mktemp)
echo '#!/bin/bash' >> $TMP_FILE
echo 'exec "{CORE_VENV_PYTHON}" "$@"' >> $TMP_FILE
install -m 0755 $TMP_FILE %{buildroot}%{_bindir}/core-python
rm -f $TMP_FILE
%pyproject_install
cd ..
%make_install
install -d %{buildroot}%{_sysconfdir}
install -d %{buildroot}%{_sysconfdir}/core
cp -r --update=none package/etc/* %{buildroot}%{_sysconfdir}/core
install -d %{buildroot}%{_datadir}
cp -r package/share %{buildroot}%{_datadir}/core
install -d %{buildroot}/%{_unitdir}
SERVICE_FILE="
[Unit]
Description=Common Open Research Emulator Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/core-daemon
TasksMax=infinity
[Install]
WantedBy=multi-user.target
"
echo "$SERVICE_FILE" > %{buildroot}/%{_unitdir}/core-daemon.service
chmod 644 %{buildroot}/%{_unitdir}/core-daemon.service
%pre
%service_add_pre %{services}
%post
%service_add_post %{services}
%preun
%service_del_preun %{services}
%postun
%service_del_postun %{services}
%check
%files
%config %{_sysconfdir}/core
#%config %{_sysconfdir}/core/core.conf
#%config %{_sysconfdir}/core/logging.conf
%{_unitdir}/core-daemon.service
%{_datadir}/core
%{_bindir}/vcmd
%{_bindir}/vnoded
%{_bindir}/netns
%{_bindir}/core-cleanup
%{_bindir}/core-cli
%{_bindir}/core-daemon
%{_bindir}/core-gui
%{_bindir}/core-player
%{_bindir}/core-python
%{_bindir}/core-route-monitor
%{_bindir}/core-service-update
%{python_sitelib}/core
%{python_sitelib}/core-%{version}.dist-info
%changelog