From: Íñigo Huguet <ihuguet@xxxxxxxxxx> redhat/Makefile: fix default values for dist-brew's DISTRO and DIST In dist-brew target, target-specific variables to change the default value of DISTRO and DIST to 'rhel' and '.el9', but they're not useful because the rest of variables that depends on them, such us BUILD_TARGET, has been calculated yet. The most visible error is that `make dist-brew` fails with 'brew: error: No such build target: rawhide'. Rawhide is the default BUILD_TARGET for Fedora, not for RHEL. Fix it by recursively calling `make` so the sub-make has the correct DISTRO and DIST values since the beginning, thus calculating the rest of values correctly. Variables BUILD_TARGET and BUILD_PROFILE need to be cleared so they're recalculated in the 2nd level sub-make. However, variables listed in Makefile.variables file must be allowed to be customizable by the user, so we can't override the ones defined by the user. Save them in variables *_USERDEF so we know if they were defined by user or by the Makefile's logic. Also, fix a missing closing quote in `ifeq ("$(DIST)", ".eln)`. Signed-off-by: Íñigo Huguet <ihuguet@xxxxxxxxxx> diff --git a/redhat/Makefile b/redhat/Makefile index blahblah..blahblah 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -65,6 +65,16 @@ SPECCHANGELOG:=$(PACKAGE_NAME).changelog-$(RHEL_MAJOR).$(RHEL_MINOR) CHANGELOG_PREV:=$(PACKAGE_NAME).changelog-$(RHEL_MAJOR).$(shell expr $(RHEL_MINOR) - 1) ARCH_LIST=aarch64 ppc64le s390x x86_64 +# save some user selectable values to know later if we can override them +DISTRO_USERDEF:=$(DISTRO) +DIST_USERDEF:=$(DIST) +BUILD_PROFILE_USERDEF:=$(BUILD_PROFILE) +BUILD_TARGET_USERDEF:=$(BUILD_TARGET) + +ifndef DIST + DIST := $(shell $(RPMBUILD) --eval '%{?dist}') +endif + ifndef DISTRO ifneq ($(findstring .fc,$(DIST)),) DISTRO := fedora @@ -259,7 +269,7 @@ else BUILD_TARGET:=rhel-$(RHEL_MAJOR)-newest-test-pesign endif endif - ifeq ("$(DIST)", ".eln) + ifeq ("$(DIST)", ".eln") DISTRELEASETAG:=$(RELEASETAG) DISTBASEVERSION:=$(BASEVERSION) SPECTARFILE_RELEASE:=$(BASEVERSION) @@ -753,14 +763,21 @@ dist-vr-check: exit 1; \ fi -dist-brew: DIST=.el9 -dist-brew: DISTRO=rhel -dist-brew dist-koji: dist-%: dist-vr-check dist-srpm +# Call as sub-make to select different default DISTRO and DIST for dist-brew. +# This is because target-specific variables only apply inside the recipe, but we +# need to recalculate some values such as BUILD_TARGET that depends on them. +# However, do not override any value directly defined by the user. +dist-brew distg-brew: DISTRO=$(if $(DISTRO_USERDEF),$(DISTRO_USERDEF),rhel) +dist-brew distg-brew: DIST=$(if $(DIST_USERDEF),$(DIST_USERDEF),.el$(RHEL_MAJOR)) +dist-brew distg-brew: BUILD_PROFILE=$(if $(BUILD_PROFILE_USERDEF),$(BUILD_PROFILE_USERDEF)) +dist-brew distg-brew: BUILD_TARGET=$(if $(BUILD_TARGET_USERDEF),$(BUILD_TARGET_USERDEF)) +dist-brew distg-brew dist-koji distg_koji: + $(MAKE) _$@ + +_dist-brew _dist-koji: _dist-%: dist-vr-check dist-srpm $* $(BUILD_PROFILE) build $(BUILD_FLAGS) --scratch $(BUILD_TARGET) $(SRPMS)/$(RELEASETAG)$(DIST).src.rpm $(OUTPUT_FILE) -distg-brew: DIST=.el9 -distg-brew: DISTRO=rhel -distg-brew distg-koji: distg-%: dist-vr-check +_distg-brew _distg-koji: _distg-%: dist-vr-check $* $(BUILD_PROFILE) build $(BUILD_FLAGS) --scratch $(BUILD_TARGET) "$(RHGITURL)?redhat/koji#$(RHGITCOMMIT)" .PHONY: $(REDHAT)/rpm/SOURCES/$(SPECFILE) diff --git a/redhat/Makefile.variables b/redhat/Makefile.variables index blahblah..blahblah 100644 --- a/redhat/Makefile.variables +++ b/redhat/Makefile.variables @@ -40,7 +40,7 @@ BUMP_RELEASE:=yes # This is the dist release suffix used in the package release, eg. .fc34, # .el8 etc. In a different branch this may be set to a fixed value. -DIST ?= $(shell $(RPMBUILD) --eval '%{?dist}') +DIST ?= # This is the source branch that you are building out of typically this is # the current branch. -- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2339 _______________________________________________ kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue