From 9d582abe0f790c981fcb03c5a3a1e776f40d1dc5 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 5 Jan 2015 16:04:22 +0100 Subject: [PATCH] Fixed a regression with virtual packages declared via xbps.d(5). Added a new test case to verify its correctness. Somehow virtual packages declared via xbps.d(5) were not working correctly for dependencies. This now works as expected with vpkgs declared with and without a version component. --- NEWS | 4 ++- lib/plist_find.c | 42 ++++++++++++++++++++------- tests/xbps/libxbps/shell/vpkg_test.sh | 33 +++++++++++++++++++++ 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index dbfd72c3..d40363d2 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ -xbps-0.44 (???): +xbps-0.43.1 (2015-01-05): + + * Fixed a regression in virtual packages defined via xbps.d(5) introduced in 0.43. xbps-0.43 (2014-12-31): diff --git a/lib/plist_find.c b/lib/plist_find.c index 1337d5c7..b6b0c61a 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -207,32 +207,54 @@ vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg) while ((obj = xbps_object_iterator_next(iter))) { xbps_string_t rpkg; + char *dpkgname, *vpkgname; const char *vpkg_conf; vpkg_conf = xbps_dictionary_keysym_cstring_nocopy(obj); rpkg = xbps_dictionary_get_keysym(xhp->vpkgd, obj); pkg = xbps_string_cstring_nocopy(rpkg); - if (xbps_pkgpattern_version(vpkg_conf)) { - if (!xbps_pkgpattern_match(vpkg_conf, vpkg)) { - continue; - } + if (xbps_pkg_version(vpkg_conf)) { + vpkgname = xbps_pkg_name(vpkg_conf); + assert(vpkgname); } else { + vpkgname = strdup(vpkg_conf); + assert(vpkgname); + } + + if (xbps_pkgpattern_version(vpkg)) { + char *vpkgver; + if (xbps_pkg_version(vpkg_conf)) { - char *vpkgname = xbps_pkg_name(vpkg_conf); - assert(vpkgname); - if (strcmp(vpkg, vpkgname)) { + if (!xbps_pkgpattern_match(vpkg_conf, vpkg)) { free(vpkgname); continue; } - free(vpkgname); } else { - /* assume a correct pkgname */ - if (strcmp(vpkg, vpkg_conf)) { + vpkgver = xbps_xasprintf("%s-999999_1", vpkg_conf); + if (!xbps_pkgpattern_match(vpkgver, vpkg)) { + free(vpkgver); + free(vpkgname); continue; } + free(vpkgver); + } + } else if (xbps_pkg_version(vpkg)) { + dpkgname = xbps_pkg_name(vpkg); + assert(dpkgname); + if (strcmp(dpkgname, vpkgname)) { + free(dpkgname); + free(vpkgname); + continue; + } + free(dpkgname); + } else { + if (strcmp(vpkg, vpkgname)) { + free(vpkgname); + continue; } } + free(vpkgname); xbps_dbg_printf(xhp, "matched vpkg `%s' with `%s (provides %s)`\n", vpkg, pkg, vpkg_conf); found = true; diff --git a/tests/xbps/libxbps/shell/vpkg_test.sh b/tests/xbps/libxbps/shell/vpkg_test.sh index 73f44af0..af19b11f 100644 --- a/tests/xbps/libxbps/shell/vpkg_test.sh +++ b/tests/xbps/libxbps/shell/vpkg_test.sh @@ -160,9 +160,42 @@ vpkg03_body() { atf_check_equal $out $exp } +atf_test_case vpkg04 + +vpkg04_head() { + atf_set "descr" "Tests for virtual pkgs: dependency provider in configuration file" +} + +vpkg04_body() { + mkdir some_repo + mkdir -p pkg_gawk pkg_blah + cd some_repo + xbps-create -A noarch -n blah-1.0_1 -s "blah pkg" ../pkg_blah + atf_check_equal $? 0 + xbps-create -A noarch -n gawk-1.0_1 -s "gawk pkg" --dependencies "vpkg>=4.4" ../pkg_gawk + atf_check_equal $? 0 + + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + mkdir -p root/xbps.d + echo "virtualpkg=vpkg:blah" > root/xbps.d/blah.conf + xbps-install -C xbps.d -r root --repository=$PWD/some_repo -dy gawk + atf_check_equal $? 0 + + rm -rf root + mkdir -p root/xbps.d + echo "virtualpkg=vpkg-4.4_1:blah" > root/xbps.d/blah.conf + xbps-install -C xbps.d -r root --repository=$PWD/some_repo -dy gawk + atf_check_equal $? 0 + +} + atf_init_test_cases() { atf_add_test_case vpkg00 atf_add_test_case vpkg01 atf_add_test_case vpkg02 atf_add_test_case vpkg03 + atf_add_test_case vpkg04 }