pkg: add support for PKGCONF_CMP_NOT_EQUAL Provides rules, completing support of Provides rules (closes #95)

pull/100/head
William Pitcock 2016-09-10 01:51:19 -05:00
parent c81f72bf3c
commit b900e04628
2 changed files with 52 additions and 41 deletions

View File

@ -890,102 +890,88 @@ typedef struct {
} pkgconf_pkg_scan_providers_ctx_t; } pkgconf_pkg_scan_providers_ctx_t;
typedef struct { typedef struct {
const pkgconf_vercmp_res_func_t depcmp;
const pkgconf_vercmp_res_func_t rulecmp[PKGCONF_CMP_COUNT]; const pkgconf_vercmp_res_func_t rulecmp[PKGCONF_CMP_COUNT];
const bool check_a[PKGCONF_CMP_COUNT]; const pkgconf_vercmp_res_func_t depcmp[PKGCONF_CMP_COUNT];
} pkgconf_pkg_provides_vermatch_rule_t; } pkgconf_pkg_provides_vermatch_rule_t;
static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_rules[] = { static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_rules[] = {
[PKGCONF_CMP_ANY] = { [PKGCONF_CMP_ANY] = {
.depcmp = pkgconf_pkg_comparator_any,
.rulecmp = {}, .rulecmp = {},
.depcmp = {},
}, },
[PKGCONF_CMP_LESS_THAN] = { [PKGCONF_CMP_LESS_THAN] = {
.depcmp = pkgconf_pkg_comparator_lt,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte, [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 = { .depcmp = {
[PKGCONF_CMP_GREATER_THAN] = true, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = true, [PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_EQUAL] = true, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_NOT_EQUAL] = true, [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_gte,
}, },
}, },
[PKGCONF_CMP_GREATER_THAN] = { [PKGCONF_CMP_GREATER_THAN] = {
.depcmp = pkgconf_pkg_comparator_gt,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte, [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 = { .depcmp = {
[PKGCONF_CMP_LESS_THAN] = true, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = true, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_EQUAL] = true, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_NOT_EQUAL] = true, [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_lte,
}, },
}, },
[PKGCONF_CMP_LESS_THAN_EQUAL] = { [PKGCONF_CMP_LESS_THAN_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_lte,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte, [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 = { .depcmp = {
[PKGCONF_CMP_GREATER_THAN] = true, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = true, [PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_EQUAL] = true, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_NOT_EQUAL] = true, [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_gt,
}, },
}, },
[PKGCONF_CMP_GREATER_THAN_EQUAL] = { [PKGCONF_CMP_GREATER_THAN_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_gte,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte, [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 = { .depcmp = {
[PKGCONF_CMP_LESS_THAN] = true, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_LESS_THAN_EQUAL] = true, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = true, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_NOT_EQUAL] = true, [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_lt,
}, },
}, },
[PKGCONF_CMP_EQUAL] = { [PKGCONF_CMP_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_eq,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt, [PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte, [PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte, [PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_any, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_eq,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne
} },
.depcmp = {},
}, },
[PKGCONF_CMP_NOT_EQUAL] = { [PKGCONF_CMP_NOT_EQUAL] = {
.depcmp = pkgconf_pkg_comparator_ne,
.rulecmp = { .rulecmp = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none, [PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_none,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_gte, [PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_gte,
@ -994,7 +980,8 @@ static const pkgconf_pkg_provides_vermatch_rule_t pkgconf_pkg_provides_vermatch_
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_lt, [PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_ne, [PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_eq [PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_eq
} },
.depcmp = {},
}, },
}; };
@ -1013,7 +1000,8 @@ pkgconf_pkg_scan_provides_vercmp(const pkgconf_dependency_t *pkgdep, const pkgco
if (rule == NULL) if (rule == NULL)
return false; return false;
if (rule->check_a[provider->compare] && !rule->depcmp(provider->version, pkgdep->version)) if (rule->depcmp[provider->compare] != NULL &&
!rule->depcmp[provider->compare](provider->version, pkgdep->version))
return false; return false;
if (rule->rulecmp[provider->compare] != NULL && if (rule->rulecmp[provider->compare] != NULL &&

View File

@ -414,6 +414,29 @@ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.1
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.2.0'; echo \$?" \ run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.2.0'; echo \$?" \
"0" "0"
# provides-test-meow != 1.3.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow = 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow != 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow > 1.2.9'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow < 1.3.1'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow > 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow < 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow >= 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow >= 1.3.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow <= 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow <= 1.2.9'; echo \$?" \
"0"
# 11) tests for internal getopt implementation with options at the end # 11) tests for internal getopt implementation with options at the end
if [ "x@STRICT_MODE@" = "xno" ]; then if [ "x@STRICT_MODE@" = "xno" ]; then