From 8285a1c0ce6ec1995f84d2a9beae899bd5868c0d Mon Sep 17 00:00:00 2001 From: "suyun@aosc.io" Date: Thu, 13 Jun 2024 10:55:17 +0800 Subject: [PATCH] binwalk: update to 2.4.1. --- srcpkgs/binwalk/patches/fix-2.3.3-test.patch | 14 --- srcpkgs/binwalk/patches/python-3.10.patch | 22 ----- srcpkgs/binwalk/patches/python-3.12.patch | 90 -------------------- srcpkgs/binwalk/template | 10 +-- 4 files changed, 5 insertions(+), 131 deletions(-) delete mode 100644 srcpkgs/binwalk/patches/fix-2.3.3-test.patch delete mode 100644 srcpkgs/binwalk/patches/python-3.10.patch delete mode 100644 srcpkgs/binwalk/patches/python-3.12.patch diff --git a/srcpkgs/binwalk/patches/fix-2.3.3-test.patch b/srcpkgs/binwalk/patches/fix-2.3.3-test.patch deleted file mode 100644 index bce5ed7c8f3984..00000000000000 --- a/srcpkgs/binwalk/patches/fix-2.3.3-test.patch +++ /dev/null @@ -1,14 +0,0 @@ -https://github.com/ReFirmLabs/binwalk/issues/566 -https://github.com/ReFirmLabs/binwalk/issues/569 - ---- a/testing/tests/test_firmware_zip.py -+++ b/testing/tests/test_firmware_zip.py -@@ -10,6 +10,8 @@ - ''' - expected_results = [ - [0, 'Zip archive data, at least v1.0 to extract, name: dir655_revB_FW_203NA/'], -+ [51, 'Zip archive data, at least v2.0 to extract, compressed size: 6395868, uncompressed size: 6422554, name: dir655_revB_FW_203NA/DIR655B1_FW203NAB02.bin'], -+ [6395993, 'Zip archive data, at least v2.0 to extract, compressed size: 14243, uncompressed size: 61440, name: dir655_revB_FW_203NA/dir655_revB_release_notes_203NA.doc'], - [6410581, 'End of Zip archive, footer length: 22'], - - ] diff --git a/srcpkgs/binwalk/patches/python-3.10.patch b/srcpkgs/binwalk/patches/python-3.10.patch deleted file mode 100644 index c9ab6cdd0fbe71..00000000000000 --- a/srcpkgs/binwalk/patches/python-3.10.patch +++ /dev/null @@ -1,22 +0,0 @@ -Index: binwalk-2.3.3/src/binwalk/modules/extractor.py -=================================================================== ---- binwalk-2.3.3.orig/src/binwalk/modules/extractor.py -+++ binwalk-2.3.3/src/binwalk/modules/extractor.py -@@ -966,7 +966,7 @@ class Extractor(Module): - - # Fork a child process - child_pid = os.fork() -- if child_pid is 0: -+ if child_pid == 0: - # Switch to the run-as user privileges, if one has been set - if self.runas_uid is not None and self.runas_gid is not None: - os.setgid(self.runas_uid) -@@ -981,7 +981,7 @@ class Extractor(Module): - rval = subprocess.call(shlex.split(command), stdout=tmp, stderr=tmp) - - # A true child process should exit with the subprocess exit value -- if child_pid is 0: -+ if child_pid == 0: - sys.exit(rval) - # If no os.fork() happened, just return the subprocess exit value - elif child_pid is None: diff --git a/srcpkgs/binwalk/patches/python-3.12.patch b/srcpkgs/binwalk/patches/python-3.12.patch deleted file mode 100644 index 1675ae8f274226..00000000000000 --- a/srcpkgs/binwalk/patches/python-3.12.patch +++ /dev/null @@ -1,90 +0,0 @@ ---- a/src/binwalk/core/module.py -+++ b/src/binwalk/core/module.py -@@ -688,6 +688,16 @@ class Modules(object): - else: - return '--' + opt - -+ @staticmethod -+ def _imp_load_source(name, path): -+ import importlib.util -+ import importlib.machinery -+ loader = importlib.machinery.SourceFileLoader(name, path) -+ spec = importlib.util.spec_from_file_location(name, path, loader=loader) -+ module = importlib.util.module_from_spec(spec) -+ loader.exec_module(module) -+ return module -+ - def list(self, attribute="run"): - ''' - Finds all modules with the specified attribute. -@@ -704,14 +714,13 @@ class Modules(object): - modules[module] = module.PRIORITY - - # user-defined modules -- import imp - user_modules = binwalk.core.settings.Settings().user.modules - for file_name in os.listdir(user_modules): - if not file_name.endswith('.py'): - continue - module_name = file_name[:-3] - try: -- user_module = imp.load_source(module_name, os.path.join(user_modules, file_name)) -+ user_module = _imp_load_source(module_name, os.path.join(user_modules, file_name)) - except KeyboardInterrupt as e: - raise e - except Exception as e: ---- a/src/binwalk/core/plugin.py -+++ b/src/binwalk/core/plugin.py -@@ -1,7 +1,6 @@ - # Core code for supporting and managing plugins. - - import os --import imp - import inspect - import binwalk.core.common - import binwalk.core.settings -@@ -131,6 +130,15 @@ class Plugins(object): - return klass - raise Exception("Failed to locate Plugin class in " + plugin) - -+ def _imp_load_source(self, name, path): -+ import importlib.util -+ import importlib.machinery -+ loader = importlib.machinery.SourceFileLoader(name, path) -+ spec = importlib.util.spec_from_file_location(name, path, loader=loader) -+ module = importlib.util.module_from_spec(spec) -+ loader.exec_module(module) -+ return module -+ - def list_plugins(self): - ''' - Obtain a list of all user and system plugin modules. -@@ -180,7 +188,7 @@ class Plugins(object): - module = file_name[:-len(self.MODULE_EXTENSION)] - - try: -- plugin = imp.load_source(module, os.path.join(plugins[key]['path'], file_name)) -+ plugin = self._imp_load_source(module, os.path.join(plugins[key]['path'], file_name)) - plugin_class = self._find_plugin_class(plugin) - - plugins[key]['enabled'][module] = True -@@ -222,7 +230,7 @@ class Plugins(object): - continue - - try: -- plugin = imp.load_source(module, file_path) -+ plugin = self._imp_load_source(module, file_path) - plugin_class = self._find_plugin_class(plugin) - - class_instance = plugin_class(self.parent) ---- a/src/binwalk/core/magic.py -+++ b/src/binwalk/core/magic.py -@@ -428,7 +428,7 @@ class Magic(object): - # Regex rule to find format strings - self.fmtstr = re.compile("%[^%]") - # Regex rule to find periods (see self._do_math) -- self.period = re.compile("\.") -+ self.period = re.compile(r'\.') - - def reset(self): - self.display_once = set() diff --git a/srcpkgs/binwalk/template b/srcpkgs/binwalk/template index 64c832d89765d6..1f86150c8d3c93 100644 --- a/srcpkgs/binwalk/template +++ b/srcpkgs/binwalk/template @@ -1,16 +1,16 @@ # Template file for 'binwalk' pkgname=binwalk -version=2.3.4 -revision=3 +version=2.4.1 +revision=1 build_style=python3-module hostmakedepends="python3-setuptools" depends="python3" short_desc="Easy tool for analyzing/reversing/extracting firmware images" maintainer="Duncaen " license="MIT" -homepage="https://github.com/ReFirmLabs/binwalk" -distfiles="https://github.com/ReFirmLabs/binwalk/archive/v${version}.tar.gz" -checksum=60416bfec2390cec76742ce942737df3e6585c933c2467932f59c21e002ba7a9 +homepage="https://github.com/OSPG/binwalk" +distfiles="https://github.com/OSPG/binwalk/archive/v${version}.tar.gz" +checksum=26d13afd3610b39a38a3062a34c05d94dacda3f6f6aa6d1d19e42b61fabe1c8f post_extract() { vsed -i -e 's;/etc/bash_completion.d/%s;%s.bash;' setup.py