diff --git a/lib/conf.c b/lib/conf.c index f455bd92..1a824984 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -59,7 +59,7 @@ store_vars(struct xbps_handle *xhp, xbps_dictionary_t *d, if (*d == NULL) *d = xbps_dictionary_create(); - if (xhp->vpkgd_conf) + if (xhp->vpkgd_conf == NULL) xhp->vpkgd_conf = xbps_dictionary_create(); /* diff --git a/lib/plist_find.c b/lib/plist_find.c index 9f387897..cff0a49d 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -304,7 +304,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, xbps_dictionary_t pkgd = NULL; const char *vpkg; - /* Try matching vpkg from configuration files */ + /* Try matching vpkg via xhp->vpkgd */ vpkg = vpkg_user_conf(xhp, pkg, false); if (vpkg != NULL) { if (xbps_pkgpattern_version(vpkg)) diff --git a/lib/plist_match.c b/lib/plist_match.c index 6dac70e2..d3b62966 100644 --- a/lib/plist_match.c +++ b/lib/plist_match.c @@ -42,11 +42,15 @@ bool xbps_match_virtual_pkg_in_array(xbps_array_t a, const char *str) { - if ((xbps_match_pkgname_in_array(a, str)) || - (xbps_match_pkgdep_in_array(a, str)) || - (xbps_match_pkgpattern_in_array(a, str))) + if (xbps_pkgpattern_version(str)) { + if (xbps_match_pkgdep_in_array(a, str) || + xbps_match_pkgpattern_in_array(a, str)) return true; - + } else if (xbps_pkg_version(str)) { + return xbps_match_string_in_array(a, str); + } else { + return xbps_match_pkgname_in_array(a, str); + } return false; } diff --git a/lib/repo.c b/lib/repo.c index 1b0755d2..693cf419 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -398,8 +398,7 @@ xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg) pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg); if (pkgd) { - xbps_dictionary_set_cstring_nocopy(pkgd, - "repository", repo->uri); + xbps_dictionary_set_cstring_nocopy(pkgd, "repository", repo->uri); return pkgd; } return NULL; @@ -417,14 +416,14 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) return NULL; /* Try matching vpkg from configuration files */ - if ((pkgd = xbps_find_virtualpkg_in_conf(repo->xhp, repo->idx, pkg))) + if ((pkgd = xbps_find_virtualpkg_in_conf(repo->xhp, repo->idx, pkg))) { + xbps_dictionary_set_cstring_nocopy(pkgd, "repository", repo->uri); return pkgd; - + } /* ... otherwise match a real pkg */ pkgd = xbps_find_pkg_in_dict(repo->idx, pkg); if (pkgd) { - xbps_dictionary_set_cstring_nocopy(pkgd, - "repository", repo->uri); + xbps_dictionary_set_cstring_nocopy(pkgd, "repository", repo->uri); return pkgd; } diff --git a/tests/xbps/libxbps/shell/vpkg_test.sh b/tests/xbps/libxbps/shell/vpkg_test.sh index 9876e4d2..9771d042 100644 --- a/tests/xbps/libxbps/shell/vpkg_test.sh +++ b/tests/xbps/libxbps/shell/vpkg_test.sh @@ -334,6 +334,35 @@ vpkg_provider_remove_body() { atf_check_equal $? 19 } + +atf_test_case vpkg_multirepo + +vpkg_multirepo_head() { + atf_set "descr" "Tests for virtual pkgs: vpkg provider in multiple repos" +} + +vpkg_multirepo_body() { + mkdir empty repo-1 repo-2 + + cd repo-1 + xbps-create -n A-1.0_1 -s A -A noarch -P V-0_1 ../empty + atf_check_equal $? 0 + + cd ../repo-2 + xbps-create -n B-1.0_1 -s B -A noarch -P V-0_1 ../empty + atf_check_equal $? 0 + + cd .. + xbps-rindex -a repo-1/*.xbps + atf_check_equal $? 0 + xbps-rindex -a repo-2/*.xbps + atf_check_equal $? 0 + + echo "virtualpkg=V-0_1:B" > virtualpkg.conf + out="$(xbps-install -C $PWD -r root --repo=repo-1 --repo=repo-2 -n V|awk '{print $1}')" + atf_check_equal "$out" "B-1.0_1" +} + atf_init_test_cases() { atf_add_test_case vpkg_dont_update atf_add_test_case vpkg_replace_provider @@ -344,4 +373,5 @@ atf_init_test_cases() { atf_add_test_case vpkg_incompat_downgrade atf_add_test_case vpkg_provider_and_revdeps_downgrade atf_add_test_case vpkg_provider_remove + atf_add_test_case vpkg_multirepo }