Create Makefile.variables for a single point of configuration change

The existing Makefiles and scripts are hard coded to expect that we are
building from the os-build branch with master being the upstream branch.
This does not work well for fedora-stable releases, and does not offer
flexibility to build different trees without knowing the Makefiles and
scripts well enough to know what to change.  This change creates a
redhat/Makefile.variables which should be a self documented single file
to change when building with a different upstream or dist branch.

Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
This commit is contained in:
Justin M. Forbes 2021-08-26 19:56:10 -05:00
parent 654c1c5533
commit f58a81e17a
No known key found for this signature in database
GPG Key ID: B8FA7924A4B1C140
6 changed files with 70 additions and 32 deletions

View File

@ -236,7 +236,7 @@ setup-source: dist-git-version-check dist-clean-sources
cp $(REDHAT)/$(CHANGELOG_PREV) $(REDHAT)/$(CHANGELOG); \
fi
@cp $(REDHAT)/$(CHANGELOG) $(SOURCES)/$(CHANGELOG)
@$(REDHAT)/genspec.sh $(SOURCES) $(SOURCES)/$(SPECFILE) $(SOURCES)/$(CHANGELOG) $(PKGRELEASE) $(RPMKVERSION) $(RPMKPATCHLEVEL) $(RPMKSUBLEVEL) $(DISTRO_BUILD) $(RELEASED_KERNEL) $(SPECRELEASE) $(__ZSTREAM) "$(BUILDOPTS)" $(MARKER) `cat $(REDHAT)/marker` $(SINGLE_TARBALL) $(TARFILE_RELEASE) $(SNAPSHOT) $(BUILDID)
@$(REDHAT)/genspec.sh $(SOURCES) $(SOURCES)/$(SPECFILE) $(SOURCES)/$(CHANGELOG) $(PKGRELEASE) $(RPMKVERSION) $(RPMKPATCHLEVEL) $(RPMKSUBLEVEL) $(DISTRO_BUILD) $(RELEASED_KERNEL) $(SPECRELEASE) $(__ZSTREAM) "$(BUILDOPTS)" $(MARKER) `cat $(REDHAT)/marker` $(SINGLE_TARBALL) $(TARFILE_RELEASE) $(SNAPSHOT) $(UPSTREAM_BRANCH) $(BUILDID)
@cp $(SOURCES)/$(SPECFILE) $(SOURCES)/../SPECS/
generate-testpatch-tmp:
@ -340,7 +340,7 @@ dist-release-changed: setup-source
echo "Nothing changed, skipping updates"; \
else \
$(GIT) checkout -- $(REDHAT)/$(CHANGELOG); \
$(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
$(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM) $(BUMP_RELEASE); \
$(MAKE) dist-release-finish; \
fi
dist-release: dist-clean-sources

View File

@ -1,6 +1,7 @@
TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel)
REDHAT:=$(TOPDIR)/redhat
include $(TOPDIR)/Makefile.rhelver
include $(REDHAT)/Makefile.variables
RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
else echo rpm; fi)
@ -15,15 +16,17 @@ GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
# marker is git tag which we base off of for exporting patches
# Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel
# makefile as opposed to any adjusted version for snapshotting.
MARKER:=v$(RPMKVERSION).$(RPMKPATCHLEVEL)$(RPMKEXTRAVERSION)
ifneq ($(RPMKEXTRAVERSION),)
MARKER:=v$(RPMKVERSION).$(RPMKPATCHLEVEL)$(RPMKEXTRAVERSION)
KEXTRAVERSION:=$(shell echo $(RPMKEXTRAVERSION) | sed -e s/-/./)
PREBUILD:=0$(KEXTRAVERSION).
UPSTREAM_TARBALL_NAME:=$(RPMKVERSION).$(RPMKPATCHLEVEL)$(RPMKEXTRAVERSION)
else
ifeq ($(RPMKSUBLEVEL),0)
MARKER:=v$(RPMKVERSION).$(RPMKPATCHLEVEL)
UPSTREAM_TARBALL_NAME:=$(RPMKVERSION).$(RPMKPATCHLEVEL)
else
MARKER:=v$(RPMKVERSION).$(RPMKPATCHLEVEL).$(RPMKSUBLEVEL)
UPSTREAM_TARBALL_NAME:=$(RPMKVERSION).$(RPMKPATCHLEVEL).$(RPMKSUBLEVEL)
endif
PREBUILD:=
@ -39,21 +42,23 @@ endif
# If VERSION_ON_UPSTREAM is set, the versioning of the rpm package is based
# on a branch tracking upstream. This allows for generating rpms
# based on untagged releases.
ifeq ("$(DIST)", ".elrdy")
VERSION_ON_UPSTREAM:=1
else ifeq ("$(DISTRO)", "fedora")
VERSION_ON_UPSTREAM:=1
else
VERSION_ON_UPSTREAM:=0
ifndef VERSION_ON_UPSTREAM
ifeq ("$(DIST)", ".elrdy")
VERSION_ON_UPSTREAM:=1
else ifeq ("$(DISTRO)", "fedora")
VERSION_ON_UPSTREAM:=1
else
VERSION_ON_UPSTREAM:=0
endif
endif
ifeq ($(VERSION_ON_UPSTREAM),1)
# master is expected to track mainline.
MASTER:=$(shell $(GIT) rev-parse -q --verify origin/master || \
$(GIT) rev-parse -q --verify master)
ifeq ($(MASTER),)
$(error "Missing an 'origin/master' or 'master' branch")
# UPSTREAM_BRANCH is expected to track mainline.
UPSTREAM:=$(shell $(GIT) rev-parse -q --verify origin/$(UPSTREAM_BRANCH) || \
$(GIT) rev-parse -q --verify $(UPSTREAM_BRANCH))
ifeq ($(UPSTREAM),)
$(error "Missing an $(UPSTREAM_BRANCH) branch")
endif
MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) $(MASTER))
MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) $(UPSTREAM))
_TAG:=$(shell $(GIT) describe $(MERGE_BASE))
# a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash]
SNAPSHOT:=$(shell echo $(_TAG) | grep -c '\-g')
@ -107,14 +112,6 @@ else
SINGLE_TARBALL:=1
endif
# RELEASED_KERNEL: swaps between the pre-release secureboot keys and
# the release one, for vmlinux signing.
#
# 0 : pre-release (devel) secureboot keys are used for signing
# 1 : release (RC/GA) secureboot keys are used for signing
#
RELEASED_KERNEL:=0
STAMP_VERSION:=$(KVERSION)
LOCVERFILE:=../localversion

36
redhat/Makefile.variables Normal file
View File

@ -0,0 +1,36 @@
# Variables below should be changed as needed for building on a different
# branch, or with a different upstream branch. This should be the only
# file that needs to be changed now, and is included in redhat/Makefile
# and redhat/Makefile.common
# This is the source branch that you are building out of typically this is
# the current branch.
DIST_BRANCH ?= "os-build"
# The branch used as upstream. This is what the upstream tarball is it
# should be tracked in a local branch. This would be "master" for the
# Linus master branch or linux-5.x.y for a stable branch. It can also be
# any other upstream you have added as a branch locally.
UPSTREAM_BRANCH ?= master
# If VERSION_ON_UPSTREAM is set, the versioning of the rpm package is based
# on a branch tracking upstream. This allows for generating rpms
# based on untagged releases.
VERSION_ON_UPSTREAM:=1
# RELEASED_KERNEL swaps between the pre-release secureboot keys and
# the release one, for vmlinux signing. It also controls whether Fedora
# kernels are built as debug kernels or release kernels with a separate
# kernel-debug build.
# Set RELEASED_KERNEL to 1 when the upstream source tarball contains a
# kernel release. (This includes prepatch or "rc" releases.)
# Set RELEASED_KERNEL to 0 when the upstream source tarball contains an
# unreleased kernel development snapshot.
RELEASED_KERNEL:=0
# BUMP_RELEASE determines whether the pkgrelease is bumped when you call
# 'make dist-release'. It should be set to "yes" if you expect to do
# multiple updates and builds without bumping the base version, and no
# when you expect every build to use a different base kernel version.
BUMP_RELEASE:=yes

View File

@ -21,8 +21,9 @@ LAST_MARKER=${14}
SINGLE_TARBALL=${15}
TARFILE_RELEASE=${16}
SNAPSHOT=${17}
BUILDID=${18}
RPMVERSION=${KVERSION}.${KPATCHLEVEL}.${KSUBLEVEL}
UPSTREAM_BRANCH=${18}
BUILDID=${19}
RPMVERSION=${KVERSION}.${KPATCHLEVEL}
clogf="$SOURCES/changelog"
# hide [redhat] entries from changelog
HIDE_REDHAT=1;
@ -48,11 +49,11 @@ if [[ -z $lasttag ]]; then
fi
echo "Gathering new log entries since $lasttag"
# master is expected to track mainline.
MASTER="$(git rev-parse -q --verify origin/master || \
git rev-parse -q --verify master)"
UPSTREAM="$(git rev-parse -q --verify origin/$UPSTREAM_BRANCH || \
git rev-parse -q --verify $UPSTREAM_BRANCH)"
git log --topo-order --reverse --no-merges -z --format="- %s (%an)%n%b" \
^${MASTER} "$lasttag".. -- ':!/redhat/rhdocs' | ${0%/*}/genlog.py >> "$clogf"
^${UPSTREAM} "$lasttag".. -- ':!/redhat/rhdocs' | ${0%/*}/genlog.py >> "$clogf"
grep -v "tagging $RPM_VERSION" "$clogf" > "$clogf.stripped"
cp "$clogf.stripped" "$clogf"
@ -171,7 +172,7 @@ ARK_COMMIT_URL="https://gitlab.com/cki-project/kernel-ark/-/commit"
#
# May need to preserve word splitting in EXCLUDE_FILES
# shellcheck disable=SC2086
git log --no-merges --pretty=oneline --no-decorate ${MASTER}.. $EXCLUDE_FILES | \
git log --no-merges --pretty=oneline --no-decorate ${UPSTREAM}.. $EXCLUDE_FILES | \
sed "s!^\([^ ]*\)!$ARK_COMMIT_URL/\1\n &!; s!\$!\n!" \
> "$SOURCES"/Patchlist.changelog

View File

@ -124,6 +124,7 @@ Summary: The Linux kernel
%define kversion %%KVERSION%%.%%KPATCHLEVEL%%
%define rpmversion %%KVERSION%%.%%KPATCHLEVEL%%.%%KSUBLEVEL%%
%define patchversion %%KVERSION%%.%%KPATCHLEVEL%%
%define pkgrelease %%PKGRELEASE%%
# This is needed to do merge window version magic
@ -827,7 +828,7 @@ Source4002: gating.yaml
%if !%{nopatches}
Patch1: patch-%{rpmversion}-redhat.patch
Patch1: patch-%{patchversion}-redhat.patch
%endif
# empty final patch to facilitate testing of kernel patches
@ -1365,7 +1366,7 @@ cp -a %{SOURCE1} .
%if !%{nopatches}
ApplyOptionalPatch patch-%{rpmversion}-redhat.patch
ApplyOptionalPatch patch-%{patchversion}-redhat.patch
%endif
ApplyOptionalPatch linux-kernel-test.patch

View File

@ -7,6 +7,7 @@ fi
RHPATH="$1";
YSTREAM_FLAG="$2";
ZSTREAM_FLAG="$3";
BUMP_RELEASE="$4";
if [ -s "$RHPATH/linux-kernel-test.patch" ]; then
echo "linux-kernel-test.patch is not empty, aborting" >&2;
@ -22,7 +23,9 @@ ZMAJ=${ZMAJ:=0}
ZMIN=$(echo "$RELEASE" | cut -s -d "." -f 3)
ZMIN=${ZMIN:=0}
if [ "$ZSTREAM_FLAG" == "no" ]; then
if [ "$BUMP_RELEASE" == "no" ]; then
NEW_RELEASE="$RELEASE";
elif [ "$ZSTREAM_FLAG" == "no" ]; then
if [ "$YSTREAM_FLAG" == "yes" ]; then
NEW_RELEASE="$((RELEASE + 1))";
else