xbps-checkvers: implement --format %R (repository).

Close #128
This commit is contained in:
Juan RP 2019-06-19 13:07:42 +02:00
parent 3a00a9eb9b
commit 0727d9a53a
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368
2 changed files with 13 additions and 7 deletions

View File

@ -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;
}

View File

@ -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