Upstream-Status: Inappropriate [distribution]

Fix "arch" integration with Poky.

Add a missing "any" architecture type and update the semantics to use it.

Disable the built-in archpolicies structure, and replace it with one
we generate in the recipe.

Also add poky semantics option in CMake.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Qing He <qing.he@intel.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 443281e..4456a87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,11 @@ MESSAGE(STATUS "Building for Debian")
 ADD_DEFINITIONS( -DDEBIAN -DDEBIAN_SEMANTICS)
 ENDIF ( DEBIAN )
 
+IF ( OE_CORE )
+MESSAGE(STATUS "Building for OE core")
+ADD_DEFINITIONS( -DOE_CORE -DOE_CORE_SEMANTICS)
+ENDIF ( OE_CORE )
+
 IF ( MULTI_SEMANTICS )
 MESSAGE(STATUS "Enabling multi dist support")
 ADD_DEFINITIONS( -DMULTI_SEMANTICS)
diff --git a/src/knownid.h b/src/knownid.h
index 7757ae0..4b8bee7 100644
--- a/src/knownid.h
+++ b/src/knownid.h
@@ -57,6 +57,7 @@ KNOWNID(SYSTEM_SYSTEM,			"system:system"),
 KNOWNID(ARCH_SRC,			"src"),
 KNOWNID(ARCH_NOSRC,			"nosrc"),
 KNOWNID(ARCH_NOARCH,			"noarch"),
+KNOWNID(ARCH_ANY,			"any"),
 KNOWNID(ARCH_ALL,			"all"),
 
 KNOWNID(REPOSITORY_SOLVABLES,		"repository:solvables"),
diff --git a/src/policy.c b/src/policy.c
index 55c8677..3356ff8 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -486,6 +486,13 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2)
     }
 
   /* we allow changes to/from noarch */
+#ifdef OE_CORE_SEMANTICS
+  if (a1 == a2 || 
+	a1 == ARCH_NOARCH || a2 == ARCH_NOARCH ||
+	a1 == ARCH_ANY || a2 == ARCH_ANY ||
+	a1 == ARCH_ALL || a2 == ARCH_ALL)
+    return 0;
+#else
 #ifndef DEBIAN_SEMANTICS
   if (a1 == a2 || a1 == ARCH_NOARCH || a2 == ARCH_NOARCH)
     return 0;
@@ -493,6 +500,7 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2)
   if (a1 == a2 || a1 == ARCH_ALL || a2 == ARCH_ALL)
     return 0;
 #endif
+#endif
   if (!pool->id2arch)
     return 0;
   a1 = a1 <= pool->lastarch ? pool->id2arch[a1] : 0;
diff --git a/src/poolarch.c b/src/poolarch.c
index 34a14a3..2d7cd70 100644
--- a/src/poolarch.c
+++ b/src/poolarch.c
@@ -20,38 +20,8 @@
 #include "poolarch.h"
 #include "util.h"
 
-const char *archpolicies[] = {
-  "x86_64",	"x86_64:i686:i586:i486:i386",
-  "i686",	"i686:i586:i486:i386",
-  "i586",	"i586:i486:i386",
-  "i486",	"i486:i386",
-  "i386",	"i386",
-  "s390x",	"s390x:s390",
-  "s390",	"s390",
-  "ia64",	"ia64:i686:i586:i486:i386",
-  "ppc64",	"ppc64:ppc",
-  "ppc",	"ppc",
-  "armv7nhl",	"armv7nhl:armv7hl",
-  "armv7hl",	"armv7hl",
-  "armv7l",	"armv7l:armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-  "armv6l",	"armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-  "armv5tejl",	"armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-  "armv5tel",	"armv5tel:armv5l:armv4tl:armv4l:armv3l",
-  "armv5l",	"armv5l:armv4tl:armv4l:armv3l",
-  "armv4tl",	"armv4tl:armv4l:armv3l",
-  "armv4l",	"armv4l:armv3l",
-  "armv3l",	"armv3l",
-  "sh3",	"sh3",
-  "sh4",	"sh4",
-  "sh4a",	"sh4a:sh4",
-  "sparc64v",	"sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc",
-  "sparc64",	"sparc64:sparcv9:sparcv8:sparc",
-  "sparcv9v",	"sparcv9v:sparcv9:sparcv8:sparc",
-  "sparcv9",	"sparcv9:sparcv8:sparc",
-  "sparcv8",	"sparcv8:sparc",
-  "sparc",	"sparc",
-  0
-};
+/* Provide the const char *archpolicies structure */
+#include "core-arch.h"
 
 void
 pool_setarch(Pool *pool, const char *arch)
@@ -71,10 +41,10 @@ pool_setarch(Pool *pool, const char *arch)
       pool->lastarch = 0;
       return;
     }
-#ifndef DEBIAN_SEMANTICS
-  id = ARCH_NOARCH;
-#else
+#if defined(DEBIAN_SEMANTICS) || defined(OE_CORE_SEMANTICS)
   id = ARCH_ALL;
+#else
+  id = ARCH_NOARCH;
 #endif
   lastarch = id + 255;
   id2arch = sat_calloc(lastarch + 1, sizeof(Id));
