From 7a220b37db3ee3cc6009223a0015a596ca64d55f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 27 Dec 2019 12:18:30 +0100 Subject: [PATCH] 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 --- bin/xbps-checkvers/main.c | 15 +++++++++ tests/xbps/xbps-checkvers/checkvers_test.sh | 36 +++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/bin/xbps-checkvers/main.c b/bin/xbps-checkvers/main.c index f1b0e978..3e9aedce 100644 --- a/bin/xbps-checkvers/main.c +++ b/bin/xbps-checkvers/main.c @@ -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"); diff --git a/tests/xbps/xbps-checkvers/checkvers_test.sh b/tests/xbps/xbps-checkvers/checkvers_test.sh index 8f8d6083..e1936378 100755 --- a/tests/xbps/xbps-checkvers/checkvers_test.sh +++ b/tests/xbps/xbps-checkvers/checkvers_test.sh @@ -462,6 +462,41 @@ EOF atf_check_equal "$out" "process ? 1_1 process ?" } +atf_test_case subpkg + +subpkg_head() { + atf_set "descr" "xbps-checkvers(1): test subpkgs" +} +subpkg_body() { + mkdir -p some_repo pkg_A void-packages/srcpkgs/A + touch pkg_A/file00 + cat > void-packages/srcpkgs/A/template <