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