From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EDA23A0548; Tue, 20 Apr 2021 12:24:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6419441707; Tue, 20 Apr 2021 12:23:56 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id CD1D1416F5 for ; Tue, 20 Apr 2021 12:23:54 +0200 (CEST) IronPort-SDR: aMzq0kNnvG0vk/874HpwTsgJ/gMEajNEQMY9Mhvg4pI9ji6gQjS4bRE719EzZvZL3XRYMWRm+c nVDJluveMKXQ== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="195509112" X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="195509112" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 03:23:44 -0700 IronPort-SDR: 3J7W7P9REu/51N0BWmSCx8zLbwWLt1m+wB1+6M28pNEmYCDTaYU3ZUcoKqcQL4JGupClqnOYRx 0C80GxU+kfNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="616862790" Received: from silpixa00399126.ir.intel.com ([10.237.223.116]) by fmsmga005.fm.intel.com with ESMTP; 20 Apr 2021 03:23:43 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Tue, 20 Apr 2021 11:22:31 +0100 Message-Id: <20210420102232.314452-16-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210420102232.314452-1-bruce.richardson@intel.com> References: <20210401115009.1063844-1-bruce.richardson@intel.com> <20210420102232.314452-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 15/16] devtools: add script to ease backport of renamed files X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" With all the library folders renamed to remove the "librte_" prefix, we need to fixup patches for easier backport, i.e. add back in the prefix for any references to those renamed files. In the script itself we use a general approach to allow other functions to be added in future for other modifications needed to patches. Signed-off-by: Bruce Richardson --- devtools/update_patches.py | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 devtools/update_patches.py diff --git a/devtools/update_patches.py b/devtools/update_patches.py new file mode 100755 index 0000000000..0cff215a96 --- /dev/null +++ b/devtools/update_patches.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +import os +import sys +import shutil +from os.path import abspath, dirname, join + +def fixup_library_renames(contents): + """since library directory names have dropped the 'librte_' prefix, + add those prefixes back in for patches than need it""" + modified = False + + # first get all the DPDK libs to build up replacement list + # stored in function attribute between calls + try: + libdirs = fixup_library_renames.libdirs + except AttributeError: + dpdk_libdir = abspath(join(dirname(sys.argv[0]), '..', 'lib')) + for root, dirs, files in os.walk(dpdk_libdir): + fixup_library_renames.libdirs = dirs + libdirs = dirs + break + + for i in range(len(contents)): + # skip over any lines which don't have lib in it + if not "lib/" in contents[i]: + continue + for d in libdirs: + if f'lib/{d}' in contents[i]: + modified = True + contents[i] = contents[i].replace(f'lib/{d}', f'lib/librte_{d}') + return modified + +def main(): + "takes list of patches off argv and processes each" + for patch in sys.argv[1:]: + modified = False + with open(patch) as f: + contents = f.readlines() + + modified |= fixup_library_renames(contents) + # other functions to change the patch go here + + if not modified: + continue + shutil.copyfile(f'{patch}', f'{patch}.bak') + with open(patch, 'w') as f: + f.writelines(contents) + +if __name__ == "__main__": + main() -- 2.27.0