diff options
author | pixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2012-11-22 04:18:17 (EST) |
---|---|---|
committer | pixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2012-11-22 04:18:17 (EST) |
commit | 932c8d8f499f26d3f7ac0b5b0307f6a886396a0d (patch) | |
tree | 76ae05d6d664f45e6cb3d2d649319dcef989f363 /libopkg/pkg_depends.c | |
parent | 15f255915ce893750165c89af9d1ebbbc571a8dc (diff) |
pkg_depends: fix version constraints
* factor parsing version constraint to str_to_constraint and use that
from pkg (pkg_version_satisfied) and also pkg_depends (parseDepends)
* fix constraint_to_str(), for EARLIER and LATER it was using '<' and
'>' which is parsed later as EARLIER_EQUAL and LATER_EQUAL
* show notice when deprecated '<' or '>' is used
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
git-svn-id: http://opkg.googlecode.com/svn/trunk@644 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg_depends.c')
-rw-r--r-- | libopkg/pkg_depends.c | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c index d45f697..243fac7 100644 --- a/libopkg/pkg_depends.c +++ b/libopkg/pkg_depends.c @@ -781,7 +781,7 @@ constraint_to_str(enum version_constraint c) case NONE: return ""; case EARLIER: - return "< "; + return "<< "; case EARLIER_EQUAL: return "<= "; case EQUAL: @@ -789,12 +789,51 @@ constraint_to_str(enum version_constraint c) case LATER_EQUAL: return ">= "; case LATER: - return "> "; + return ">> "; } return ""; } +enum version_constraint +str_to_constraint(char **str) +{ + if(!strncmp(*str, "<<", 2)){ + *str += 2; + return EARLIER; + } + else if(!strncmp(*str, "<=", 2)){ + *str += 2; + return EARLIER_EQUAL; + } + else if(!strncmp(*str, ">=", 2)){ + *str += 2; + return LATER_EQUAL; + } + else if(!strncmp(*str, ">>", 2)){ + *str += 2; + return LATER; + } + else if(!strncmp(*str, "=", 1)){ + *str += 1; + return EQUAL; + } + /* should these be here to support deprecated designations; dpkg does */ + else if(!strncmp(*str, "<", 1)){ + *str += 1; + opkg_msg(NOTICE, "Deprecated version constraint '<' was used with the same meaning as '<='. Use '<<' for EARLIER constraint.\n"); + return EARLIER_EQUAL; + } + else if(!strncmp(*str, ">", 1)){ + *str += 1; + opkg_msg(NOTICE, "Deprecated version constraint '>' was used with the same meaning as '>='. Use '>>' for LATER constraint.\n"); + return LATER_EQUAL; + } + else { + return NONE; + } +} + /* * Returns a printable string for pkg's dependency at the specified idx. The * resultant string must be passed to free() by the caller. @@ -949,35 +988,7 @@ static int parseDepends(compound_depend_t *compound_depend, /* extract constraint and version */ if(*src == '('){ src++; - if(!strncmp(src, "<<", 2)){ - possibilities[i]->constraint = EARLIER; - src += 2; - } - else if(!strncmp(src, "<=", 2)){ - possibilities[i]->constraint = EARLIER_EQUAL; - src += 2; - } - else if(!strncmp(src, ">=", 2)){ - possibilities[i]->constraint = LATER_EQUAL; - src += 2; - } - else if(!strncmp(src, ">>", 2)){ - possibilities[i]->constraint = LATER; - src += 2; - } - else if(!strncmp(src, "=", 1)){ - possibilities[i]->constraint = EQUAL; - src++; - } - /* should these be here to support deprecated designations; dpkg does */ - else if(!strncmp(src, "<", 1)){ - possibilities[i]->constraint = EARLIER_EQUAL; - src++; - } - else if(!strncmp(src, ">", 1)){ - possibilities[i]->constraint = LATER_EQUAL; - src++; - } + possibilities[i]->constraint = str_to_constraint(&src); /* now we have any constraint, pass space to version string */ while(isspace(*src)) src++; |