mirror of
https://github.com/rizinorg/rizin
synced 2026-08-22 20:26:16 -04:00
Change how version is reported in -v command flag
This commit is contained in:
parent
a191b2a1a0
commit
018c0eaa53
9 changed files with 91 additions and 30 deletions
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -17,7 +17,7 @@ Make sure you are testing using the latest git version of rizin before submittin
|
|||
| OS/arch/bits (mandatory) | Debian arm 64, Ubuntu x86 32
|
||||
| File format of the file you reverse (mandatory) | PE, ELF etc.
|
||||
| Architecture/bits of the file (mandatory) | PPC, x86/32, x86/64 etc.
|
||||
| `rizin -v` full output, **not truncated** (mandatory) | rizin 0.1.0-git 26866 @ linux-x86-64 git.4.5.1-869-g4d01f3c7f commit: 4d01f3c7f6c15c01e19a4e00ac706ffa5f3a3459 build: 2021-01-21__13:00:24
|
||||
| `rizin -v` full output, **not truncated** (mandatory) | rizin 0.2.0-git @ linux-x86-64, package: 0.2.0.1 (ret2libc) commit: c875be9afde5a6eed037249854b8a8759517263c, build: 2021-01-26__18:17:13
|
||||
|
||||
|
||||
### Expected behavior
|
||||
|
|
|
|||
|
|
@ -24,7 +24,13 @@ Building
|
|||
Rizin uses the `meson` build system. Command line flags passed to meson can
|
||||
change how Rizin is built.
|
||||
|
||||
To define the base install location for Rizin use the `--prefix` flag when
|
||||
First, we suggest you use the options `-Dpackager_version=<package-version>`
|
||||
and `-Dpackager=<packager>` to help us track the version of Rizin users are
|
||||
using, because these options are used when you run `rizin -v`. In this way
|
||||
when a user reports a issue and he provides his `rizin -v` output, we know
|
||||
how Rizin was built.
|
||||
|
||||
Then, to define the base install location for Rizin use the `--prefix` flag when
|
||||
invoking `meson`. For system installs it is common to use `/usr`. If in doubt
|
||||
check your distributions packaging guidelines.
|
||||
|
||||
|
|
|
|||
|
|
@ -860,17 +860,12 @@ RZ_IPI int rz_cmd_help(void *data, const char *input) {
|
|||
case '?': // "?V?"
|
||||
rz_core_cmd_help(core, help_msg_question_V);
|
||||
break;
|
||||
case 0: // "?V"
|
||||
#if RZ_VERSION_COMMIT == 0
|
||||
rz_cons_printf("%s release\n", RZ_VERSION);
|
||||
#else
|
||||
if (!strcmp(RZ_VERSION, RZ_GITTAP)) {
|
||||
rz_cons_printf("%s %d\n", RZ_VERSION, RZ_VERSION_COMMIT);
|
||||
} else {
|
||||
rz_cons_printf("%s aka %s commit %d\n", RZ_VERSION, RZ_GITTAP, RZ_VERSION_COMMIT);
|
||||
}
|
||||
#endif
|
||||
case 0: { // "?V"
|
||||
char *v = rz_str_version(NULL);
|
||||
rz_cons_printf("%s\n", v);
|
||||
free (v);
|
||||
break;
|
||||
}
|
||||
case 'c': // "?Vc"
|
||||
rz_cons_printf("%d\n", vernum(RZ_VERSION));
|
||||
break;
|
||||
|
|
@ -881,7 +876,6 @@ RZ_IPI int rz_cmd_help(void *data, const char *input) {
|
|||
pj_ks(pj, "arch", RZ_SYS_ARCH);
|
||||
pj_ks(pj, "os", RZ_SYS_OS);
|
||||
pj_ki(pj, "bits", RZ_SYS_BITS);
|
||||
pj_ki(pj, "commit", RZ_VERSION_COMMIT);
|
||||
pj_ks(pj, "tap", RZ_GITTAP);
|
||||
pj_ki(pj, "major", RZ_VERSION_MAJOR);
|
||||
pj_ki(pj, "minor", RZ_VERSION_MINOR);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@
|
|||
#define RZ_VERSION_MINOR @RZ_VERSION_MINOR@
|
||||
#define RZ_VERSION_PATCH @RZ_VERSION_PATCH@
|
||||
#define RZ_VERSION_NUMBER @RZ_VERSION_NUMBER@
|
||||
#define RZ_VERSION_COMMIT @VERSIONCOMMIT@
|
||||
#define RZ_VERSION "@RZ_VERSION@"
|
||||
#define RZ_GITTAP "@RZ_GITTAP@"
|
||||
#define RZ_GITTIP "@RZ_GITTIP@"
|
||||
#define RZ_BIRTH "@RZ_BIRTH@"
|
||||
#mesondefine RZ_PACKAGER_VERSION
|
||||
#mesondefine RZ_PACKAGER
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3810,13 +3810,31 @@ RZ_API RzList *rz_str_wrap(char *str, size_t width) {
|
|||
#define RZ_BIRTH "unknown"
|
||||
#endif
|
||||
|
||||
#ifdef RZ_PACKAGER_VERSION
|
||||
# ifdef RZ_PACKAGER
|
||||
# define RZ_STR_PKG_VERSION_STRING ", package: " RZ_PACKAGER_VERSION " (" RZ_PACKAGER ")"
|
||||
# else
|
||||
# define RZ_STR_PKG_VERSION_STRING ", package: " RZ_PACKAGER_VERSION
|
||||
# endif
|
||||
#else
|
||||
# define RZ_STR_PKG_VERSION_STRING ""
|
||||
#endif
|
||||
|
||||
RZ_API char *rz_str_version(const char *program) {
|
||||
char *s = rz_str_newf("%s " RZ_VERSION " %d @ " RZ_SYS_OS "-" RZ_SYS_ARCH "-%d git.%s\n",
|
||||
program, RZ_VERSION_COMMIT,
|
||||
(RZ_SYS_BITS & 8) ? 64 : 32,
|
||||
*RZ_GITTAP ? RZ_GITTAP : "");
|
||||
if (*RZ_GITTIP) {
|
||||
s = rz_str_appendf(s, "commit: " RZ_GITTIP " build: " RZ_BIRTH);
|
||||
RzStrBuf *sb = rz_strbuf_new(NULL);
|
||||
if (program) {
|
||||
rz_strbuf_appendf(sb, "%s ", program);
|
||||
}
|
||||
return s;
|
||||
rz_strbuf_appendf(sb, RZ_VERSION " @ " RZ_SYS_OS "-" RZ_SYS_ARCH "-%d",
|
||||
(RZ_SYS_BITS & 8) ? 64 : 32);
|
||||
if (RZ_STR_ISNOTEMPTY(RZ_STR_PKG_VERSION_STRING)) {
|
||||
rz_strbuf_append(sb, RZ_STR_PKG_VERSION_STRING);
|
||||
}
|
||||
if (RZ_STR_ISNOTEMPTY(RZ_GITTIP)) {
|
||||
rz_strbuf_append(sb, "\n");
|
||||
rz_strbuf_append(sb, "commit: " RZ_GITTIP ", build: " RZ_BIRTH);
|
||||
}
|
||||
return rz_strbuf_drain(sb);
|
||||
}
|
||||
|
||||
#undef RZ_STR_PKG_VERSION_STRING
|
||||
|
|
|
|||
25
meson.build
25
meson.build
|
|
@ -7,6 +7,7 @@ pkgconfig_mod = import('pkgconfig')
|
|||
# Python scripts used during the build process
|
||||
create_tags_rz_py = files('sys/create_tags_rz.py')
|
||||
syscall_preprocessing_py = files('sys/syscall_preprocessing.py')
|
||||
git_exe_repo_py = files('sys/meson_git_wrapper.py')
|
||||
|
||||
# Get rizin version
|
||||
rizin_version = 'unknown-error'
|
||||
|
|
@ -46,7 +47,7 @@ endif
|
|||
version_commit = '0'
|
||||
|
||||
gittap = ''
|
||||
gittip = 'unknown'
|
||||
gittip = ''
|
||||
|
||||
git_dir_exists = run_command(py3_exe, '-c', '__import__("sys").exit(0 if __import__("os").path.isdir(".git") else 1)')
|
||||
if git_exe.found() and git_dir_exists.returncode() == 0
|
||||
|
|
@ -56,19 +57,19 @@ if git_exe.found() and git_dir_exists.returncode() == 0
|
|||
endif
|
||||
|
||||
# Get version_commit
|
||||
git_rev_list = run_command(git_exe, '-C', repo, 'rev-list', '--all', '--count')
|
||||
git_rev_list = run_command(py3_exe, git_exe_repo_py, git_exe, repo, 'rev-list', '--all', '--count')
|
||||
if git_rev_list.returncode() == 0
|
||||
version_commit = git_rev_list.stdout().strip()
|
||||
endif
|
||||
|
||||
# Get gittap
|
||||
git_describe = run_command(git_exe, '-C', repo, 'describe', '--tags', '--match', '[0-9]*')
|
||||
git_describe = run_command(py3_exe, git_exe_repo_py, git_exe, repo, 'describe', '--tags', '--match', '[0-9]*')
|
||||
if git_describe.returncode() == 0
|
||||
gittap = git_describe.stdout().strip()
|
||||
endif
|
||||
|
||||
# Get gittip
|
||||
git_rev_parse = run_command(git_exe, '-C', repo, 'rev-parse', 'HEAD')
|
||||
git_rev_parse = run_command(py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD')
|
||||
if git_rev_parse.returncode() == 0
|
||||
gittip = git_rev_parse.stdout().strip()
|
||||
endif
|
||||
|
|
@ -359,9 +360,17 @@ rz_userconf_h = configure_file(
|
|||
install_dir: rizin_incdir
|
||||
)
|
||||
|
||||
packager = get_option('packager')
|
||||
packager_version = get_option('packager_version')
|
||||
|
||||
message('Version Major: ' + rizin_version_major)
|
||||
message('Version Minor: ' + rizin_version_minor)
|
||||
message('Version Patch: ' + rizin_version_patch)
|
||||
message('Version GitTap: ' + gittap)
|
||||
message('Version GitTip: ' + gittip)
|
||||
|
||||
versionconf = configuration_data()
|
||||
versionconf.set('MESON_VERSION', meson.version())
|
||||
versionconf.set('VERSIONCOMMIT', version_commit)
|
||||
versionconf.set('RZ_VERSION_MAJOR', rizin_version_major)
|
||||
versionconf.set('RZ_VERSION_MINOR', rizin_version_minor)
|
||||
versionconf.set('RZ_VERSION_PATCH', rizin_version_patch)
|
||||
|
|
@ -370,6 +379,12 @@ versionconf.set('RZ_VERSION', rizin_version)
|
|||
versionconf.set('RZ_GITTAP', gittap)
|
||||
versionconf.set('RZ_GITTIP', gittip)
|
||||
versionconf.set('RZ_BIRTH', rizinbirth)
|
||||
if packager_version != ''
|
||||
versionconf.set_quoted('RZ_PACKAGER_VERSION', packager_version)
|
||||
if packager != ''
|
||||
versionconf.set_quoted('RZ_PACKAGER', packager)
|
||||
endif
|
||||
endif
|
||||
rz_version_h = configure_file(
|
||||
input: 'librz/include/rz_version.h.in',
|
||||
output: 'rz_version.h',
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
option('packager', type: 'string', value: '', description: 'Extra packager name')
|
||||
option('packager_version', type: 'string', value: '', description: 'Extra packager version')
|
||||
option('cli', type: 'feature', value: 'auto', description: 'Build CLI programs (“auto” means they will be built when not a subproject)')
|
||||
option('static_runtime', type: 'boolean', value: false)
|
||||
option('local', type: 'feature', value: 'auto', description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ if not capstone_dep.found() or not get_option('use_sys_capstone')
|
|||
error('Cannot execute git clone command')
|
||||
endif
|
||||
|
||||
reset_cmd_str = '-C @0@ reset --hard @1@'.format(capstone_path, CS_TIP)
|
||||
reset_cmd = run_command(git_exe, reset_cmd_str.split())
|
||||
reset_cmd = run_command(py3_exe, git_exe_repo_py, git_exe, capstone_path, 'reset', '--hard', CS_TIP)
|
||||
if reset_cmd.returncode() != 0
|
||||
error('Cannot execute git reset command')
|
||||
endif
|
||||
|
|
@ -60,8 +59,7 @@ if not capstone_dep.found() or not get_option('use_sys_capstone')
|
|||
message('Patching capstone with rizin\'s patches')
|
||||
foreach file : patches_files
|
||||
patch_path = join_paths(meson.current_source_dir(), 'capstone-patches', file)
|
||||
patch_cmd_str = '-C @0@ apply -p1 @1@'.format(capstone_path, patch_path)
|
||||
patch_cmd = run_command(git_exe, patch_cmd_str.split())
|
||||
patch_cmd = run_command(py3_exe, git_exe_repo_py, git_exe, capstone_path, 'apply', '-p1', patch_path)
|
||||
if patch_cmd.returncode() != 0
|
||||
warning('Cannot apply patch ' + file)
|
||||
endif
|
||||
|
|
|
|||
27
sys/meson_git_wrapper.py
Executable file
27
sys/meson_git_wrapper.py
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
""" Portable python script to execute git -C (even on system where -C is not available) """
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
if len(sys.argv) <= 3:
|
||||
print('Usage: %s <git_executable_path> <repo_path> [git_args...]')
|
||||
sys.exit(1)
|
||||
|
||||
git_exe = sys.argv[1]
|
||||
repo_path = sys.argv[2]
|
||||
args = sys.argv[3:]
|
||||
|
||||
def isCArgSupported(git_exe, repo_path):
|
||||
r = subprocess.run([git_exe, '-C', repo_path, 'status'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
return r.returncode == 0
|
||||
|
||||
if isCArgSupported(git_exe, repo_path):
|
||||
called = subprocess.run([git_exe, '-C', repo_path] + args)
|
||||
sys.exit(called.returncode)
|
||||
else:
|
||||
os.chdir(repo_path)
|
||||
called = subprocess.run([git_exe] + args)
|
||||
sys.exit(called.returncode)
|
||||
Loading…
Add table
Add a link
Reference in a new issue