bbc6dd6
%define srcname nmstate
bbc6dd6
%define libname libnmstate
bbc6dd6
bbc6dd6
Name:           nmstate
59c76c1
Version:        2.2.8
4be409d
Release:        %autorelease
bbc6dd6
Summary:        Declarative network manager API
4cbf66e
License:        LGPLv2+
bbc6dd6
URL:            https://github.com/%{srcname}/%{srcname}
bcc29a1
Source0:        %{url}/releases/download/v%{version}/%{srcname}-%{version}.tar.gz
bcc29a1
Source1:        %{url}/releases/download/v%{version}/%{srcname}-%{version}.tar.gz.asc
9adc7ec
Source2:        https://nmstate.io/nmstate.gpg
878db1a
# We use `dep: dep_name` to prevent rust packaging generate incorect dependency
878db1a
# https://bugzilla.redhat.com/show_bug.cgi?id=2161128
878db1a
# but list Requires manually
878db1a
Patch1:         0001-Workaround-for-Fedora-rust-packaging.patch
8bbb58a
BuildRequires:  patchelf
bbc6dd6
BuildRequires:  python3-devel
bbc6dd6
BuildRequires:  python3-setuptools
61a0975
BuildRequires:  gnupg2
Fernando Fernandez Mancera 5a5dcb9
BuildRequires:  systemd-devel
Fernando Fernandez Mancera 5a5dcb9
BuildRequires:  systemd-rpm-macros
8bbb58a
BuildRequires:  rust-packaging
5f2fc75
BuildRequires:  (crate(clap/cargo) >= 3.1 with crate(clap/cargo) < 4.0)
5f2fc75
BuildRequires:  (crate(clap/default) >= 3.1 with crate(clap/default) < 4.0)
999e4c9
BuildRequires:  (crate(chrono/default) >= 0.4 with crate(chrono/default) < 0.5)
5f2fc75
BuildRequires:  (crate(ctrlc/default) >= 3.2 with crate(ctrlc/default) < 4.0)
5f2fc75
BuildRequires:  (crate(env_logger/default) >= 0.9 with crate(env_logger/default) < 1.0)
8f29f16
BuildRequires:  (crate(ipnet/default) >= 2.5 with crate(ipnet/default) < 3.0)
5f2fc75
BuildRequires:  (crate(libc/default) >= 0.2 with crate(libc/default) < 0.3)
5f2fc75
BuildRequires:  (crate(log/default) >= 0.4 with crate(log/default) < 0.5)
59c76c1
BuildRequires:  (crate(nispor/default) >= 1.2.10 with crate(nispor/default) < 2.0)
8bbb58a
BuildRequires:  (crate(serde/default) >= 1.0 with crate(serde/default) < 2.0)
8bbb58a
BuildRequires:  (crate(serde/derive) >= 1.0 with crate(serde/derive) < 2.0)
8bbb58a
BuildRequires:  (crate(serde_json/default) >= 1.0 with crate(serde_json/default) < 2.0)
5f2fc75
BuildRequires:  (crate(serde_yaml/default) >= 0.9 with crate(serde_yaml/default) < 1.0)
9adc7ec
BuildRequires:  (crate(uuid/v4) >= 1.1 with crate(uuid/v4) < 2.0)
9adc7ec
BuildRequires:  (crate(uuid/v5) >= 1.1 with crate(uuid/v5) < 2.0)
8bbb58a
BuildRequires:  (crate(zbus/default) >= 1.9 with crate(zbus/default) < 2.0)
8bbb58a
BuildRequires:  (crate(zvariant/default) >= 2.10 with crate(zvariant/default) < 3.0)
878db1a
BuildRequires:  (crate(nix/default) >= 0.24 with crate(nix/default) < 0.25)
bbc6dd6
bbc6dd6
%description
d263beb
Nmstate is a library with an accompanying command line tool that manages host
bbc6dd6
networking settings in a declarative manner and aimed to satisfy enterprise
bbc6dd6
needs to manage host networking through a northbound declarative API and multi
bbc6dd6
provider support on the southbound.
bbc6dd6
bbc6dd6
8bbb58a
%package libs
8bbb58a
Summary:        C binding of nmstate
8bbb58a
# Use Recommends for NetworkManager because only access to NM DBus is required,
8bbb58a
# but NM could be running on a different host
8bbb58a
Recommends:     NetworkManager
8bbb58a
# Avoid automatically generated profiles
8bbb58a
Recommends:     NetworkManager-config-server
25aebab
License:        ASL 2.0
8bbb58a
8bbb58a
%description libs
8bbb58a
C binding of nmstate.
8bbb58a
8bbb58a
%package devel
8bbb58a
Summary:        Development files for nmstate
8bbb58a
Group:          Development/Libraries
8bbb58a
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
25aebab
License:        ASL 2.0
8bbb58a
8bbb58a
%description devel
8bbb58a
Development files of nmstate C binding.
8bbb58a
9adc7ec
%package static
9adc7ec
Summary:        Static development files for nmstate
9adc7ec
Group:          Development/Libraries
9adc7ec
Requires:       %{name}-devel%{?_isa} = %{version}-%{release}
9adc7ec
9adc7ec
%description static
9adc7ec
Static C library bindings for nmstate.
8bbb58a
bbc6dd6
%package -n python3-%{libname}
bbc6dd6
Summary:        nmstate Python 3 API library
24dfa16
# Use Recommends for NetworkManager because only access to NM DBus is required,
24dfa16
# but NM could be running on a different host
24dfa16
Recommends:     NetworkManager
d263beb
# Avoid automatically generated profiles
d263beb
Recommends:     NetworkManager-config-server
Gris Ge 4a5bb4e
Recommends:     (nmstate-plugin-ovsdb if openvswitch)
Fernando Fernandez Mancera d88b118
# Use Suggests for NetworkManager-ovs and NetworkManager-team since it is only
Fernando Fernandez Mancera d88b118
# required for OVS and team support
24dfa16
Suggests:       NetworkManager-ovs
Fernando Fernandez Mancera d88b118
Suggests:       NetworkManager-team
8bbb58a
Provides:       nmstate-plugin-ovsdb = %{version}-%{release}
8bbb58a
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
8bbb58a
Obsoletes:      nmstate-plugin-ovsdb < 2.0-1
bbc6dd6
bbc6dd6
%description -n python3-%{libname}
d263beb
This package contains the Python 3 library for Nmstate.
bbc6dd6
ced44e2
%package -n rust-%{name}-devel
ced44e2
Summary:        Rust crate of nmstate
ced44e2
BuildArch:      noarch
ced44e2
ced44e2
%description -n rust-%{name}-devel
ced44e2
This package contains library source intended for building other packages
ced44e2
which use "%{name}" crate.
ced44e2
ced44e2
%package -n rust-%{name}+default-devel
ced44e2
Summary:        Rust crate of nmstate with default feature
ced44e2
BuildArch:      noarch
ced44e2
ced44e2
%description -n rust-%{name}+default-devel
ced44e2
This package contains library source intended for building other packages
ced44e2
which use "%{name}" crate with default feature.
ced44e2
3fd9def
%package -n rust-%{name}+gen_conf-devel
3fd9def
Summary:        Rust crate of nmstate with default feature
3fd9def
BuildArch:      noarch
3fd9def
3fd9def
%description -n rust-%{name}+gen_conf-devel
3fd9def
This package contains library source intended for building other packages
3fd9def
which use "%{name}" crate with gen_conf feature.
3fd9def
3fd9def
%package -n rust-%{name}+query_apply-devel
3fd9def
Summary:        Rust crate of nmstate with default feature
3fd9def
BuildArch:      noarch
878db1a
# https://bugzilla.redhat.com/show_bug.cgi?id=2161128
878db1a
Requires:  (crate(nispor/default) >= 1.2.9 with crate(nispor/default) < 2.0)
878db1a
Requires:  (crate(nix/default) >= 0.24 with crate(nix/default) < 0.25)
878db1a
Requires:  (crate(zbus/default) >= 1.9 with crate(zbus/default) < 2.0)
3fd9def
3fd9def
%description -n rust-%{name}+query_apply-devel
3fd9def
This package contains library source intended for building other packages
3fd9def
which use "%{name}" crate with query_apply feature.
3fd9def
bbc6dd6
%prep
8bbb58a
gpg2 --import --import-options import-export,import-minimal \
8bbb58a
    %{SOURCE2} > ./gpgkey-mantainers.gpg
Fernando Fernandez Mancera dfd9905
gpgv2 --keyring ./gpgkey-mantainers.gpg %{SOURCE1} %{SOURCE0}
9adc7ec
%autosetup -p1
bbc6dd6
8bbb58a
pushd rust
8bbb58a
rm .cargo/config.toml
8bbb58a
%cargo_prep
8bbb58a
popd
8bbb58a
bbc6dd6
%build
8bbb58a
pushd rust
8bbb58a
%cargo_build
8bbb58a
popd
8bbb58a
8bbb58a
pushd rust/src/python
bbc6dd6
%py3_build
8bbb58a
popd
bbc6dd6
bbc6dd6
%install
1b919fd
env SKIP_PYTHON_INSTALL=1 \
1b919fd
    PREFIX=%{_prefix} \
1b919fd
    LIBDIR=%{_libdir} \
9adc7ec
    SYSCONFDIR=%{_sysconfdir} \
1b919fd
    %make_install
8bbb58a
patchelf --set-soname libnmstate.so.2 \
8bbb58a
    %{buildroot}/%{_libdir}/libnmstate.so.%{version}
8bbb58a
8bbb58a
pushd rust/src/python
bbc6dd6
%py3_install
8bbb58a
popd
8bbb58a
59c76c1
# cargo_install has problem on detecting library when running in workspace
59c76c1
# due to bug https://pagure.io/fedora-rust/cargo2rpm/issue/5
59c76c1
# Removing the workspace Cargo.toml will workaround this problem.
59c76c1
rm rust/Cargo.toml
1e1eb1c
pushd rust/src/lib
1e1eb1c
%cargo_install
1e1eb1c
popd
1e1eb1c
bbc6dd6
%files
bbc6dd6
%doc README.md
24dfa16
%doc examples/
d263beb
%{_mandir}/man8/nmstatectl.8*
Gris Ge de9c1d0
%{_mandir}/man8/nmstate-autoconf.8*
9adc7ec
%{_mandir}/man8/nmstate.service.8*
bbc6dd6
%{_bindir}/nmstatectl
Gris Ge de9c1d0
%{_bindir}/nmstate-autoconf
9adc7ec
%{_unitdir}/nmstate.service
9adc7ec
%dir %{_sysconfdir}/%{name}
9adc7ec
%{_sysconfdir}/%{name}/README
bbc6dd6
8bbb58a
%files libs
8bbb58a
%{_libdir}/libnmstate.so.*
8bbb58a
8bbb58a
%files devel
8bbb58a
%{_libdir}/libnmstate.so
8bbb58a
%{_includedir}/nmstate.h
8bbb58a
%{_libdir}/pkgconfig/nmstate.pc
8bbb58a
bbc6dd6
%files -n python3-%{libname}
bbc6dd6
%license LICENSE
bbc6dd6
%{python3_sitelib}/%{libname}
bbc6dd6
%{python3_sitelib}/%{srcname}-*.egg-info/
bbc6dd6
9adc7ec
%files static
9adc7ec
%{_libdir}/libnmstate.a
9adc7ec
ced44e2
%files -n rust-%{name}-devel
ced44e2
%license LICENSE
ced44e2
%{cargo_registry}/%{name}-%{version}/
ced44e2
ced44e2
%files -n rust-%{name}+default-devel
ced44e2
%ghost %{cargo_registry}/%{name}-%{version}/Cargo.toml
ced44e2
3fd9def
%files -n rust-%{name}+gen_conf-devel
3fd9def
%ghost %{cargo_registry}/%{name}-%{version}/Cargo.toml
3fd9def
3fd9def
%files -n rust-%{name}+query_apply-devel
3fd9def
%ghost %{cargo_registry}/%{name}-%{version}/Cargo.toml
3fd9def
1e1eb1c
%changelog
8bbb58a
%autochangelog