2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2021 Intel Corporation
8 from os.path import abspath, dirname, join
10 def fixup_library_renames(contents):
11 """since library directory names have dropped the 'librte_' prefix,
12 add those prefixes back in for patches than need it"""
15 # first get all the DPDK libs to build up replacement list
16 # stored in function attribute between calls
18 libdirs = fixup_library_renames.libdirs
19 except AttributeError:
20 dpdk_libdir = abspath(join(dirname(sys.argv[0]), '..', 'lib'))
21 for root, dirs, files in os.walk(dpdk_libdir):
22 fixup_library_renames.libdirs = dirs
26 for i in range(len(contents)):
27 # skip over any lines which don't have lib in it
28 if not "lib/" in contents[i]:
31 if f'lib/{d}' in contents[i]:
33 contents[i] = contents[i].replace(f'lib/{d}', f'lib/librte_{d}')
37 "takes list of patches off argv and processes each"
38 for patch in sys.argv[1:]:
40 with open(patch) as f:
41 contents = f.readlines()
43 modified |= fixup_library_renames(contents)
44 # other functions to change the patch go here
48 shutil.copyfile(f'{patch}', f'{patch}.bak')
49 with open(patch, 'w') as f:
50 f.writelines(contents)
52 if __name__ == "__main__":