ipkg: Fix version comparisions

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3827 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Richard Purdie
2008-02-19 10:31:48 +00:00
parent 84e7b04add
commit 4de220459c
5 changed files with 199 additions and 2 deletions

View File

@@ -0,0 +1,111 @@
OE makes heavy use of the revision field so it makes sense to
enable it. We don't want the familiar stuff though so patch that
out.
RP - 19/02/2008
Index: ipkg-0.99.163/pkg.c
===================================================================
--- ipkg-0.99.163.orig/pkg.c 2008-02-19 00:35:03.000000000 +0000
+++ ipkg-0.99.163/pkg.c 2008-02-19 00:36:02.000000000 +0000
@@ -1118,15 +1118,11 @@
return r;
}
-#ifdef USE_DEBVERSION
r = verrevcmp(pkg->revision, ref_pkg->revision);
if (r) {
return r;
}
- r = verrevcmp(pkg->familiar_revision, ref_pkg->familiar_revision);
-#endif
-
return r;
}
@@ -1240,10 +1236,7 @@
{
char *complete_version;
char *epoch_str;
-#ifdef USE_DEBVERSION
char *revision_str;
- char *familiar_revision_str;
-#endif
if (pkg->epoch) {
sprintf_alloc(&epoch_str, "%d:", pkg->epoch);
@@ -1251,33 +1244,18 @@
epoch_str = strdup("");
}
-#ifdef USE_DEBVERSION
if (pkg->revision && strlen(pkg->revision)) {
sprintf_alloc(&revision_str, "-%s", pkg->revision);
} else {
revision_str = strdup("");
}
- if (pkg->familiar_revision && strlen(pkg->familiar_revision)) {
- sprintf_alloc(&familiar_revision_str, "-fam%s", pkg->familiar_revision);
- } else {
- familiar_revision_str = strdup("");
- }
-#endif
-#ifdef USE_DEBVERSION
- sprintf_alloc(&complete_version, "%s%s%s%s",
- epoch_str, pkg->version, revision_str, familiar_revision_str);
-#else
- sprintf_alloc(&complete_version, "%s%s",
- epoch_str, pkg->version);
-#endif
+ sprintf_alloc(&complete_version, "%s%s%s",
+ epoch_str, pkg->version, revision_str);
free(epoch_str);
-#ifdef USE_DEBVERSION
free(revision_str);
- free(familiar_revision_str);
-#endif
return complete_version;
}
Index: ipkg-0.99.163/pkg_parse.c
===================================================================
--- ipkg-0.99.163.orig/pkg_parse.c 2008-02-19 00:35:03.000000000 +0000
+++ ipkg-0.99.163/pkg_parse.c 2008-02-19 00:38:42.000000000 +0000
@@ -105,9 +105,7 @@
int parseVersion(pkg_t *pkg, char *raw)
{
char *colon, *eepochcolon;
-#ifdef USE_DEBVERSION
char *hyphen;
-#endif
unsigned long epoch;
if (!*raw) {
@@ -149,23 +147,12 @@
}
strcpy(pkg->version, raw);
-#ifdef USE_DEBVERSION
hyphen= strrchr(pkg->version,'-');
if (hyphen) {
*hyphen++= 0;
- if (strncmp("fam", hyphen, 3) == 0) {
- pkg->familiar_revision=hyphen+3;
- hyphen= strrchr(pkg->version,'-');
- if (hyphen) {
- *hyphen++= 0;
- pkg->revision = hyphen;
- }
- } else {
pkg->revision = hyphen;
- }
}
-#endif
/*
fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n",

View File

@@ -0,0 +1,84 @@
Update the version comparision to a more recent one from dpkg. This
means it now recognises 0.0-foo > 0.0+foo as it should.
RP - 19/02/2008
Index: ipkg-0.99.163/pkg.c
===================================================================
--- ipkg-0.99.163.orig/pkg.c 2008-02-18 11:24:45.000000000 +0000
+++ ipkg-0.99.163/pkg.c 2008-02-19 00:24:50.000000000 +0000
@@ -1128,43 +1130,37 @@
return r;
}
-int verrevcmp(const char *val, const char *ref)
-{
- int vc, rc;
- long vl, rl;
- const char *vp, *rp;
- const char *vsep, *rsep;
-
- if (!val) val= "";
- if (!ref) ref= "";
- for (;;) {
- vp= val; while (*vp && !isdigit(*vp)) vp++;
- rp= ref; while (*rp && !isdigit(*rp)) rp++;
- for (;;) {
- vc= (val == vp) ? 0 : *val++;
- rc= (ref == rp) ? 0 : *ref++;
- if (!rc && !vc) break;
- if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
- if (rc && !isalpha(rc)) rc += 256;
- if (vc != rc) return vc - rc;
- }
- val= vp;
- ref= rp;
- vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
- rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
- if (vl != rl) return vl - rl;
-
- vc = *val;
- rc = *ref;
- vsep = strchr(".-", vc);
- rsep = strchr(".-", rc);
- if (vsep && !rsep) return -1;
- if (!vsep && rsep) return +1;
-
- if (!*val && !*ref) return 0;
- if (!*val) return -1;
- if (!*ref) return +1;
- }
+/* assume ascii; warning: evaluates x multiple times! */
+#define order(x) ((x) == '~' ? -1 \
+ : isdigit((x)) ? 0 \
+ : !(x) ? 0 \
+ : isalpha((x)) ? (x) \
+ : (x) + 256)
+
+static int verrevcmp(const char *val, const char *ref) {
+ if (!val) val= "";
+ if (!ref) ref= "";
+
+ while (*val || *ref) {
+ int first_diff= 0;
+
+ while ( (*val && !isdigit(*val)) || (*ref && !isdigit(*ref)) ) {
+ int vc= order(*val), rc= order(*ref);
+ if (vc != rc) return vc - rc;
+ val++; ref++;
+ }
+
+ while ( *val == '0' ) val++;
+ while ( *ref == '0' ) ref++;
+ while (isdigit(*val) && isdigit(*ref)) {
+ if (!first_diff) first_diff= *val - *ref;
+ val++; ref++;
+ }
+ if (isdigit(*val)) return 1;
+ if (isdigit(*ref)) return -1;
+ if (first_diff) return first_diff;
+ }
+ return 0;
}
int pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op)

View File

@@ -1,4 +1,4 @@
require ipkg.inc
require ipkg-native.inc
PR = "r2"
PR = "r3"

View File

@@ -11,6 +11,8 @@ AUTO_LIBNAME_PKGS = "libipkg"
SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')} \
file://fix_tar_extension.patch;patch=1 \
file://update_version_comparision.patch;patch=1 \
file://enable_debversion.patch;patch=1 \
file://terse.patch;patch=1 \
file://ipkg_bugfix.patch;patch=1 \
file://noupdalt.patch;patch=1"

View File

@@ -1,4 +1,4 @@
require ipkg.inc
PR = "r9"
PR = "r10"
RDEPENDS_${PN} += "${VIRTUAL-RUNTIME_update-alternatives}"