diff --git a/Makefile.work b/Makefile.work index b81ac591246f..4e46e940b71b 100644 --- a/Makefile.work +++ b/Makefile.work @@ -229,6 +229,7 @@ showtag: init : @git submodule update --init --recursive @git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' + @sh inv_build/apply_patch.sh .ONESHELL : reset reset : diff --git a/inv_build/apply_patch.sh b/inv_build/apply_patch.sh new file mode 100755 index 000000000000..cedceae770e2 --- /dev/null +++ b/inv_build/apply_patch.sh @@ -0,0 +1,89 @@ +#!/bin/bash +## This script is to apply inventec own patch to SONiC + +BASE_PATH=$(pwd) +INV_PATCH_DIR=$BASE_PATH/inv_build/patch_files + +if [ ! -d ${INV_PATCH_DIR}/* ]; then + exit 0 +fi + +# Find each submodule need to patch +echo "[INFO] start to apply patch in different module" +for entry in $INV_PATCH_DIR/* +do + if [ ! -d $entry ]; then + continue + fi + + SUB_MODULE="$(basename $entry)" + + if [ "$SUB_MODULE" = "README" ]; then + continue + elif [ "$SUB_MODULE" = "sonic-buildimage" ]; then + echo + echo "=== apply patch to $SUB_MODULE ===" + seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series" + exec < ${seriesfile} + + while read line + do + content=$(echo $line | awk /#/'{print $1}') + if [ "$content" = "#" ]; then + continue + fi + + content=$(echo $line | awk /CodeBase/'{print $1}') + if [ "$content" = "[CodeBase]" ]; then + content=$(echo $line | awk '{print $NF}') + continue + fi + + content=$(echo $line | awk /order/'{print $1}') + if [ "$content" = "[order]" ]; then + continue + fi + + git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line + echo $line + + done + echo + else + cd src/$SUB_MODULE + echo "=== apply patch to ${SUB_MODULE} ===" + CURRENT_HEAD="$(git rev-parse HEAD)" + seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series" + exec < ${seriesfile} + + while read line + do + content=$(echo $line | awk /#/'{print $1}') + if [ "$content" = "#" ]; then + continue + fi + + content=$(echo $line | awk /CodeBase/'{print $1}') + if [ "$content" = "[CodeBase]" ]; then + TARGET_VERSION=$(echo $line | awk '{print $NF}') + if [ "$CURRENT_HEAD" != "$TARGET_VERSION" ]; then + echo "error --> $SUB_MODULE:Target version $TARGET_VERSION not match current $CURRENT_HEAD" + break + fi + continue + fi + + content=$(echo $line | awk /order/'{print $1}') + if [ "$content" = "[order]" ]; then + continue + fi + + git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line + + done + echo + fi + + cd $BASE_PATH + echo "already executed make init and patched files" > ${INV_PATCH_DIR}/already_patched +done diff --git a/inv_build/patch_files/sonic-platform-daemons/[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch b/inv_build/patch_files/sonic-platform-daemons/[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch new file mode 100644 index 000000000000..496451450006 --- /dev/null +++ b/inv_build/patch_files/sonic-platform-daemons/[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch @@ -0,0 +1,30 @@ +From 8fcfd356b0bbfd81329e4b7a0aea5d6196cc4349 Mon Sep 17 00:00:00 2001 +From: James Huang +Date: Fri, 6 Mar 2020 15:27:00 +0800 +Subject: [PATCH] [xcvrd] Retrieve DOM info using platform API 2.0 if + implemented #48 + +--- + sonic-xcvrd/scripts/xcvrd | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/sonic-xcvrd/scripts/xcvrd b/sonic-xcvrd/scripts/xcvrd +index c491375..0347c65 100644 +--- a/sonic-xcvrd/scripts/xcvrd ++++ b/sonic-xcvrd/scripts/xcvrd +@@ -143,8 +143,10 @@ def _wrapper_get_transceiver_dom_info(physical_port): + + def _wrapper_get_transceiver_dom_threshold_info(physical_port): + if platform_chassis is not None: +- return None +- ++ try: ++ return platform_chassis.get_sfp(physical_port).get_transceiver_threshold_info() ++ except NotImplementedError: ++ pass + return platform_sfputil.get_transceiver_dom_threshold_info_dict(physical_port) + + def _wrapper_get_transceiver_change_event(timeout): +-- +2.7.4 + diff --git a/inv_build/patch_files/sonic-platform-daemons/series b/inv_build/patch_files/sonic-platform-daemons/series new file mode 100644 index 000000000000..b5834e521347 --- /dev/null +++ b/inv_build/patch_files/sonic-platform-daemons/series @@ -0,0 +1,4 @@ +# This series applies to sonic-platform-daemons GIT commit +[CodeBase] a34ba131f618a8df6beec1f548aa08f9cedc48db +[order] +[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch