Compare commits

...
10 Commits
Author SHA1 Message Date
pancake 0af796baa0 stupid python rules 2021-06-17 18:08:56 +02:00
pancake f64c5d8dd3 mec 2021-06-17 17:57:58 +02:00
pancake 0f4197ef60 fixes 2021-06-17 17:54:16 +02:00
pancake 9dcd499400 Fix build and shell for termux 2021-06-17 17:41:41 +02:00
pancake 7513c6d1b6 Implement r2env shell for unix (#4) 2021-06-17 01:07:30 +02:00
pancake f097dbb7c5 Fix use 2021-06-17 00:14:59 +02:00
murphy 02e188bf70 Fix r2env use validation 2021-06-16 18:07:30 +02:00
murphy 6a702b428d Fix conflicts 2021-06-16 18:06:46 +02:00
murphy a8118544e3 Fix r2env use, listing installed versions 2021-06-16 17:26:33 +02:00
murphy 740f66ab9b Fix config cmd 2021-06-16 17:26:33 +02:00
3 changed files with 35 additions and 12 deletions

No files matched your search

+15 -4
View File
@@ -35,7 +35,8 @@ class R2Env:
print_console(" [*] {0} ({1})".format(r2_version, r2_path))
def show_config(self):
return json.dumps(self._config)
print_console("[*] Current r2env config:")
print_console(json.dumps(self._config))
def list_available_packages(self):
print_console("[*] List of available Radare packages")
@@ -70,8 +71,12 @@ class R2Env:
return
self._package_manager.uninstall_package(package)
def use(self, package):
def use(self, package=None):
self.exit_if_r2env_not_initialized()
if not package:
print_console("[x] Package not defined. Please use 'r2env use' with one installed package. ", ERROR)
self.list_installed_packages()
return
cur_ver = self._get_current_version()
new_dst_dir = self._package_manager.get_package_path(package)
if cur_ver:
@@ -85,8 +90,14 @@ class R2Env:
with open("version.txt", "r") as version:
return version.read()
def shell(self):
pass
def shell(self, cmd=""):
line = "export PS1=\"r2env\\$ \";export PATH=\"" + self._r2env_path + "/bin:$PATH\"; $SHELL -f"
if os.path.isfile("/default.prop"): # hack for pre-dtag builds of r2
line = "export LD_LIBRARY_PATH=\"" + self._r2env_path + "/lib\";" + line
if cmd.strip() == "":
return os.system(line)
print(os.system(line + " -c '" + cmd + "'"))
return os.system(line + " -c '" + cmd + "'")
@staticmethod
def _load_config():
+7 -3
View File
@@ -94,9 +94,13 @@ class PackageManager:
def _build_using_acr(source_path, dst_path, logfile):
"""Only works in Unix systems"""
exit_if_not_exists(['make'])
print_console("[-] Building package using acr ...")
cmd = "(cd {0} && rm -rf shlr/capstone && ./configure --with-rpath --prefix={1} 2>&1 && make -j4 2>&1" \
"&& make install) > {2}".format(source_path, dst_path, logfile)
print_console("[-] Building package using acr for Termux...")
extra_flags = ""
if os.path.isfile("/default.prop"):
extra_flags = " --with-compiler=termux"
cmd = "(cd {0} && rm -rf shlr/capstone && ./configure {1}" \
" --with-rpath --prefix={2} 2>&1 && make -j4 2>&1" \
"&& make install) > {3}".format(source_path, extra_flags, dst_path, logfile)
return os.system(cmd) == 0
@staticmethod
+13 -5
View File
@@ -29,12 +29,14 @@ def show_help():
actions_with_argument = ["install", "uninstall", "use"]
actions_with_arguments = ["shell"]
actions = {
"init": R2Env().init,
"version": R2Env().get_r2_path,
"config": R2Env().show_config,
"list": R2Env().list_available_packages,
"install": R2Env().install,
"shell": R2Env().shell,
"uninstall": R2Env().uninstall,
"use": R2Env().use,
"versions": R2Env().list_installed_packages,
@@ -45,9 +47,10 @@ actions = {
def run_action(action, args, use_meson):
if action not in actions:
print_console("[X] Action not found", ERROR)
return
if action in actions_with_argument:
exit_if_not_argument_is_set(args)
elif action in actions_with_arguments:
actions[action](" ".join(args))
elif action in actions_with_argument:
exit_if_not_argument_is_set(args, action)
if action == "install":
actions[action](args[0], use_meson=use_meson)
else:
@@ -56,9 +59,14 @@ def run_action(action, args, use_meson):
actions[action]()
def exit_if_not_argument_is_set(args):
def exit_if_not_argument_is_set(args, action):
if len(args) < 1:
print_console("[x] Missing package argument.", ERROR)
if action == "use":
print_console("[x] Package not defined. Please use 'r2env use' with one installed package. ", ERROR)
actions["versions"]()
else:
print_console("[x] Missing package argument. ( as for example: radare2@latest)", ERROR)
print_console("[x] Missing package argument. ( as for example: radare2@latest)", ERROR)
sys.exit(-1)