Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Remove external-changes patch if no downstream changes are found #95

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions platform/mellanox/integration-scripts.mk
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,8 @@ endif
git add -- $(PLATFORM_PATH)/non-upstream-patches/
git add -- $(PLATFORM_PATH)/hw-management.mk

echo -en '\n###-> Non Upstream external-changes.patch changes <-###\n' >> ${HWMGMT_USER_OUTFILE}
git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/external-changes.patch >> ${HWMGMT_USER_OUTFILE}

echo -en '\n###-> Non Upstream kconfig-inclusions.patch changes <-###\n' >> ${HWMGMT_USER_OUTFILE}
git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/kconfig-inclusions.patch >> ${HWMGMT_USER_OUTFILE}
echo -en '\n###-> Non Upstream changes <-###\n' >> ${HWMGMT_USER_OUTFILE}
git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/ >> ${HWMGMT_USER_OUTFILE}

echo -en '\n###-> Non Upstream patch list file <-###\n' >> ${HWMGMT_USER_OUTFILE}
git diff --no-color --staged -- $($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hwmgmt_nonup_patches >> ${HWMGMT_USER_OUTFILE}
Expand Down
33 changes: 27 additions & 6 deletions platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +18,7 @@

from hwmgmt_helper import *

COMMIT_TITLE = "Intgerate HW-MGMT {} Changes"
COMMIT_TITLE = "Integrate HW-MGMT {} Changes"

PATCH_TABLE_LOC = "platform/mellanox/hw-management/hw-mgmt/recipes-kernel/linux/"
PATCHWORK_LOC = "linux-{}/patchwork"
Expand Down Expand Up @@ -270,9 +270,15 @@ def rm_old_non_up_mlnx(self):
sys.exit(1)

def mv_new_non_up_mlnx(self):
dest_fpath = os.path.join(self.args.build_root, NON_UP_PATCH_LOC)
if not Data.new_non_up and os.path.exists(dest_fpath):
os.rmdir(dest_fpath)
return

for patch in Data.new_non_up:
src_path = os.path.join(self.args.non_up_patches, patch)
shutil.copy(src_path, os.path.join(self.args.build_root, NON_UP_PATCH_LOC))
os.makedirs(dest_fpath, exist_ok=True)
shutil.copy(src_path, dest_fpath)

def construct_series_with_non_up(self):
Data.agg_slk_series = copy.deepcopy(Data.up_slk_series)
Expand Down Expand Up @@ -309,7 +315,23 @@ def get_series_diff(self):
return lines

def get_merged_diff(self, series_diff: list, kcfg_diff: list) -> list:
return series_diff + ["\n"] + kcfg_diff
if series_diff or kcfg_diff:
return series_diff + ["\n"] + kcfg_diff
else:
return []

def write_non_up_diff(self, series_diff, kcfg_diff):
final_diff = self.get_merged_diff(series_diff, kcfg_diff)
non_up_diff_path = os.path.join(self.args.build_root, NON_UP_DIFF)
if "".join(final_diff).strip():
# don't write anything if the diff just contains whitespaces
FileHandler.write_lines(non_up_diff_path, final_diff, True)
else:
# if nothing to write, delete the patch file
try:
os.remove(non_up_diff_path)
except OSError as error:
print("-> NOTICE File {} remove failed with error {}".format(non_up_diff_path, error))

def list_patches(self):
old_up_patches = []
Expand Down Expand Up @@ -388,8 +410,7 @@ def perform(self):
series_diff = self.get_series_diff()
# handle kconfig and get any diff
kcfg_diff = self.kcfg_handler.perform()
final_diff = self.get_merged_diff(series_diff, kcfg_diff)
FileHandler.write_lines(os.path.join(self.args.build_root, NON_UP_DIFF), final_diff, True)
self.write_non_up_diff(series_diff, kcfg_diff)

path = os.path.join(self.args.build_root, PATCH_TABLE_LOC)
patch_table = load_patch_table(path, Data.k_ver)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -56,7 +56,7 @@
"""

TEST_SLK_COMMIT = """\
Intgerate HW-MGMT 7.0030.0937 Changes
Integrate HW-MGMT 7.0030.0937 Changes
## Patch List
* 0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch : https://github.com/torvalds/linux/commit/cb9744178f33
* 0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch : https://github.com/torvalds/linux/commit/66b0c2846ba8
Expand All @@ -71,7 +71,7 @@
"""

TEST_SB_COMMIT = """\
Intgerate HW-MGMT 7.0030.0937 Changes
Integrate HW-MGMT 7.0030.0937 Changes

"""

Expand Down Expand Up @@ -165,8 +165,8 @@ def test_write_final_diff(self, mock_write_lines):
series_diff = self.action.get_series_diff()
kcfg_diff = self._get_kcfg_incl_diff()
final_diff = self.action.get_merged_diff(series_diff, kcfg_diff)
self.action.write_non_up_diff(series_diff, kcfg_diff)
print("".join(final_diff))
FileHandler.write_lines(os.path.join(self.action.args.build_root, NON_UP_DIFF), final_diff, True)
assert check_file_content(MOCK_INPUTS_DIR+"expected_data/external-changes.patch")

def test_commit_msg(self):
Expand Down