aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build_dpdk1802.sh
blob: 1ed84bb82963018414f1926c73c9b1fd18594e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash -x
#########################################################################
#
# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#########################################################################

echo "check whether dpdk installed"
cur_directory=${PWD}
check_dpdk=$(rpm -qa | grep dpdk-devel)
if [ -z "$check_dpdk"  ]; then
    echo "system will install the dpdk"
else
    echo "system has installed the dpdk"
    echo "$check_dpdk"
    exit 0
fi

cd ~
mkdir -p rpmbuild/SOURCES

cd ~/rpmbuild/SOURCES

if [ ! -s dpdk-18.02.tar.gz ]; then
wget http://dpdk.org/browse/dpdk/snapshot/dpdk-18.02.tar.gz
fi

tar xzvf dpdk-18.02.tar.gz
cp dpdk-18.02/pkg/dpdk.spec ~/rpmbuild/SOURCES/

echo "modify the spec"

#get rid of the dependence of texlive-collection
sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec

#delete something of generating doc
sed -i '/%{target} doc/s/^/#&/' dpdk.spec
sed -i '98d' dpdk.spec
sed -i '97a      datadir=%{_datadir}/dpdk' dpdk.spec
sed -i '98a #      datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec
sed -i '/%files doc/s/^/#&/' dpdk.spec
sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec

sed -i '82a sed -i '\''s!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1'\'' config/common_base' dpdk.spec
sed -i '83a sed -i '\''s!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1'\'' config/common_base' dpdk.spec
sed -i '84a sed -i '\''s!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1'\'' config/common_base' dpdk.spec
sed -i '85a sed -i '\''s!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1'\'' config/common_base' dpdk.spec

#disable KNI mode by default
sed -i '93a sed -ri '\''s!CONFIG_RTE_LIBRARY_KNI=.*!CONFIG_RTE_LIBRARY_KNI=n!1'\'' %{target}/.config' dpdk.spec
sed -i '94a sed -ri '\''s!CONFIG_RTE_LIBRARY_PMD_KNI=.*!CONFIG_RTE_LIBRARY_PMD_KNI=n!1'\'' %{target}/.config' dpdk.spec
sed -i '95a sed -ri '\''s!CONFIG_RTE_KNI_KMOD=.*!CONFIG_RTE_KNI_KMOD=n!1'\'' %{target}/.config' dpdk.spec
sed -i '96a sed -ri '\''s!CONFIG_RTE_KNI_PREEMPT_DEFAULT=.*!CONFIG_RTE_KNI_PREEMPT_DEFAULT=n!1'\'' %{target}/.config' dpdk.spec

echo "build the dependence"
#sudo yum-builddep -y dpdk.spec
sudo yum install -y  libpcap-devel python-sphinx inkscape


echo "generate the rpm package"
rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}"
if [ $? -eq 0 ]; then
	echo "rpm build success"
else
	echo "rpm build error"
	exit
fi

echo "install the rpm"
cd ../RPMS/x86_64/
sudo rpm -ivh dpdk-18.02-1.x86_64.rpm || exit 1
sudo rpm -ivh dpdk-devel-18.02-1.x86_64.rpm || exit 1

mkdir -p /tmp/dpdk/drivers/
cp -f /usr/lib64/librte_mempool_ring.so /tmp/dpdk/drivers/

cd ${cur_directory}