From: Scott Weaver <scwea...@redhat.com>

redhat/Makefile: introduce AUTOMOTIVE_BUILD

This removes the automotive specific targets (except
dist-automotive-configs) and introduces the AUTOMOTIVE_BUILD variable
that can be used to repurpose the existing stock kernel make targets for
kernel-automotive.

For example:
  make AUTOMOTIVE_BUILD=1 dist-srpm

Signed-off-by: Scott Weaver <scwea...@redhat.com>

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -294,15 +294,11 @@ ifeq ("$(DISTRO)", "fedora")
   RHPKG_BIN:=fedpkg
 else ifeq ("$(DISTRO)", "centos")
   RHDISTGIT_BRANCH=c$(RHEL_MAJOR)s
-  # This is a CentOS SIG dist-git for AutoSD rather than for CentOS Stream.
-  AUTOMOTIVE_DISTGIT_BRANCH=c$(RHEL_MAJOR)s-sig-automotive-main
   ifndef BUILD_PROFILE
     BUILD_PROFILE:= -p stream
   endif
   ifndef BUILD_TARGET
     BUILD_TARGET:=c$(RHEL_MAJOR)s-candidate
-    # The CentOS Stream equivalent for automotive is AutoSD built out of CBS
-    AUTOMOTIVE_BUILD_TARGET = 
autosd$(RHEL_MAJOR)s-packages-main-el$(RHEL_MAJOR)s
   endif
   SPECTARFILE_RELEASE=$(BASEVERSION)$(DIST)
   SPECKABIVERSION=$(BASEVERSION)$(DIST)
@@ -310,12 +306,8 @@ else ifeq ("$(DISTRO)", "centos")
   DISTBASEVERSION=$(BASEVERSION)$(DIST)
   PATCHLIST_URL:=none
   RHPKG_BIN:=centpkg
-  AUTOMOTIVE_RHPKG_BIN:=centpkg-sig
-  AUTOMOTIVE_DISTGIT_NS:=automotive/rpms/
-  AUTOMOTIVE_RHPKG_OPTS:=--config $(REDHAT)/automotive-centpkg-sig.conf
 else
   RHDISTGIT_BRANCH:=rhel-$(RHEL_MAJOR).$(RHEL_MINOR).0
-  AUTOMOTIVE_DISTGIT_BRANCH=rhivos-$(AUTOMOTIVE_MAJOR).$(AUTOMOTIVE_MINOR).0
   ifndef BUILD_TARGET
     ifeq ("$(DIST)", ".eln")
       BUILD_TARGET:=eln
@@ -323,7 +315,6 @@ 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
-      AUTOMOTIVE_BUILD_TARGET = rhivos-$(AUTOMOTIVE_MAJOR)-newest-test-pesign
     endif
   endif
   ifeq ("$(DIST)", ".eln")
@@ -339,9 +330,39 @@ else
   endif
   PATCHLIST_URL:=none
   RHPKG_BIN:=rhpkg
-  AUTOMOTIVE_RHPKG_BIN:=rhpkg
-  AUTOMOTIVE_DISTGIT_NS:=
-  AUTOMOTIVE_RHPKG_OPTS:=
+
+endif
+
+# 
+ifeq ($(AUTOMOTIVE_BUILD), 1)
+  ifeq ("$(DISTRO)", "rhel")
+    RHDISTGIT_BRANCH=rhivos-$(AUTOMOTIVE_MAJOR).$(AUTOMOTIVE_MINOR).0
+    RHPKG_BIN:=rhpkg
+    RHPKG_NS:=
+    RHPKG_OPTS:=
+    ifeq ("$(DIST)", ".eln")
+      $(error "Error: the distro 'eln' does not support automotive.")
+    else
+      BUILD_TARGET = rhivos-$(AUTOMOTIVE_MAJOR)-newest-test-pesign
+    endif
+  else ifeq ("$(DISTRO)", "centos")
+    # This is a CentOS SIG dist-git for AutoSD rather than for CentOS Stream.
+    RHDISTGIT_BRANCH=c$(RHEL_MAJOR)s-sig-automotive-main
+    RHPKG_BIN:=centpkg-sig
+    RHPKG_NS:=automotive/rpms/
+    RHPKG_OPTS:=--config $(REDHAT)/automotive-centpkg-sig.conf
+    BUILD_TARGET = autosd$(RHEL_MAJOR)s-packages-main-el$(RHEL_MAJOR)s
+  else
+    $(error "Error: the distro '$(DISTRO)' does not support automotive.")
+  endif
+  SPECPACKAGE_NAME:=kernel-automotive
+  DIST:=.el$(RHEL_MAJOR)iv
+  BUILDOPTS += +automotiveonly
+  INCLUDE_FEDORA_FILES:=0
+  INCLUDE_RHEL_FILES:=0
+  INCLUDE_RT_FILES:=0
+  INCLUDE_AUTOMOTIVE_FILES:=1
+  FLAVOR:=rhel
 endif
 
 TARFILE=linux-$(SPECTARFILE_RELEASE).tar.xz
@@ -586,25 +607,28 @@ dist-rhel-configs: FLAVOR = rhel
 dist-rhel-configs: dist-configs
 rh-configs: dist-rhel-configs
 
-# although automotive is not a flavor we want to treat it like it has it's own 
config priority file
-automotive-configs-pre:
-       @cp $(REDHAT)/configs/priority.$(FLAVOR) 
$(REDHAT)/configs/priority.$(FLAVOR).bak
-       @sed -i '/^#\|^ORDER\|^\(x86_64\|aarch64\)-automotive/!d' 
$(REDHAT)/configs/priority.$(FLAVOR)
-       @sed -i 's/^\([^=]*\)-automotive/\1/' 
$(REDHAT)/configs/priority.$(FLAVOR)
-automotive-configs-post:
-       @mv $(REDHAT)/configs/priority.$(FLAVOR).bak 
$(REDHAT)/configs/priority.$(FLAVOR)
-
 dist-automotive-configs: ##build build only the automotive configs
-dist-automotive-configs: SPECPACKAGE_NAME := kernel-automotive
-dist-automotive-configs: FLAVOR = rhel
-dist-automotive-configs: automotive-configs-pre .WAIT dist-configs .WAIT 
automotive-configs-post
+dist-automotive-configs: AUTOMOTIVE_BUILD := 1
+dist-automotive-configs:
+       $(MAKE) dist-configs
 
 dist-configs-check: dist-configs-prep
        +cd $(REDHAT)/configs; ./process_configs.sh 
$(PROCESS_CONFIGS_CHECK_OPTS) "" ""
 
 dist-configs-prep: dist-clean-configs
+# automotive is not a flavor but we want to treat it like it is in this case
+ifdef AUTOMOTIVE_BUILD
+       @trap 'echo "Cleaning up..."; mv 
$(REDHAT)/configs/priority.$(FLAVOR).bak $(REDHAT)/configs/priority.$(FLAVOR); 
exit 1' SIGINT; \
+       cp $(REDHAT)/configs/priority.$(FLAVOR) 
$(REDHAT)/configs/priority.$(FLAVOR).bak; \
+       sed -i '/^#\|^ORDER\|^\(x86_64\|aarch64\)-automotive/!d' 
$(REDHAT)/configs/priority.$(FLAVOR); \
+       sed -i 's/^\([^=]*\)-automotive/\1/' 
$(REDHAT)/configs/priority.$(FLAVOR); \
+       cd $(REDHAT)/configs; ./build_configs.sh "partial" "snip"; \
+       cd $(REDHAT)/configs; ./build_configs.sh "$(SPECPACKAGE_NAME)" 
"$(FLAVOR)"; \
+       mv $(REDHAT)/configs/priority.$(FLAVOR).bak 
$(REDHAT)/configs/priority.$(FLAVOR)
+else
        +cd $(REDHAT)/configs; ./build_configs.sh "partial" "snip"
        +cd $(REDHAT)/configs; ./build_configs.sh "$(SPECPACKAGE_NAME)" 
"$(FLAVOR)"
+endif
 
 dist-configs-arch: ##configuration Same as dist-configs but for single 
architecture only.
 dist-configs-arch: ARCH_MACH = $(MACH)
@@ -784,18 +808,6 @@ dist-srpm-gcov: DISTLOCALVERSION=.gcov
 dist-srpm-gcov: BUILDOPTS+=+gcov
 dist-srpm-gcov: dist-srpm
 
-dist-srpm-automotive: ##build Create a source RPM for kernel-automotive and 
put it into the redhat/rpm/SRPMS/ directory.
-dist-srpm-automotive: SPECPACKAGE_NAME := kernel-automotive
-dist-srpm-automotive: DIST := .el$(RHEL_MAJOR)iv
-dist-srpm-automotive: BUILDOPTS += +automotiveonly
-dist-srpm-automotive: INCLUDE_FEDORA_FILES := 0
-dist-srpm-automotive: INCLUDE_RHEL_FILES := 0
-dist-srpm-automotive: INCLUDE_RT_FILES := 0
-dist-srpm-automotive: INCLUDE_AUTOMOTIVE_FILES := 1
-dist-srpm-automotive: FLAVOR := rhel
-dist-srpm-automotive: automotive-configs-pre .WAIT dist-srpm .WAIT 
automotive-configs-post
-       @rm -f $(REDHAT)/kernel-automotive*
-
 dist-rpms: ##build Create the binary RPMS for the kernel. See the dist-brew 
target for available options.
 dist-rpms: RPMBUILDOPTS=--target $(MACH) -bb
 dist-rpms: dist-sources do-rpmbuild
@@ -909,36 +921,19 @@ _dist-brew _dist-koji: _dist-%: dist-vr-check dist-srpm
 _distg-brew _distg-koji: _distg-%: dist-vr-check
        $* $(BUILD_PROFILE) build $(BUILD_FLAGS) --scratch $(BUILD_TARGET) 
"$(RHGITURL)?redhat/koji#$(RHGITCOMMIT)"
 
-dist-cbs-automotive: ##build Create a kernel-automotive SRPM and then call cbs 
to build the created SRPM.
-dist-cbs-automotive: SPECPACKAGE_NAME := kernel-automotive
-dist-cbs-automotive: DISTRO=$(if $(DISTRO_USERDEF),$(DISTRO_USERDEF),centos)
-dist-cbs-automotive: DIST=$(if 
$(DIST_USERDEF),$(DIST_USERDEF),.el$(RHEL_MAJOR)iv)
-dist-cbs-automotive: BUILD_PROFILE=$(if 
$(BUILD_PROFILE_USERDEF),$(BUILD_PROFILE_USERDEF))
-dist-cbs-automotive: BUILD_TARGET=$(if 
$(BUILD_TARGET_USERDEF),$(BUILD_TARGET_USERDEF))
-dist-cbs-automotive:
-       $(MAKE) _$@
-
-_dist-cbs-automotive: dist-srpm-automotive
-       cbs build $(BUILD_FLAGS) --scratch $(AUTOMOTIVE_BUILD_TARGET) 
$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
-
-dist-brew-automotive: ##build Create a kernel-automotive SRPM and then call 
brew to build the created SRPM.
-dist-brew-automotive: SPECPACKAGE_NAME := kernel-automotive
-dist-brew-automotive: DISTRO=$(if $(DISTRO_USERDEF),$(DISTRO_USERDEF),rhel)
-dist-brew-automotive: DIST=$(if 
$(DIST_USERDEF),$(DIST_USERDEF),.el$(RHEL_MAJOR)iv)
-dist-brew-automotive: BUILD_PROFILE=$(if 
$(BUILD_PROFILE_USERDEF),$(BUILD_PROFILE_USERDEF))
-dist-brew-automotive: BUILD_TARGET=$(if 
$(BUILD_TARGET_USERDEF),$(BUILD_TARGET_USERDEF))
-dist-brew-automotive:
+dist-cbs: ##build Create a kernel-automotive SRPM for the Automotive SIG and 
then call cbs to build the created SRPM.
+dist-cbs: AUTOMOTIVE_BUILD := 1
+dist-cbs: DISTRO=$(if $(DISTRO_USERDEF),$(DISTRO_USERDEF),centos)
+dist-cbs: BUILD_TARGET=$(if $(BUILD_TARGET_USERDEF),$(BUILD_TARGET_USERDEF))
+dist-cbs:
        $(MAKE) _$@
 
-_dist-brew-automotive: dist-srpm-automotive
-       brew build $(BUILD_FLAGS) --scratch $(AUTOMOTIVE_BUILD_TARGET) 
$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
+_dist-cbs: dist-srpm
+       cbs build $(BUILD_FLAGS) --scratch $(BUILD_TARGET) 
$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
 
 dist-git-test: export RH_DIST_GIT_TEST="1"
 dist-git-test: dist-git
 
-dist-git-automotive-test: export RH_DIST_GIT_TEST="1"
-dist-git-automotive-test: dist-git-automotive
-
 dist-git: dist-srpm $(KABI_TARBALL) $(KABIDW_TARBALL) dist-check-release
        @if [ -z "$(RHDISTGIT_BRANCH)" ]; then \
                echo "RHDISTGIT_BRANCH is unset"; \
@@ -946,21 +941,6 @@ dist-git: dist-srpm $(KABI_TARBALL) $(KABIDW_TARBALL) 
dist-check-release
        fi
        $(REDHAT)/scripts/rh-dist-git.sh
 
-# kernel-automotive uses a separate dist-git
-dist-git-automotive: SPECPACKAGE_NAME := kernel-automotive
-dist-git-automotive: DIST := .el$(RHEL_MAJOR)iv
-dist-git-automotive: RHDISTGIT_BRANCH := $(AUTOMOTIVE_DISTGIT_BRANCH)
-dist-git-automotive: RHPKG_BIN := $(AUTOMOTIVE_RHPKG_BIN)
-dist-git-automotive: RHPKG_OPTS := $(AUTOMOTIVE_RHPKG_OPTS)
-dist-git-automotive: RHPKG_NS := $(AUTOMOTIVE_DISTGIT_NS)
-dist-git-automotive: dist-srpm-automotive dist-check-release
-dist-git-automotive:
-       @if [ -z "$(AUTOMOTIVE_DISTGIT_BRANCH)" ]; then \
-               echo "AUTOMOTIVE_DISTGIT_BRANCH is unset"; \
-               exit 1; \
-       fi
-       $(REDHAT)/scripts/rh-dist-git.sh
-
 dist-headers-srpm:
        @scripts/create_headers_tarball.sh
        @cp $(REDHAT)/kernel-headers.spec.template 
$(SOURCES)/kernel-headers.spec
diff --git a/redhat/Makefile.variables b/redhat/Makefile.variables
index blahblah..blahblah 100644
--- a/redhat/Makefile.variables
+++ b/redhat/Makefile.variables
@@ -14,8 +14,8 @@
 # which is then reflected in the package NVR.
 ADD_COMMITID_TO_VERSION ?=
 
-# This is the brew/cbs scratch build target.
-AUTOMOTIVE_BUILD_TARGET ?=
+# Repurpose the stock kernel make targets for kernel-automotive.
+AUTOMOTIVE_BUILD ?=
 
 # This sets the incremental build version value in the rpm NVR.  If unset, this
 # defaults to RHEL_RELEASE from Makefile.rhelver

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3870

-- 
_______________________________________________
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