--- /dev/null
+diff -urpa rpm-4.5.orig/build/parsePreamble.c rpm-4.5/build/parsePreamble.c
+--- rpm-4.5.orig/build/parsePreamble.c 2019-06-01 18:55:39.351000000 +0200
++++ rpm-4.5/build/parsePreamble.c 2019-06-01 19:24:30.398000000 +0200
+@@ -730,19 +730,32 @@ static int handlePreambleTag(Spec spec,
+ case RPMTAG_EXCLUSIVEOS:
+ addOrAppendListEntry(spec->sourceHeader, tag, field);
+ break;
+- case RPMTAG_BUILDARCHS:
+- if ((rc = poptParseArgvString(field,
+- &(spec->BACount),
+- &(spec->BANames)))) {
++ case RPMTAG_BUILDARCHS: {
++ int BACount;
++ const char **BANames = NULL;
++ if ((rc = poptParseArgvString(field, &BACount, &BANames))) {
+ rpmError(RPMERR_BADSPEC,
+ _("line %d: Bad BuildArchitecture format: %s\n"),
+ spec->lineNum, spec->line);
+ return RPMERR_BADSPEC;
+ }
+- if (!spec->BACount)
++ if (spec->packages == pkg) {
++ spec->BACount = BACount;
++ spec->BANames = BANames;
++ } else {
++ if (BACount != 1 || strcmp(BANames[0], "noarch")) {
++ rpmError(RPMERR_BADSPEC,
++ _("line %d: Only noarch subpackages are supported: %s\n"),
++ spec->lineNum, spec->line);
++ BANames = _free(BANames);
++ return RPMRC_FAIL;
++ }
++ headerAddEntry(pkg->header, RPMTAG_ARCH, RPM_STRING_TYPE, "noarch", 1);
++ }
++ if (!BACount)
+ spec->BANames = _free(spec->BANames);
+ break;
+-
++ }
+ default:
+ rpmError(RPMERR_INTERNAL, _("Internal error: Bogus tag %d\n"), tag);
+ return RPMERR_INTERNAL;
+diff -urpa rpm-4.5.orig/build/parseSpec.c rpm-4.5/build/parseSpec.c
+--- rpm-4.5.orig/build/parseSpec.c 2019-06-01 18:55:39.226000000 +0200
++++ rpm-4.5/build/parseSpec.c 2019-06-01 19:27:44.338000000 +0200
+@@ -627,8 +627,11 @@ int parseSpec(rpmts ts, const char *spec
+ }
+
+ (void) headerAddEntry(pkg->header, RPMTAG_OS, RPM_STRING_TYPE, os, 1);
+- (void) headerAddEntry(pkg->header, RPMTAG_ARCH,
+- RPM_STRING_TYPE, arch, 1);
++ /* noarch subpackages already have arch set here, leave it alone */
++ if (!headerIsEntry(pkg->header, RPMTAG_ARCH)) {
++ (void) headerAddEntry(pkg->header, RPMTAG_ARCH,
++ RPM_STRING_TYPE, arch, 1);
++ }
+ (void) headerAddEntry(pkg->header, RPMTAG_PLATFORM,
+ RPM_STRING_TYPE, platform, 1);
+