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.
This commit is contained in:
Juan RP 2015-01-05 16:04:22 +01:00
parent 3e01986864
commit 9d582abe0f
3 changed files with 68 additions and 11 deletions

4
NEWS
View File

@ -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):

View File

@ -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_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)) {
if (!xbps_pkgpattern_match(vpkg_conf, vpkg)) {
free(vpkgname);
continue;
}
} else {
if (xbps_pkg_version(vpkg_conf)) {
char *vpkgname = xbps_pkg_name(vpkg_conf);
assert(vpkgname);
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);
} else {
/* assume a correct pkgname */
if (strcmp(vpkg, vpkg_conf)) {
continue;
}
}
}
xbps_dbg_printf(xhp, "matched vpkg `%s' with `%s (provides %s)`\n",
vpkg, pkg, vpkg_conf);
found = true;

View File

@ -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
}