summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-11-05 20:37:48 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-11-05 20:37:48 +0200
commitf2a7667482475bbb9bf3acbcf57b755fee987a83 (patch)
treed1ae6fee58e5cd675c3abb6406ca322d11e89073
parenta9169c46abddfe620c6ae83f3064b50c8bb35852 (diff)
downloadlibrpm-tizen-f2a7667482475bbb9bf3acbcf57b755fee987a83.tar.gz
librpm-tizen-f2a7667482475bbb9bf3acbcf57b755fee987a83.tar.bz2
librpm-tizen-f2a7667482475bbb9bf3acbcf57b755fee987a83.zip
Nuke the ugly hardwired "known arch" list from label parsing
- we have list of known archs in rpmrc, might as well use it - avoids having to patch & recompile rpm just to have rpmtsInitIterator() recognize new archs when it's runtime configurable otherwise - checking against compatible arch would be saner except then people could get into even more trouble using --ignorearch...
-rw-r--r--lib/misc.h4
-rw-r--r--lib/rpmrc.c9
-rw-r--r--lib/rpmts.c31
3 files changed, 15 insertions, 29 deletions
diff --git a/lib/misc.h b/lib/misc.h
index 405455dd3..e2a54539a 100644
--- a/lib/misc.h
+++ b/lib/misc.h
@@ -13,6 +13,10 @@
extern "C" {
#endif
+/* known arch? */
+RPM_GNUC_INTERNAL
+int rpmIsKnownArch(const char *name);
+
/*
* These may be called w/ a NULL argument to flush the cache -- they return
* -1 if the user can't be found.
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 49b3e7e86..69d55d635 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -21,6 +21,7 @@
#include "rpmio/rpmlua.h"
#include "rpmio/rpmio_internal.h" /* XXX for rpmioSlurp */
+#include "lib/misc.h"
#include "debug.h"
@@ -1327,6 +1328,14 @@ int rpmMachineScore(int type, const char * name)
return (info != NULL ? info->score : 0);
}
+int rpmIsKnownArch(const char *name)
+{
+ canonEntry canon = lookupInCanonTable(name,
+ tables[RPM_MACHTABLE_INSTARCH].canons,
+ tables[RPM_MACHTABLE_INSTARCH].canonsLength);
+ return (canon != NULL || strcmp(name, "noarch") == 0);
+}
+
/** \ingroup rpmrc
* Set current arch/os names.
* NULL as argument is set to the default value (munged uname())
diff --git a/lib/rpmts.c b/lib/rpmts.c
index 88298e5fc..d431a1b58 100644
--- a/lib/rpmts.c
+++ b/lib/rpmts.c
@@ -24,6 +24,7 @@
#include "rpmio/digest.h"
#include "lib/rpmlock.h"
#include "lib/rpmts_internal.h"
+#include "lib/misc.h"
/* XXX FIXME: merge with existing (broken?) tests in system.h */
/* portability fiddles */
@@ -153,34 +154,6 @@ int rpmtsVerifyDB(rpmts ts)
return rpmdbVerify(ts->rootDir);
}
-static int isArch(const char * arch)
-{
- const char * const * av;
- static const char * const arches[] = {
- "i386", "i486", "i586", "i686", "athlon", "pentium3", "pentium4", "x86_64", "amd64", "ia32e", "geode",
- "alpha", "alphaev5", "alphaev56", "alphapca56", "alphaev6", "alphaev67",
- "sparc", "sun4", "sun4m", "sun4c", "sun4d", "sparcv8", "sparcv9", "sparcv9v",
- "sparc64", "sparc64v", "sun4u",
- "mips", "mipsel", "IP",
- "ppc", "ppciseries", "ppcpseries",
- "ppc64", "ppc64iseries", "ppc64pseries",
- "m68k",
- "rs6000",
- "ia64",
- "armv3l", "armv4b", "armv4l", "armv4tl", "armv5tel", "armv5tejl", "armv6l",
- "s390", "i370", "s390x",
- "sh", "xtensa",
- "noarch",
- NULL,
- };
-
- for (av = arches; *av != NULL; av++) {
- if (!strcmp(arch, *av))
- return 1;
- }
- return 0;
-}
-
/* keyp might no be defined. */
rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
const void * keyp, size_t keylen)
@@ -247,7 +220,7 @@ rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
t = (char *) keyp;
t = strrchr(t, '.');
/* Is this a valid ".arch" suffix? */
- if (t != NULL && isArch(t+1)) {
+ if (t != NULL && rpmIsKnownArch(t+1)) {
*t++ = '\0';
arch = t;
}