xbps-checkvers: use binpkg's pkgname rather than srcpkgs.

Up until now `xbps-checkvers` would only check for the
real sourcepkg, this broke detection of binary packages
that are subpkgs.

Added a new test case.

Close #192
This commit is contained in:
Juan RP
2019-12-27 12:18:30 +01:00
parent 0e1482917a
commit 7a220b37db
2 changed files with 51 additions and 0 deletions

View File

@ -366,6 +366,21 @@ rcv_get_pkgver(rcv_t *rcv)
else
val = strndup(v, vlen);
/*
* Do not override binary package "pkgname"
* with the one from template, because the
* former might be a subpkg.
*/
if (strcmp(key, "pkgname") == 0) {
char *s;
size_t len;
free(val);
s = strchr(rcv->fname, '/');
len = s ? strlen(rcv->fname) - strlen(s) : strlen(rcv->fname);
val = strndup(rcv->fname, len);
assert(val);
}
if (!xbps_dictionary_set(rcv->env, key,
xbps_string_create_cstring(val))) {
fprintf(stderr, "error: xbps_dictionary_set");