Skip to content

Commit

Permalink
Add support for multiple r2pm package repos
Browse files Browse the repository at this point in the history
  • Loading branch information
condret authored and trufae committed May 14, 2023
1 parent a1de6ab commit f5273b1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions libr/main/r2pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ static char *r2pm_pkgdir(void) {

typedef enum {
TT_TEXTLINE,
TT_TEXTLINE_LIST,
TT_CODEBLOCK,
TT_ENDQUOTE,
} R2pmTokenType;
Expand Down Expand Up @@ -224,6 +225,14 @@ static char *r2pm_get(const char *file, const char *token, R2pmTokenType type) {
}
res = strdup (descptr);
break;
case TT_TEXTLINE_LIST:
descptr += strlen (needle);
nl = strchr (descptr, '\n');
if (nl) {
*nl = 0;
}
res = strdup (descptr);
break;
case TT_ENDQUOTE:
nl = strchr (descptr + strlen (token), '\n');
if (nl) {
Expand Down Expand Up @@ -600,17 +609,18 @@ static int r2pm_clone(const char *pkg) {
if (r_file_is_directory (srcdir)) {
git_pull (srcdir, 0);
} else {
char *url = r2pm_get (pkg, "\nR2PM_GIT ", TT_TEXTLINE);
if (url) {
char *dir = strchr (url, ' ');
if (dir) {
*dir++ = 0;
if (strcmp (dir, pkg)) {
R_LOG_WARN ("pkgname != clonedir");
char *url_list = r2pm_get (pkg, "\nR2PM_GIT ", TT_TEXTLINE_LIST);
if (url_list) {
r_str_replace_ch (url_list, ',', ' ', true);
int url_ct, i;
char **urls = r_str_argv (url_list, &url_ct);
for (i = 0; i < url_ct; i++) {
if (!git_clone (srcdir, urls[i])) {
break;
}
}
git_clone (srcdir, url);
free (url);
r_str_argv_free (urls);
free (url_list);
} else {
char *url = r2pm_get (pkg, "\nR2PM_TGZ", TT_TEXTLINE);
if (!url) {
Expand Down

0 comments on commit f5273b1

Please sign in to comment.