Skip to content

Commit

Permalink
Use LibBS, drop BinSync for Plugin Installer (#83)
Browse files Browse the repository at this point in the history
* Drop binsync requirements, use libbs

* bump

* fix

* require updated libbs
  • Loading branch information
mahaloz authored Jan 4, 2024
1 parent 3a830e7 commit e32dee3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion decomp2dbg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.7.2"
__version__ = "3.8.0"

try:
from .clients.client import DecompilerClient
Expand Down
4 changes: 2 additions & 2 deletions decomp2dbg/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse

from .installer import Decomp2dbgInstaller
from .installer import D2dInstaller


def main():
Expand All @@ -23,7 +23,7 @@ def main():
args = parser.parse_args()

if args.install:
Decomp2dbgInstaller().install()
D2dInstaller().install()


if __name__ == "__main__":
Expand Down
34 changes: 16 additions & 18 deletions decomp2dbg/installer.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e32dee3

Please sign in to comment.