diff options
author | Ales Kozumplik <akozumpl@redhat.com> | 2012-01-03 16:04:18 +0100 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2012-03-30 13:55:03 +0200 |
commit | b714dcea37af2e23026a52be76e7317592ecb52e (patch) | |
tree | ecb50bc2f9209bbd67f2aa934d4a3cf8faa4e754 | |
parent | 7c39c65da4b1b012061ffbac179a650643d00ba9 (diff) | |
download | rpm-b714dcea37af2e23026a52be76e7317592ecb52e.tar.gz rpm-b714dcea37af2e23026a52be76e7317592ecb52e.tar.bz2 rpm-b714dcea37af2e23026a52be76e7317592ecb52e.zip |
rpmbuild: warn if header color differs from color of the package architecture.
- For example, warn when building an x86_64 package that only contains 32
bit binaries.
- This should indicate to the maintainers that they might have gotten the
architecture wrong.
- Introduces 'archcolor' in rpmrc so we can map architectures to colors.
- Related: RhBug:713323
-rw-r--r-- | build/files.c | 12 | ||||
-rw-r--r-- | lib/rpmlib.h | 7 | ||||
-rw-r--r-- | lib/rpmrc.c | 24 | ||||
-rw-r--r-- | rpmrc.in | 33 |
4 files changed, 75 insertions, 1 deletions
diff --git a/build/files.c b/build/files.c index d4dc974f1..7778d2275 100644 --- a/build/files.c +++ b/build/files.c @@ -2109,6 +2109,8 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { char *nvr; const char *a; + int header_color; + int arch_color; if (pkg->fileList == NULL) continue; @@ -2124,7 +2126,15 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, goto exit; a = headerGetString(pkg->header, RPMTAG_ARCH); - if (rstreq(a, "noarch") && headerGetNumber(pkg->header, RPMTAG_HEADERCOLOR) != 0) { + header_color = headerGetNumber(pkg->header, RPMTAG_HEADERCOLOR); + if (!rstreq(a, "noarch")) { + arch_color = rpmGetArchColor(a); + if (arch_color > 0 && !(arch_color & header_color)) { + rpmlog(RPMLOG_WARNING, + _("Binaries arch (%d) not matching the package arch (%d).\n"), + header_color, arch_color); + } + } else if (header_color != 0) { int terminate = rpmExpandNumeric("%{?_binaries_in_noarch_packages_terminate_build}"); rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING, _("Arch dependent binaries in noarch package\n")); diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 0b5f0c44e..41a285d04 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -69,6 +69,13 @@ void rpmGetArchInfo( const char ** name, int * num); /** \ingroup rpmrc + * Return color for an arch + * @param arch name of an architecture + * @return color color of arch, -1 if the arch couldn't be determined + */ +int rpmGetArchColor(const char *arch); + +/** \ingroup rpmrc * Return current os name and/or number. * @todo Generalize to extract os component from target_platform macro. * @retval name address of os name (or NULL) diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 38c62084a..4b6b29aa1 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -110,6 +110,7 @@ static struct tableType_s tables[RPM_MACHTABLE_COUNT] = { /* XXX get rid of this stuff... */ /* Stuff for maintaining "variables" like SOURCEDIR, BUILDDIR, etc */ #define RPMVAR_OPTFLAGS 3 +#define RPMVAR_ARCHCOLOR 42 #define RPMVAR_INCLUDE 43 #define RPMVAR_MACROFILES 49 @@ -119,6 +120,7 @@ static struct tableType_s tables[RPM_MACHTABLE_COUNT] = { /* The order of the flags is archSpecific, macroize, localize */ static const struct rpmOption optionTable[] = { + { "archcolor", RPMVAR_ARCHCOLOR, 1, 0, 0 }, { "include", RPMVAR_INCLUDE, 0, 0, 2 }, { "macrofiles", RPMVAR_MACROFILES, 0, 0, 1 }, { "optflags", RPMVAR_OPTFLAGS, 1, 1, 0 }, @@ -1287,6 +1289,28 @@ void rpmGetArchInfo(const char ** name, int * num) getMachineInfo(ARCH, name, num); } +int rpmGetArchColor(const char *arch) +{ + const char *color; + char *e; + int color_i; + + arch = lookupInDefaultTable(arch, + tables[currTables[ARCH]].defaults, + tables[currTables[ARCH]].defaultsLength); + color = rpmGetVarArch(RPMVAR_ARCHCOLOR, arch); + if (color == NULL) { + return -1; + } + + color_i = strtol(color, &e, 10); + if (!(e && *e == '\0')) { + return -1; + } + + return color_i; +} + void rpmGetOsInfo(const char ** name, int * num) { getMachineInfo(OS, name, num); @@ -83,6 +83,39 @@ optflags: sh4 -O2 -g -mieee optflags: sh4a -O2 -g -mieee ############################################################# +# Architecture colors + +archcolor: noarch 0 +archcolor: i386 1 +archcolor: alpha 2 +archcolor: sparc 1 +archcolor: sparc64 2 +archcolor: sparcv9 2 +archcolor: ppc 1 +archcolor: ppc64 2 + +archcolor: armv3l 1 +archcolor: armv4b 1 +archcolor: armv4l 1 +archcolor: armv4tl 1 +archcolor: armv5tel 1 +archcolor: armv5tejl 1 +archcolor: armv6l 1 +archcolor: armv7l 1 + +archcolor: m68kmint 1 + +archcolor: s390 1 +archcolor: s390x 2 + +archcolor: ia64 2 + +archcolor: x86_64 2 + +archcolor: sh3 1 +archcolor: sh4 1 + +############################################################# # Canonical arch names and numbers arch_canon: athlon: athlon 1 |