[OS-BUILD PATCH] Makefile: Check PKGRELEASE size on dist-brew targets
by Prarit Bhargava (via Email Bridge)
From: Prarit Bhargava <prarit(a)redhat.com>
Makefile: Check PKGRELEASE size on dist-brew targets
The Red Hat brew system is a build system used internally within Red Hat
which is similar to the externally available koji build system. One of
the architectures of a brew build is 's390x+zfcpdump'. This arch using
the default of localversion 'test' always causes the rpm build error:
"5.17.0-0.rc0.20220114gitfb3b0673b7d5.65.test.el9_b.s390x+zfcpdump" exceeds 64 characters
make: *** [Makefile:1257: include/generated/utsrelease.h] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.tMkhuG (%build)
The 64 character limit is built into rpm and cannot be dynamically
changed so the only other option is to reduce the package release
(PKGRELEASE) string in length. Removing the date field and the string
'git' results in a string that is shorter by 11 characters, with a minimal
loss in information.
Add an option, PREBUILD_GIT_ONLY, to shorten the PREBUILD variable which
is used in the PKGRELEASE string. Add a check for the size of PKGRELEASE
and return a pre-build error if PKGRELEASE is greater than 35 characters.
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -391,10 +391,26 @@ dist-koji : BUILD_FLAGS ?= $(KOJI_FLAGS) $(TEST_FLAGS)
distg-brew: BUILD_FLAGS ?= $(BREW_FLAGS) $(TEST_FLAGS)
distg-koji: BUILD_FLAGS ?= $(KOJI_FLAGS) $(TEST_FLAGS)
-dist-brew dist-koji: dist-%: dist-srpm
+dist-brew-check:
+ @# brew builds for RHEL and ARK include a s390x+zfcpdump arch build.
+ @# RPM can only have a version-release string with max 64 chars. The
+ @# kernel version and release for s390x+zfcpdump are 29 characters,
+ @# leaving a maximum of 35 characters for PKGRELEASE.
+ @if [ $$(echo "$(PKGRELEASE)" | wc -c) -gt 35 ]; then \
+ echo "PKGRELEASE ($(PKGRELEASE)) is too long. Use a shorter localversion or set PREBUILD_GIT_ONLY=1"; \
+ exit 1; \
+ fi
+
+dist-brew: dist-%: dist-brew-check dist-srpm
+ $* $(BUILD_PROFILE) build $(BUILD_FLAGS) $(BUILD_TARGET) $(SRPMS)/$(PACKAGE_NAME)-$(KVERSION)-$(PKGRELEASE)$(DIST).src.rpm $(OUTPUT_FILE)
+
+distg-brew : distg-%: dist-brew-check
+ $* $(BUILD_PROFILE) build $(BUILD_FLAGS) $(BUILD_TARGET) "$(RHGITURL)?redhat/koji#$(RHGITCOMMIT)"
+
+dist-koji: dist-%: dist-srpm
$* $(BUILD_PROFILE) build $(BUILD_FLAGS) $(BUILD_TARGET) $(SRPMS)/$(PACKAGE_NAME)-$(KVERSION)-$(PKGRELEASE)$(DIST).src.rpm $(OUTPUT_FILE)
-distg-brew distg-koji: distg-%:
+distg-koji: distg-%:
$* $(BUILD_PROFILE) build $(BUILD_FLAGS) $(BUILD_TARGET) "$(RHGITURL)?redhat/koji#$(RHGITCOMMIT)"
.PHONY: $(REDHAT)/rpm/SOURCES/$(PACKAGE_NAME).spec
diff --git a/redhat/Makefile.common b/redhat/Makefile.common
index blahblah..blahblah 100644
--- a/redhat/Makefile.common
+++ b/redhat/Makefile.common
@@ -75,9 +75,13 @@ ifeq ($(SNAPSHOT),1)
PREBUILD:=0$(KEXTRAVERSION).
RPMKPATCHLEVEL:=$(shell expr $(RPMKPATCHLEVEL) + 1)
endif
- # Obtain the date that HEAD was committed (not the snapshot commit).
- HEAD_DATE:=$(shell $(GIT) show -s --format=%cd --date=format:%Y%m%d $(HEAD))
- PREBUILD:=$(PREBUILD)$(HEAD_DATE)git$(MARKER).
+ ifneq ($(PREBUILD_GIT_ONLY),1)
+ # Obtain the date that HEAD was committed (not the snapshot commit).
+ HEAD_DATE:=$(shell $(GIT) show -s --format=%cd --date=format:%Y%m%d $(HEAD))
+ PREBUILD:=$(PREBUILD)$(HEAD_DATE)git$(MARKER).
+ else
+ PREBUILD:=$(PREBUILD)$(MARKER).
+ endif
UPSTREAM_TARBALL_NAME:=$(patsubst v%,%,$(_TAG))
endif
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1579