From 0727d9a53a50f8dcad55f3f72037554a4bb77899 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 19 Jun 2019 13:07:42 +0200 Subject: [PATCH] xbps-checkvers: implement --format %R (repository). Close #128 --- bin/xbps-checkvers/main.c | 16 ++++++++++------ bin/xbps-checkvers/xbps-checkvers.1 | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/xbps-checkvers/main.c b/bin/xbps-checkvers/main.c index d9a3480d..d4c57c66 100644 --- a/bin/xbps-checkvers/main.c +++ b/bin/xbps-checkvers/main.c @@ -495,7 +495,7 @@ check_reverts(const char *repover, const char *reverts) static void rcv_printf(rcv_t *rcv, FILE *fp, const char *pkgname, const char *repover, - const char *srcver) + const char *srcver, const char *repourl) { const char *f, *p; @@ -520,6 +520,7 @@ rcv_printf(rcv_t *rcv, FILE *fp, const char *pkgname, const char *repover, case '%': fputc(*f, fp); break; case 'n': fputs(pkgname, fp); break; case 'r': fputs(repover, fp); break; + case 'R': fputs(repourl, fp); break; case 's': fputs(srcver, fp); break; case 't': p = strchr(rcv->fname, '/'); @@ -535,7 +536,7 @@ rcv_check_version(rcv_t *rcv) { const char *repover = NULL; char srcver[BUFSIZ] = { '\0' }; - const char *pkgname, *version, *revision, *reverts; + const char *pkgname, *version, *revision, *reverts, *repourl; int sz; assert(rcv); @@ -567,11 +568,13 @@ rcv_check_version(rcv_t *rcv) if (sz < 0 || (size_t)sz >= sizeof srcver) exit(EXIT_FAILURE); - if (rcv->installed) + if (rcv->installed) { rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, pkgname); - else + repourl = NULL; + } else { rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, pkgname); - + xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "repository", &repourl); + } xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover); if (repover) repover += strlen(pkgname)+1; @@ -587,7 +590,8 @@ rcv_check_version(rcv_t *rcv) return 0; repover = repover ? repover : "?"; - rcv_printf(rcv, stdout, pkgname, repover, srcver); + repourl = repourl ? repourl : "?"; + rcv_printf(rcv, stdout, pkgname, repover, srcver, repourl); return 0; } diff --git a/bin/xbps-checkvers/xbps-checkvers.1 b/bin/xbps-checkvers/xbps-checkvers.1 index b0046a6d..85783f6f 100644 --- a/bin/xbps-checkvers/xbps-checkvers.1 +++ b/bin/xbps-checkvers/xbps-checkvers.1 @@ -1,4 +1,4 @@ -.Dd June 13, 2019 +.Dd June 19, 2019 .Dt XBPS-CHECKVERS 1 .Sh NAME .Nm xbps-checkvers @@ -58,6 +58,8 @@ The repository version. The source package version. .It Cm \&%t The requested template name (this can be a sub package). +.It Cm \&%R +The repository url (returns ? if not found). .El .Pp The default format is