File netplan.spec of Package netplan

#
# spec file for package netplan
#
# Copyright (c) 2024 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/
#
#!BuildIgnore: dpdk


%define         sover 1
%define         appid io.netplan.Netplan
%bcond_with     tests
Name:           netplan
Version:        1.1.2
Release:        0
Summary:        Declarative network configuration for various backends
License:        GPL-3.0-only
URL:            https://github.com/canonical/netplan
Source0:        %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source99:       %{name}.rpmlintrc
Patch0:         fix-package-naming.patch
Patch1:         https://patch-diff.githubusercontent.com/raw/canonical/netplan/pull/448.patch#/use-stable-python-c-api.patch
Patch2:         fix-versions.patch
Patch3:         fallback-NM.patch
BuildRequires:  cmake
BuildRequires:  gcovr
BuildRequires:  iproute2
BuildRequires:  meson >= 1.3.0
BuildRequires:  openvswitch
BuildRequires:  pandoc-cli
BuildRequires:  pkgconfig
%if 0%{?suse_version} < 1600
BuildRequires:  python311-PyYAML
BuildRequires:  python311-cffi
BuildRequires:  python311-coverage
BuildRequires:  python311-devel
BuildRequires:  python311-netifaces
BuildRequires:  python311-pycodestyle
BuildRequires:  python311-pyflakes
BuildRequires:  python311-pytest
BuildRequires:  python311-pytest-cov
%else
BuildRequires:  python3-PyYAML
BuildRequires:  python3-cffi
BuildRequires:  python3-coverage
BuildRequires:  python3-netifaces
BuildRequires:  python3-pycodestyle
BuildRequires:  python3-pyflakes
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-cov
BuildRequires:  pkgconfig(python3)
%endif
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(bash-completion)
BuildRequires:  pkgconfig(cmocka)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
BuildRequires:  pkgconfig(uuid)
BuildRequires:  pkgconfig(yaml-0.1)
Requires:       lib%{name}%{sover} = %{version}
# This software is called netplan.io in debian/ubuntu
Provides:       netplan.io = %{version}

%description
Netplan is a utility for easily configuring networking on a linux system.
You simply create a YAML description of the required network interfaces and
what each should be configured to do. From this description Netplan will
generate all the necessary configuration for your chosen renderer tool.

%package doc
Summary:        Documentation for %{name}
BuildArch:      noarch

%description doc
%{summary}.

This package ships the documentation for %{name}.

%package devel
Summary:        Development files for %{name}
Requires:       lib%{name}%{sover} = %{version}

%description devel
%{summary}.

This package ships the development files for %{name}.

%package -n lib%{name}%{sover}
Summary:        Library files for %{name}

%description -n lib%{name}%{sover}
%{summary}.

This package ships the library files for %{name}.

%package bash-completion
Summary:        Bash-completions for %{name}
Supplements:    (%{name} and bash-completion)
BuildArch:      noarch

%description bash-completion
%{summary}.

This package ships the bash-completions for %{name}.
%package dbus
Summary:         This ships the dbus parts for %{name}
# requires netplan_cli for now
Requires:        %{name} = %{version}

%description dbus
%{summary}.

This package ships the dbus parts for %{name}
%package generator
Summary:         This ships the generator parts for %{name}

%description generator
%{summary}.

This package ships the generator parts for %{name}
%package -n python3-%{name}
Summary:         Python parts for %{name}

%description -n python3-%{name}
%{summary}.

This package holds the python stuff for %{name}.
%prep
%autosetup -N
%if 0%{?suse_version} < 1600
%patch -P0 -p1
%patch -P1 -p1
%patch -P2 -p1
%patch -P3 -p1
%else
%patch -P0 -p1
%patch -P1 -p1
%patch -P3 -p1
%endif

%build
%meson \
  -Dtesting=true \
  -Dunit_testing=true \
%meson_build

%install
%meson_install

# fix permissions
chmod +x %{buildroot}%{_datadir}/%{name}/%{name}_cli/{,cli/,cli/commands/}*.py
chmod -x %{buildroot}%{_datadir}/%{name}/%{name}_cli/{_features,cli/utils}.py

%if %{with tests}
#tests need systemd(dbus)
%check
%meson_test
%endif

%ldconfig_scriptlets -n lib%{name}%{sover}

%files
%license COPYING
%doc README.md CONTRIBUTING SECURITY.md
%{_sbindir}/%{name}
%{_datadir}/%{name}
%{_mandir}/man?/netplan*.?%{?ext_man}

%files dbus
%dir %{_libexecdir}/%{name}
%{_datadir}/dbus-1/system.d/%{appid}.conf
%{_datadir}/dbus-1/system-services/%{appid}.service
%{_libexecdir}/%{name}/%{name}-dbus

%files generator
%dir %{_libexecdir}/%{name}
%{_prefix}/lib/systemd/system-generators/%{name}
%{_libexecdir}/%{name}/generate

%files -n python3-%{name}
%if 0%{?suse_version} < 1600
%{python311_sitearch}/%{name}
%{python311_sitelib}/%{name}
%pycache_only %{python311_sitelib}/%{name}/__pycache__
%else
%{python_sitearch}/%{name}
%{python_sitelib}/%{name}
%pycache_only %{python_sitelib}/%{name}/__pycache__
%endif

%files doc
%{_datadir}/doc/%{name}

%files -n lib%{name}%{sover}
%{_libdir}/lib%{name}.so.1

%files devel
%{_libdir}/lib%{name}.so
%{_includedir}/%{name}
%{_libdir}/pkgconfig/%{name}.pc

%files bash-completion
%{_datadir}/bash-completion/completions/%{name}

%changelog
openSUSE Build Service is sponsored by