Skip to content

Commit

Permalink
Don't reinstall pkg dependencies when not doing clean installs if tha…
Browse files Browse the repository at this point in the history
…y are already there ##r2pm
  • Loading branch information
radare committed Oct 6, 2023
1 parent f31fcac commit 1c9337a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions libr/main/r2pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ static bool r2pm_check(const char *program) {
return found;
}

static int r2pm_install_pkg(const char *pkg, bool global) {
static int r2pm_install_pkg(const char *pkg, bool clean, bool global) {
bool have_builddir = r2pm_have_builddir (pkg);
R_LOG_INFO ("Starting install for %s", pkg);
char *needs = r2pm_get (pkg, "\nR2PM_NEEDS ", TT_TEXTLINE);
Expand All @@ -692,7 +692,7 @@ static int r2pm_install_pkg(const char *pkg, bool global) {
const char *const cmd = "apt install build-essential git make patch python wget binutils";
R_LOG_INFO ("Running %s");
r_sys_cmd (cmd);
return r2pm_install_pkg (pkg, global);
return r2pm_install_pkg (pkg, clean, global);
}
}
return -1;
Expand All @@ -703,14 +703,25 @@ static int r2pm_install_pkg(const char *pkg, bool global) {
char *dep;
RListIter *iter;
RList *l = r_str_split_list (deps, " ", 0);
char *pkgdir = r2pm_gitdir ();
r_list_foreach (l, iter, dep) {
if (!clean) {
// skip dep if already installed
char *srcdir = r_file_new (pkgdir, pkg, NULL);
bool is_installed = r_file_is_directory (srcdir);
free (srcdir);
if (is_installed) {
continue;
}
}
if (r2pm_clone (dep) == 0) {
r2pm_install_pkg (dep, false); // XXX get current pkg global value
r2pm_install_pkg (dep, clean, false); // XXX get current pkg global value
} else {
R_LOG_ERROR ("Cannot clone %s", dep);
// ignore return -1;
}
}
free (pkgdir);
}
char *srcdir = r2pm_gitdir ();
r2pm_setenv ();
Expand Down Expand Up @@ -845,7 +856,7 @@ static int r2pm_install(RList *targets, bool uninstall, bool clean, bool force,
r2pm_clean_pkg (t);
}
if (r2pm_clone (t) == 0) {
rc |= r2pm_install_pkg (t, global);
rc |= r2pm_install_pkg (t, clean, global);
} else {
R_LOG_ERROR ("Cannot clone %s", t);
rc = 1;
Expand Down

0 comments on commit 1c9337a

Please sign in to comment.