xref: /spdk/test/common/config/pkgdep/git (revision 18c8b52afa69f39481ebb75711b2f30b11693f9d)
1function install_spdk() {
2	mkdir -p "$GIT_REPOS/spdk_repo/output" || echo "Can not create spdk_repo/output directory."
3
4	if [[ -d $GIT_REPOS/spdk_repo/spdk/.git ]]; then
5		echo "spdk source already present, not cloning"
6		if [[ $OSID != freebsd ]]; then
7			chown -R "$USER:$USER" "$GIT_REPOS/spdk_repo/spdk"
8		fi
9	else
10		git -C "$GIT_REPOS/spdk_repo" clone "${GIT_REPO_SPDK}"
11	fi
12	git --git-dir=$GIT_REPOS/spdk_repo/spdk/.git config submodule.dpdk.url ${GIT_REPO_DPDK}
13	git --git-dir=$GIT_REPOS/spdk_repo/spdk/.git config submodule.intel-ipsec-mb.url ${GIT_REPO_INTEL_IPSEC_MB}
14	git -C "$GIT_REPOS/spdk_repo/spdk" submodule update --init --recursive
15}
16
17function install_refspdk() {
18	local release
19	local output_dir
20	local config_params
21	local rootdir
22	local version
23	# Note to keep cherry-pick'ed commits in proper order
24	local cherry_picks=()
25
26	version=$1
27
28	# Create a reference SPDK build for ABI tests
29	git -C "$GIT_REPOS/spdk_repo/spdk" fetch --tags --force
30
31	if [[ "$version" == "latest" ]]; then
32		release=${REFSPDK_TAG:-$(git -C "$GIT_REPOS/spdk_repo/spdk" tag | sort --version-sort | grep -vE 'rc|pre' | tail -n 1)}
33		output_dir="$GIT_REPOS/spdk_abi_latest"
34	elif [[ "$version" == "LTS" ]]; then
35		release=$(git -C "$GIT_REPOS/spdk_repo/spdk" describe --tags --exclude=LTS LTS)
36		output_dir="$GIT_REPOS/spdk_abi_lts"
37	fi
38
39	rm -rf "$output_dir"
40
41	if [[ ! -d $output_dir ]]; then
42		cp -R "$GIT_REPOS/spdk_repo/spdk" "$output_dir"
43	fi
44
45	git -C "$output_dir" checkout "$release"
46	git -C "$output_dir" submodule update --init
47
48	git -C "$output_dir" config --global user.name "spdk"
49	git -C "$output_dir" config --global user.email "hotpatch@spdk.io"
50
51	release=${release#v}
52
53	if ((gcc_version >= 11)) && eq "$release" 22.05.0; then
54		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13404
55		cherry_picks+=("713506d5da4676b9f900ae59963f6eb50ecdba36")
56	fi
57
58	if ((gcc_version >= 12)); then
59		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13405
60		cherry_picks+=("8c532ae0322edc71003db3e4d3ece138f0f47ef7")
61		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13412
62		cherry_picks+=("98292d1eee805256ff72757de87ef4813f7fb714")
63		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13413
64		cherry_picks+=("862bdb53b984a9ab3fc524bfb253553a2e892753")
65	fi
66
67	if [[ $OSID == "freebsd" ]]; then
68		# Fetch all the branches
69		git -C "$output_dir" fetch origin '+refs/heads/v*:refs/remotes/origin/v*'
70		# Slurp commit from the master and the LTS branch to address changes in the
71		# use of cpu macros under latest freebsd releases (13.x).
72		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13484 - master
73		# https://review.spdk.io/gerrit/c/spdk/spdk/+/13541 - LTS.x
74		case "$version" in
75			latest) eq "$release" 22.05.0 && cherry_picks+=("a83dc0546f838905dbe96605e99811b2f62c0eb5") ;;
76			LTS   ) eq "$release" 22.01.1 && cherry_picks+=("1d1248bd1b0e11896ed5e3fa5ce4a8b94c3d5fd0") ;;
77		esac
78	fi
79
80	for cherry in "${cherry_picks[@]}"; do
81		git -C "$output_dir" cherry-pick "$cherry"
82	done
83
84	# Make sure submodules point at proper commits after cherry-picks are applied
85	git -C "$output_dir" submodule update
86
87	if ((gcc_version >= 11)) && eq "$release" 22.01.1; then
88		if ((gcc_version >= 12)); then
89			# This series is needed to cleany apply https://review.spdk.io/gerrit/c/spdk/spdk/+/12639
90			git -C "$output_dir/libvfio-user" cherry-pick 9ad7474568a6c9f1fbb12fb8048f2083078a8144
91			git -C "$output_dir/libvfio-user" cherry-pick 3779fca8c766b18b6d68feda9ed7958aa60bd4cf
92			git -C "$output_dir/libvfio-user" cherry-pick bc44bd1a246dc95b91faae30defafc3c259f5c4d
93		fi
94		# HACK: We can't apply https://review.spdk.io/gerrit/c/spdk/spdk/+/13506 cleanly under
95		# the LTS, however, we can cherry-pick target commit directly into the submodule.
96		git -C "$output_dir/libvfio-user" cherry-pick b52bff72d4eb646a453d19e19ddbd13ed6111a09
97	fi
98	if ((gcc_version >= 12)); then
99		if eq "$release" 22.01.1 || eq "$release" 22.05.0; then
100			# https://review.spdk.io/gerrit/c/spdk/dpdk/+/13411
101			git -C "$output_dir/dpdk" cherry-pick 66866df9602b024541b7071f5c4142ce47c9f640
102		fi
103	fi
104
105	cat > $HOME/autorun-spdk.conf <<- EOF
106		SPDK_BUILD_SHARED_OBJECT=1
107		SPDK_TEST_AUTOBUILD=1
108		SPDK_TEST_UNITTEST=1
109		SPDK_TEST_BLOCKDEV=1
110		SPDK_TEST_PMDK=1
111		SPDK_TEST_ISAL=1
112		SPDK_TEST_REDUCE=1
113		SPDK_TEST_CRYPTO=1
114		SPDK_TEST_FTL=1
115		SPDK_TEST_OCF=1
116		SPDK_TEST_RAID5=1
117		SPDK_TEST_RBD=1
118		SPDK_RUN_ASAN=1
119		SPDK_RUN_UBSAN=1
120		SPDK_TEST_NVME_PMR=1
121		SPDK_TEST_NVME_SCC=1
122		SPDK_TEST_NVME_BP=1
123		SPDK_TEST_NVME_CUSE=1
124		SPDK_TEST_BLOBFS=1
125		SPDK_TEST_URING=1
126		SPDK_TEST_VFIOUSER=1
127	EOF
128
129	mkdir -p $HOME/output
130
131	(
132		rootdir="$output_dir"
133		source $HOME/autorun-spdk.conf
134		source $output_dir/test/common/autotest_common.sh
135
136		# Prepare separate, fixed, cmdline for the FreeBSD, Issue #1397.
137		if [[ $OSID == freebsd ]]; then
138			config_params="--enable-debug"
139			config_params+=" --without-isal"
140			config_params+=" --with-idxd --disable-unit-tests"
141
142			MAKE=gmake
143		else
144			config_params="$(get_config_params)"
145		fi
146		$output_dir/configure $(echo $config_params | sed 's/--enable-coverage//g') --without-fio
147		if [[ $OSID != freebsd ]]; then
148			$MAKE -C $output_dir $MAKEFLAGS include/spdk/config.h
149			CONFIG_OCF_PATH="$output_dir/ocf" $MAKE -C $output_dir/lib/env_ocf $MAKEFLAGS exportlib O=$output_dir/ocf.a
150			$output_dir/configure $config_params --with-ocf=$output_dir/ocf.a --with-shared --without-fio
151		fi
152		$MAKE -C $output_dir $MAKEFLAGS
153	)
154}
155
156function install_qat() {
157	if ! hash yasm; then
158		install yasm
159	fi
160
161	in_syms() {
162		local syms
163		if [[ -e /proc/kallsyms ]]; then
164			syms=/proc/kallsyms
165		elif [[ -e /boot/System.map-$kernel_ver ]]; then
166			syms=/boot/System.map-$kernel_ver
167		else
168			return 0
169		fi
170
171		grep -q "$1" "$syms"
172	}
173
174	if [[ -e /sys/module/qat_c62x ]]; then
175		sudo modprobe -r qat_c62x || :
176	fi
177	if [[ -d $GIT_REPOS/QAT ]]; then
178		sudo rm -rf "$GIT_REPOS/QAT"
179	fi
180
181	mkdir "$GIT_REPOS/QAT"
182
183	tar -C "$GIT_REPOS/QAT" -xzof - < <(wget -O- "$DRIVER_LOCATION_QAT")
184
185	if ge "$kernel_ver" 5.16.0; then
186		patch --dir="$GIT_REPOS/QAT" -p1
187	fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-dma-mask.patch"
188
189	if ge "$kernel_ver" 5.18.0; then
190		patch --dir="$GIT_REPOS/QAT" -p1
191	fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-default-groups.patch"
192
193	(cd "$GIT_REPOS/QAT" && sudo ./configure --enable-icp-sriov=host && sudo make -j$jobs install)
194
195	if ! sudo service qat_service start; then
196		echo "failed to start the qat service. Something may be wrong with your device or package."
197	fi
198}
199
200function install_rocksdb() {
201	# Rocksdb is installed for use with the blobfs tests.
202	if [ ! -d /usr/src/rocksdb ]; then
203		git clone "${GIT_REPO_ROCKSDB}" "$GIT_REPOS/rocksdb"
204		git -C "$GIT_REPOS/rocksdb" checkout 6.15.fb
205		sudo mv "$GIT_REPOS/rocksdb" /usr/src/
206	else
207		sudo git -C /usr/src/rocksdb checkout 6.15.fb
208		echo "rocksdb already in /usr/src. Not checking out again"
209	fi
210}
211
212function install_fio() {
213	# This version of fio is installed in /usr/src/fio to enable
214	# building the spdk fio plugin.
215	local fio_version="fio-3.28"
216
217	if [ ! -d /usr/src/fio ]; then
218		if [ ! -d fio ]; then
219			git clone "${GIT_REPO_FIO}" "$GIT_REPOS/fio"
220			sudo mv "$GIT_REPOS/fio" /usr/src/
221		else
222			sudo mv "$GIT_REPOS/fio" /usr/src/
223		fi
224		(
225			git -C /usr/src/fio checkout master \
226				&& git -C /usr/src/fio pull \
227				&& git -C /usr/src/fio checkout $fio_version \
228				&& if [ $OSID == 'freebsd' ]; then
229					gmake -C /usr/src/fio -j${jobs} \
230						&& sudo gmake -C /usr/src/fio install
231				else
232					make -C /usr/src/fio -j${jobs} \
233						&& sudo make -C /usr/src/fio install
234				fi
235		)
236	else
237		echo "fio already in /usr/src/fio. Not installing"
238	fi
239}
240
241function install_flamegraph() {
242	# Flamegraph is used when printing out timing graphs for the tests.
243	if [ ! -d /usr/local/FlameGraph ]; then
244		git clone "${GIT_REPO_FLAMEGRAPH}" "$GIT_REPOS/FlameGraph"
245		mkdir -p /usr/local
246		sudo mv "$GIT_REPOS/FlameGraph" /usr/local/FlameGraph
247	else
248		echo "flamegraph already installed. Skipping"
249	fi
250}
251
252function _install_qemu() {
253	local repo=$1
254	local branch=$2
255	local prefix=${3:-}
256
257	mkdir -p "$GIT_REPOS/qemu"
258
259	local repo_dir=$GIT_REPOS/qemu/$branch
260	if [[ -n $prefix ]]; then
261		repo_dir=$GIT_REPOS/qemu/$prefix-$branch
262	fi
263
264	if [[ ! -d $repo_dir ]]; then
265		git clone "$repo" -b "$branch" "$repo_dir"
266	else
267		echo "qemu already checked out. Skipping"
268	fi
269
270	declare -a opt_params=("--prefix=/usr/local/qemu/${repo_dir##*/}")
271	declare -a extra_cflags=()
272
273	opt_params+=("--disable-docs")
274	if ((gcc_version >= 9)); then
275		opt_params+=("--disable-glusterfs")
276	fi
277
278	extra_cflags+=("-Wno-error")
279
280	# Most tsocks proxies rely on a configuration file in /etc/tsocks.conf.
281	# If using tsocks, please make sure to complete this config before trying to build qemu.
282	if [[ $INSTALL_TSOCKS == true && $NO_TSOCKS != true ]]; then
283		if hash tsocks 2> /dev/null; then
284			opt_params+=("--with-git='tsocks git'")
285		fi
286	fi
287	opt_params+=("--extra-cflags=${extra_cflags[*]}")
288
289	if [[ $prefix == vanilla ]]; then
290		# Latest qemu seems to take sysconfdir from the prefix and instead of checking /etc
291		# it looks under /usr/local/qemu/vanilla*/bin/../etc which is a bit peculiar. Fix it.
292		opt_params+=("--sysconfdir=/etc/")
293	fi
294
295	# The qemu configure script places several output files in the CWD.
296	(cd "$repo_dir" && ./configure "${opt_params[@]}" --target-list="x86_64-softmmu" --enable-kvm --enable-linux-aio --enable-numa)
297
298	make -C "$repo_dir" -j${jobs}
299	sudo make -C "$repo_dir" install
300}
301
302function install_qemu() {
303	# Four versions of QEMU are used in the tests, three are installed
304	# directly from the source. Each QEMU is dedicated for different
305	# use-cases:
306	#  - Packed QEMU: version provided by given distro. Used to boot VMs
307	#    from within vhost tests.
308	#  - vfio-user QEMU: A special fork to test libvfio-user components.
309	#  - Vanilla QEMU: Used by the CI to boot the testing VMs.
310
311	_install_qemu $GIT_REPO_QEMU_VFIO $VFIO_QEMU_BRANCH
312	_install_qemu "$GIT_REPO_QEMU" "$VANILLA_QEMU_BRANCH" vanilla
313}
314
315function install_nvmecli() {
316	# nvme-cli >1.11.1 should be used.
317	if [[ ! -d $GIT_REPOS/nvme-cli-cuse ]]; then
318		git clone "https://github.com/linux-nvme/nvme-cli.git" "$GIT_REPOS/nvme-cli-cuse"
319	fi
320	git -C "$GIT_REPOS/nvme-cli-cuse" checkout v2.0
321
322	cflags=("-Wno-error")
323
324	make -C "$GIT_REPOS/nvme-cli-cuse" CFLAGS="${cflags[*]}"
325	if [ -d "/usr/local/src/nvme-cli" ]; then
326		sudo rm -rf /usr/local/src/nvme-cli
327	fi
328	sudo mv "$GIT_REPOS/nvme-cli-cuse" /usr/local/src/nvme-cli
329	# Make sure binary is available for the cuse tests
330	if [[ -e /usr/local/src/nvme-cli/.build/nvme ]]; then
331		sudo ln -s .build/nvme /usr/local/src/nvme-cli/
332	fi
333}
334
335function install_libiscsi() {
336	# We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need
337	# to later. Cloning from git is just future proofing the machines.
338	if [[ ! -d $GIT_REPOS/libiscsi ]]; then
339		git clone "${GIT_REPO_LIBISCSI}" "$GIT_REPOS/libiscsi"
340	else
341		echo "libiscsi already checked out. Skipping"
342	fi
343	(cd "$GIT_REPOS/libiscsi" && ./autogen.sh && ./configure --prefix=/usr/local/libiscsi)
344	make -C "$GIT_REPOS/libiscsi" -j${jobs} WARN_CFLAGS=
345	sudo make -C "$GIT_REPOS/libiscsi" install
346}
347
348function install_git() {
349	if type -P git; then
350		if ge "$(git --version | awk '{print $3}')" "$GIT_VERSION"; then
351			return 0
352		fi
353	fi >/dev/null
354
355	install zlib-devel curl-devel
356	tar -C "$GIT_REPOS" -xzof <(wget -qO- "$GIT_REPO_GIT")
357	(cd "$GIT_REPOS/git-$GIT_VERSION" \
358		&& make configure \
359		&& ./configure --prefix=/usr/local/git \
360		&& sudo make -j${jobs} install)
361	sudo sh -c "echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc"
362	export "PATH=/usr/local/git/bin:$PATH"
363	# Be nice for vagrant-proxyconf setup
364	mkdir -p "/usr/local/git/etc"
365}
366
367function install_extra_pkgs() {
368	if [[ $INSTALL_QAT == true ]]; then
369		install libudev-devel || install libudev-dev || :
370	fi
371
372	if [[ $INSTALL_QEMU == true ]]; then
373		install qemu-system-x86 qemu-img \
374			|| install qemu-system-x86 qemu-utils \
375			|| install qemu \
376			|| :
377	fi
378}
379
380function install_vagrant() {
381	local vagrant_version="2.2.7"
382	local vagrant_installer="vagrant_${vagrant_version}_x86_64.deb"
383	local vagrant_plugins=(vagrant-libvirt vagrant-sshfs vagrant-cachier vagrant-proxyconf)
384
385	if [[ $OSID != ubuntu ]]; then
386		echo "Currently, Vagrant installation is supported only on ubuntu"
387		return 0
388	fi
389
390	# Install vagrant and it's plugins dependencies
391	# function should be defined in pkgdep/$package_manager file
392	install_vagrant_dependencies
393
394	# Download and install vagrant
395	if hash vagrant &> /dev/null; then
396		echo "Vagrant is already installed"
397	else
398		wget "https://releases.hashicorp.com/vagrant/${vagrant_version}/${vagrant_installer}"
399		sudo dpkg -i "${vagrant_installer}"
400	fi
401	vagrant --version
402
403	# Install vagrant plugins
404	local vagrant_plugin_list
405	vagrant_plugin_list=$(vagrant plugin list)
406
407	local plugin
408	for plugin in "${vagrant_plugins[@]}"; do
409		if grep -Fq "$plugin" <<< "$vagrant_plugin_list"; then
410			echo "$plugin already installed"
411		else
412			vagrant plugin install "$plugin"
413		fi
414	done
415}
416
417function install_igb_uio() {
418	git clone "${GIT_REPO_DPDK_KMODS}" "$GIT_REPOS/dpdk-kmods"
419
420	if ge "$kernel_ver" 5.16.0; then
421		patch --dir="$GIT_REPOS/dpdk-kmods" -p1
422	fi < "$rootdir/test/common/config/pkgdep/patches/dpdk_kmods/0001-dma-mask.patch"
423
424	(cd "$GIT_REPOS/dpdk-kmods/linux/igb_uio" && make -j ${jobs})
425	sudo mkdir -p "/lib/modules/$(uname -r)/extra/dpdk"
426	sudo cp "$GIT_REPOS/dpdk-kmods/linux/igb_uio/igb_uio.ko" "/lib/modules/$(uname -r)/extra/dpdk"
427	sudo depmod
428}
429
430function install_irdma() {
431	local RDMA_CORE_VERSION=35.0
432	local RDMA_CORE=https://github.com/linux-rdma/rdma-core/releases/download/v$RDMA_CORE_VERSION/rdma-core-$RDMA_CORE_VERSION.tar.gz
433
434	if [[ $ID != fedora ]]; then
435		echo "Installation of the irdma can be attempted only on Fedora"
436		return 0
437	fi
438
439	# Install extra dependencies needed by the rdma-core-35.0
440	install ninja-build pandoc perl-generators valgrind-devel python-docutils libnl3 libnl3-devel python3-Cython
441
442	rm -rf "$GIT_REPOS/irdma-$IRDMA_VERSION"
443	rm -rf "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION"
444
445	curl -L -o- "$IRDMA_DRIVER" | tar -C "$GIT_REPOS" -xzf -
446	[[ -e $GIT_REPOS/irdma-$IRDMA_VERSION/build.sh ]]
447
448	(
449		cd "$GIT_REPOS/irdma-$IRDMA_VERSION"
450		sed -i "s/IRDMA_FLUSH_DELAY_MS 1500/IRDMA_FLUSH_DELAY_MS 50/" \
451			"$GIT_REPOS/irdma-$IRDMA_VERSION/src/irdma/verbs.h"
452		"$GIT_REPOS/irdma-$IRDMA_VERSION/build.sh"
453	)
454
455	# Fetch and build the rdma-core irdma depends on
456	curl -L -o- "$RDMA_CORE" | tar -C "$GIT_REPOS" -xzf -
457	[[ -e $GIT_REPOS/irdma-$IRDMA_VERSION/libirdma-$RDMA_CORE_VERSION.patch ]]
458
459	patch --dir="$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION" -p2 \
460		< "$GIT_REPOS/irdma-$IRDMA_VERSION/libirdma-$RDMA_CORE_VERSION.patch"
461
462	# Note that paths and the name of the package are hardcoded into .spec, hence they need to stay like this.
463	[[ -e $GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec ]]
464	mkdir -p "$HOME/rpmbuild/"{SOURCES,SPECS}
465	cp "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec" "$HOME/rpmbuild/SPECS"
466
467	# Re-package the source
468	tar -czf "$HOME/rpmbuild/SOURCES/rdma-core-$RDMA_CORE_VERSION.tgz" -C "$GIT_REPOS" "rdma-core-$RDMA_CORE_VERSION"
469
470	# Build the rpms
471	(
472		cd "$HOME/rpmbuild/SPECS"
473		# Make sure stock ninja-build is used
474		PATH="/usr/bin:$PATH" rpmbuild -ba rdma-core.spec
475	)
476
477	# Now, don't install the packages since this will, most likely, conflict with packages already installed
478	# in the system. Instead, simply inform user what the next step is and note what potential issues it may
479	# have with the installation.
480
481	shopt -s nullglob
482	local rpms=("$HOME/rpmbuild/RPMS/x86_64/"*.rpm)
483	shopt -u nullglob
484	((${#rpms[@]} > 0))
485
486	cat <<-EOF
487
488		INFO: rdma-core-$RDMA_CORE_VERSION was successfully built, following packages are
489		available for installation:
490
491		$(printf '  - %s\n' "${rpms[@]##*/}")
492
493		Note that installing the above packages may raise conflicts with their
494		potentially newer versions already installed on the system. Dependent
495		packages may be uninstalled during the process as well. Please, run the
496		following command to finish the installation:
497
498		  $package_manager install [--allowerasing] $HOME/rpmbuild/RPMS/x86_64/*.rpm
499
500	EOF
501}
502
503function install_ice() {
504	rm -rf "$GIT_REPOS/ice-$ICE_VERSION"
505
506	curl -L -o- "$ICE_DRIVER" | tar -C "$GIT_REPOS" -xzf -
507
508	if [[ $OSID == ubuntu && $OSVERSION == 18.04 ]]; then
509		if ge "$kernel_ver" 4.15.0-159; then
510			patch --dir="$GIT_REPOS/ice-$ICE_VERSION" -p1
511		fi < "$rootdir/test/common/config/pkgdep/patches/ice/0001-undef-skb-frag-off.patch"
512	fi
513
514	if ge "$kernel_ver" 5.17.0; then
515		patch --dir="$GIT_REPOS/ice-$ICE_VERSION" -p1
516	fi < "$rootdir/test/common/config/pkgdep/patches/ice/0001-ringparam-incompatible-pointer-types.patch"
517
518	(
519		cd "$GIT_REPOS/ice-$ICE_VERSION/src"
520		sudo make -j"$(nproc)" install
521	)
522}
523
524function install_lcov() {
525	local lcov_version=v1.15
526
527	rm -rf /usr/src/lcov
528	sudo git clone "$GIT_REPO_LCOV" --branch "$lcov_version" /usr/src/lcov
529	(cd /usr/src/lcov; sudo make install)
530}
531
532function install_bpftrace() {
533	install llvm-devel clang-devel cereal-devel gtest-devel gmock-devel cmake
534	rm -rf $GIT_REPOS/bcc
535	rm -rf $GIT_REPOS/bpftrace
536	git clone --recursive $GIT_REPO_BCC $GIT_REPOS/bcc
537	git -C $GIT_REPOS/bcc checkout $BCC_BRANCH
538	git clone --recursive $GIT_REPO_BPFTRACE --branch $BPFTRACE_VERSION $GIT_REPOS/bpftrace
539	mkdir -p $GIT_REPOS/bcc/build $GIT_REPOS/bpftrace/build
540
541	cmake -DCMAKE_BUILD_TYPE=Release -B $GIT_REPOS/bcc/build -S $GIT_REPOS/bcc
542	make -C $GIT_REPOS/bcc/build -j$(nproc)
543	make -C $GIT_REPOS/bcc/build install
544
545	cmake -DCMAKE_BUILD_TYPE=Release -B $GIT_REPOS/bpftrace/build -S $GIT_REPOS/bpftrace
546	make -C $GIT_REPOS/bpftrace/build -j$(nproc)
547	make -C $GIT_REPOS/bpftrace/build install
548}
549
550function install_sources() {
551	if [[ $ID == centos ]] && (( VERSION_ID == 7 )); then
552		# install proper version of the git first
553		install_git
554	fi
555
556	IFS="," read -ra conf_env <<< "$CONF"
557	for conf in "${conf_env[@]}"; do
558		export "INSTALL_${conf^^}=true"
559	done
560
561	if [[ $OSID == freebsd ]]; then
562		jobs=$(($(sysctl -n hw.ncpu) * 2))
563	else
564		jobs=$(($(nproc) * 2))
565		sources+=(
566			install_irdma
567			install_libiscsi
568			install_nvmecli
569			install_qat
570			install_rocksdb
571			install_flamegraph
572			install_qemu
573			install_igb_uio
574			install_ice
575			install_lcov
576			install_bpftrace
577		)
578		install_extra_pkgs
579	fi
580	sources+=(install_fio)
581	sources+=(install_vagrant)
582	sources+=(install_spdk)
583
584	sudo mkdir -p /usr/{,local}/src
585	sudo mkdir -p "$GIT_REPOS"
586
587	for source in "${sources[@]}"; do
588		source_conf=${source^^}
589		if [[ ${!source_conf} == true ]]; then
590			"$source"
591		fi
592	done
593
594	if [[ $INSTALL_REFSPDK == true ]]; then
595		# Serialize builds as refspdk depends on spdk
596		[[ $INSTALL_SPDK != true ]] && install_spdk
597		install_refspdk latest
598		install_refspdk LTS
599	fi
600}
601
602GIT_VERSION=2.25.1
603IRDMA_VERSION=1.7.72
604ICE_VERSION=1.8.8
605BPFTRACE_VERSION=v0.15.0
606
607VFIO_QEMU_BRANCH=${VFIO_QEMU_BRANCH:-vfio-user-irqmask2}
608VANILLA_QEMU_BRANCH=${VANILLA_QEMU_BRANCH:-v7.0.0}
609BCC_BRANCH=${BCC_BRANCH:-6dac27d9}
610
611: ${GIT_REPO_SPDK=https://github.com/spdk/spdk.git}
612export GIT_REPO_SPDK
613: ${GIT_REPO_DPDK=https://github.com/spdk/dpdk.git}
614export GIT_REPO_DPDK
615: ${GIT_REPO_ROCKSDB=https://review.spdk.io/spdk/rocksdb}
616export GIT_REPO_ROCKSDB
617: ${GIT_REPO_FIO=https://github.com/axboe/fio.git}
618export GIT_REPO_FIO
619: ${GIT_REPO_FLAMEGRAPH=https://github.com/brendangregg/FlameGraph.git}
620export GIT_REPO_FLAMEGRAPH
621: ${GIT_REPO_QEMU=https://github.com/qemu/qemu}
622export GIT_REPO_QEMU
623: ${GIT_REPO_QEMU_VFIO=https://github.com/oracle/qemu}
624export GIT_REPO_QEMU_VFIO
625: ${GIT_REPO_LIBISCSI=https://github.com/sahlberg/libiscsi}
626export GIT_REPO_LIBISCSI
627: ${GIT_REPO_INTEL_IPSEC_MB=https://github.com/spdk/intel-ipsec-mb.git}
628export GIT_REPO_INTEL_IPSEC_MB
629: ${DRIVER_LOCATION_QAT=https://downloadmirror.intel.com/729932/QAT.L.4.18.0-00008.tar.gz}
630export DRIVER_LOCATION_QAT
631: ${GIT_REPO_GIT=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz}
632export GIT_REPO_GIT
633: ${GIT_REPO_DPDK_KMODS=http://dpdk.org/git/dpdk-kmods}
634export GIT_REPO_DPDK_KMODS
635: ${IRDMA_DRIVER=https://downloadmirror.intel.com/709709/irdma-$IRDMA_VERSION.tgz}
636export IRDMA_DRIVER
637: ${ICE_DRIVER="https://sourceforge.net/projects/e1000/files/ice%20stable/$ICE_VERSION/ice-$ICE_VERSION.tar.gz"}
638export ICE_DRIVER
639: ${GIT_REPO_LCOV=https://github.com/linux-test-project/lcov}
640export GIT_REPO_LCOV
641: ${GIT_REPO_BCC=https://github.com/iovisor/bcc.git}
642export GIT_REPO_BCC
643: ${GIT_REPO_BPFTRACE=https://github.com/iovisor/bpftrace.git}
644export GIT_REPO_BPFTRACE
645
646GIT_REPOS=${GIT_REPOS:-$HOME}
647
648gcc_version=$(gcc -dumpversion) gcc_version=${gcc_version%%.*}
649if [[ -e /proc/sys/kernel/osrelease ]]; then
650	kernel_ver=$(< /proc/sys/kernel/osrelease)
651fi
652