summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2012-01-08 10:18:55 +0000
committerJason Woodward2012-01-08 11:51:52 +0000
commit7517a5ba3280de332145985bd6d1f34f656179c2 (patch)
tree41d6e286d76bf3260ba9de70419a6ea59bb2d6eb
parentafebb536b69bb7040bee5fc93f84dfeec1bbe904 (diff)
downloadslapt-get-7517a5ba3280de332145985bd6d1f34f656179c2.tar.gz
[HACK] prefer our architecture in x86/x86_64 multilib package comparison
-rw-r--r--ChangeLog1
-rw-r--r--src/package.c15
-rw-r--r--t/test_packages.c8
3 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 472024c..f3b9161 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.10.2m Jan 08, 2012
+ * prefer our architecture in x86/x86_64 multilib package comparison
* strip whitespace from url before parsing from slapt-getrc
0.10.2l Oct 08, 2011
diff --git a/src/package.c b/src/package.c
index cce8f06..b0ac4a8 100644
--- a/src/package.c
+++ b/src/package.c
@@ -1146,8 +1146,21 @@ int slapt_cmp_pkg_versions(const char *a, const char *b)
if (a_build != NULL && b_build != NULL) {
/* they are equal if the integer values are equal */
/* for instance, "1rob" and "1" will be equal */
- if (atoi(a_build) == atoi(b_build))
+ if (atoi(a_build) == atoi(b_build)) {
+/* prefer our architecture in x86/x86_64 multilib settings */
+#if defined(__x86_64__)
+ if ((strcmp(a_build,b_build) == 0) && (strcmp(a,b) != 0) && (strstr(a,"-x86_64") != NULL && (strstr(b,"-x86_64-") == NULL)))
+ return greater;
+ if ((strcmp(a_build,b_build) == 0) && (strcmp(a,b) != 0) && (strstr(a,"-x86_64") == NULL && (strstr(b,"-x86_64-") != NULL)))
+ return lesser;
+#elif defined(__i386__)
+ if ((strcmp(a_build,b_build) == 0) && (strcmp(a,b) != 0) && (strstr(a,"-x86_64") == NULL && (strstr(b,"-x86_64-") != NULL)))
+ return greater;
+ if ((strcmp(a_build,b_build) == 0) && (strcmp(a,b) != 0) && (strstr(a,"-x86_64") != NULL && (strstr(b,"-x86_64-") == NULL)))
+ return lesser;
+#endif
return equal;
+ }
if (atoi(a_build) < atoi(b_build))
return greater;
diff --git a/t/test_packages.c b/t/test_packages.c
index 95aee66..301df6d 100644
--- a/t/test_packages.c
+++ b/t/test_packages.c
@@ -289,6 +289,14 @@ START_TEST (test_version)
fail_unless (slapt_cmp_pkg_versions("1.4rc5-i486-2","1.4rc4-i486-2") > 0);
fail_unless (slapt_cmp_pkg_versions("1.3.35-i486-2_slack10.2","1.3.35-i486-1") > 0);
+
+#if defined(__x86_64__)
+ fail_unless (slapt_cmp_pkg_versions("4.1-x86_64-1","4.1-i486-1") > 0);
+ fail_unless (slapt_cmp_pkg_versions("4.1-i486-1","4.1-x86_64-1") < 0);
+#elif defined(__i386__)
+ fail_unless (slapt_cmp_pkg_versions("4.1-i486-1","4.1-x86_64-1") > 0);
+ fail_unless (slapt_cmp_pkg_versions("4.1-x86_64-1","4.1-486-1") < 0);
+#endif
}
END_TEST