Skip to content

Commit

Permalink
pkg: support rpm build
Browse files Browse the repository at this point in the history
Add script to pack dpdk-vhost-vfe as rpm package.
Install vfe-vhostd/vfe-vhost-cli to /opt/mellanox/dpdk-vhost-vfe/bin.
  • Loading branch information
yajwu committed Mar 6, 2023
1 parent 89a6cd2 commit bd935e0
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pkg/build_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e -x

name=dpdk-vhost-vfe
topdir=/tmp/build_dpdk_topdir
specfile=pkg/$name.spec
[ -z "$VER" ] && VER=`cut -f 3 -d '-' VERSION`
release=`rpm --eval 1%{?dist}`

srctar=$name-$VER.tar.gz
srcrpm=$name-$VER-$release.src.rpm
binrpm=$name-$VER-$release.`uname -m`.rpm
srcrpm_full=$topdir/SRPMS/$srcrpm
binrpm_full=$topdir/RPMS/`uname -m`/$binrpm

mkdir -p ${topdir}/{SOURCES,RPMS,SRPMS,SPECS,BUILD,BUILDROOT}

# generate src.rpm
if [[ ! -f $srcrpm ]] ; then
echo "==== building source rpm package $srcrpm ===="

rm -rf $topdir/SOURCES/$srctar
git archive \
--format=tar.gz --prefix=$name-$VER/ -o $topdir/SOURCES/$srctar HEAD

rpmbuild -bs --define "_topdir $topdir" $specfile

if [ -f $srcrpm_full ]; then
echo "$srcrpm build success"
ls -l $srcrpm_full
else
echo "$srcrpm build fail"
fi

cp $srcrpm_full .

else
echo -e "$srcrpm exists, rm it to regenerate"
fi

# build rpm
if [[ ! -f $binrpm ]] ; then
echo "==== building $binrpm ===="

rpmbuild --rebuild --define "_topdir $topdir" $srcrpm_full

if [ -f $binrpm_full ]; then
echo "$binrpm build success"
ls -l $binrpm_full
else
echo "$binrpm build fail"
fi

cp $binrpm_full .
else
echo -e "$binrpm exists, rm it to regenerate"
fi

185 changes: 185 additions & 0 deletions pkg/dpdk-vhost-vfe.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014 6WIND S.A.
# Copyright 2018 Luca Boccassi <bluca@debian.org>

%undefine _include_gdb_index

%define __arch_install_post QA_SKIP_RPATHS=2 %{__arch_install_post}

# debug symbols add ~300 MB of storage requirement on OBS per target
%define debug_package %{nil}
%bcond_with bluefield

Name: dpdk-vhost-vfe
Version: 0.4
Release: 1%{?dist}
Packager: dev@dpdk.org
URL: http://dpdk.org
Source: http://dpdk.org/browse/dpdk/snapshot/dpdk-vhost-vfe-%{version}.tar.gz

Summary: Data Plane Development Kit core
Group: System Environment/Libraries
License: BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-only

ExclusiveArch: i686 x86_64 aarch64 ppc64 ppc64le armv7l armv7hl

%global dst_prefix /opt/mellanox/dpdk-vhost-vfe
%global dst_lib lib64

%ifarch aarch64
%global machine armv8a
%global target arm64-%{machine}-linux-gcc
%global config arm64-%{machine}-linux-gcc
%else
%ifarch armv7l armv7hl
%global machine armv7a
%global target arm-%{machine}-linux-gcc
%global config arm-%{machine}-linux-gcc
%else
%ifarch ppc64 ppc64le
%global machine power8
%global target ppc_64-%{machine}-linux-gcc
%global config ppc_64-%{machine}-linux-gcc
%else
%global machine default
%global target %{_arch}-%{machine}-linux-gcc
%global config %{_arch}-native-linux-gcc
%endif
%endif
%endif

%define _unpackaged_files_terminate_build 0

BuildRequires: zlib-devel, meson, libev-devel
%if ! 0%{?rhel_version}
BuildRequires: libpcap-devel
%endif
%if 0%{?suse_version}
%ifnarch armv7l armv7hl
BuildRequires: libnuma-devel
%endif
BuildRequires: libelf-devel
BuildRequires: %{kernel_module_package_buildreqs}
%if 0%{?sle_version} >= 150000
BuildRequires: rdma-core-devel
%endif
%else
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
%ifnarch armv7l armv7hl
BuildRequires: numactl-devel
%endif
BuildRequires: elfutils-libelf-devel
BuildRequires: kernel-devel, kernel-headers
%endif
%endif

Requires: libev

%description
DPDK core includes kernel modules, core libraries and tools.
testpmd application allows to test fast packet processing environments
on x86 platforms. For instance, it can be used to check that environment
can support fast path applications such as 6WINDGate, pktgen, rumptcpip, etc.
More libraries are available as extensions in other packages.

%package devel
Summary: Data Plane Development Kit for development
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: pkgconfig(libdpdk) = %{version}-%{release}
%description devel
DPDK devel is a set of makefiles, headers and examples
for fast packet processing on x86 platforms.

%prep
%setup -q
MESON_PARAMS=%{?meson_params}
ENABLED_DRVS="bus/pci,bus/auxiliary,bus/vdev"
ENABLED_DRVS="mempool/bucket,mempool/stack,mempool/ring,$ENABLED_DRVS"
#ENABLED_DRVS="common/mlx5,$ENABLED_DRVS"
#ENABLED_DRVS="net/mlx5,net/vhost,net/virtio,net/af_packet,$ENABLED_DRVS"
#ENABLED_DRVS="vdpa/mlx5,compress/mlx5,regex/mlx5,$ENABLED_DRVS"
#ENABLED_DRVS="gpu/cuda,$ENABLED_DRVS"
ENABLED_DRVS="net/vhost,net/virtio,vdpa/virtio,common/virtio,common/virtio_mi,$ENABLED_DRVS"
disable_drivers () {
enabled_drvs=$1
types=$(ls -d drivers/*/)
for t in $types; do
drivers=$(ls -d "$t"*/)
for d in $drivers; do
enable="False"
OIFS=$IFS; IFS=','
for e in $enabled_drvs; do
if [ -z "${d##*"$e"*}" ]; then enable="True"; fi
done
IFS=$OIFS
if [ "$enable" = "False" ]; then
disabled="$(printf '%s' "$d" | cut -d'/' -f2-),$disabled"
fi
done
done
printf '%s' "$disabled"
}
DISABLED_DRVS=$(disable_drivers "$ENABLED_DRVS")

%if %{with bluefield}
MESON_PARAMS="$MESON_PARAMS --cross-file config/arm/arm64_bluefield_linux_native_gcc"
MACHINE=native
%else
%ifarch aarch64
MACHINE=native
%else
MACHINE=default
%endif
%endif

CFLAGS="$CFLAGS -fcommon -Werror" meson %{target} -Dexamples=vdpa -Dc_args='-DRTE_LIBRTE_VDPA_DEBUG' --debug -Dprefix=%{dst_prefix} -Dlibdir=%{dst_prefix}/%{dst_lib} --includedir=include/dpdk -Dmachine=$MACHINE -Dmax_ethports=1024 -Ddisable_drivers=$DISABLED_DRVS -Dtests=false -Ddrivers_install_subdir=dpdk/pmds --default-library=shared $MESON_PARAMS

%build
%{__ninja} -v -C %{target}

%install
rm -rf %{buildroot}
DESTDIR=%{buildroot} %{__ninja} -v -C %{target} install

# Create ld.so.conf.d entry
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
cat > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf << EOF
%{dst_prefix}/%{dst_lib}
EOF

# Export PKG_CONFIG_PATH
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
cat > %{buildroot}%{_sysconfdir}/profile.d/%{name}-%{_arch}.sh << 'EOF'
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:%{dst_prefix}/%{dst_lib}/pkgconfig
EOF

%files
%dir %{dst_prefix}/%{dst_lib}/dpdk
%dir %{dst_prefix}/%{dst_lib}/dpdk/pmds
%{dst_prefix}/bin/vfe-vhost*
%{dst_prefix}/bin/vhostmgmt
%{dst_prefix}/bin/dpdk-vfe-vdpa
%{dst_prefix}/%{dst_lib}/*.so.*
%{dst_prefix}/%{dst_lib}/dpdk/*/*.so.*
/etc/ld.so.conf.d/%{name}-%{_arch}.conf

%files devel
%{dst_prefix}/include/dpdk
%{dst_prefix}/%{dst_lib}/*.so
%{dst_prefix}/%{dst_lib}/dpdk/*/*.so
%{dst_prefix}/%{dst_lib}/*.a
%{dst_prefix}/%{dst_lib}/pkgconfig/*.pc
/etc/ld.so.conf.d/%{name}-%{_arch}.conf
/etc/profile.d/%{name}-%{_arch}.sh

%post
/sbin/ldconfig
%ifarch %{ix86}
/sbin/depmod
%endif

%postun
/sbin/ldconfig
%ifarch %{ix86}
/sbin/depmod
%endif

0 comments on commit bd935e0

Please sign in to comment.