107 lines
3.1 KiB
RPMSpec
107 lines
3.1 KiB
RPMSpec
%bcond_with check
|
|
%global __cargo_skip_build 0
|
|
Name: nispor
|
|
Version: 1.0.1
|
|
Release: 2
|
|
Summary: Unified interface for Linux network state querying
|
|
License: ASL 2.0
|
|
URL: https://github.com/nispor/nispor
|
|
Source: https://github.com/nispor/nispor/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
|
ExclusiveArch: aarch64 x86_64 riscv64
|
|
BuildRequires: make pkg-config python3-devel rust-packaging systemd-devel openEuler-rpm-config
|
|
|
|
%description
|
|
Unified interface for Linux network state querying.
|
|
|
|
%package -n python3-%{name}
|
|
Summary: %{summary}
|
|
Requires: nispor = %{?epoch:%{epoch}:}%{version}-%{release}
|
|
BuildArch: noarch
|
|
%description -n python3-%{name}
|
|
This package contains python3 binding of %{name}.
|
|
|
|
%package devel
|
|
Summary: %{summary}
|
|
Requires: nispor%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
|
|
%description devel
|
|
This package contains C binding of %{name}.
|
|
|
|
%prep
|
|
%autosetup -n %{name}-%{version} -p1
|
|
|
|
%cargo_prep
|
|
_FLAGS=`sed -ne 's/rustflags = "\(.\+\)"/\1/p' .cargo/config.toml`
|
|
sed -i -e "s/rustflags = \[\(.\+\), \]$/rustflags = [\1, \"$_FLAGS\"]/" \
|
|
.cargo/config
|
|
|
|
%build
|
|
sed -i '/\[source.crates-io\]/{n;d}' ./.cargo/config
|
|
sed -i '/\[source.local-registry\]/{n;d}' ./.cargo/config
|
|
sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config
|
|
%cargo_build
|
|
pushd src/python
|
|
%py3_build
|
|
popd
|
|
|
|
%install
|
|
pushd src/lib
|
|
%__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x "$(printf 'lib\nrlib\nproc-macro')"
|
|
CRATE_NAME=$(%__cargo_inspector --name Cargo.toml)
|
|
CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml)
|
|
REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION
|
|
%{__mkdir} -p $REG_DIR
|
|
mv Cargo.toml{,.deps}
|
|
awk '/^\[((.+\.)?((dev|build)-)?dependencies|features)/{f=1;next} /^\[/{f=0}; !f' Cargo.toml.deps > Cargo.toml
|
|
/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 /usr/bin/cargo package -l | grep -w -E -v 'Cargo.(lock|toml.orig)'| xargs -d '\n' /usr/bin/cp --parents -a -t $REG_DIR
|
|
/usr/bin/mv Cargo.toml{.deps,}
|
|
/usr/bin/cp -a Cargo.toml $REG_DIR/Cargo.toml
|
|
/usr/bin/rm -f $REG_DIR/Cargo.toml.deps
|
|
echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json
|
|
popd
|
|
env SKIP_PYTHON_INSTALL=1 PREFIX=%{_prefix} LIBDIR=%{_libdir} %make_install
|
|
pushd src/python
|
|
%py3_install
|
|
popd
|
|
rm -rf %{buildroot}%{cargo_registry}/%{name}-%{version}/
|
|
|
|
%post
|
|
%systemd_post nispor.service
|
|
|
|
%preun
|
|
%systemd_preun nispor.service
|
|
|
|
%postun
|
|
%systemd_postun_with_restart nispor.service
|
|
|
|
%if %{with check}
|
|
|
|
%check
|
|
%cargo_test
|
|
%endif
|
|
|
|
%files
|
|
%doc AUTHORS CHANGELOG DEVEL.md README.md
|
|
%license LICENSE
|
|
%{_bindir}/npc
|
|
%{_bindir}/npd
|
|
%{_libdir}/libnispor.so.*
|
|
%{_unitdir}/nispor.socket
|
|
%{_unitdir}/nispor.service
|
|
|
|
%files -n python3-%{name}
|
|
%license LICENSE
|
|
%{python3_sitelib}/nispor*
|
|
|
|
%files devel
|
|
%license LICENSE
|
|
%{_libdir}/libnispor.so
|
|
%{_includedir}/nispor.h
|
|
%{_libdir}/pkgconfig/nispor.pc
|
|
|
|
%changelog
|
|
* Fri Mar 24 2023 misaka00251 <liuxin@iscas.ac.cn> - 1.0.1-2
|
|
- Add riscv64 to ExclusiveArch
|
|
|
|
* Mon Sep 13 2021 huanghaitao <huanghaitao8@huawei.com> - 1.0.1-1
|
|
- package init
|