pkg: fill in a lot of the fuzzy matching stuff (but some of it may be wrong, needs to be looked at)

pull/100/head
William Pitcock 2016-09-09 01:04:26 -05:00
parent 7c0264ac7a
commit 892a03cd8c
3 changed files with 136 additions and 12 deletions

View File

@ -892,6 +892,7 @@ typedef struct {
typedef struct {
const pkgconf_vercmp_res_func_t depcmp;
const pkgconf_vercmp_res_func_t rulecmp[PKGCONF_CMP_COUNT];
const bool check_a[PKGCONF_CMP_COUNT];
} pkgconf_pkg_provides_vermatch_rule_t;
static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_rules[] = {
@ -909,7 +910,13 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
}
},
.check_a = {
[PKGCONF_CMP_GREATER_THAN] = true,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = true,
[PKGCONF_CMP_EQUAL] = true,
[PKGCONF_CMP_NOT_EQUAL] = true,
},
},
[PKGCONF_CMP_GREATER_THAN] = {
.depcmp = pkgconf_pkg_comparator_gt,
@ -921,7 +928,13 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
}
},
.check_a = {
[PKGCONF_CMP_LESS_THAN] = true,
[PKGCONF_CMP_LESS_THAN_EQUAL] = true,
[PKGCONF_CMP_EQUAL] = true,
[PKGCONF_CMP_NOT_EQUAL] = true,
},
},
[PKGCONF_CMP_LESS_THAN_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_lte,
@ -933,7 +946,13 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
}
},
.check_a = {
[PKGCONF_CMP_GREATER_THAN] = true,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = true,
[PKGCONF_CMP_EQUAL] = true,
[PKGCONF_CMP_NOT_EQUAL] = true,
},
},
[PKGCONF_CMP_GREATER_THAN_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_gte,
@ -945,7 +964,13 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
}
},
.check_a = {
[PKGCONF_CMP_LESS_THAN] = true,
[PKGCONF_CMP_LESS_THAN_EQUAL] = true,
[PKGCONF_CMP_EQUAL] = true,
[PKGCONF_CMP_NOT_EQUAL] = true,
},
},
[PKGCONF_CMP_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_eq,
@ -963,12 +988,12 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
.depcmp = pkgconf_pkg_comparator_ne,
.rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_eq
}
},
};
@ -988,7 +1013,7 @@ pkgconf_pkg_scan_provides_vercmp(const pkgconf_dependency_t *pkgdep, const pkgco
if (rule == NULL)
return false;
if (!rule->depcmp(provider->version, pkgdep->version))
if (rule->check_a[provider->compare] && !rule->depcmp(provider->version, pkgdep->version))
return false;
if (rule->rulecmp[provider->compare] != NULL &&

View File

@ -3,4 +3,4 @@ Description: A testing pkg-config file
Version: 1.2.3
Libs: -lfoo
Cflags: -I/usr/include/foo
Provides: provides-test-foo = 1.0.0, provides-test-baz >= 1.1.0, provides-test-moo <= 1.2.0
Provides: provides-test-foo = 1.0.0, provides-test-bar > 1.1.0, provides-test-baz >= 1.1.0, provides-test-quux < 1.2.0, provides-test-moo <= 1.2.0

View File

@ -316,6 +316,105 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo > 1.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo < 1.0.0'; echo \$?" \
"1"
# provides-test-bar > 1.1.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar = 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar >= 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar <= 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar != 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar != 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar > 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar <= 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar < 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar > 1.2.0'; echo \$?" \
"0"
# provides-test-baz >= 1.1.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz = 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz <= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz != 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz != 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz > 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz < 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz < 1.2.0'; echo \$?" \
"0"
# provides-test-quux < 1.2.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux = 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux <= 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux <= 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux > 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux > 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux < 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux < 1.2.0'; echo \$?" \
"1"
# provides-test-moo <= 1.2.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo = 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.2.1'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo <= 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo != 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo != 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo > 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo > 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.2.0'; echo \$?" \
"0"
# 11) tests for internal getopt implementation with options at the end
if [ "x@STRICT_MODE@" = "xno" ]; then
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} foo --libs" \