From: Íñigo Huguet <ihug...@redhat.com>

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.

To make this work, get rid of the `ifdef BUILD_TARGET` checks, or the
sub-make will see it as already defined (inherited) and won't change it.
Since variables defined as commandline arguments always override
variables defined inside the Makefile, users still can select a
different one: `make dist-brew BUILD_TARGET=whatever`.

Also, fix a missing closing quote in `ifeq ("$(DIST)", ".eln)`.

Signed-off-by: Íñigo Huguet <ihug...@redhat.com>

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -223,9 +223,7 @@ SRPM:=$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
 #
 ifeq ("$(DISTRO)", "fedora")
   RHDISTGIT_BRANCH:=rawhide
-  ifndef BUILD_TARGET
-    BUILD_TARGET:=rawhide
-  endif
+  BUILD_TARGET:=rawhide
   # The Fedora tarfile name is based on an upstream tag as users may
   # replace the tarball from one with upstream, rebuild, and then deploy
   # without changing anything else in the specfile.
@@ -236,12 +234,8 @@ ifeq ("$(DISTRO)", "fedora")
   RHPKG_BIN:=fedpkg
 else ifeq ("$(DISTRO)", "centos")
   RHDISTGIT_BRANCH:=c$(RHEL_MAJOR)s
-  ifndef BUILD_PROFILE
-    BUILD_PROFILE:= -p stream
-  endif
-  ifndef BUILD_TARGET
-    BUILD_TARGET:=c$(RHEL_MAJOR)s-candidate
-  endif
+  BUILD_PROFILE:= -p stream
+  BUILD_TARGET:=c$(RHEL_MAJOR)s-candidate
   SPECTARFILE_RELEASE:=$(BASEVERSION)$(DIST)
   SPECKABIVERSION:=$(BASEVERSION)$(DIST)
   DISTRELEASETAG:=$(RELEASETAG)$(DIST)
@@ -250,21 +244,16 @@ else ifeq ("$(DISTRO)", "centos")
   RHPKG_BIN:=centpkg
 else
   RHDISTGIT_BRANCH:=rhel-$(RHEL_MAJOR).$(RHEL_MINOR).0
-  ifndef BUILD_TARGET
-    ifeq ("$(DIST)", ".eln")
-      BUILD_TARGET:=eln
-    else
-      # This value is used by the dist[g]-targets.  Changing this value has 
significant
-      # consequences for all of RHEL kernel engineering.
-      BUILD_TARGET:=rhel-$(RHEL_MAJOR)-newest-test-pesign
-    endif
-  endif
-  ifeq ("$(DIST)", ".eln)
+  ifeq ("$(DIST)", ".eln")
+    BUILD_TARGET:=eln
     DISTRELEASETAG:=$(RELEASETAG)
     DISTBASEVERSION:=$(BASEVERSION)
     SPECTARFILE_RELEASE:=$(BASEVERSION)
     SPECKABIVERSION:=$(BASEVERSION)
   else
+    # This value is used by the dist[g]-targets.  Changing this value has 
significant
+    # consequences for all of RHEL kernel engineering.
+    BUILD_TARGET:=rhel-$(RHEL_MAJOR)-newest-test-pesign
     DISTRELEASETAG:=$(RELEASETAG)$(DIST)
     DISTBASEVERSION:=$(BASEVERSION)$(DIST)
     SPECTARFILE_RELEASE:=$(BASEVERSION)$(DIST)
@@ -753,14 +742,18 @@ 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.
+dist-brew distg-brew: DISTRO=rhel
+dist-brew distg-brew: DIST=.el9
+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)

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2339
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
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@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to