Test the new default native r2pm fix flushing and using RLOG ##r2pm

This commit is contained in:
pancake 2022-09-20 12:36:10 +02:00 committed by pancake
parent b0636a2939
commit 503d46c03b
2 changed files with 25 additions and 23 deletions

View File

@ -119,17 +119,19 @@ jobs:
./configure --prefix=/usr --with-compiler=tcc
make -j
sudo make install
- name: Initialize and update the r2pm package database
run: r2pm -U
- name: Install samurai
run: r2pm -i samurai
- name: Install samurai (clean)
run: r2pm -ci samurai
- name: Install samurai (native)
run: R2PM_NATIVE=1 r2pm -i samurai
run: r2pm -i samurai
- name: Install muon
run: r2pm -i muon
- name: Install muon (native)
run: R2PM_NATIVE=1 r2pm -i muon
run: r2pm -i muon
- name: Building r2 with muon+samu
run: |
R2PM_NATIVE=1 r2pm -r muon setup b
R2PM_NATIVE=1 r2pm -r samu -j4 -C b >/dev/null
r2pm -r muon setup b
r2pm -r samu -j4 -C b >/dev/null

View File

@ -1,12 +1,12 @@
/* radare - LGPL - Copyright 2021-2022 - pancake */
#define R_LOG_ORIGIN "r2pm"
#include <r_main.h>
#if R2_580
#define R2PM_DEFAULT_NATIVE 1
#else
#define R2PM_DEFAULT_NATIVE 0
#endif
#define R2PM_GITURL "https://github.com/radareorg/radare2-pm"
static int r2pm_install(RList *targets, bool uninstall, bool clean, bool global);
static int r_main_r2pm_sh(int argc, const char **argv) {
#if __WINDOWS__
@ -46,7 +46,7 @@ static const char *helpmsg = \
" -uci <pkgname> uninstall + clean + install\n"\
" -ui <pkgname> uninstall + install\n"\
" -u <pkgname> r2pm -u baleful (See -f to force uninstall)\n"\
" -U r2pm -U (upgrade all outdated packages)\n"\
" -U initialize/update database and upgrade all outdated packages\n"\
" -v show version\n";
typedef struct r_r2pm_t {
@ -81,13 +81,14 @@ static int git_clone(const char *dir, const char *url) {
static bool r2pm_actionword(R2Pm *r2pm, const char *action) {
if (!strcmp (action, "init") || !strcmp (action, "update")) {
R_LOG_WARN ("Action words will be deprecated in r2-5.9.x, use -U instead of %s", action);
r2pm->init = true;
} else if (!strcmp (action, "help")) {
R_LOG_WARN ("Action words will be deprecated in r2-5.9.x, use -h instead of %s", action);
r2pm->help = true;
} else if (!strcmp (action, "info")) {
R_LOG_WARN ("Action words will be deprecated in r2-5.9.x, use -I instead of %s", action);
r2pm->info = true;
} else if (!strcmp (action, "help")) {
r2pm->help = true;
} else {
return false;
}
@ -205,8 +206,6 @@ static char *r2pm_get(const char *file, const char *token, R2pmTokenType type) {
return res;
}
static int r2pm_install(RList *targets, bool uninstall, bool clean, bool global);
static void striptrim(RList *list) {
char *s;
RListIter *iter, *iter2;
@ -223,7 +222,7 @@ static void r2pm_upgrade(void) {
RList *list = r_str_split_list (s, "\n", -1);
striptrim (list);
if (r_list_length (list) < 1) {
eprintf ("Nothing to upgrade.\n");
R_LOG_INFO ("Nothing to upgrade");
} else {
r2pm_install (list, false, true, false);
}
@ -351,19 +350,19 @@ static void r2pm_setenv(void) {
}
static int r2pm_install_pkg(const char *pkg, bool global) {
printf ("[r2pm] Installing %s ...\n", pkg);
R_LOG_INFO ("Starting install for %s", pkg);
char *deps = r2pm_get (pkg, "\nR2PM_DEPS ", TT_TEXTLINE);
if (deps) {
char *dep;
RListIter *iter;
RList *l = r_str_split_list (deps, " ", 0);
r_list_foreach (l, iter, dep) {
eprintf ("(%s)\n", dep);
r2pm_install_pkg (dep, false); // XXX get current pkg global value
}
}
char *srcdir = r2pm_gitdir ();
r2pm_setenv ();
R_LOG_DEBUG ("Entering %s", srcdir);
#if __WINDOWS__
char *script = r2pm_get (pkg, "\nR2PM_INSTALL_WINDOWS() {", TT_CODEBLOCK);
if (!script) {
@ -376,7 +375,7 @@ static int r2pm_install_pkg(const char *pkg, bool global) {
#else
char *script = r2pm_get (pkg, "\nR2PM_INSTALL() {", TT_CODEBLOCK);
if (!script) {
R_LOG_ERROR ("Invalid package name or script");
R_LOG_ERROR ("Invalid package name or script '%s'", pkg);
free (srcdir);
return 1;
}
@ -403,7 +402,7 @@ static int r2pm_doc_pkg(const char *pkg) {
}
static int r2pm_clean_pkg(const char *pkg) {
printf ("[r2pm] Cleaning %s ...\n", pkg);
R_LOG_INFO ("Cleaning %s", pkg);
// TODO. make clean/mrproper instead maybe better?
char *srcdir = r2pm_gitdir ();
if (R_STR_ISNOTEMPTY (srcdir)) {
@ -418,7 +417,7 @@ static int r2pm_clean_pkg(const char *pkg) {
}
static int r2pm_uninstall_pkg(const char *pkg) {
printf ("[r2pm] Uninstalling %s ...\n", pkg);
R_LOG_INFO ("Uninstalling %s", pkg);
char *srcdir = r2pm_gitdir ();
r2pm_setenv ();
#if __WINDOWS__
@ -483,7 +482,7 @@ static int r2pm_install(RList *targets, bool uninstall, bool clean, bool global)
int rc = 0;
char *r2v = r_sys_cmd_str ("radare2 -qv", NULL, NULL);
r_str_trim (r2v);
printf ("Using r2-%s and r2pm-"R2_VERSION"\n", r2v);
R_LOG_INFO ("Using r2-%s and r2pm-"R2_VERSION, r2v);
free (r2v);
if (global) {
r_sys_setenv ("GLOBAL", "1");
@ -542,7 +541,7 @@ static bool is_valid_package(const char *dbdir, const char *pkg) {
}
char *script = r2pm_get (pkg, "\nR2PM_INSTALL() {", TT_CODEBLOCK);
if (!script) {
R_LOG_WARN ("Unable to find R2PM_INSTALL script in '%s'", pkg);
R_LOG_DEBUG ("Unable to find R2PM_INSTALL script in '%s'", pkg);
return false;
}
free (script);
@ -601,9 +600,10 @@ static char *r2pm_search(const char *grep) {
RStrBuf *sb = r_strbuf_new ("");
r_list_foreach (files, iter, file) {
if (*file != '.') {
bool match = R_STR_ISEMPTY (grep) || strstr (file, grep);
char *desc = r2pm_desc (file);
if (desc) {
if (!grep || (strstr (desc, grep) || strstr (file, grep))) {
if (match || strstr (desc, grep)) {
r_strbuf_appendf (sb, "%s%s%s\n", file, r_str_pad (' ', 20 - strlen (file)), desc);
}
free (desc);