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 a size limit on UTSRELEASE 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.
This option should not be set for the dist-git target so explicitly set
PREBUILD_GIT_ONLY to zero on the dist-git and dist-git-test targets.
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
@@ -390,10 +390,19 @@ 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-vr-check:
+ @# builds may include a s390x+zfcpdump arch build. UTS_RELEASE can only have a
+ @# version-release string with max 64 chars. The version-release for s390x+zfcpdump
+ @# is 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
(currently $(BUILDID))"; \
+ exit 1; \
+ fi
+
+dist-brew dist-koji: dist-%: dist-vr-check 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-brew distg-koji: distg-%: dist-vr-check
$* $(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,20 @@ 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).
+ ifeq ($(MAKECMDGOALS), $(filter $(MAKECMDGOALS),dist-git-test dist-git))
+ ifneq ($(PREBUILD_GIT_ONLY),1)
+ PREBUILD_GIT_ONLY:=0
+ endif
+ else
+ PREBUILD_GIT_ONLY:=1
+ endif
+ ifeq ($(PREBUILD_GIT_ONLY),1)
+ PREBUILD:=$(PREBUILD)$(MARKER).
+ else
+ # 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).
+ endif
UPSTREAM_TARBALL_NAME:=$(patsubst v%,%,$(_TAG))
endif
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1579