From 812949799829e7c6dd56a200ed7f29fbc1a8fe6b Mon Sep 17 00:00:00 2001 From: xuezhixin Date: Wed, 6 Nov 2024 20:22:50 +0800 Subject: [PATCH] add detection ELF content in abi file --- ...dd-detection-ELF-content-in-abi-file.patch | 46 +++++++++++++++++++ migration-tools.spec | 7 ++- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 0062-add-detection-ELF-content-in-abi-file.patch diff --git a/0062-add-detection-ELF-content-in-abi-file.patch b/0062-add-detection-ELF-content-in-abi-file.patch new file mode 100644 index 0000000..8adf05d --- /dev/null +++ b/0062-add-detection-ELF-content-in-abi-file.patch @@ -0,0 +1,46 @@ +From 0827581dc9f64cfa96601fa36ae1fdc6d8e14dac Mon Sep 17 00:00:00 2001 +From: xuezhixin +Date: Mon, 13 Nov 2023 10:19:04 +0800 +Subject: [PATCH] =?UTF-8?q?ABI=E5=A2=9E=E5=8A=A0ELF=E6=96=87=E4=BB=B6?= + =?UTF-8?q?=E6=A3=80=E6=B5=8B?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + sysmig_agent/Abisystmcompchk.py | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/sysmig_agent/Abisystmcompchk.py b/sysmig_agent/Abisystmcompchk.py +index e442cb5..541e9a8 100644 +--- a/sysmig_agent/Abisystmcompchk.py ++++ b/sysmig_agent/Abisystmcompchk.py +@@ -180,3 +180,25 @@ def logger_init(): + logger.addHandler(fh) + + return logger ++ ++ ++# Check whether it is an ELF file ++def is_ELFfile(filepath, logger): ++ if not os.path.exists(filepath): ++ logger.info('file not exit:' + filepath) ++ return False ++ try: ++ FileStates = os.stat(filepath) ++ FileMode = FileStates[stat.ST_MODE] ++ if not stat.S_ISREG(FileMode) or stat.S_ISLNK(FileMode): ++ return False ++ with open(filepath, 'rb') as f: ++ header = (bytearray(f.read(4)[1:4])).decode(encoding="utf-8") ++ # logger.info("header is {}".format(header)) ++ if header in ["ELF"]: ++ return True ++ except UnicodeDecodeError as e: ++ # logger.info("is_ELFfile UnicodeDecodeError {}".format(filepath)) ++ # logger.info(str(e)) ++ pass ++ return False +-- +2.20.1 + diff --git a/migration-tools.spec b/migration-tools.spec index 59ea0ba..57b4787 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,6 +1,6 @@ Name: migration-tools Version: 1.0.2 -Release: 61 +Release: 62 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: %{name}-%{version}.tar.gz @@ -68,7 +68,7 @@ Patch58: 0058-get-detection-envirnment-process-interface.patch Patch59: 0059-add-kernel-detection-result-to-abi-report.patch Patch60: 0060-add-four-detection-item-to-abi-report.patch Patch61: 0061-detection-abi-log.patch - +Patch62: 0062-add-detection-ELF-content-in-abi-file.patch BuildArch: noarch BuildRequires: systemd @@ -167,6 +167,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Tue Nov 5 2024 xuezhixin - 1.0.2-62 +- 0062-add-detection-ELF-content-in-abi-file.patch + * Tue Nov 5 2024 xuezhixin - 1.0.2-61 - 0061-detection-abi-log.patch -- Gitee