From e32dee32d7d815ba059bfed642fa55774d91c134 Mon Sep 17 00:00:00 2001 From: Zion Leonahenahe Basque Date: Thu, 4 Jan 2024 11:56:21 -0700 Subject: [PATCH] Use LibBS, drop BinSync for Plugin Installer (#83) * Drop binsync requirements, use libbs * bump * fix * require updated libbs --- decomp2dbg/__init__.py | 2 +- decomp2dbg/__main__.py | 4 ++-- decomp2dbg/installer.py | 34 ++++++++++++++++------------------ setup.cfg | 2 +- setup.py | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/decomp2dbg/__init__.py b/decomp2dbg/__init__.py index 6791d78..334cca1 100644 --- a/decomp2dbg/__init__.py +++ b/decomp2dbg/__init__.py @@ -1,4 +1,4 @@ -__version__ = "3.7.2" +__version__ = "3.8.0" try: from .clients.client import DecompilerClient diff --git a/decomp2dbg/__main__.py b/decomp2dbg/__main__.py index 49d1894..d0c477f 100644 --- a/decomp2dbg/__main__.py +++ b/decomp2dbg/__main__.py @@ -1,6 +1,6 @@ import argparse -from .installer import Decomp2dbgInstaller +from .installer import D2dInstaller def main(): @@ -23,7 +23,7 @@ def main(): args = parser.parse_args() if args.install: - Decomp2dbgInstaller().install() + D2dInstaller().install() if __name__ == "__main__": diff --git a/decomp2dbg/installer.py b/decomp2dbg/installer.py index d4fd066..6a8d7b6 100644 --- a/decomp2dbg/installer.py +++ b/decomp2dbg/installer.py @@ -1,33 +1,31 @@ import textwrap from urllib.request import urlretrieve -import pkg_resources -from pathlib import Path +from libbs.plugin_installer import LibBSPluginInstaller, PluginInstaller -from binsync.installer import Installer - -class Decomp2dbgInstaller(Installer): +class D2dInstaller(LibBSPluginInstaller): def __init__(self): - super(Decomp2dbgInstaller, self).__init__(targets=Installer.DECOMPILERS + ('gdb',)) - self.plugins_path = Path( - pkg_resources.resource_filename("decomp2dbg", f"decompilers") - ) - + super().__init__(targets=PluginInstaller.DECOMPILERS + PluginInstaller.DEBUGGERS) + pkg_files = self.find_pkg_files("decomp2dbg") + if pkg_files is None: + raise RuntimeError("Failed to find decomp2dbg package files! Please reinstall or file an issue.") + + self.plugins_path = pkg_files / "decompilers" + def display_prologue(self): print(textwrap.dedent(""" + Now installing... __ ___ ____ ____/ /__ _________ ____ ___ ____ |__ \ ____/ / /_ ____ _ / __ / _ \/ ___/ __ \/ __ `__ \/ __ \__/ // __ / __ \/ __ `/ / /_/ / __/ /__/ /_/ / / / / / / /_/ / __// /_/ / /_/ / /_/ / \__,_/\___/\___/\____/_/ /_/ /_/ .___/____/\__,_/_.___/\__, / /_/ /____/ - Now installing decomp2dbg... - Please input decompiler/debugger install paths as prompted. Enter nothing to either use - the default install path if one exists, or to skip. + The Decompiler to Debugger Bridge """)) - def install_gdb(self, path=None): + def install_gdb(self, path=None, interactive=True): path = super().install_gdb(path=None) if path is None: return None @@ -46,7 +44,7 @@ def install_gdb(self, path=None): return path - def install_ida(self, path=None): + def install_ida(self, path=None, interactive=True): ida_plugin_path = super().install_ida(path=path) if ida_plugin_path is None: return @@ -59,7 +57,7 @@ def install_ida(self, path=None): self.link_or_copy(src_d2d_ida_py, dst_d2d_ida_py) return dst_d2d_ida_pkg - def install_angr(self, path=None): + def install_angr(self, path=None, interactive=True): angr_plugin_path = super().install_angr(path=path) if angr_plugin_path is None: return None @@ -69,7 +67,7 @@ def install_angr(self, path=None): self.link_or_copy(src_d2d_angr_pkg, dst_d2d_angr_pkg, is_dir=True) return dst_d2d_angr_pkg - def install_ghidra(self, path=None): + def install_ghidra(self, path=None, interactive=True): ghidra_path = super().install_ghidra(path=path) if ghidra_path is None: return None @@ -79,7 +77,7 @@ def install_ghidra(self, path=None): urlretrieve(download_url, dst_path) return dst_path - def install_binja(self, path=None): + def install_binja(self, path=None, interactive=True): binja_plugin_path = super().install_binja(path=path) if binja_plugin_path is None: return None diff --git a/setup.cfg b/setup.cfg index ad8741b..d5c7872 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ long_description_content_type = text/markdown install_requires = sortedcontainers pyelftools - binsync + libbs>=0.10.0 python_requires = >= 3.5 include_package_data = True diff --git a/setup.py b/setup.py index 1367e51..3041c10 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def _copy_decomp_plugins(): class build(st_build): def run(self, *args): - self.execute(_copy_decomp_plugins, (), msg="Copying binsync plugins") + self.execute(_copy_decomp_plugins, (), msg="Copying plugins") super().run(*args) class develop(st_develop):