diff options
| author | Martin Jansa <martin.jansa@gmail.com> | 2012-10-01 13:41:42 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-10-02 11:40:51 +0100 |
| commit | 97160f8e92af94640692846997b5f242067fb3bc (patch) | |
| tree | 6b45b1a84db624277dfab046a1273d2c58557b24 | |
| parent | 31fcfefbfdaa7c4c1061c5204302fb9d6fa0d1b0 (diff) | |
| download | poky-97160f8e92af94640692846997b5f242067fb3bc.tar.gz | |
opkg: fix version constraints in conflicts, depends, replaces
* http://code.google.com/p/opkg/issues/detail?id=94
(From OE-Core rev: 7ebce895a215b31cf01aea2ac43e554f96ef814f)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 228 insertions, 1 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/0009-pkg_depends-fix-version-constraints.patch b/meta/recipes-devtools/opkg/opkg/0009-pkg_depends-fix-version-constraints.patch new file mode 100644 index 0000000000..f7aa4eac91 --- /dev/null +++ b/meta/recipes-devtools/opkg/opkg/0009-pkg_depends-fix-version-constraints.patch | |||
| @@ -0,0 +1,188 @@ | |||
| 1 | From b93ce2249751e0d90dab38e91691a6e9f33c3512 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 3 | Date: Sat, 29 Sep 2012 11:38:03 +0200 | ||
| 4 | Subject: [PATCH 09/10] pkg_depends: fix version constraints | ||
| 5 | |||
| 6 | * factor parsing version constraint to str_to_constraint and use that | ||
| 7 | from pkg (pkg_version_satisfied) and also pkg_depends (parseDepends) | ||
| 8 | * fix constraint_to_str(), for EARLIER and LATER it was using '<' and | ||
| 9 | '>' which is parsed later as EARLIER_EQUAL and LATER_EQUAL | ||
| 10 | * show notice when deprecated '<' or '>' is used | ||
| 11 | |||
| 12 | Upstream-Status: Submitted | ||
| 13 | http://code.google.com/p/opkg/issues/detail?id=94 | ||
| 14 | |||
| 15 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 16 | --- | ||
| 17 | libopkg/pkg.c | 36 +++++++++++-------------- | ||
| 18 | libopkg/pkg_depends.c | 73 +++++++++++++++++++++++++++++---------------------- | ||
| 19 | libopkg/pkg_depends.h | 1 + | ||
| 20 | 3 files changed, 59 insertions(+), 51 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/libopkg/pkg.c b/libopkg/pkg.c | ||
| 23 | index 255c673..1e98b9c 100644 | ||
| 24 | --- a/libopkg/pkg.c | ||
| 25 | +++ b/libopkg/pkg.c | ||
| 26 | @@ -968,28 +968,24 @@ pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op) | ||
| 27 | int r; | ||
| 28 | |||
| 29 | r = pkg_compare_versions(it, ref); | ||
| 30 | + char *op2 = op; | ||
| 31 | + enum version_constraint constraint = str_to_constraint(&op2); | ||
| 32 | |||
| 33 | - if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) { | ||
| 34 | - return r <= 0; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) { | ||
| 38 | - return r >= 0; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - if (strcmp(op, "<<") == 0) { | ||
| 42 | - return r < 0; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - if (strcmp(op, ">>") == 0) { | ||
| 46 | - return r > 0; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - if (strcmp(op, "=") == 0) { | ||
| 50 | - return r == 0; | ||
| 51 | + switch (constraint) | ||
| 52 | + { | ||
| 53 | + case EARLIER_EQUAL: | ||
| 54 | + return r <= 0; | ||
| 55 | + case LATER_EQUAL: | ||
| 56 | + return r >= 0; | ||
| 57 | + case EARLIER: | ||
| 58 | + return r < 0; | ||
| 59 | + case LATER: | ||
| 60 | + return r > 0; | ||
| 61 | + case EQUAL: | ||
| 62 | + return r == 0; | ||
| 63 | + case NONE: | ||
| 64 | + opkg_msg(ERROR, "Unknown operator: %s.\n", op); | ||
| 65 | } | ||
| 66 | - | ||
| 67 | - opkg_msg(ERROR, "Unknown operator: %s.\n", op); | ||
| 68 | return 0; | ||
| 69 | } | ||
| 70 | |||
| 71 | diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c | ||
| 72 | index a72eed7..3dd8240 100644 | ||
| 73 | --- a/libopkg/pkg_depends.c | ||
| 74 | +++ b/libopkg/pkg_depends.c | ||
| 75 | @@ -781,7 +781,7 @@ constraint_to_str(enum version_constraint c) | ||
| 76 | case NONE: | ||
| 77 | return ""; | ||
| 78 | case EARLIER: | ||
| 79 | - return "< "; | ||
| 80 | + return "<< "; | ||
| 81 | case EARLIER_EQUAL: | ||
| 82 | return "<= "; | ||
| 83 | case EQUAL: | ||
| 84 | @@ -789,12 +789,51 @@ constraint_to_str(enum version_constraint c) | ||
| 85 | case LATER_EQUAL: | ||
| 86 | return ">= "; | ||
| 87 | case LATER: | ||
| 88 | - return "> "; | ||
| 89 | + return ">> "; | ||
| 90 | } | ||
| 91 | |||
| 92 | return ""; | ||
| 93 | } | ||
| 94 | |||
| 95 | +enum version_constraint | ||
| 96 | +str_to_constraint(char **str) | ||
| 97 | +{ | ||
| 98 | + if(!strncmp(*str, "<<", 2)){ | ||
| 99 | + *str += 2; | ||
| 100 | + return EARLIER; | ||
| 101 | + } | ||
| 102 | + else if(!strncmp(*str, "<=", 2)){ | ||
| 103 | + *str += 2; | ||
| 104 | + return EARLIER_EQUAL; | ||
| 105 | + } | ||
| 106 | + else if(!strncmp(*str, ">=", 2)){ | ||
| 107 | + *str += 2; | ||
| 108 | + return LATER_EQUAL; | ||
| 109 | + } | ||
| 110 | + else if(!strncmp(*str, ">>", 2)){ | ||
| 111 | + *str += 2; | ||
| 112 | + return LATER; | ||
| 113 | + } | ||
| 114 | + else if(!strncmp(*str, "=", 1)){ | ||
| 115 | + *str += 1; | ||
| 116 | + return EQUAL; | ||
| 117 | + } | ||
| 118 | + /* should these be here to support deprecated designations; dpkg does */ | ||
| 119 | + else if(!strncmp(*str, "<", 1)){ | ||
| 120 | + *str += 1; | ||
| 121 | + opkg_msg(NOTICE, "Deprecated version constraint '<' was used with the same meaning as '<='. Use '<<' for EARLIER constraint.\n"); | ||
| 122 | + return EARLIER_EQUAL; | ||
| 123 | + } | ||
| 124 | + else if(!strncmp(*str, ">", 1)){ | ||
| 125 | + *str += 1; | ||
| 126 | + opkg_msg(NOTICE, "Deprecated version constraint '>' was used with the same meaning as '>='. Use '>>' for LATER constraint.\n"); | ||
| 127 | + return LATER_EQUAL; | ||
| 128 | + } | ||
| 129 | + else { | ||
| 130 | + return NONE; | ||
| 131 | + } | ||
| 132 | +} | ||
| 133 | + | ||
| 134 | /* | ||
| 135 | * Returns a printable string for pkg's dependency at the specified idx. The | ||
| 136 | * resultant string must be passed to free() by the caller. | ||
| 137 | @@ -949,35 +988,7 @@ static int parseDepends(compound_depend_t *compound_depend, | ||
| 138 | /* extract constraint and version */ | ||
| 139 | if(*src == '('){ | ||
| 140 | src++; | ||
| 141 | - if(!strncmp(src, "<<", 2)){ | ||
| 142 | - possibilities[i]->constraint = EARLIER; | ||
| 143 | - src += 2; | ||
| 144 | - } | ||
| 145 | - else if(!strncmp(src, "<=", 2)){ | ||
| 146 | - possibilities[i]->constraint = EARLIER_EQUAL; | ||
| 147 | - src += 2; | ||
| 148 | - } | ||
| 149 | - else if(!strncmp(src, ">=", 2)){ | ||
| 150 | - possibilities[i]->constraint = LATER_EQUAL; | ||
| 151 | - src += 2; | ||
| 152 | - } | ||
| 153 | - else if(!strncmp(src, ">>", 2)){ | ||
| 154 | - possibilities[i]->constraint = LATER; | ||
| 155 | - src += 2; | ||
| 156 | - } | ||
| 157 | - else if(!strncmp(src, "=", 1)){ | ||
| 158 | - possibilities[i]->constraint = EQUAL; | ||
| 159 | - src++; | ||
| 160 | - } | ||
| 161 | - /* should these be here to support deprecated designations; dpkg does */ | ||
| 162 | - else if(!strncmp(src, "<", 1)){ | ||
| 163 | - possibilities[i]->constraint = EARLIER_EQUAL; | ||
| 164 | - src++; | ||
| 165 | - } | ||
| 166 | - else if(!strncmp(src, ">", 1)){ | ||
| 167 | - possibilities[i]->constraint = LATER_EQUAL; | ||
| 168 | - src++; | ||
| 169 | - } | ||
| 170 | + possibilities[i]->constraint = str_to_constraint(&src); | ||
| 171 | |||
| 172 | /* now we have any constraint, pass space to version string */ | ||
| 173 | while(isspace(*src)) src++; | ||
| 174 | diff --git a/libopkg/pkg_depends.h b/libopkg/pkg_depends.h | ||
| 175 | index ca0801f..685a722 100644 | ||
| 176 | --- a/libopkg/pkg_depends.h | ||
| 177 | +++ b/libopkg/pkg_depends.h | ||
| 178 | @@ -87,6 +87,7 @@ pkg_vec_t * pkg_hash_fetch_conflicts(pkg_t * pkg); | ||
| 179 | int pkg_dependence_satisfiable(depend_t *depend); | ||
| 180 | int pkg_dependence_satisfied(depend_t *depend); | ||
| 181 | const char* constraint_to_str(enum version_constraint c); | ||
| 182 | +enum version_constraint str_to_constraint(char **str); | ||
| 183 | int is_pkg_in_pkg_vec(pkg_vec_t * vec, pkg_t * pkg); | ||
| 184 | |||
| 185 | #endif | ||
| 186 | -- | ||
| 187 | 1.7.12 | ||
| 188 | |||
diff --git a/meta/recipes-devtools/opkg/opkg/0010-pkg_depends-fix-version_constraints_satisfied.patch b/meta/recipes-devtools/opkg/opkg/0010-pkg_depends-fix-version_constraints_satisfied.patch new file mode 100644 index 0000000000..a13d6585c3 --- /dev/null +++ b/meta/recipes-devtools/opkg/opkg/0010-pkg_depends-fix-version_constraints_satisfied.patch | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | From e9add8fe4a63ef14aba8bd238ddde84d5470b611 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 3 | Date: Sat, 29 Sep 2012 18:56:01 +0200 | ||
| 4 | Subject: [PATCH 10/10] pkg_depends: fix version_constraints_satisfied | ||
| 5 | |||
| 6 | * with | ||
| 7 | Package: a | ||
| 8 | Version: 1 | ||
| 9 | and | ||
| 10 | Conflicts: a (<< 1) | ||
| 11 | we have comparison == 0, but constraint EARLIER is not satisfied! | ||
| 12 | |||
| 13 | Upstream-Status: Submitted | ||
| 14 | http://code.google.com/p/opkg/issues/detail?id=94 | ||
| 15 | |||
| 16 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 17 | --- | ||
| 18 | libopkg/pkg_depends.c | 3 ++- | ||
| 19 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 20 | |||
| 21 | diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c | ||
| 22 | index 3dd8240..be81b7f 100644 | ||
| 23 | --- a/libopkg/pkg_depends.c | ||
| 24 | +++ b/libopkg/pkg_depends.c | ||
| 25 | @@ -464,7 +464,8 @@ int version_constraints_satisfied(depend_t * depends, pkg_t * pkg) | ||
| 26 | else if((depends->constraint == LATER) && | ||
| 27 | (comparison > 0)) | ||
| 28 | return 1; | ||
| 29 | - else if(comparison == 0) | ||
| 30 | + else if((depends->constraint == EQUAL) && | ||
| 31 | + (comparison == 0)) | ||
| 32 | return 1; | ||
| 33 | else if((depends->constraint == LATER_EQUAL) && | ||
| 34 | (comparison >= 0)) | ||
| 35 | -- | ||
| 36 | 1.7.12 | ||
| 37 | |||
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb index 820a2243b2..d89a3f6c66 100644 --- a/meta/recipes-devtools/opkg/opkg_svn.bb +++ b/meta/recipes-devtools/opkg/opkg_svn.bb | |||
| @@ -9,6 +9,8 @@ SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;protocol=http \ | |||
| 9 | file://0006-detect-circular-dependencies.patch \ | 9 | file://0006-detect-circular-dependencies.patch \ |
| 10 | file://0007-merge-newpkg-provides-even-when-oldpkg-provides-exis.patch \ | 10 | file://0007-merge-newpkg-provides-even-when-oldpkg-provides-exis.patch \ |
| 11 | file://0008-select_higher_version.patch \ | 11 | file://0008-select_higher_version.patch \ |
| 12 | file://0009-pkg_depends-fix-version-constraints.patch \ | ||
| 13 | file://0010-pkg_depends-fix-version_constraints_satisfied.patch \ | ||
| 12 | " | 14 | " |
| 13 | 15 | ||
| 14 | S = "${WORKDIR}/trunk" | 16 | S = "${WORKDIR}/trunk" |
| @@ -16,4 +18,4 @@ S = "${WORKDIR}/trunk" | |||
| 16 | SRCREV = "633" | 18 | SRCREV = "633" |
| 17 | PV = "0.1.8+svnr${SRCPV}" | 19 | PV = "0.1.8+svnr${SRCPV}" |
| 18 | 20 | ||
| 19 | PR = "${INC_PR}.4" | 21 | PR = "${INC_PR}.5" |
