From 1fccc97ee7243374263d37c237899feb9a9653a7 Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 18 Sep 2023 11:54:28 -0700 Subject: [PATCH] [Nvidia] Fix mlnx-sai build failure (#14) Signed-off-by: Vivek Reddy [Nvidia] Enable iproute2 & fix mft build (#16) * Enable iproute2 as the SDK is also built Signed-off-by: Vivek Reddy * [Nvidia] Dont use mkbmdeb method of dkms to build the package Signed-off-by: Vivek Reddy * Added linux image to the Depends section of mft Signed-off-by: Vivek Reddy [Nvidia] [Bookworm] Separate KERNEL_MFT into a new target (#16782) * [Nvidia] Seperate KERNEL_MFT into a new target because of kernel header dependency Signed-off-by: Vivek Reddy * Update linux-kernel submodule Signed-off-by: Vivek Reddy * Fix paralell build problem Signed-off-by: Vivek Reddy --------- Signed-off-by: Vivek Reddy --- platform/mellanox/mft.mk | 10 ++-- platform/mellanox/mft/Makefile | 52 ++++++++++++++------- platform/mellanox/mft/templates/control.j2 | 10 ++++ platform/mellanox/mft/templates/postinst.j2 | 3 ++ platform/mellanox/mft/templates/postrm.j2 | 3 ++ platform/mellanox/mlnx-sai.mk | 2 +- rules/docker-platform-monitor.mk | 2 +- 7 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 platform/mellanox/mft/templates/control.j2 create mode 100644 platform/mellanox/mft/templates/postinst.j2 create mode 100644 platform/mellanox/mft/templates/postrm.j2 diff --git a/platform/mellanox/mft.mk b/platform/mellanox/mft.mk index 5ef30af77c55..2fd01811eae5 100644 --- a/platform/mellanox/mft.mk +++ b/platform/mellanox/mft.mk @@ -31,12 +31,12 @@ export MFT_VERSION MFT_REVISION MFT_FROM_INTERNAL MLNX_MFT_INTERNAL_SOURCE_BASE_ MFT = mft_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb $(MFT)_SRC_PATH = $(PLATFORM_PATH)/mft -SONIC_MAKE_DEBS += $(MFT) -$(MFT)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +MFT_OEM = mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(MFT),$(MFT_OEM))) KERNEL_MFT = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(MFT),$(KERNEL_MFT))) +$(KERNEL_MFT)_SRC_PATH = $(PLATFORM_PATH)/mft +$(KERNEL_MFT)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) -MFT_OEM = mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(MFT),$(MFT_OEM))) +SONIC_MAKE_DEBS += $(MFT) $(KERNEL_MFT) diff --git a/platform/mellanox/mft/Makefile b/platform/mellanox/mft/Makefile index 3139e874cc08..2f331ea879ce 100644 --- a/platform/mellanox/mft/Makefile +++ b/platform/mellanox/mft/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Copyright (c) 2016-2023 NVIDIA CORPORATION & AFFILIATES. # Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,19 +34,46 @@ MFT_TGZ_URL = http://www.mellanox.com/downloads/MFT/$(MFT_TGZ) endif SRC_DEB = kernel-mft-dkms_$(MFT_VERSION)-$(MFT_REVISION)_all.deb -MOD_DEB = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_$(CONFIGURED_ARCH).deb +KERNEL_MFT_TARGET = kernel-mft-dkms-modules-$(KVERSION)_$(MFT_VERSION)_$(CONFIGURED_ARCH).deb MAIN_TARGET = mft_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = $(MOD_DEB) mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = mft-oem_$(MFT_VERSION)-$(MFT_REVISION)_$(CONFIGURED_ARCH).deb -DKMS_BMDEB = /var/lib/dkms/kernel-mft-dkms/$(MFT_VERSION)/bmdeb +DKMS_CTRL = /var/lib/dkms/kernel-mft-dkms/ DKMS_TMP := $(shell mktemp -u -d -t dkms.XXXXXXXXXX) +MFT_TMP = /tmp/mft_build/ + $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + mkdir -p $(MFT_TMP) + pushd $(MFT_TMP) + wget -O $(MFT_TGZ) $(MFT_TGZ_URL) + tar xzf $(MFT_TGZ) + + # fix timestamp + touch $(MFT_NAME)/DEBS/*.deb + mv $(MFT_NAME)/DEBS/*.deb $(DEST) + popd + rm -rf $(MFT_TMP) + +$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) + +$(addprefix $(DEST)/, $(KERNEL_MFT_TARGET)): $(DEST)/% : rm -rf $(MFT_NAME) wget -O $(MFT_TGZ) $(MFT_TGZ_URL) tar xzf $(MFT_TGZ) + # Prepare the directory to build kernel-mft-dkms-modules debian package + mkdir -p $(DKMS_TMP)/DEBIAN + mkdir -p $(DKMS_TMP)/lib/modules/$(KVERSION)/updates/dkms/ + export kversion="$(KVERSION)" + export mft_version="$(MFT_VERSION)" + j2 templates/control.j2 > $(DKMS_TMP)/DEBIAN/control + j2 templates/postinst.j2 > $(DKMS_TMP)/DEBIAN/postinst + j2 templates/postrm.j2 > $(DKMS_TMP)/DEBIAN/postrm + chmod +x $(DKMS_TMP)/DEBIAN/postinst + chmod +x $(DKMS_TMP)/DEBIAN/postrm + pushd $(MFT_NAME)/SDEBS # put a lock here because dpkg does not allow installing packages in parallel @@ -59,15 +86,10 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : popd sudo dkms build kernel-mft-dkms/$(MFT_VERSION) -k $(KVERSION) -a $(CONFIGURED_ARCH) - sudo dkms mkbmdeb kernel-mft-dkms/$(MFT_VERSION) -k $(KVERSION) -a $(CONFIGURED_ARCH) - - # w/a: remove dependencies - mkdir -p $(DKMS_TMP)/DEBIAN - - dpkg -e $(DKMS_BMDEB)/$(MOD_DEB) $(DKMS_TMP)/DEBIAN - dpkg -x $(DKMS_BMDEB)/$(MOD_DEB) $(DKMS_TMP) - sed -i '/^Depends:/c\Depends:' $(DKMS_TMP)/DEBIAN/control + # copy the built modules + cp -r $(DKMS_CTRL)/kernel-$(KVERSION)-$(CONFIGURED_ARCH)/module/*.ko \ + $(DKMS_TMP)/lib/modules/$(KVERSION)/updates/dkms/ pushd $(MFT_NAME)/DEBS dpkg -b $(DKMS_TMP) . @@ -75,8 +97,6 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf $(DKMS_TMP) - # fix timestamp because we do not actually build tools, only kernel - touch $(MFT_NAME)/DEBS/*.deb - mv $(MFT_NAME)/DEBS/*.deb $(DEST) + mv $(MFT_NAME)/DEBS/$(KERNEL_MFT_TARGET) $(DEST) + -$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/platform/mellanox/mft/templates/control.j2 b/platform/mellanox/mft/templates/control.j2 new file mode 100644 index 000000000000..629019b23db4 --- /dev/null +++ b/platform/mellanox/mft/templates/control.j2 @@ -0,0 +1,10 @@ +Package: kernel-mft-dkms-modules-{{kversion}} +Source: kernel-mft-dkms-dkms-bin +Version: {{mft_version}} +Architecture: amd64 +Maintainer: Vivek Reddy +Provides: kernel-mft-dkms-modules +Depends: linux-image-{{ kversion }}-unsigned +Section: misc +Priority: optional +Description: kernel-mft-dkms binary drivers for linux-image-{{kversion}} Kernel diff --git a/platform/mellanox/mft/templates/postinst.j2 b/platform/mellanox/mft/templates/postinst.j2 new file mode 100644 index 000000000000..b0dc57909367 --- /dev/null +++ b/platform/mellanox/mft/templates/postinst.j2 @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +depmod -a {{kversion}} diff --git a/platform/mellanox/mft/templates/postrm.j2 b/platform/mellanox/mft/templates/postrm.j2 new file mode 100644 index 000000000000..b0dc57909367 --- /dev/null +++ b/platform/mellanox/mft/templates/postrm.j2 @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +depmod -a {{kversion}} diff --git a/platform/mellanox/mlnx-sai.mk b/platform/mellanox/mlnx-sai.mk index 0061132941e0..63ee673d9a6e 100644 --- a/platform/mellanox/mlnx-sai.mk +++ b/platform/mellanox/mlnx-sai.mk @@ -3,7 +3,7 @@ MLNX_SAI_VERSION = SAIBuild2211.25.1.4 MLNX_SAI_ASSETS_GITHUB_URL = https://github.com/Mellanox/Spectrum-SDK-Drivers-SONiC-Bins MLNX_SAI_ASSETS_RELEASE_TAG = sai-$(MLNX_SAI_VERSION)-$(BLDENV)-$(CONFIGURED_ARCH) -MLNX_SAI_ASSETS_URL = $(MLNX_ASSETS_GITHUB_URL)/releases/download/$(MLNX_SAI_ASSETS_RELEASE_TAG) +MLNX_SAI_ASSETS_URL = $(MLNX_SAI_ASSETS_GITHUB_URL)/releases/download/$(MLNX_SAI_ASSETS_RELEASE_TAG) MLNX_SAI_DEB_VERSION = $(subst -,.,$(subst _,.,$(MLNX_SAI_VERSION))) # Place here URL where SAI sources exist diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 6652dfe18a05..55923416845a 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -6,7 +6,7 @@ DOCKER_PLATFORM_MONITOR_DBG = $(DOCKER_PLATFORM_MONITOR_STEM)-$(DBG_IMAGE_MARK). $(DOCKER_PLATFORM_MONITOR)_PATH = $(DOCKERS_PATH)/$(DOCKER_PLATFORM_MONITOR_STEM) -$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(MFT) +$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3)