xbps-checkvers: restore previous behaviour after 7a220b37db.

The '%n' pkgname fmt option still needs to be the sourcepkg
for xbps-src to work with no additional changes.

This restores previous behaviour, and uses binpkg's pkgname
while checking for pkgdb/repo.
This commit is contained in:
Juan RP 2019-12-27 18:04:53 +01:00
parent 90c040f37f
commit 64aeabf3f6
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368
2 changed files with 23 additions and 37 deletions

View File

@ -46,22 +46,15 @@
#define GOT_REVISION_VAR 0x4
typedef struct _rcv_t {
const char *prog, *fname;
char *xbps_conf, *rootdir, *distdir;
char *buf;
size_t bufsz;
size_t len;
char *ptr;
const char *prog, *fname, *format;
char *xbps_conf, *rootdir, *distdir, *buf, *ptr, *cachefile;
size_t bufsz, len;
uint8_t have_vars;
bool show_all, manual, installed;
xbps_dictionary_t env;
xbps_dictionary_t pkgd;
xbps_dictionary_t cache;
struct xbps_handle xhp;
bool show_all;
bool manual;
bool installed;
const char *format;
char *cachefile;
} rcv_t;
typedef int (*rcv_check_func)(rcv_t *);
@ -366,21 +359,6 @@ 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");
@ -550,9 +528,10 @@ static int
rcv_check_version(rcv_t *rcv)
{
const char *repover = NULL;
char srcver[BUFSIZ] = { '\0' };
char srcver[BUFSIZ] = { '\0' }, *binpkgname = NULL, *s = NULL;
const char *pkgname, *version, *revision, *reverts, *repourl;
int sz;
size_t len;
assert(rcv);
@ -583,17 +562,24 @@ rcv_check_version(rcv_t *rcv)
if (sz < 0 || (size_t)sz >= sizeof srcver)
exit(EXIT_FAILURE);
/* Check against binpkg's pkgname, not pkgname from template */
s = strchr(rcv->fname, '/');
len = s ? strlen(rcv->fname) - strlen(s) : strlen(rcv->fname);
binpkgname = strndup(rcv->fname, len);
assert(binpkgname);
repourl = NULL;
if (rcv->installed) {
rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, pkgname);
rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, binpkgname);
} else {
rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, pkgname);
rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, binpkgname);
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "repository", &repourl);
}
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover);
if (repover)
repover += strlen(pkgname)+1;
repover += strlen(binpkgname)+1;
free(binpkgname);
if (!repover && rcv->manual)
;
else if (rcv->show_all)

View File

@ -468,7 +468,7 @@ subpkg_head() {
atf_set "descr" "xbps-checkvers(1): test subpkgs"
}
subpkg_body() {
mkdir -p some_repo pkg_A void-packages/srcpkgs/A
mkdir -p repo pkg_A void-packages/srcpkgs/A
touch pkg_A/file00
cat > void-packages/srcpkgs/A/template <<EOF
pkgname=A
@ -478,21 +478,21 @@ revision=1
EOF
ln -s A void-packages/srcpkgs/A-subpkg
ln -s A void-packages/srcpkgs/B-subpkg
cd some_repo
cd repo
xbps-create -A noarch -n A-subpkg-1.1_1 -s "A-subpkg pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm A-subpkg)
out=$(xbps-checkvers -i -R $PWD/repo -D $PWD/void-packages -sm A-subpkg)
atf_check_equal $? 0
atf_check_equal "$out" "A-subpkg 1.1_1 1.0_1 A-subpkg $PWD/some_repo"
atf_check_equal "$out" "A 1.1_1 1.0_1 A-subpkg $PWD/repo"
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm B-subpkg)
out=$(xbps-checkvers -i -R repo -D $PWD/void-packages -sm B-subpkg)
atf_check_equal $? 0
atf_check_equal "$out" "B-subpkg ? 1.0_1 B-subpkg ?"
atf_check_equal "$out" "A ? 1.0_1 B-subpkg ?"
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm A)
out=$(xbps-checkvers -i -R repo -D $PWD/void-packages -sm A)
atf_check_equal $? 0
atf_check_equal "$out" "A ? 1.0_1 A ?"
}