mirror of
https://github.com/radareorg/r2env.git
synced 2026-11-07 23:03:20 -10:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c0577ad14 | ||
|
|
50f444dab0 | ||
|
|
db4e174ecf | ||
|
|
9ada5d4322 | ||
|
|
47c5b9feab | ||
|
|
e94f9c07af | ||
|
|
ef703be9fe | ||
|
|
b0c2e38ece | ||
|
|
aa4a5170cd | ||
|
|
01e2b5efaa | ||
|
|
d58b97085c | ||
|
|
e15c4249a3 | ||
|
|
2a7f1893f1 | ||
|
|
378adc688a | ||
|
|
092eda37ea |
No files matched your search
@@ -0,0 +1,70 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '34 6 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'python' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
@@ -6,14 +6,16 @@ Create self-contained environments with multiple versions of radare2
|
||||
and plugins, make it easy to switch between them.
|
||||
|
||||
* Build from source or install the system package if available.
|
||||
*
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
r2env is available via PIP. (`pip install r2env`)
|
||||
r2env is available via PIP.
|
||||
|
||||
If you want to try it directly from git just run `make`.
|
||||
* `pip install -U -f r2env`
|
||||
|
||||
If you want to try it directly from source.
|
||||
|
||||
* `pip install .`
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -72,6 +72,17 @@
|
||||
"deb_x64": "radare2_5.4.2_amd64.deb"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "5.5.0",
|
||||
"packages": {
|
||||
"w32": "radare2-5.5.0-w32.zip",
|
||||
"w64": "radare2-5.5.0-w64.zip",
|
||||
"mac_x64": "radare2-5.5.0-amd64.pkg",
|
||||
"mac_arm64": "radare2-5.5.0-m1.pkg",
|
||||
"deb_i386": "radare2_5.5.0_i386.deb",
|
||||
"deb_x64": "radare2_5.5.0_amd64.deb"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "git",
|
||||
"packages": {}
|
||||
|
||||
@@ -105,6 +105,9 @@ class R2Env:
|
||||
return version.read()
|
||||
|
||||
def shell(self, cmd=""):
|
||||
if os.name== "nt":
|
||||
os.system("set PATH="+self._r2env_path+"\\bin;%PATH% && cmd")
|
||||
return True
|
||||
line = "export PS1=\"r2env\\$ \";export PKG_CONFIG_PATH=\""
|
||||
line = line + self._r2env_path+"/lib/pkgconfig\";export PATH=\""
|
||||
line = line + self._r2env_path + "/bin:$PATH\"; $SHELL -f"
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import wget
|
||||
import sys
|
||||
import time
|
||||
|
||||
from zipfile import ZipFile
|
||||
|
||||
from r2env.tools import load_json_file, git_fetch, git_clean, print_console, ERROR, exit_if_not_exists, host_distname
|
||||
|
||||
class PackageManager:
|
||||
@@ -104,24 +107,65 @@ class PackageManager:
|
||||
dn = host_distname()
|
||||
disturl = self._get_disturl(profile, version, dn)
|
||||
pkgname = self._get_pkgname(profile, version, dn)
|
||||
print(disturl)
|
||||
os.system("wget -c " + disturl)
|
||||
sysname = os.uname().sysname
|
||||
if sysname == "Darwin":
|
||||
if os.system("sudo installer -pkg " + pkgname + " -target /") == 0:
|
||||
return True
|
||||
ofile = "/".join([self._r2env_path, "src", pkgname])
|
||||
# os.system("wget -O " + ofile + " -qc " + disturl)
|
||||
wget.download(disturl, ofile);
|
||||
try:
|
||||
sysname = os.uname().sysname
|
||||
except:
|
||||
sysname = "Windows"
|
||||
# TODO: checksum
|
||||
if sysname == "Darwin":
|
||||
if os.system("sudo installer -pkg " + ofile + " -target /") == 0:
|
||||
return True
|
||||
if sysname == "Windows":
|
||||
with ZipFile(ofile, 'r') as z:
|
||||
z.extractall()
|
||||
dst = os.path.sep.join([self._r2env_path, "bin"])
|
||||
for f in z.namelist():
|
||||
if f.endswith(".exe") or f.endswith(".dll") and f.find("bin") != -1:
|
||||
fname = os.path.basename(f)
|
||||
d = os.path.sep.join([dst, fname])
|
||||
dname = os.path.dirname(d)
|
||||
if not os.path.isdir(dname):
|
||||
os.makedirs(dname, 493) # 0755)
|
||||
shutil.copyfile(f, d)
|
||||
print(f)
|
||||
f = os.path.sep.join([self._r2env_path, "bin", "radare2.exe"])
|
||||
d = os.path.sep.join([self._r2env_path, "bin", "r2.exe"])
|
||||
shutil.copyfile(f, d)
|
||||
if sysname == "Linux" and os.path.exists("/usr/bin/dpkg"):
|
||||
if os.system("sudo dpkg -i " + ofile) == 0:
|
||||
return True
|
||||
if os.path.isfile("/default.prop"): # termux
|
||||
if os.system("apt install radare2") == 0:
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
def _uninstall_from_dist(self, profile, version):
|
||||
print_console("[*] Uninstalling {}@{} package from binary dist".format(profile, version))
|
||||
sysname = os.uname().sysname
|
||||
try:
|
||||
sysname = os.uname().sysname
|
||||
except:
|
||||
sysname = "Windows"
|
||||
if sysname == "Darwin":
|
||||
pkgname = "org.radare.radare2"
|
||||
os.system("pkgutil --pkg-info " + pkgname)
|
||||
os.system("cd / && pkgutil --only-files --files "+pkgname+" | tr '\\n' '\\0' | xargs -n 1 -0 sudo rm -f")
|
||||
os.system("cd / && pkgutil --only-dirs --files "+pkgname+" | tail -r | tr '\\n' '\\0' | xargs -n 1 -0 sudo rmdir 2>/dev/null")
|
||||
os.system("sudo pkgutil --forget " + pkgname)
|
||||
if sysname == "Linux" and os.path.exists("/usr/bin/dpkg"):
|
||||
try:
|
||||
pkgname = profile.split("@")[0]
|
||||
except:
|
||||
pkgname = profile
|
||||
if os.system("sudo dpkg -r " + pkgname) == 0:
|
||||
return True
|
||||
if os.path.isfile("/default.prop"): # termux
|
||||
if os.system("sudo dpkg -r radare2") == 0:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
def _build_from_source(self, profile, version, source_path, dst_path, logfile, use_meson=False):
|
||||
|
||||
+15
-15
@@ -12,27 +12,27 @@ Usage: r2env [-flags] [action] [args...]
|
||||
|
||||
Flags:
|
||||
|
||||
-h, --help - show this help
|
||||
-v, --version - display r2env version
|
||||
-m, --meson - use meson instead of acr
|
||||
-p, --package - install the dist package instead of building
|
||||
-l, --list - list available and installed packages
|
||||
-h, --help - show this help.
|
||||
-v, --version - display r2env version.
|
||||
-m, --meson - use meson instead of acr.
|
||||
-p, --package - install the dist package instead of building
|
||||
-l, --list - list available and installed packages
|
||||
|
||||
Actions:
|
||||
|
||||
init - create ~/.r2env directory
|
||||
config - display current .r2env settings
|
||||
add [pkg] - build and install given package. See -p and -m
|
||||
use [pkg] - use r2 package defined. pkg should be a release version or git.
|
||||
rm [pkg] - remove package from ~/.r2env
|
||||
path - show path of current r2 in use
|
||||
list - list all packages available to r2env
|
||||
shell - enter a new shell with PATH env var set
|
||||
purge - remove ~/.r2env
|
||||
init - create ~/.r2env directory.
|
||||
config - display current .r2env settings.
|
||||
add [pkg] - build and install given package. See -p and -m
|
||||
use [pkg] - stow a specific version to be the default.
|
||||
rm [pkg] - remove package from ~/.r2env
|
||||
path - show path of current r2 in use.
|
||||
list - list all packages available to r2env.
|
||||
shell - enter a new shell with PATH env var set.
|
||||
purge - remove ~/.r2env
|
||||
|
||||
Environment
|
||||
|
||||
R2ENV_PATH - specify different path other than ~/.r2env
|
||||
R2ENV_PATH - specify different path other than ~/.r2env
|
||||
|
||||
"""
|
||||
|
||||
|
||||
+13
-2
@@ -19,6 +19,9 @@ def print_console(msg, level=INFO, formatter=0):
|
||||
tabs, color = ["", ""]
|
||||
for _ in range(formatter):
|
||||
tabs += " "
|
||||
if os.name == 'nt':
|
||||
print(tabs + msg)
|
||||
return
|
||||
if level == ERROR:
|
||||
color = Fore.RED
|
||||
elif level == WARNING:
|
||||
@@ -36,8 +39,12 @@ def host_platform():
|
||||
|
||||
# TODO :improve to support all archs
|
||||
def host_distname():
|
||||
sysname = os.uname().sysname
|
||||
machine = os.uname().machine
|
||||
try:
|
||||
sysname = os.uname().sysname
|
||||
machine = os.uname().machine
|
||||
except:
|
||||
sysname = "w64"
|
||||
machine = "amd64"
|
||||
if sysname == "Darwin":
|
||||
if machine == "x86_64":
|
||||
return "mac_x64"
|
||||
@@ -65,6 +72,10 @@ def git_fetch(url, version, source_path):
|
||||
repo = Repo.clone_from(url, source_path)
|
||||
if version != "git":
|
||||
repo.git.checkout(version)
|
||||
sms = repo.submodules
|
||||
for sm in sms:
|
||||
if not sm.module_exists():
|
||||
sm.update()
|
||||
|
||||
|
||||
def git_clean(source_path):
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.4.0
|
||||
0.4.2
|
||||
@@ -1,3 +1,4 @@
|
||||
dploy>=0.1.2
|
||||
colorama>=0.4.4
|
||||
wget
|
||||
GitPython
|
||||
Reference in new issue
Block a user