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

redhat/Makefile: introduce AUTOMOTIVE_BUILD

This adds the automotive specific targets dist-automotive-configs and
dist-cbs, 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

In order to treat kernel-automotive as a separate package rather than a
standard variant of the stock kernel, this generates the configs based
on a temporary version of the priority.rhel file. In this way, the
automotive configs are generated as kernel-automotive instead of having
a strange looking name that implies we are generating the automotive
variant of kernel-automotive (which would happen if we only changed the
package name). This has the added benefit of only needing to build the
automotive configs rather than all of the stock kernel configs.

The kernel-automotive package is not a CentOS Stream package, but its
equivalent is the AutoSD distribution maintained by the Automotive SIG.
Packages for the SIG are built in CBS and thus the dist-cbs target was
added specifically for the purpose of making kernel-automotive scratch
builds.

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

diff --git a/Makefile.rhelver b/Makefile.rhelver
index blahblah..blahblah 100644
--- a/Makefile.rhelver
+++ b/Makefile.rhelver
@@ -78,3 +78,13 @@ ifneq ("$(ZSTREAM)", "yes")
     RHEL_RELEASE:=$(RHEL_RELEASE).$(EARLY_YRELEASE)
   endif
 endif
+
+#
+# Automotive
+# ----------
+#
+# Represents the major and minor release used by automotive.
+# Primarily this is used to to identify the build target when
+# building the kernel-automotive packages.
+AUTOMOTIVE_MAJOR = 2
+AUTOMOTIVE_MINOR = 99
diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -1,4 +1,5 @@
 include Makefile.variables
+include Makefile.automotive
 
 #
 # Deprecated variables
@@ -69,13 +70,13 @@ ARCHCONFIG := $(shell uname -m | sed -e s/x86_64/X86_64/ \
                                     -e s/s390x/S390/ -e s/ppc.*/PPC/ )
 
 # rpm information
-SPECFILE:=$(SPECPACKAGE_NAME).spec
+SPECFILE=$(SPECPACKAGE_NAME).spec
 RPM:=$(REDHAT)/rpm
 SRPMS:=$(RPM)/SRPMS
 SOURCES:=$(RPM)/SOURCES
 TESTPATCH:=$(REDHAT)/linux-kernel-test.patch
 CHANGELOG_EXT:=changelog-$(RHEL_MAJOR).$(RHEL_MINOR)
-SPECCHANGELOG:=$(SPECPACKAGE_NAME).$(CHANGELOG_EXT)
+SPECCHANGELOG=$(SPECPACKAGE_NAME).$(CHANGELOG_EXT)
 ARCH_LIST=aarch64 ppc64le s390x x86_64 riscv64
 
 # save some user selectable values to know later if we can override them
@@ -272,8 +273,8 @@ else
   SPECRPMVERSION:=$(SPECRVERSION).$(SPECRPATCHLEVEL)
 endif
 BASEVERSION:=$(SPECRPMVERSION)-$(SPECBUILD)
-RELEASETAG:=$(SPECPACKAGE_NAME)-$(BASEVERSION)
-SRPM:=$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
+RELEASETAG=$(SPECPACKAGE_NAME)-$(BASEVERSION)
+SRPM=$(SRPMS)/$(RELEASETAG)$(DIST).src.rpm
 
 #
 # This conditional statement is where fedora, centos, and other (aka RHEL)
@@ -300,10 +301,10 @@ else ifeq ("$(DISTRO)", "centos")
   ifndef BUILD_TARGET
     BUILD_TARGET:=c$(RHEL_MAJOR)s-candidate
   endif
-  SPECTARFILE_RELEASE:=$(BASEVERSION)$(DIST)
-  SPECKABIVERSION:=$(BASEVERSION)$(DIST)
-  DISTRELEASETAG:=$(RELEASETAG)$(DIST)
-  DISTBASEVERSION:=$(BASEVERSION)$(DIST)
+  SPECTARFILE_RELEASE=$(BASEVERSION)$(DIST)
+  SPECKABIVERSION=$(BASEVERSION)$(DIST)
+  DISTRELEASETAG=$(RELEASETAG)$(DIST)
+  DISTBASEVERSION=$(BASEVERSION)$(DIST)
   PATCHLIST_URL:=none
   RHPKG_BIN:=centpkg
 else
@@ -323,13 +324,46 @@ else
     SPECTARFILE_RELEASE:=$(BASEVERSION)
     SPECKABIVERSION:=$(BASEVERSION)
   else
-    DISTRELEASETAG:=$(RELEASETAG)$(DIST)
-    DISTBASEVERSION:=$(BASEVERSION)$(DIST)
-    SPECTARFILE_RELEASE:=$(BASEVERSION)$(DIST)
-    SPECKABIVERSION:=$(BASEVERSION)$(DIST)
+    DISTRELEASETAG=$(RELEASETAG)$(DIST)
+    DISTBASEVERSION=$(BASEVERSION)$(DIST)
+    SPECTARFILE_RELEASE=$(BASEVERSION)$(DIST)
+    SPECKABIVERSION=$(BASEVERSION)$(DIST)
   endif
   PATCHLIST_URL:=none
   RHPKG_BIN:=rhpkg
+
+endif
+
+# When building kernel-automotive, set AUTOMOTIVE_BUILD=1.
+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
@@ -574,12 +608,29 @@ dist-rhel-configs: FLAVOR = rhel
 dist-rhel-configs: dist-configs
 rh-configs: dist-rhel-configs
 
+dist-automotive-configs: ##build build only the automotive configs
+dist-automotive-configs: AUTOMOTIVE_BUILD := 1
+dist-automotive-configs: DISTRO=$(if 
$(DISTRO_USERDEF),$(DISTRO_USERDEF),centos)
+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)
@@ -725,8 +776,8 @@ sources-rh: $(TARBALL) $(KABI_TARBALL) $(KABIDW_TARBALL) 
generate-testpatch-tmp
                kernel-local \
                dracut-virt.conf \
                $(SOURCES)/
-       @cat $$(ls -1 $(SPECPACKAGE_NAME).changelog-* | sort -V -r) \
-               > $(SOURCES)/kernel.changelog
+       @cat $$(ls -1 kernel.changelog-* | sort -V -r) \
+               > $(SOURCES)/$(SPECPACKAGE_NAME).changelog
        cp keys/redhatsecureboot{501,ca5}.cer $(SOURCES)/;
        @for KABIARCH in $(ARCH_LIST); do \
                cp kabi/Module.kabi_$$KABIARCH $(SOURCES)/; \
@@ -872,6 +923,16 @@ _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: ##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-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
 
@@ -913,7 +974,7 @@ dist-os-version: ##misc Displays the current Red Hat 
Enterprise Linux version ta
        @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
 
 dist-dump-variables: ##misc Dump makefile variables.
-       $(eval VARS:=$(sort $(shell cat Makefile.variables | sed '/^#/d; 
/^$$/d; s/[ ]*[?:]=.*//')))
+       $(eval VARS:=$(sort $(shell cat Makefile.variables Makefile.automotive 
| sed '/^#/d; /^$$/d; s/[ ]*[?:]=.*//')))
        @$(foreach V,$(sort $(.VARIABLES)), $(if $(filter-out environment 
default automatic, $(origin $V)),$(info $V=$($V)),$(if $(filter 
$(VARS),$(V)),$(info $V=$($V)))))
 
 dist-self-test: ##misc Runs self-tests from the redhat/self-test directory.
diff --git a/redhat/Makefile.automotive b/redhat/Makefile.automotive
new file mode 100644
index blahblah..blahblah 100644
--- /dev/null
+++ b/redhat/Makefile.automotive
@@ -0,0 +1,15 @@
+# Variables in this file are available for command line modification and is
+# included in redhat/Makefile.
+#
+# These variables are automotive specific and are only needed when working
+# with the kernel-automotive package.
+
+# Repurpose the stock kernel make targets for kernel-automotive.
+# Set this to '1' to build kernel-automotive configs, srpm, etc.
+AUTOMOTIVE_BUILD ?=
+
+# Indicates if the specific OS flavor files will be included as part of the
+# source RPM. Although automotive is not a true flavor, it is not a true
+# variant of the stock kernel either and therefore we need to manage its
+# source files independently.
+INCLUDE_AUTOMOTIVE_FILES ?= 0
diff --git a/redhat/Makefile.variables b/redhat/Makefile.variables
index blahblah..blahblah 100644
--- a/redhat/Makefile.variables
+++ b/redhat/Makefile.variables
@@ -67,10 +67,9 @@ HEAD ?= HEAD
 # be included as part of the source RPM.  Downstream projects, such as
 # centos-stream or RHEL, can disable file inclusion by setting these values
 # to '0'.
-INCLUDE_FEDORA_FILES:=1
-INCLUDE_RHEL_FILES:=1
-INCLUDE_RT_FILES:=1
-INCLUDE_AUTOMOTIVE_FILES:=1
+INCLUDE_FEDORA_FILES ?= 1
+INCLUDE_RHEL_FILES ?= 1
+INCLUDE_RT_FILES ?= 1
 
 # This variable is the location of the KABI cross compilers
 KABI_CROSS_COMPILE_PREFIX ?= /usr/bin/
diff --git a/redhat/automotive-centpkg-sig.conf 
b/redhat/automotive-centpkg-sig.conf
new file mode 100644
index blahblah..blahblah 100644
--- /dev/null
+++ b/redhat/automotive-centpkg-sig.conf
@@ -0,0 +1,32 @@
+# kernel-automotive is not a centos stream package. It is part of the
+# Automotive SIG and its dist-git is in the new gitlab centos namespace.
+# This file was originally copied from centpkg-0.9.1-2.el10_1 which is
+# used to override /etc/rpkg/centpkg-sig.conf.
+# Usage: centpkg-sig --config path/to/automotive-centpkg-sig.conf clone 
automotive/rpms/kernel-automotive
+[centpkg-sig]
+lookaside = https://git.centos.org/sources
+lookasidehash = sha512
+lookaside_cgi = https://git.centos.org/sources/upload_sig.cgi
+distgit_namespaced = True
+distgit_namespaces = rpms
+gitbaseurl = ssh://g...@gitlab.com/CentOS/%(repo)s.git
+anongiturl = https://gitlab.com/CentOS/%(repo)s
+branchre = .*
+kojiprofile = cbs
+build_client = cbs
+lookaside_namespaced = True
+git_excludes =
+  i386/
+  i686/
+  x86_64/
+  ppc/
+  ppc64/
+  ia64/
+  mips/
+  arm/
+  noarch/
+  /*.src.rpm
+  /build*.log
+  /.build-*.log
+  results_*/
+  clog
diff --git a/redhat/scripts/rh-dist-git.sh b/redhat/scripts/rh-dist-git.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/rh-dist-git.sh
+++ b/redhat/scripts/rh-dist-git.sh
@@ -29,7 +29,7 @@ cd "$tmpdir" || die "Unable to create temporary directory";
 test -n "$RHDISTGIT_CACHE" && reference="-- --reference $RHDISTGIT_CACHE"
 echo "Cloning using $RHPKG_BIN" >&2;
 # shellcheck disable=SC2086
-eval $RHPKG_BIN clone "$SPECPACKAGE_NAME" "$reference" >/dev/null || die 
"Unable to clone using $RHPKG_BIN";
+eval $RHPKG_BIN $RHPKG_OPTS clone "${RHPKG_NS}${SPECPACKAGE_NAME}" 
"$reference" >/dev/null || die "Unable to clone using $RHPKG_BIN";
  
 echo "Switching the branch"
 # change in the correct branch

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