forked from TencentOS/TencentOS-kernel
Merge pull request #299 from ryncsn/tk4/0009-kabi
[WIP][Draft] Initial Koji/Standard Dist Support
This commit is contained in:
commit
e3f15df5df
|
|
@ -1,2 +1,3 @@
|
|||
*.c diff=cpp
|
||||
*.h diff=cpp
|
||||
dist/ export-ignore
|
||||
|
|
|
|||
|
|
@ -146,3 +146,7 @@ x509.genkey
|
|||
|
||||
# Clang's compilation database file
|
||||
/compile_commands.json
|
||||
|
||||
# Tencent dist files
|
||||
/dist/rpm
|
||||
/dist/workdir
|
||||
|
|
|
|||
11
Makefile
11
Makefile
|
|
@ -1,8 +1,15 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# dist_make: Tencent Dist Makefile, which contains dist-* make targets
|
||||
ifneq ($(shell echo $(MAKECMDGOALS) | grep "^dist-"),)
|
||||
include dist/Makefile
|
||||
else
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
VERSION = 5
|
||||
PATCHLEVEL = 4
|
||||
SUBLEVEL = 119
|
||||
EXTRAVERSION = -1
|
||||
EXTRAVERSION = -19
|
||||
NAME = Kleptomaniac Octopus
|
||||
|
||||
# *DOCUMENTATION*
|
||||
|
|
@ -1881,3 +1888,5 @@ FORCE:
|
|||
# Declare the contents of the PHONY variable as phony. We keep that
|
||||
# information in a variable so we can use it in if_changed and friends.
|
||||
.PHONY: $(PHONY)
|
||||
|
||||
endif # dist_make
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#define TRACE_INCLUDE_FILE msr-trace
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH asm/
|
||||
#define TRACE_INCLUDE_PATH asm
|
||||
|
||||
#if !defined(_TRACE_MSR_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_MSR_H
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ DEFINE_EVENT(x86_fpu, x86_fpu_xstate_check_failed,
|
|||
);
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH asm/trace/
|
||||
#define TRACE_INCLUDE_PATH asm/trace
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE fpu
|
||||
#endif /* _TRACE_FPU_H */
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ TRACE_EVENT(hyperv_send_ipi_mask,
|
|||
#endif /* CONFIG_HYPERV */
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH asm/trace/
|
||||
#define TRACE_INCLUDE_PATH asm/trace
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE hyperv
|
||||
#endif /* _TRACE_HYPERV_H */
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ void trace_bounds_exception_mpx(const struct mpx_bndcsr *bndcsr)
|
|||
#endif /* CONFIG_X86_INTEL_MPX */
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH asm/trace/
|
||||
#define TRACE_INCLUDE_PATH asm/trace
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE mpx
|
||||
#endif /* _TRACE_MPX_H */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,387 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# A simple and clean build system initially inspired by Fedora ARK Kernel and Tencent Linux Kernel public.
|
||||
#
|
||||
|
||||
TOPDIR := $(shell git rev-parse --show-toplevel)
|
||||
ifeq ("$(TOPDIR)", "")
|
||||
TOPDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
|
||||
endif
|
||||
|
||||
DISTPATH = dist
|
||||
DISTDIR := $(TOPDIR)/$(DISTPATH)
|
||||
ifeq ("$(abspath $(DISTDIR)/Makefile)", "$(lastword $(MAKEFILE_LIST))")
|
||||
$(error Can't detect Makefile, aborting)
|
||||
endif
|
||||
|
||||
### Downstream marker, update this when forking to another downstream
|
||||
KDIST =
|
||||
|
||||
### Vendor mark
|
||||
VENDOR = tencent
|
||||
VENDOR_CAPITALIZED = Tencent
|
||||
URL = https://github.com/Tencent/TencentOS-kernel
|
||||
|
||||
### Get native arch for binary build by default
|
||||
NATIVE_ARCH := $(shell uname -m | sed -e 's/amd64/x86_64/;s/arm64/aarch64/;s/*86$$/x86/')
|
||||
|
||||
###### Build parameters, change them with `make <PARAM>=<VALUE>` ######
|
||||
# When building binary package, which arch to build against
|
||||
ARCH := $(NATIVE_ARCH)
|
||||
# ARCH to be covered by spec file
|
||||
SPEC_ARCH := x86_64 aarch64 riscv64
|
||||
# Kernel variant, will be appended to kernel release string as suffix
|
||||
# to indicate this is a variant kernel (eg. debug; minimal;)
|
||||
VARIANT :=
|
||||
# Which kernel config to use, this build system supports multiple config targets,
|
||||
# Get the available config by scripts/ls-config.sh
|
||||
CONFIG := generic-release
|
||||
# Build a specific tag/commit with `make TAG=<tag>` or `make COMMIT=<commit>`
|
||||
TAG := $(COMMIT)
|
||||
# Extra RPM flags
|
||||
RPMFLAGS :=
|
||||
####### Build parameters end ######
|
||||
|
||||
### Basic variables
|
||||
DISTCONFIGDIR = $(DISTDIR)/configs
|
||||
DISTWORKDIR = $(DISTDIR)/workdir
|
||||
|
||||
DISTTEMPLATES = $(wildcard $(DISTDIR)/templates/*)
|
||||
DISTCONFIGS = $(shell find $(DISTDIR)/configs -type f)
|
||||
DISTSCRIPTS = $(wildcard $(DISTDIR)/scripts/*)
|
||||
DISTSOURCES = $(wildcard $(DISTDIR)/sources/*)
|
||||
DISTKABIS = $(wildcard $(DISTDIR)/kabi/*)
|
||||
DISTFILES = $(DISTDIR) $(DISTTEMPLATES) $(DISTCONFIGS) $(DISTSCRIPTS) $(DISTSOURCES) $(DISTKABIS)
|
||||
|
||||
### Force unify arch name, so Kbuild, and other Makefiles can work seamlessly
|
||||
# BUILD_ARCH is for RPM, Dist make
|
||||
BUILD_ARCH := $(ARCH)
|
||||
override BUILD_ARCH := $(shell echo $(BUILD_ARCH) | sed -e 's/amd64/x86_64/;s/arm64/aarch64/;s/*86$$/x86/')
|
||||
# ARCH is for Kbuild
|
||||
override ARCH := $(shell echo $(BUILD_ARCH) | sed -e 's/amd64/x86_64/;s/aarch64/arm64/;s/*86$$/x86/')
|
||||
|
||||
### Check if TAG is valid
|
||||
TAG := HEAD
|
||||
COMMIT := $(shell git rev-parse --verify --quiet $(TAG))
|
||||
ifeq ($(COMMIT),)
|
||||
$(error Invalid git reference, tag '$(TAG)' commit '$(COMMIT)', aborting)
|
||||
endif
|
||||
|
||||
### Build files
|
||||
KFULLVER := $(shell $(DISTDIR)/scripts/get-version.sh $(COMMIT))
|
||||
CONFIGFILE := $(shell $(DISTDIR)/scripts/ls-config-files.sh $(CONFIG))
|
||||
WORKDIRS = $(DISTWORKDIR) $(RPM_TOPDIR) $(RPM_BUILDDIR) $(RPM_RPMDIR) $(RPM_SOURCEDIR) $(RPM_SPECDIR) $(RPM_SRCRPMDIR) $(RPM_BUILDROOTDIR)
|
||||
SPECFILE = $(RPM_SOURCEDIR)/kernel.spec
|
||||
TARFILE = $(RPM_SOURCEDIR)/kernel-$(KFULLVER).tar
|
||||
TESTPATCH = $(RPM_SOURCEDIR)/linux-kernel-test.patch
|
||||
ifeq ($(CONFIGFILE),)
|
||||
$(error Invalid CONFIG value '$(CONFIG)', no matching config target found)
|
||||
endif
|
||||
|
||||
### RPM files
|
||||
RPM_TOPDIR := $(DISTDIR)/rpm
|
||||
RPM_BUILDDIR := $(RPM_TOPDIR)/BUILD
|
||||
RPM_RPMDIR := $(RPM_TOPDIR)/RPMS
|
||||
RPM_SOURCEDIR := $(RPM_TOPDIR)/SOURCES
|
||||
RPM_SPECDIR := $(RPM_TOPDIR)/SPECS
|
||||
RPM_SRCRPMDIR := $(RPM_TOPDIR)/SRPMS
|
||||
RPM_BUILDROOTDIR := $(RPM_TOPDIR)/BUILDROOT
|
||||
|
||||
### RPM build options
|
||||
# All params enabled by default (except kABI check, see below), DEFAULT_ENABLED overrides DEFAULT_DISABLE.
|
||||
DEFAULT_DISABLED=
|
||||
DEFAULT_ENABLED=
|
||||
|
||||
## A few shortcut for commonly used params:
|
||||
# Disable KABI check by default
|
||||
KABI=0
|
||||
ifeq ($(KABI), 0)
|
||||
override DEFAULT_DISABLED := kabichk $(DEFAULT_DISABLED)
|
||||
endif
|
||||
|
||||
# Enabled module sign by default
|
||||
MODSIGN=1
|
||||
ifeq ($(MODSIGN), 0)
|
||||
override DEFAULT_DISABLED := modsign $(DEFAULT_DISABLED)
|
||||
endif
|
||||
|
||||
# Allow to skip RPM dependency check
|
||||
NODEP=0
|
||||
ifeq ($(NODEP), 1)
|
||||
override RPMFLAGS := --nodeps $(RPMFLAGS)
|
||||
endif
|
||||
|
||||
# Crossbuild
|
||||
ifneq ($(BUILD_ARCH),$(NATIVE_ARCH))
|
||||
RPMCROSSFLAGS = --with crossbuild --target $(BUILD_ARCH) --define "_cross_compile $(BUILD_ARCH)-linux-gnu-"
|
||||
else
|
||||
RPMCROSSFLAGS = --without crossbuild
|
||||
endif
|
||||
|
||||
# For re-distribute to another distro
|
||||
ifneq ($(DISTRO),)
|
||||
override RPMFLAGS := --define "dist .$(DISTRO)" $(RPMFLAGS)
|
||||
$(info "NOTE: DISTRO is set, building for another distro $(DISTRO)")
|
||||
$(info " You shoudn't do this unless you know what you are doing.")
|
||||
endif
|
||||
|
||||
# Always make sure workdir exists
|
||||
$(shell mkdir -p $(WORKDIRS))
|
||||
|
||||
default: dist-help
|
||||
|
||||
$(TARFILE):
|
||||
@echo "Generating kernel source tar: $(TARFILE)"
|
||||
@cd $(TOPDIR); git archive $(COMMIT) $(TOPDIR) --format=tar --prefix=kernel-$(KFULLVER)/ --output $(TARFILE)
|
||||
|
||||
dist-tarball: $(TARFILE)
|
||||
@echo "$(TARFILE)"
|
||||
|
||||
$(CONFIGFILE): $(DISTFILES)
|
||||
@echo "Generating kernel config style '$(CONFIG)'"
|
||||
@$(DISTDIR)/scripts/gen-configs.sh $(CONFIG)
|
||||
|
||||
dist-configs: $(CONFIGFILE)
|
||||
dist-config: dist-configs
|
||||
rm -f $(TOPDIR)/.config
|
||||
cp $(RPM_SOURCEDIR)/$(CONFIG).$(BUILD_ARCH).config $(TOPDIR)/.config
|
||||
@printf "\033[0;32mDefault kernel config copied as $(TOPDIR)/.config\033[0m\n"
|
||||
|
||||
# TODO: Build from a unclean tree is not working yet
|
||||
# which can't be detected by make.
|
||||
# $(TESTPATCH): always-rebuild
|
||||
# @git diff --no-renames HEAD -- ":(exclude)$(DISTDIR)" > $(TESTPATCH)
|
||||
# @[ -s "$(TESTPATCH)" ] && echo "Building from a unclean tree" || :
|
||||
|
||||
# TODO: Remove always-rebuild - currently these targets depend on git worktree or variables,
|
||||
.PHONY: always-rebuild
|
||||
$(SPECFILE): always-rebuild
|
||||
@echo "Generating kernel RPM spec: $(SPECFILE)"
|
||||
@$(DISTDIR)/scripts/gen-spec.sh \
|
||||
--commit "$(COMMIT)" \
|
||||
--build-arch "$(SRPM_ARCH)" \
|
||||
--kernel-config "$(CONFIG)" \
|
||||
--kernel-variant "$(VARIANT)" \
|
||||
--set-default-disabled "$(DEFAULT_DISABLED)" \
|
||||
--set-default-enabled "$(DEFAULT_ENABLED)" \
|
||||
> $(SPECFILE)
|
||||
@grep -A2 "# == Package options ==" $(SPECFILE) | cut -c3-
|
||||
|
||||
dist-specfile: $(SPECFILE) $(TOPDIR)/.config
|
||||
@echo "$(SPECFILE)"
|
||||
|
||||
dist-sources: dist-configs $(TARFILE) $(DISTSOURCES) $(DISTKABIS) $(SPECFILE)
|
||||
@cp $(DISTSOURCES) $(DISTKABIS) $(RPM_SOURCEDIR)
|
||||
|
||||
define DO_RPMBUILD
|
||||
@echo "=== DISTBUILD ==="
|
||||
@echo "Building kernel: $(KFULLVER)"
|
||||
@echo "Config style: $(CONFIG)"
|
||||
@echo "RPM build flags: $(1)"
|
||||
@echo "=== RPMBULID ==="
|
||||
rpmbuild \
|
||||
--define '_topdir $(RPM_TOPDIR)' \
|
||||
--define '_builddir $(RPM_BUILDDIR)' \
|
||||
--define '_rpmdir $(RPM_RPMDIR)' \
|
||||
--define '_sourcedir $(RPM_SOURCEDIR)' \
|
||||
--define '_specdir $(RPM_SPECDIR)' \
|
||||
--define '_srcrpmdir $(RPM_SRCRPMDIR)' \
|
||||
--define '_buildrootdir $(RPM_BUILDROOTDIR)' \
|
||||
$(SPECFILE) $(1)
|
||||
endef
|
||||
|
||||
dist-srpm: dist-sources
|
||||
$(call DO_RPMBUILD,-bs --nodeps --rmsource --rmspec $(RPMFLAGS))
|
||||
|
||||
dist: dist-rpm
|
||||
dist-rpms: dist-rpm
|
||||
dist-rpm: dist-sources
|
||||
$(call DO_RPMBUILD,-bb $(RPMCROSSFLAGS) --rmsource --rmspec $(RPMFLAGS))
|
||||
|
||||
dist-prep: dist-sources
|
||||
$(call DO_RPMBUILD,-bp --nodeps $(RPMCROSSFLAGS) $(RPMFLAGS))
|
||||
|
||||
dist-new-release:
|
||||
@$(DISTDIR)/scripts/make-release.sh
|
||||
|
||||
dist-new-sub-release:
|
||||
@$(DISTDIR)/scripts/make-release.sh --sub-release
|
||||
|
||||
dist-clean:
|
||||
@for i in $(RPM_TOPDIR)/* $(DISTWORKDIR); do \
|
||||
echo Cleaning up $$i; \
|
||||
rm -rf $$i/*; \
|
||||
rm -rf $$i/.* 2>/dev/null; \
|
||||
done; :;
|
||||
|
||||
BUILDDEPS=$(shell rpmspec -q --buildrequires $(SPECFILE) | cut -d ' ' -f 1)
|
||||
MISSINGDEPS=$(shell echo "$(BUILDDEPS)" | xargs -n1 echo | while read -r _d; do rpm -q --whatprovides "$$_d" >/dev/null || echo "$$_d"; done)
|
||||
dist-check-buildrequires: $(SPECFILE)
|
||||
@if [ -n "$(MISSINGDEPS)" ]; then \
|
||||
echo "Error: Build dependency packages missing, please install: $(MISSINGDEPS)"; \
|
||||
echo "Hint: You can try run \`make dist-install-buildrequires\` to fix this."; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
dist-install-buildrequires: $(SPECFILE)
|
||||
@if [ -n "$(MISSINGDEPS)" ]; then \
|
||||
echo "Installing kernel build dependency "$(MISSINGDEPS)" using yum..." \
|
||||
echo "Missing dependency packages: $(MISSINGDEPS)..."; \
|
||||
if [ -x /usr/bin/yum ]; then \
|
||||
echo "Trying to install..."; \
|
||||
echo "$(MISSINGDEPS)" | sudo xargs yum install -y && exit 0; \
|
||||
else \
|
||||
echo "Yum is not available for current user."; \
|
||||
fi; \
|
||||
echo "Error: Intallation failed."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
dist-check-requires: dist-check-buildrequires
|
||||
@if [ ! -x /usr/bin/python3 ]; then \
|
||||
echo "ERROR: Python 3 is required." ; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ ! -x /usr/bin/git ]; then \
|
||||
echo "ERROR: Git is required." ; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
dist-format-config:
|
||||
@$(DISTDIR)/scripts/format-configs.sh
|
||||
dist-format-configs: dist-format-config
|
||||
|
||||
dist-check-new-config:
|
||||
@echo "Checking for unset Kconfig..."
|
||||
@$(DISTDIR)/scripts/check-configs.sh check-new-configs $(CONFIG)
|
||||
dist-check-new-configs: dist-check-new-config
|
||||
|
||||
dist-fix-new-config:
|
||||
@echo "Fixing unset Kconfig issue..."
|
||||
@$(DISTDIR)/scripts/check-configs.sh check-new-configs --autofix $(CONFIG)
|
||||
dist-fix-new-configs: dist-fix-new-config
|
||||
|
||||
dist-check-dup-config:
|
||||
@echo "Checking for duplicated Kconfig..."
|
||||
@$(DISTDIR)/scripts/check-configs.sh check-dup-configs $(CONFIG)
|
||||
dist-check-dup-configs: dist-check-dup-config
|
||||
|
||||
dist-fix-dup-config:
|
||||
@echo "Fixing duplicated Kconfig issue..."
|
||||
@$(DISTDIR)/scripts/check-configs.sh check-dup-configs --autofix $(CONFIG)
|
||||
dist-fix-dup-configs: dist-fix-dup-config
|
||||
|
||||
dist-check-diff-config:
|
||||
@echo "Checking for duplicated Kconfig..."
|
||||
@$(DISTDIR)/scripts/check-configs.sh check-diff-configs $(CONFIG)
|
||||
dist-check-diff-configs: dist-check-diff-config
|
||||
|
||||
dist-check-config: dist-check-new-config dist-check-dup-config dist-check-diff-config
|
||||
dist-check-configs: dist-check-config
|
||||
|
||||
dist-check-commit:
|
||||
@echo "Checking for new commits..."
|
||||
@$(DISTDIR)/scripts/check-commits.sh
|
||||
dist-check-commits: dist-check-commit
|
||||
|
||||
dist-check-tag:
|
||||
@echo "Checking tag of '$(TAG)' ..."
|
||||
@$(DISTDIR)/scripts/check-tag.sh '$(TAG)'
|
||||
|
||||
dist-check-kabi: dist-sources
|
||||
@echo "Checking kABI for $(BUILD_ARCH)..."
|
||||
$(call DO_RPMBUILD,-bi $(RPMCROSSFLAGS) \
|
||||
--without doc --without headers --without perf --without tools --without bpftool \
|
||||
--without debuginfo --without selftest --without modsign \
|
||||
--with kabichk \
|
||||
)
|
||||
|
||||
dist-update-kabi: KABI_WORKDIR:=$(shell mktemp -d $(DISTWORKDIR)/kabi.XXXX)
|
||||
dist-update-kabi: RPM_BUILDDIR:=$(KABI_WORKDIR)
|
||||
dist-update-kabi: dist-sources dist-check-buildrequires
|
||||
@echo "Updating kABI for $(BUILD_ARCH)..."
|
||||
$(call DO_RPMBUILD,-bc $(RPMCROSSFLAGS) \
|
||||
--without doc --without headers --without perf --without tools --without bpftool \
|
||||
--without debuginfo --without selftest --without modsign --without kabichk \
|
||||
)
|
||||
MODSYM=$$(find $(KABI_WORKDIR) -maxdepth 3 -type f -name 'Module.symvers'); \
|
||||
if [ -f "$$MODSYM" ]; then \
|
||||
echo "Using $$MODSYM as kABI reference file."; \
|
||||
$(DISTDIR)/scripts/helper/update-kabi.sh \
|
||||
$(DISTDIR)/kabi/Module.kabi_$(BUILD_ARCH) $$MODSYM > $(KABI_WORKDIR)/Module.kabi.updated; \
|
||||
cp $(KABI_WORKDIR)/Module.kabi.updated $(DISTDIR)/kabi/Module.kabi_$(BUILD_ARCH); \
|
||||
else \
|
||||
echo "Failed to find Module.symvers."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Do a fast check
|
||||
dist-check: dist-check-commit dist-check-new-config
|
||||
dist-help:
|
||||
@echo 'This helps you to manage, release, and develop $(VENDOR_CAPITALIZED) Linux kernel.'
|
||||
@echo 'Use below make targets as sub-command:'
|
||||
@echo
|
||||
@echo 'NOTE: Before you submit any patch, please see the "Sanity check" targets and at lease run:'
|
||||
@echo '`make dist-check`'
|
||||
@echo 'And ensure there is no error.'
|
||||
@echo
|
||||
@echo 'For building a kernel RPM distrobution package:'
|
||||
@echo ' dist, dist-rpms - Alias to dist-rpm.'
|
||||
@echo ' dist-rpm - Create the binary RPMS for the kernel and put it under:'
|
||||
@echo ' $(RPM_RPMDIR)'
|
||||
@echo ' dist-srpm - Create a source RPM and put it under:'
|
||||
@echo ' $(RPM_SRCRPMDIR)'
|
||||
@echo ' dist-prep - Prep the kernel dist build source code under:'
|
||||
@echo ' $(RPM_BUILDDIR)'
|
||||
@echo
|
||||
@echo 'Available params (most of these params are usable for all sub-commands besides dist-rpm/dist-srpm):'
|
||||
@echo ' ARCH="$(ARCH)"'
|
||||
@echo ' Target ARCH used for binary/RPM build.'
|
||||
@echo ' SPEC_ARCH="$(SPEC_ARCH)"'
|
||||
@echo ' Targer ARCH coverted by spec/SRPM build.'
|
||||
@echo ' TAG="$(TAG)" (or COMMIT="$(COMMIT)")'
|
||||
@echo ' Specify a git tag or commit, and this Makefile will build the kernel from that version.'
|
||||
@echo ' VARIANT="$(VARIANT)"'
|
||||
@echo ' Kernel variant, will be appended to kernel release string as suffix'
|
||||
@echo ' to indicate this is a variant kernel (eg. debug; minimal;), especially'
|
||||
@echo ' useful when combined with CONFIG=<variant config>'
|
||||
@echo ' RPMFLAGS="$(RPMFLAGS)"'
|
||||
@echo ' Extra RPM flags to be passed to rpmbuild for RPM bulding related commands.'
|
||||
@echo ' CONFIG="$(CONFIG)"'
|
||||
@echo ' Which kernel config to use, $(VENDOR_CAPITALIZED) build system supports multiple config targets,'
|
||||
@echo ' Avaiable targets:'
|
||||
@$(DISTDIR)/scripts/ls-config-targets.sh | xargs -n3 printf " %s %s %s\n"
|
||||
@echo
|
||||
@echo 'To make a new kernel version release:'
|
||||
@echo ' dist-new-release - Update changelog, increase release number and tag a new commit properly.'
|
||||
@echo ' dist-new-sub-release - Same as dist-new-release but increase the sub release number (eg. 5.18.0-1, 5.18.0-1.1, 5.18.0-1.2, ...).'
|
||||
@echo
|
||||
@echo 'Build prepare:'
|
||||
@echo ' dist-check-requires - Check build time and dist targets package dependency.'
|
||||
@echo ' dist-check-buildrequires - Check build time package dependency.'
|
||||
@echo ' dist-install-buildrequires - Check and automatically install build time dependency, requires root.'
|
||||
@echo
|
||||
@echo 'Sanity check:'
|
||||
@echo ' dist-check-commit - Check commit message and patch.'
|
||||
@printf " \033[1;33m* Please at least ensure this check doesn't raise any error before submitting a patch.\033[0m\n"
|
||||
@echo ' dist-check-diff-config - Check for invalid configs. If a CONFIG_XXX=y is set in config file but gone after make oldconfig,'
|
||||
@echo ' it it considered a invalid config. There are many potential resons causing this, changed or missing'
|
||||
@echo ' config dependency, deprecated config, auto-select configs, this tool will also provide some hint.'
|
||||
@echo ' dist-check-dup-config - Check for duplicated configs, '
|
||||
@echo ' dist-check-new-config - Check for unset configs. If any config is not set, kbuild will prompt during built time.'
|
||||
@echo ' This helper will check for unset configs so you can set them properly in predefined config file.'
|
||||
@echo 'Code clean up:'
|
||||
@echo ' dist-fix-new-config - Same as dist-check-new-configs but automatically set unset configs to its default value and'
|
||||
@echo ' update config files.'
|
||||
@echo ' dist-fix-dup-config - Automatically remove duplicated configs.'
|
||||
@echo " dist-format-config - Sort and simplify the base config files, won\'t change the final config output."
|
||||
@printf ' \033[1;33m* Please run this before submitting any config change.\033[0m\n'
|
||||
@echo ' dist-clean - Clean up directories under:'
|
||||
@echo ' $(DISTDIR)'
|
||||
@echo
|
||||
@echo 'Configuration targets:'
|
||||
@echo ' dist-configs - Generate dist config files, using config matrix in:'
|
||||
@echo ' $(DISTDIR)/config/'
|
||||
@echo ' dist-config - Generate config, and override .config file with the config corresponding'
|
||||
@echo ' to arch $(BUILD_ARCH)'
|
||||
@echo
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
RPM based dist Makefile and build system for the Linux kernel.
|
||||
|
||||
Run `make dist-help` to see the usage.
|
||||
|
||||
Authors:
|
||||
Kairui Song <kasong@tencent.com>
|
||||
Katrin Zhou <katrinzhou@tencent.com>
|
||||
Kaixu Xia <kaixuxia@tencent.com>
|
||||
|
||||
Bundle with the Linux Kernel, licensed under the GPLv2
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
CONFIG_BPF_SYSCALL=y
|
||||
CONFIG_DEBUG_INFO_BTF=y
|
||||
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
|
||||
CONFIG_DEBUG_KERNEL=y
|
||||
CONFIG_IKCONFIG=m
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_MODVERSIONS=y
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../../../package/arm/config.default
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../../../package/default/config.default
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
CONFIG_DEBUG_PERF_USE_VMALLOC=y
|
||||
# CONFIG_DEBUG_VM is not set
|
||||
CONFIG_DEVMEM=y
|
||||
# CONFIG_IP_VS_DEBUG is not set
|
||||
CONFIG_KASAN=y
|
||||
CONFIG_KASAN_GENERIC=y
|
||||
# CONFIG_KASAN_HW_TAGS is not set
|
||||
CONFIG_KASAN_INLINE=y
|
||||
CONFIG_KDB_DEFAULT_ENABLE=0x1
|
||||
# CONFIG_LOCK_STAT is not set
|
||||
CONFIG_MAILBOX_TEST=m
|
||||
CONFIG_PANIC_ON_OOPS=y
|
||||
CONFIG_PANIC_ON_OOPS_VALUE=1
|
||||
CONFIG_PERCPU_TEST=m
|
||||
# CONFIG_RANDOM32_SELFTEST is not set
|
||||
CONFIG_SPI_DEBUG=y
|
||||
CONFIG_WQ_WATCHDOG=y
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
CONFIG_ACPI_APEI_ERST_DEBUG=m
|
||||
CONFIG_ACPI_CONFIGFS=m
|
||||
CONFIG_ACPI_CUSTOM_METHOD=m
|
||||
CONFIG_ACPI_DEBUG=y
|
||||
CONFIG_ACPI_DEBUGGER=y
|
||||
CONFIG_ACPI_DEBUGGER_USER=m
|
||||
CONFIG_ACPI_EC_DEBUGFS=m
|
||||
CONFIG_ATH10K_DEBUG=y
|
||||
CONFIG_ATH10K_TRACING=y
|
||||
CONFIG_ATH_DEBUG=y
|
||||
# CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION is not set
|
||||
CONFIG_CAN_DEBUG_DEVICES=y
|
||||
CONFIG_CEPH_LIB_PRETTYDEBUG=y
|
||||
CONFIG_CFG80211_DEBUGFS=y
|
||||
CONFIG_CGROUP_DEBUG=y
|
||||
CONFIG_CPUMASK_OFFSTACK=y
|
||||
CONFIG_CRYPTO_DEV_CCP_DEBUGFS=y
|
||||
CONFIG_CSD_LOCK_WAIT_DEBUG=y
|
||||
CONFIG_DEBUG_ATOMIC_SLEEP=y
|
||||
CONFIG_DEBUG_CREDENTIALS=y
|
||||
CONFIG_DEBUG_IRQFLAGS=y
|
||||
CONFIG_DEBUG_KMEMLEAK=y
|
||||
CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y
|
||||
CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
|
||||
CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE=40000
|
||||
CONFIG_DEBUG_LOCK_ALLOC=y
|
||||
CONFIG_DEBUG_MUTEXES=y
|
||||
CONFIG_DEBUG_NOTIFIERS=y
|
||||
CONFIG_DEBUG_OBJECTS=y
|
||||
CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT=1
|
||||
CONFIG_DEBUG_OBJECTS_FREE=y
|
||||
CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
|
||||
CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
|
||||
CONFIG_DEBUG_OBJECTS_TIMERS=y
|
||||
CONFIG_DEBUG_OBJECTS_WORK=y
|
||||
CONFIG_DEBUG_PAGEALLOC=y
|
||||
# CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT is not set
|
||||
CONFIG_DEBUG_PAGE_REF=y
|
||||
CONFIG_DEBUG_PER_CPU_MAPS=y
|
||||
CONFIG_DEBUG_PREEMPT=y
|
||||
CONFIG_DEBUG_RT_MUTEXES=y
|
||||
CONFIG_DEBUG_RWSEMS=y
|
||||
CONFIG_DEBUG_SG=y
|
||||
CONFIG_DEBUG_SPINLOCK=y
|
||||
CONFIG_DEBUG_STACK_USAGE=y
|
||||
CONFIG_DEBUG_VM=y
|
||||
CONFIG_DEBUG_VM_PGTABLE=y
|
||||
CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y
|
||||
CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
|
||||
CONFIG_DMABUF_DEBUG=y
|
||||
CONFIG_DMADEVICES_DEBUG=y
|
||||
CONFIG_DMADEVICES_VDEBUG=y
|
||||
CONFIG_DMA_API_DEBUG=y
|
||||
CONFIG_DMA_API_DEBUG_SG=y
|
||||
CONFIG_EDAC_DEBUG=y
|
||||
CONFIG_EXT4_DEBUG=y
|
||||
CONFIG_FAILSLAB=y
|
||||
# CONFIG_FAIL_FUNCTION is not set
|
||||
CONFIG_FAIL_IO_TIMEOUT=y
|
||||
CONFIG_FAIL_MAKE_REQUEST=y
|
||||
CONFIG_FAIL_MMC_REQUEST=y
|
||||
CONFIG_FAIL_PAGE_ALLOC=y
|
||||
CONFIG_FAIL_SUNRPC=y
|
||||
CONFIG_FAULT_INJECTION=y
|
||||
CONFIG_FAULT_INJECTION_DEBUG_FS=y
|
||||
CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
|
||||
CONFIG_FSCACHE_OBJECT_LIST=y
|
||||
CONFIG_GENERIC_IRQ_DEBUGFS=y
|
||||
CONFIG_I2C_GPIO_FAULT_INJECTOR=y
|
||||
CONFIG_IOMMU_DEBUGFS=y
|
||||
CONFIG_IP_VS_DEBUG=y
|
||||
CONFIG_IWLWIFI_DEBUG=y
|
||||
CONFIG_IWLWIFI_DEVICE_TRACING=y
|
||||
CONFIG_KASAN_KUNIT_TEST=m
|
||||
# CONFIG_KASAN_OUTLINE is not set
|
||||
CONFIG_KASAN_VMALLOC=y
|
||||
CONFIG_KDB_CONTINUE_CATASTROPHIC=0
|
||||
CONFIG_KPROBE_EVENT_GEN_TEST=m
|
||||
CONFIG_LATENCYTOP=y
|
||||
CONFIG_LOCKDEP_BITS=16
|
||||
CONFIG_LOCKDEP_CHAINS_BITS=17
|
||||
CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=12
|
||||
CONFIG_LOCKDEP_STACK_TRACE_BITS=19
|
||||
CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=14
|
||||
CONFIG_LOCK_EVENT_COUNTS=y
|
||||
CONFIG_LOCK_STAT=y
|
||||
CONFIG_MAC80211_DEBUGFS=y
|
||||
CONFIG_MAC80211_MESSAGE_TRACING=y
|
||||
CONFIG_MMIOTRACE=y
|
||||
CONFIG_NET_DEV_REFCNT_TRACKER=y
|
||||
CONFIG_NET_NS_REFCNT_TRACKER=y
|
||||
CONFIG_NFP_DEBUG=y
|
||||
CONFIG_NOUVEAU_DEBUG_MMU=y
|
||||
CONFIG_NOUVEAU_DEBUG_PUSH=y
|
||||
CONFIG_PAGE_TABLE_CHECK=y
|
||||
CONFIG_PAGE_TABLE_CHECK_ENFORCED=y
|
||||
# CONFIG_PANIC_ON_OOPS is not set
|
||||
CONFIG_PERCPU_STATS=y
|
||||
CONFIG_PM_ADVANCED_DEBUG=y
|
||||
CONFIG_PM_TEST_SUSPEND=y
|
||||
CONFIG_PM_TRACE_RTC=y
|
||||
CONFIG_PROVE_LOCKING=y
|
||||
CONFIG_PTDUMP_DEBUGFS=y
|
||||
CONFIG_QUOTA_DEBUG=y
|
||||
CONFIG_RANDOM32_SELFTEST=y
|
||||
CONFIG_RC_LOOPBACK=m
|
||||
CONFIG_RTLWIFI_DEBUG=y
|
||||
CONFIG_RTW88_DEBUG=y
|
||||
CONFIG_RTW88_DEBUGFS=y
|
||||
CONFIG_RTW89_DEBUGFS=y
|
||||
CONFIG_RTW89_DEBUGMSG=y
|
||||
CONFIG_SCF_TORTURE_TEST=m
|
||||
CONFIG_SND_CTL_VALIDATION=y
|
||||
CONFIG_SND_DEBUG=y
|
||||
CONFIG_SND_JACK_INJECTION_DEBUG=y
|
||||
CONFIG_SND_PCM_XRUN_DEBUG=y
|
||||
CONFIG_SND_SOC_SOF_DEBUG_PROBES=y
|
||||
CONFIG_SND_SOC_SOF_HDA_PROBES=y
|
||||
CONFIG_SND_VERBOSE_PRINTK=y
|
||||
CONFIG_SYNTH_EVENT_GEN_TEST=m
|
||||
CONFIG_TEST_FPU=m
|
||||
CONFIG_TEST_LIST_SORT=m
|
||||
CONFIG_TEST_MIN_HEAP=m
|
||||
CONFIG_TEST_STRING_HELPERS=m
|
||||
# CONFIG_USB_XHCI_DBGCAP is not set
|
||||
CONFIG_XFS_WARN=y
|
||||
CONFIG_ZRAM_MEMORY_TRACKING=y
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
CONFIG_HYPERV_TESTING=y
|
||||
CONFIG_KASAN=y
|
||||
CONFIG_KASAN_GENERIC=y
|
||||
CONFIG_KASAN_INLINE=y
|
||||
CONFIG_PM_SLEEP_DEBUG=y
|
||||
# CONFIG_PM_TEST_SUSPEND is not set
|
||||
CONFIG_USB_XHCI_DBGCAP=y
|
||||
CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y
|
||||
CONFIG_X86_DEBUG_FPU=y
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../package/arm/Module.kabi_aarch64
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../package/default/Module.kabi_x86_64
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Check kernel commit messages
|
||||
|
||||
# shellcheck source=./lib.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib.sh"
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
check-commit-msg.sh <commit>...
|
||||
|
||||
--extra-author Who is triggering this check, check for corresponding signed-off-by in commit body
|
||||
For example, if this script is triggered by a Merge Request, the one who submitted
|
||||
the Merge Request should also sign all commits within the MR.
|
||||
|
||||
Can be also enabled by setting EXTRA_AUTHOR=<author> in environmental variable.
|
||||
|
||||
--gen-report Generate error report under corrent directory for each commit being checked
|
||||
in current directory.
|
||||
|
||||
Can be also enabled by setting GEN_REPORT=1 in environmental variable.
|
||||
|
||||
--output-dir <DIR> Specify where the report should be put if '--gen-report' is used
|
||||
An directory path is expected.
|
||||
|
||||
Defaults to current directory.
|
||||
|
||||
--vendor-only Author should be limited to vendor only.
|
||||
(Git commit email address must end with @$VENDOR.com).
|
||||
EOF
|
||||
}
|
||||
|
||||
if ! [[ -x "$TOPDIR/scripts/checkpatch.pl" ]]; then
|
||||
die "This command requires scripts/checkpatch.pl"
|
||||
fi
|
||||
|
||||
COMMITS=()
|
||||
HEAD_COMMIT=
|
||||
OUTPUT_DIR=$(pwd)
|
||||
VENDOR_ONLY=
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--extra-author )
|
||||
EXTRA_AUTHOR=$2
|
||||
shift 2
|
||||
;;
|
||||
--output-dir )
|
||||
OUTPUT_DIR=$2
|
||||
shift 2
|
||||
;;
|
||||
--gen-report )
|
||||
GEN_REPORT=1
|
||||
shift
|
||||
;;
|
||||
--vendor-only )
|
||||
VENDOR_ONLY=1
|
||||
shift
|
||||
;;
|
||||
-* )
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
* )
|
||||
COMMITS+=( "$1" )
|
||||
shift
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "${COMMITS[*]}" ]]; then
|
||||
echo "Checking all commits that are ahead of remote tracking branch."
|
||||
|
||||
if ! UPSTREAM_BASE=$(git -C "$repo" merge-base HEAD "@{u}" 2>/dev/null); then
|
||||
warn "Can't find a valid upstream, will only check HEAD commit."
|
||||
COMMITS=HEAD
|
||||
else
|
||||
if [[ $(git rev-list "$UPSTREAM_BASE..HEAD" --count) -eq 0 ]]; then
|
||||
COMMITS="HEAD"
|
||||
else
|
||||
COMMITS="$UPSTREAM_BASE..HEAD"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
is_valid_commit() {
|
||||
case $1 in
|
||||
*[!0-9A-Fa-f]* | "" )
|
||||
return 1
|
||||
;;
|
||||
* )
|
||||
if [ "${#1}" -lt 12 ] || [ "${#1}" -gt 41 ]; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check if a commit id is valid upstream commit id
|
||||
# $1: commit id to check
|
||||
is_valid_upstream_commit() {
|
||||
local commit=$1
|
||||
local upstream_repo=(
|
||||
"torvalds https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=<>"
|
||||
"stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=<>"
|
||||
"tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/patch/?id=<>"
|
||||
)
|
||||
local repo repo_name repo_url commit_url
|
||||
|
||||
for repo in "${upstream_repo[@]}"; do
|
||||
repo_name=${repo%% *}
|
||||
repo_url=${repo#* }
|
||||
commit_url=${repo_url/<>/$commit}
|
||||
if curl --fail --silent --output /dev/null "$commit_url"; then
|
||||
echo "$commit_url"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# TODO(katinzhou): 需要测试。且能支持本地调用检查commit msg是否合规
|
||||
# Check a commit for all potential issues
|
||||
# returns number of issues found
|
||||
check_commit() {
|
||||
local ret=0
|
||||
local commit=$1
|
||||
local commit_msg=$2
|
||||
|
||||
local author=$(git log --pretty=format:"%an" "$commit" -1)
|
||||
local author_email=$(git log --pretty=format:"%ae" "$commit" -1)
|
||||
local committer=$(git log --pretty=format:"%cn" "$commit" -1)
|
||||
local committer_email=$(git log --pretty=format:"%ce" "$commit" -1)
|
||||
local commit_body=$(git log --pretty=format:"%b" "$commit" -1)
|
||||
local commit_summary=$(git log --pretty=format:"%s" "$commit" -1)
|
||||
|
||||
# Ignore merge commit
|
||||
if [ "$(git show --no-patch --format="%P" "$commit" | wc -w)" -ne 1 ]; then
|
||||
echo "Found merge commit $commit"
|
||||
echo "NOTICE: This checking routine only follows one parent commit."
|
||||
return 0
|
||||
fi
|
||||
|
||||
local ignore_line="ERROR: Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")'"
|
||||
|
||||
local patch_content
|
||||
if ! patch_content=$(git format-patch --stdout -1 "$commit"); then
|
||||
echo "ERROR: FATAL: Failed to format $commit into a patch"
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! echo "$commit_body" | grep -iq "^checkpatch:.*\bno\b"; then
|
||||
local patch_err
|
||||
patch_err=$(echo "$patch_content" | "$TOPDIR/scripts/checkpatch.pl" --terse | grep -v "$ignore_line" | grep "ERROR: ")
|
||||
|
||||
if [[ -n "$patch_err" ]]; then
|
||||
echo "ERROR: scripts/checkpatch.pl reported following error:"
|
||||
echo " $patch_err"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! echo "$commit_body" | grep -q "Signed-off-by: .*\b$author\b"; then
|
||||
echo "ERROR: Commit author ($author) need to sign the commit, so a Signed-off-by: <$author's sign> is needed"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
|
||||
if [[ $EXTRA_AUTHOR ]]; then
|
||||
if ! echo "$commit_body" | grep -q "Signed-off-by: .*\b$EXTRA_AUTHOR\b"; then
|
||||
echo "ERROR: Commit co-author (eg. MR author) need to sign the commit, so a Signed-off-by: <$EXTRA_AUTHOR's sign> is needed"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
upstream_commit=$(echo "$commit_body" | sed -nE "s/^(Upstream commit:|Upstream: commit) (\S+)/\2/pg")
|
||||
upstream_status=$(echo "$commit_body" | sed -nE "s/^(Upstream status:|Upstream:) (\S+)/\2/pg")
|
||||
commits_cnt=$(echo "$upstream_commit" | wc -w)
|
||||
|
||||
if [[ $commit_summary == $VENDOR:* ]]; then
|
||||
if [[ -z "$upstream_status" ]]; then
|
||||
echo "ERROR: It seems this is a downstream commit."
|
||||
echo " Please add following mark in the commit message:"
|
||||
echo ' ```'
|
||||
echo ' Upstream status: <no/pending/downstream-only...>'
|
||||
echo ' ```'
|
||||
echo " to explain this is a downstream commit."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
|
||||
if [[ $commits_cnt -ne 0 ]]; then
|
||||
echo "ERROR: It seems this is a downstream commit, but a Upstream commit mark is provided."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
# This is an upstream commit
|
||||
if [[ $commits_cnt -eq 0 ]]; then
|
||||
if [[ $VENDOR_ONLY ]] && [[ $commit_summary != $VENDOR:* ]]; then
|
||||
echo "ERROR: '$VENDOR:' is missing in the commit summary, and no 'Upstream commit:' mark is found."
|
||||
echo " If this is a downstream commit, please add '$VENDOR': in commit summary, and add this mark in commit message:"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
|
||||
if [[ -z "$upstream_status" ]]; then
|
||||
echo "ERROR: No upstream mark found."
|
||||
echo " If this is a downstream commit, please add this mark:"
|
||||
echo ' ```'
|
||||
echo ' Upstream status: <no/pending/downstream-only...>'
|
||||
echo ' ```'
|
||||
echo " to explain this is a downstream commit."
|
||||
echo
|
||||
echo " If this is a backported upstream commit, please add one and only one mark:"
|
||||
echo ' ```'
|
||||
echo " Upstream commit: <commit id>"
|
||||
echo ' ```'
|
||||
echo " to indicate which commit is being backported."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
elif [[ "$upstream_status" =~ ^[a-f0-9]{7,}$ ]]; then
|
||||
echo "ERROR: It seems you pasted a plain commit id after 'Upstream:' or 'Upstream status:' mark."
|
||||
echo " Please use this format instead:"
|
||||
echo ' ```'
|
||||
echo " Upstream commit: <commit id>"
|
||||
echo ' ```'
|
||||
echo " If this is a actually downstream commit, please use less confusing words"
|
||||
echo " for the 'Upstream status:' mark."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
else
|
||||
if [[ $commits_cnt -ne 1 ]]; then
|
||||
echo "ERROR: It seems this is a upstream commit, please add one *and only one* upstream commit indicator per commit, in following format:"
|
||||
echo ' ```'
|
||||
echo " Upstream commit: <commit id>"
|
||||
echo ' ```'
|
||||
echo " If this is a downstream commit, please add \"$VENDOR:\" header in commit summary."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
else
|
||||
if ! is_valid_commit "$upstream_commit"; then
|
||||
echo "ERROR: $upstream_commit is not an valid commit!"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
else
|
||||
if ! is_valid_upstream_commit "$upstream_commit" > /dev/null; then
|
||||
echo "ERROR: $upstream_commit is not an valid upstream commit!"
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
conflict_cnt=$(echo "$commit_body" | grep -c "^Conflict: ")
|
||||
if [ "$conflict_cnt" -ne 1 ]; then
|
||||
echo "ERROR: This is an upstream commit, please add one (and only one) conflict indicator in following format:"
|
||||
echo ' ```'
|
||||
echo " Conflict: <none/refactored/minor/resolved...>"
|
||||
echo ' ```'
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $VENDOR_ONLY ]] && [[ $author_email != *@$VENDOR.com ]]; then
|
||||
echo "ERROR: The author of this commit is not from $VENDOR.com, did you forget to reset author?"
|
||||
echo " You can reset author to your self for better backports commits tracking, use:"
|
||||
echo " > git commit --amend --reset-author"
|
||||
echo " Or:"
|
||||
echo " > git commit --amend --author=\"yourname <yourname@$VENDOR.com>\""
|
||||
echo " If there are many commits to be modified, use:"
|
||||
echo " > git filter-branch."
|
||||
echo
|
||||
ret=$(( ret + 1 ))
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
if ! git_logs=$(git log --no-walk=sorted --no-decorate --pretty=oneline --first-parent "${COMMITS[*]}"); then
|
||||
die "Failed to parse git references '${COMMITS[*]}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IDX=0
|
||||
ERROR_MSG=""
|
||||
echo "$git_logs" | while read -r commit_id commit_msg; do
|
||||
echo "=== Checking $commit_id ('$commit_msg') ..."
|
||||
|
||||
IDX=$(( IDX + 1 ))
|
||||
ERROR_MSG=$(check_commit "$commit_id")
|
||||
RET=$?
|
||||
OUTFILE=$(printf "$OUTPUT_DIR/%04d-%s.err" $IDX "$commit_id")
|
||||
|
||||
if [[ $RET -ne 0 ]]; then
|
||||
echo_yellow "Found following issues with $commit_id ('$commit_msg'):"
|
||||
echo_red "$ERROR_MSG"
|
||||
if [[ "$GEN_REPORT" ]] && [[ "$GEN_REPORT" != "0" ]]; then
|
||||
{
|
||||
echo "$ERROR_MSG"
|
||||
} > "$OUTFILE"
|
||||
fi
|
||||
else
|
||||
if [[ -n "$ERROR_MSG" ]]; then
|
||||
echo_yellow "$commit_id have some warnings:"
|
||||
echo_red "$ERROR_MSG"
|
||||
else
|
||||
echo_green "$commit_id looks OK"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Newline as seperator
|
||||
echo
|
||||
done
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# This script takes the merged config files and processes them through listnewconfig
|
||||
# then append the new options to pending config
|
||||
|
||||
# shellcheck source=./lib-config.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-config.sh"
|
||||
|
||||
# shellcheck disable=SC2164
|
||||
export CONFIG_OUTDIR=$DISTDIR/workdir
|
||||
AUTOFIX=0
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
check-configs.sh [sub command] [--autofix] [ <config targets> ... ]
|
||||
Available sub command:
|
||||
|
||||
check-new-configs Check for new unset kernel options.
|
||||
If --autofix (or env var AUTOFIX) is enabled,
|
||||
will append to pending configs
|
||||
|
||||
check-dup-configs Check for kernel configs of the same value in different archs.
|
||||
If --autofix (or env var AUTOFIX) is enabled,
|
||||
will move these configs from arch
|
||||
specific config to the default base config.
|
||||
|
||||
check-diff-configs Check for kernel configs that failed to enabled,
|
||||
which means, they are set =y/=m in config matrix,
|
||||
but end up disabled in the final .config file.
|
||||
Doesn't support AUTOFIX since issues caused by
|
||||
Kconfig dependency is complex and always need manual fix.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Use make listnewconfig to check new Kconfigs
|
||||
check_new_configs() {
|
||||
# First generate plain concated config files
|
||||
populate_configs "$@"
|
||||
|
||||
# Check if there are unset config
|
||||
_check_new_kconfigs() {
|
||||
local arch=$1 config_file=$2 base_file=$3 base_configs new_configs
|
||||
|
||||
echo_green "=== Checking $config_file..."
|
||||
new_configs=$(config_make "$arch" KCONFIG_CONFIG="$config_file" --no-print-directory listnewconfig)
|
||||
|
||||
if [ -n "$new_configs" ]; then
|
||||
echo_yellow "=== Following configs are not set properly:"
|
||||
echo "$new_configs"
|
||||
|
||||
if [[ $AUTOFIX -eq 1 ]]; then
|
||||
echo_green "=== Appending these new configs to the base config file: '$base_file'"
|
||||
echo "$new_configs" >> "$base_file"
|
||||
|
||||
base_configs=$(<"$base_file")
|
||||
{
|
||||
echo "$base_configs"
|
||||
echo "$new_configs"
|
||||
} | config_sanitizer > "$base_file"
|
||||
fi
|
||||
else
|
||||
echo_green "=== Config is all clear"
|
||||
fi
|
||||
|
||||
# Add a newline as seperator
|
||||
echo
|
||||
}
|
||||
|
||||
for_each_config_product _check_new_kconfigs "$@"
|
||||
}
|
||||
|
||||
check_dup_configs() {
|
||||
# Merge common config items among different archs with same value into base default config.
|
||||
_dedup_single_dir() {
|
||||
local dir=$1
|
||||
local common_conf base_conf
|
||||
|
||||
echo_green "=== Checking config dir '$dir'"
|
||||
for arch in "${CONFIG_ARCH[@]}"; do
|
||||
[[ -e "$dir/$arch.config" ]] || continue
|
||||
|
||||
if [[ -z "$common_conf" ]]; then
|
||||
# Read-in first arch specific config
|
||||
common_conf=$(config_sanitizer < "$dir/$arch.config")
|
||||
else
|
||||
# Keep the common config items of differnt archs
|
||||
# The content is filtered with config_sanitizer so `comm` is enough
|
||||
common_conf=$(comm -12 \
|
||||
<(echo "$common_conf") \
|
||||
<(config_sanitizer < "$dir/$arch.config")
|
||||
)
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$common_conf" ]]; then
|
||||
echo_yellow "=== Common configs shared by all sub arch:"
|
||||
echo "$common_conf"
|
||||
|
||||
if [[ $AUTOFIX -eq 1 ]]; then
|
||||
base_conf=$(<"$dir/default.config")
|
||||
{
|
||||
echo "$base_conf"
|
||||
echo "$common_conf"
|
||||
} | config_sanitizer > "$dir/default.config"
|
||||
fi
|
||||
else
|
||||
echo_green "=== Config is all clear"
|
||||
fi
|
||||
}
|
||||
|
||||
_get_config_dirs() {
|
||||
shift; printf "%s\n" "$@"
|
||||
}
|
||||
|
||||
for dir in $(for_each_config_target _get_config_dirs "$@" | sort -u); do
|
||||
_dedup_single_dir "$dir"
|
||||
done
|
||||
}
|
||||
|
||||
# generate diff file using kernel script diffconfig after make olddefconfig
|
||||
# param: config.file.old config.file
|
||||
check_diff_configs() {
|
||||
local ALL_CONFIGS
|
||||
|
||||
[[ -x "$TOPDIR"/scripts/diffconfig ]] || die "This command rely on linux's in-tree diffconfig script"
|
||||
|
||||
ALL_CONFIGS=$(find "$TOPDIR" -name "Kconfig*" -exec grep -h "^config .*" {} + | sed "s/^config //")
|
||||
|
||||
# First generate plain concated config files
|
||||
populate_configs "$@"
|
||||
|
||||
_make_a_copy() {
|
||||
cp "$2" "$2.orig"
|
||||
}
|
||||
for_each_config_product _make_a_copy "$@"
|
||||
|
||||
makedef_configs "$@"
|
||||
|
||||
# Check why a config is not enabled
|
||||
_check_config_issue() {
|
||||
local _config=$1 _config_file=$2
|
||||
|
||||
if ! echo "$ALL_CONFIGS" | grep -q "\b$_config\b"; then
|
||||
echo "$_config no longer exists, maybe it's deprecated or renamed."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$_config have following depends:"
|
||||
get_all_depends "$_config" "$_config_file" || echo "No dependency found, likely not available on this arch."
|
||||
echo
|
||||
}
|
||||
|
||||
_check_diff_configs() {
|
||||
local arch=$1 config_file=$2 diff_configs
|
||||
|
||||
echo "=== Checking config $config_file"
|
||||
|
||||
echo "= Parsing Kconfig ..."
|
||||
kconfig_parser "$arch" "$TOPDIR/Kconfig" "$config_file"
|
||||
|
||||
echo "= Checking configs ..."
|
||||
diff_configs=$("$TOPDIR"/scripts/diffconfig "$config_file.orig" "$config_file" |
|
||||
# Ignore new added config, they should be covered by check_new_configs
|
||||
# If kernel didn't ask us to fill one config, then it's an auto-selected config
|
||||
grep -v "^+" | \
|
||||
# Ignore disappeared configs that were unset
|
||||
grep -v "^\-.*n$" \
|
||||
)
|
||||
|
||||
if [[ -z "$diff_configs" ]]; then
|
||||
echo_green "=== Config is all clear"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$diff_configs" | while read -r _line; do
|
||||
local config config_hint=""
|
||||
case $_line in
|
||||
-*" m" | -*" y" )
|
||||
config=${_line% *}
|
||||
config=${config#-}
|
||||
config_hint=$(_check_config_issue "$config" "$config_file")
|
||||
;;
|
||||
esac
|
||||
|
||||
echo_yellow "$_line"
|
||||
if [[ "$config_hint" ]]; then
|
||||
echo_yellow "$config_hint" | sed "s/^/ /"
|
||||
fi
|
||||
echo
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
for_each_config_product _check_diff_configs "$@"
|
||||
}
|
||||
|
||||
CMD=$1; shift
|
||||
[[ $1 == '--autofix' ]] && AUTOFIX=1
|
||||
case "$CMD" in
|
||||
check-new-configs )
|
||||
check_new_configs "$@"
|
||||
;;
|
||||
check-dup-configs )
|
||||
check_dup_configs "$@"
|
||||
;;
|
||||
check-diff-configs )
|
||||
check_diff_configs "$@"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# $1: tag
|
||||
# $2: (opt) git repo
|
||||
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
prepare_kernel_ver "$@"
|
||||
|
||||
# If tag is not recognized, prepare_kernel_ver will version it as snapshot
|
||||
# use this as an indicator of invalid tag
|
||||
if ! [[ $KTAGRELEASE ]]; then
|
||||
error "Invalid tag '$1'"
|
||||
exit 1
|
||||
else
|
||||
info "Tag '$KTAGRELEASE' OK, Kernel version '$KERNEL_UNAMER', RPM version '${KERNEL_MAJVER//-/.}-${KERNEL_RELVER//-/.}'"
|
||||
fi
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG
|
||||
# options your compiler does not support. This works well if you configure and
|
||||
# build the kernel on the same host machine.
|
||||
#
|
||||
# It is inconvenient if you prepare the .config that is carried to a different
|
||||
# build environment (typically this happens when you package the kernel for
|
||||
# distros) because using a different compiler potentially produces different
|
||||
# CONFIG options than the real build environment. So, you probably want to make
|
||||
# as many options visible as possible. In other words, you need to create a
|
||||
# super-set of CONFIG options that cover any build environment. If some of the
|
||||
# CONFIG options turned out to be unsupported on the build machine, they are
|
||||
# automatically disabled by the nature of Kconfig.
|
||||
#
|
||||
# However, it is not feasible to get a full-featured compiler for every arch.
|
||||
# Hence these dummy toolchains to make all compiler tests pass.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# From the top directory of the source tree, run
|
||||
#
|
||||
# $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig
|
||||
#
|
||||
# Most of compiler features are tested by cc-option, which simply checks the
|
||||
# exit code of $(CC). This script does nothing and just exits with 0 in most
|
||||
# cases. So, $(cc-option, ...) is evaluated as 'y'.
|
||||
#
|
||||
# This scripts caters to more checks; handle --version and pre-process __GNUC__
|
||||
# etc. to pretend to be GCC, and also do right things to satisfy some scripts.
|
||||
|
||||
# Check if the first parameter appears in the rest. Succeeds if found.
|
||||
# This helper is useful if a particular option was passed to this script.
|
||||
# Typically used like this:
|
||||
# arg_contain <word-you-are-searching-for> "$@"
|
||||
arg_contain ()
|
||||
{
|
||||
search="$1"
|
||||
shift
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
if [ "$search" = "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# To set CONFIG_CC_IS_GCC=y
|
||||
if arg_contain --version "$@"; then
|
||||
echo "gcc (scripts/dummy-tools/gcc)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if arg_contain -E "$@"; then
|
||||
# For scripts/cc-version.sh; This emulates GCC 20.0.0
|
||||
if arg_contain - "$@"; then
|
||||
sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}'
|
||||
exit 0
|
||||
else
|
||||
echo "no input files" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# To set CONFIG_AS_IS_GNU
|
||||
if arg_contain -Wa,--version "$@"; then
|
||||
echo "GNU assembler (scripts/dummy-tools) 2.50"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if arg_contain -S "$@"; then
|
||||
# For scripts/gcc-x86-*-has-stack-protector.sh
|
||||
if arg_contain -fstack-protector "$@"; then
|
||||
if arg_contain -mstack-protector-guard-reg=fs "$@"; then
|
||||
echo "%fs"
|
||||
else
|
||||
echo "%gs"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# For arch/powerpc/tools/gcc-check-mprofile-kernel.sh
|
||||
if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" &&
|
||||
arg_contain -mprofile-kernel "$@"; then
|
||||
if ! test -t 0 && ! grep -q notrace; then
|
||||
echo "_mcount"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# To set GCC_PLUGINS
|
||||
if arg_contain -print-file-name=plugin "$@"; then
|
||||
plugin_dir=$(mktemp -d)
|
||||
|
||||
mkdir -p $plugin_dir/include
|
||||
touch $plugin_dir/include/plugin-version.h
|
||||
|
||||
echo $plugin_dir
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# inverted return value
|
||||
if arg_contain -D__SIZEOF_INT128__=0 "$@"; then
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
# Dummy script that always succeeds.
|
||||
|
||||
# Check if the first parameter appears in the rest. Succeeds if found.
|
||||
# This helper is useful if a particular option was passed to this script.
|
||||
# Typically used like this:
|
||||
# arg_contain <word-you-are-searching-for> "$@"
|
||||
arg_contain ()
|
||||
{
|
||||
search="$1"
|
||||
shift
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
if [ "$search" = "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
if arg_contain --version "$@" || arg_contain -v "$@"; then
|
||||
progname=$(basename $0)
|
||||
echo "GNU $progname (scripts/dummy-tools/$progname) 2.50"
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -0,0 +1 @@
|
|||
ld
|
||||
|
|
@ -0,0 +1 @@
|
|||
ld
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Generate kernel config according to config matrix
|
||||
|
||||
# shellcheck source=./lib-config.sh
|
||||
. "/$(dirname "$(realpath "$0")")/lib-config.sh"
|
||||
|
||||
# Sort and remove duplicated items in each config base file
|
||||
for file in "$CONFIG_PATH"/*/*/*.config; do
|
||||
config_sanitizer < "$file" > "$file.fmt.tmp"
|
||||
|
||||
mv "$file.fmt.tmp" "$file"
|
||||
done
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Generate kernel config according to config matrix
|
||||
#
|
||||
# Params:
|
||||
# $@: [ <filter>... ] When non-empty, only generate kernel configs style matching <filter>
|
||||
|
||||
# shellcheck source=./lib-config.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-config.sh"
|
||||
|
||||
# Populate basic config entries based on our config file tree
|
||||
populate_configs "$@"
|
||||
|
||||
# Process the config files with make olddefconfig
|
||||
makedef_configs "$@"
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "/$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
gen-spec.sh [OPTION]
|
||||
|
||||
--kernel-dist Kernel distribution marker, eg. tks/tlinux4/tlinux3
|
||||
--kernel-config Kernel config base name, will look for the corresponding kernel config under $DISTDIR/configs
|
||||
--kernel-variant Kernel variant, eg. debug, gcov, kdb
|
||||
--build-arch What arch's are supported, defaults to '$SPEC_ARCH'"
|
||||
EOF
|
||||
}
|
||||
|
||||
DEFAULT_DISALBED=" kabichk "
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--kernel-config )
|
||||
KERNEL_CONFIG=$2
|
||||
shift 2
|
||||
;;
|
||||
--kernel-variant )
|
||||
KERNEL_VARIANT=$2
|
||||
shift 2
|
||||
;;
|
||||
--build-arch )
|
||||
BUILD_ARCH=$2
|
||||
shift 2
|
||||
;;
|
||||
--commit )
|
||||
COMMIT=$2
|
||||
shift 2
|
||||
;;
|
||||
--set-default-disabled )
|
||||
for param in $2; do
|
||||
DEFAULT_DISALBED=" $param $DEFAULT_DISALBED"
|
||||
done
|
||||
shift 2
|
||||
;;
|
||||
--set-default-enabled )
|
||||
for param in $2; do
|
||||
DEFAULT_DISALBED="${DEFAULT_DISALBED/ $param /}"
|
||||
done
|
||||
shift 2
|
||||
;;
|
||||
* )
|
||||
die "Unrecognized parameter $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This function will prepare $KERNEL_MAJVER, $KERNEL_RELVER
|
||||
prepare_kernel_ver "${COMMIT:-HEAD}"
|
||||
|
||||
BUILD_ARCH="${BUILD_ARCH:-$SPEC_ARCH}"
|
||||
|
||||
RPM_NAME="kernel${KERNEL_VARIANT:+-$KERNEL_VARIANT}${KERNEL_DIST:+-$KERNEL_DIST}"
|
||||
RPM_VERSION=${KERNEL_MAJVER//-/.}
|
||||
RPM_RELEASE=${KERNEL_RELVER//-/.}
|
||||
RPM_RELEASE=${RPM_RELEASE%".$KERNEL_DIST"}
|
||||
RPM_VENDOR=$(get_dist_makefile_var VENDOR_CAPITALIZED)
|
||||
RPM_URL=$(get_dist_makefile_var URL)
|
||||
|
||||
if [ -z "$KERNEL_CONFIG" ]; then
|
||||
for config in "$TOPDIR/configs/"*.config; do
|
||||
# "<config-basename>.<arch>.config" -> "<config-basename>"
|
||||
KERNEL_CONFIG=$(basename "$config")
|
||||
KERNEL_CONFIG=${config%.config}
|
||||
KERNEL_CONFIG=${config%.*}
|
||||
break
|
||||
done
|
||||
|
||||
if [ -z "$KERNEL_CONFIG" ]; then
|
||||
die "There is no valid kernel config."
|
||||
fi
|
||||
fi
|
||||
|
||||
_gen_arch_spec() {
|
||||
local arch kernel_arch
|
||||
cat << EOF
|
||||
ExclusiveArch: $BUILD_ARCH
|
||||
EOF
|
||||
for arch in $BUILD_ARCH; do
|
||||
if ! kernel_arch=$(get_kernel_arch "$arch"); then
|
||||
die "Unsupported arch '$arch'"
|
||||
fi
|
||||
cat << EOF
|
||||
%ifarch $arch
|
||||
%define kernel_arch $kernel_arch
|
||||
%endif
|
||||
EOF
|
||||
done
|
||||
}
|
||||
|
||||
_gen_kerver_spec() {
|
||||
cat << EOF
|
||||
%define rpm_name $RPM_NAME
|
||||
%define rpm_version $RPM_VERSION
|
||||
%define rpm_release $RPM_RELEASE
|
||||
%define rpm_vendor $RPM_VENDOR
|
||||
%define rpm_url $RPM_URL
|
||||
%define kernel_majver $KERNEL_MAJVER
|
||||
%define kernel_relver $KERNEL_RELVER
|
||||
EOF
|
||||
[ "$KERNEL_VARIANT" ] && cat << EOF
|
||||
%define kernel_variant $KERNEL_VARIANT
|
||||
EOF
|
||||
}
|
||||
|
||||
_gen_arch_source() {
|
||||
# Source1000 - Source1199 for kernel config
|
||||
local config_source_num=1000 arch
|
||||
for arch in $BUILD_ARCH; do
|
||||
echo "Source$config_source_num: $KERNEL_CONFIG.$arch.config"
|
||||
config_source_num=$((config_source_num + 1))
|
||||
done
|
||||
|
||||
# Source1200 - Source1399 for kabi source
|
||||
local kabi_source_num=1200 arch
|
||||
for arch in $BUILD_ARCH; do
|
||||
echo "Source$kabi_source_num: Module.kabi_$arch"
|
||||
kabi_source_num=$((kabi_source_num + 1))
|
||||
done
|
||||
|
||||
# Source1400 - Source1599 for module filter
|
||||
local filter_source_num=1400 arch
|
||||
for arch in $BUILD_ARCH; do
|
||||
echo "Source$filter_source_num: filter-$arch.sh"
|
||||
filter_source_num=$((filter_source_num + 1))
|
||||
done
|
||||
}
|
||||
|
||||
_gen_config_build() {
|
||||
cat << EOF
|
||||
%ifnarch $BUILD_ARCH
|
||||
{error:unsupported arch}
|
||||
%endif
|
||||
EOF
|
||||
local config_source_num=1000 arch
|
||||
for arch in $BUILD_ARCH; do
|
||||
cat << EOF
|
||||
%ifarch $arch
|
||||
BuildConfig %{SOURCE$config_source_num}
|
||||
%endif
|
||||
EOF
|
||||
config_source_num=$((config_source_num + 1))
|
||||
done
|
||||
}
|
||||
|
||||
_gen_kabi_check() {
|
||||
cat << EOF
|
||||
%ifnarch $BUILD_ARCH
|
||||
{error:unsupported arch}
|
||||
%endif
|
||||
EOF
|
||||
local kabi_source_num=1200 arch
|
||||
for arch in $BUILD_ARCH; do
|
||||
cat << EOF
|
||||
%ifarch $arch
|
||||
CheckKernelABI %{SOURCE$kabi_source_num}
|
||||
%endif
|
||||
EOF
|
||||
kabi_source_num=$((kabi_source_num + 1))
|
||||
done
|
||||
}
|
||||
|
||||
_gen_changelog_spec() {
|
||||
cat "$DISTDIR/templates/changelog"
|
||||
}
|
||||
|
||||
_gen_pkgopt_spec() {
|
||||
local enabled_opts disabled_opts opts_output
|
||||
for opt in \
|
||||
core \
|
||||
doc \
|
||||
headers \
|
||||
perf \
|
||||
tools \
|
||||
bpftool \
|
||||
debuginfo \
|
||||
modsign \
|
||||
kabichk
|
||||
do
|
||||
case $DEFAULT_DISALBED in
|
||||
*" $opt "* )
|
||||
disabled_opts="$disabled_opts $opt"
|
||||
opts_output="$opts_output
|
||||
%define with_$opt %{?_with_$opt: 1} %{?!_with_$opt: 0}"
|
||||
;;
|
||||
* )
|
||||
enabled_opts="$enabled_opts $opt"
|
||||
opts_output="$opts_output
|
||||
%define with_$opt %{?_without_$opt: 0} %{?!_without_$opt: 1}"
|
||||
esac
|
||||
done
|
||||
|
||||
# Marker for dist build system, a little bit ugly, maybe find a better way to present this info later
|
||||
echo ""
|
||||
echo "# === Package options ==="
|
||||
echo "# Eanbled by default: $enabled_opts"
|
||||
echo "# Disabled by default: $disabled_opts"
|
||||
echo "$opts_output"
|
||||
}
|
||||
|
||||
gen_spec() {
|
||||
local _line
|
||||
local _spec
|
||||
|
||||
while IFS='' read -r _line; do
|
||||
case $_line in
|
||||
"{{PKGPARAMSPEC}}"* )
|
||||
_spec+="$(_gen_pkgopt_spec)"
|
||||
;;
|
||||
"{{ARCHSPEC}}"* )
|
||||
_spec+="$(_gen_arch_spec)"
|
||||
;;
|
||||
"{{VERSIONSPEC}}"* )
|
||||
_spec+="$(_gen_kerver_spec)"
|
||||
;;
|
||||
"{{ARCHSOURCESPEC}}"* )
|
||||
_spec+="$(_gen_arch_source)"
|
||||
;;
|
||||
"{{CONFBUILDSPEC}}"* )
|
||||
_spec+="$(_gen_config_build)"
|
||||
;;
|
||||
"{{KABICHECKSPEC}}"* )
|
||||
_spec+="$(_gen_kabi_check)"
|
||||
;;
|
||||
"{{CHANGELOGSPEC}}"* )
|
||||
_spec+="$(_gen_changelog_spec)"
|
||||
;;
|
||||
"{{"*"}}"*)
|
||||
die "Unrecognized template keywork $_line"
|
||||
;;
|
||||
* )
|
||||
_spec+="$_line"
|
||||
;;
|
||||
esac
|
||||
_spec+="
|
||||
"
|
||||
done
|
||||
|
||||
echo "$_spec"
|
||||
}
|
||||
|
||||
gen_spec < "$DISTDIR/templates/kernel.template.spec"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
prepare_next_sub_kernel_ver "$@"
|
||||
|
||||
echo "$KERNEL_UNAMER"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
prepare_next_kernel_ver "$@"
|
||||
|
||||
echo "$KERNEL_UNAMER"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Print out the tkernel version based on git commit and work tree.
|
||||
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
prepare_kernel_ver "$@"
|
||||
|
||||
echo "$KERNEL_UNAMER"
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# shellcheck source=../lib.sh
|
||||
. "/$(dirname "$(realpath "$0")")/../lib.sh"
|
||||
|
||||
AUTHOR="$(git config user.name) <$(git config user.email)>"
|
||||
COMMIT=$1
|
||||
|
||||
[ -z "$COMMIT" ] && die "Usage: $0 <upstream commit id>"
|
||||
|
||||
_resolve_conflict_shell() {
|
||||
error "Failed to backport, please fix the problem, then commit it."
|
||||
error "then exit the shell with \`exit 0\`."
|
||||
error "To abort the backport, exited with a dirty worktree or exit with non-zero."
|
||||
|
||||
export PS1="RESOLVING CONFLICT"
|
||||
|
||||
$SHELL || {
|
||||
RET=$?
|
||||
error "Shell exited with non-zero, aborting backport"
|
||||
git reset --hard HEAD
|
||||
exit $RET
|
||||
}
|
||||
|
||||
git diff-index --quiet HEAD || {
|
||||
RET=$?
|
||||
error "Dirty worktree, aborting backport"
|
||||
git reset --hard HEAD
|
||||
exit $RET
|
||||
}
|
||||
}
|
||||
|
||||
_fetch_upstream() {
|
||||
# Try to fetch from well-known upstream
|
||||
local commit=$1
|
||||
local upstream_repos=(
|
||||
"torvalds https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=<> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
|
||||
"tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/patch/?id=<> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git"
|
||||
"mm https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/patch/?id=<> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git"
|
||||
"stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=<> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
|
||||
)
|
||||
|
||||
for repo in "${upstream_repos[@]}"; do
|
||||
repo_http_git=${repo#* }
|
||||
repo_name=${repo%% *}
|
||||
repo_http=${repo_http_git% *}
|
||||
repo_git=${repo_http_git#* }
|
||||
commit_url=${repo_http/<>/$commit}
|
||||
echo curl --fail --silent --output /dev/null "$commit_url"
|
||||
if curl --fail --silent --output /dev/null "$commit_url"; then
|
||||
echo "Found commit '$commit' in '$repo_name' repo"
|
||||
echo git fetch "$repo_git" "$commit"
|
||||
git fetch "$repo_git" "$commit"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Can't find commit $commit in upstream."
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! git cat-file -e "$COMMIT"; then
|
||||
# Available locally, just cherry-pick
|
||||
_fetch_upstream "$COMMIT"
|
||||
fi
|
||||
|
||||
if ! git cherry-pick "$COMMIT"; then
|
||||
_resolve_conflict_shell
|
||||
CONFLICT=Resolved
|
||||
else
|
||||
CONFLICT=None
|
||||
fi
|
||||
|
||||
git commit \
|
||||
--am \
|
||||
--author="$AUTHOR" \
|
||||
--date=now \
|
||||
--message \
|
||||
"$(git log -1 --format=%s "$COMMIT")
|
||||
|
||||
$MSG
|
||||
|
||||
Upstream commit: $COMMIT
|
||||
Conflict: $CONFLICT
|
||||
|
||||
Backport of following upstream commit:
|
||||
|
||||
$(git log -1 "$COMMIT")
|
||||
|
||||
Signed-off-by: $AUTHOR"
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash --norc
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# After dropping the dist build system into a upstream kernel repo,
|
||||
# use this to hook the dist build system into Kbuild Makefile.
|
||||
|
||||
# shellcheck source=../lib.sh
|
||||
. "/$(dirname "$(realpath "$0")")/../lib.sh"
|
||||
|
||||
VENDOR_CAPITALIZED=$(get_dist_makefile_var VENDOR_CAPITALIZED)
|
||||
KMAKEFILE_CONTENT=""
|
||||
|
||||
[ -d "$TOPDIR" ] || {
|
||||
die "Not a valid git repo."
|
||||
}
|
||||
|
||||
[ -e "$TOPDIR/Kbuild" ] && [ -e "$TOPDIR/Kconfig" ] && [ -e "$TOPDIR/Makefile" ] || {
|
||||
die "Not a valid kernel repo."
|
||||
}
|
||||
|
||||
[ -e "$DISTDIR/Makefile" ] || {
|
||||
die "Dist files are not properly configured, aborting."
|
||||
}
|
||||
|
||||
[[ "$DISTDIR" == "$TOPDIR"/* ]] || {
|
||||
die "Dist files are not properly configured, aborting."
|
||||
}
|
||||
|
||||
|
||||
### Patch .gitignore
|
||||
grep -qF "# ${VENDOR_CAPITALIZED:+${VENDOR_CAPITALIZED} }dist files" "$TOPDIR/.gitignore" || {
|
||||
echo "Updating Kernel .gitignore to ignore dist files..."
|
||||
cat >> "$TOPDIR/.gitignore" << EOF
|
||||
|
||||
# ${VENDOR_CAPITALIZED:+${VENDOR_CAPITALIZED} }dist files
|
||||
/$DISTPATH/rpm
|
||||
/$DISTPATH/workdir
|
||||
EOF
|
||||
}
|
||||
|
||||
### Patch .gitattributes
|
||||
for i in ".ci" "$DISTPATH"; do \
|
||||
[[ -d $TOPDIR/$i ]] || continue
|
||||
grep -qF "$i/" $TOPDIR/.gitattributes 2>/dev/null || {
|
||||
echo "Updating .gitattributes to exclude $i/..."
|
||||
echo "$i/ export-ignore" >> $TOPDIR/.gitattributes
|
||||
}
|
||||
done;
|
||||
|
||||
### Patch kernel Makefile
|
||||
grep -qF "# dist_make: ${VENDOR_CAPITALIZED:+${VENDOR_CAPITALIZED} }" "$TOPDIR/Makefile" || {
|
||||
echo "Updating Kenrel Makefile..."
|
||||
KMAKEFILE_CONTENT=$(<"$TOPDIR/Makefile")
|
||||
cat > "$TOPDIR/Makefile" << EOF
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
# dist_make: ${VENDOR_CAPITALIZED:+${VENDOR_CAPITALIZED} }Dist Makefile, which contains dist-* make targets
|
||||
ifneq (\$(shell echo \$(MAKECMDGOALS) | grep "^dist-"),)
|
||||
include $DISTPATH/Makefile
|
||||
else
|
||||
|
||||
$KMAKEFILE_CONTENT
|
||||
|
||||
endif # dist_make
|
||||
EOF
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
|
||||
KERNEL=
|
||||
SYMVER=
|
||||
TMPDIR=
|
||||
|
||||
error() {
|
||||
echo "error: $*" > /dev/stderr
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Provide a list of modules, this script will print the SYMBOLS used by these modules
|
||||
|
||||
gen-module-kabi.sh: [--kernel <kernel name>] [--symver <symver file>] [<module name or file>, ...]
|
||||
|
||||
<kernel name>: default to \$(uname -r), or specify a installed kernel
|
||||
<symver file>: default to /usr/lib/<kernel name>/symvers.gz, or specify a symver file
|
||||
<module>: module name
|
||||
EOF
|
||||
}
|
||||
|
||||
while true; do
|
||||
case $1 in
|
||||
--symver )
|
||||
SYMVER=$2
|
||||
shift 2
|
||||
;;
|
||||
--kernel )
|
||||
KERNEL=$2
|
||||
shift 2
|
||||
;;
|
||||
--usage|--help|-h )
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
* )
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! TMPDIR="$(mktemp -d -t gen-module-kabi.XXXXXX)"; then
|
||||
error "mktemp failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'ret=$?;
|
||||
[[ -d $TMPDIR ]] && rm --one-file-system -rf -- "$TMPDIR";
|
||||
exit $ret;
|
||||
' EXIT
|
||||
|
||||
[ "$KERNEL" ] || KERNEL=$(uname -r)
|
||||
[ -f "$SYMVER" ] || SYMVER=/lib/modules/$KERNEL/symvers.gz
|
||||
[ -f "$SYMVER" ] || SYMVER=/boot/symvers-$KERNEL.gz
|
||||
[ -f "$SYMVER" ] || SYMVER=./Module.symvers
|
||||
|
||||
if [[ "$#" -eq 0 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case $SYMVER in *.gz )
|
||||
gzip < "$SYMVER" -d > "$TMPDIR/symver"
|
||||
SYMVER=$TMPDIR/symver
|
||||
;;
|
||||
esac
|
||||
|
||||
_get_export_syms() {
|
||||
_temp_extract=$TMPDIR/extracted.ko
|
||||
case $1 in
|
||||
*.ko )
|
||||
modfile=$1
|
||||
;;
|
||||
*.xz )
|
||||
modfile=$_temp_extract
|
||||
xz -c -d "$1" > "$_temp_extract"
|
||||
;;
|
||||
* )
|
||||
error "unsupported file format of file: $1"
|
||||
esac
|
||||
|
||||
nm -uAg "$modfile"
|
||||
}
|
||||
|
||||
for mod in "$@"; do
|
||||
if [[ $mod == *.ko ]] && [[ -f $mod ]]; then
|
||||
mods=$mod
|
||||
elif [[ $mod == *.ko.* ]] && [[ -f $mod ]]; then
|
||||
mods=$mod
|
||||
elif ! mods="$(modinfo --set-version "$KERNEL" --filename "$mod" 2> /dev/null)"; then
|
||||
error "'$mod' is not a valid module name"
|
||||
fi
|
||||
|
||||
for m in $mods; do
|
||||
_get_export_syms "$m"
|
||||
done
|
||||
done | sort | while read -r file_path type sym_name; do
|
||||
in_symver=0
|
||||
in_vmlinux=0
|
||||
sym_line=$(grep "\s$sym_name\s" "$SYMVER") && in_symver=1
|
||||
case $sym_line in
|
||||
# print only symbol in vmlinux
|
||||
*vmlinux*EXPORT_SYMBOL* )
|
||||
in_vmlinux=1
|
||||
;;
|
||||
esac
|
||||
echo -n "$file_path $type $sym_name"
|
||||
if [[ $in_symver -eq 0 ]]; then
|
||||
echo -n " (NO-KABI: NOT IN SYMVER)"
|
||||
fi
|
||||
if [[ $in_vmlinux -eq 0 ]]; then
|
||||
echo -n " (NO-KABI: NOT IN VMLINUX)"
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
|
||||
error() {
|
||||
echo "error: $*" > /dev/stderr
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
update-kabi.sh: <kABI Module.symvers> <new Module.symvers>
|
||||
|
||||
Take kABI Module.symvers as reference and generate a new kABI symvers file.
|
||||
EOF
|
||||
}
|
||||
|
||||
KABI=$1
|
||||
SYMVER=$2
|
||||
|
||||
if ! [ -s "$KABI" ] || ! [ -s "$SYMVER" ]; then
|
||||
error "Invalid params."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$KABI" | while read -r _crc _symbol _vmlinux _gpl; do
|
||||
grep "\b$_symbol\b.*vmlinux" "$SYMVER"
|
||||
done | sed -e "s/\t$//"
|
||||
|
|
@ -0,0 +1,384 @@
|
|||
#!/bin/bash --norc
|
||||
#
|
||||
# To support different arches, compile options, and distributions,
|
||||
# Kernel configs are managed with a hierarchy matrix.
|
||||
#
|
||||
# This script is the helper for parsing and updating the config matrix
|
||||
#
|
||||
# shellcheck source=./lib.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib.sh"
|
||||
|
||||
CONFIG_PATH=${CONFIG_PATH:-$DISTDIR/configs}
|
||||
# shellcheck disable=SC2206
|
||||
CONFIG_ARCH=( $SPEC_ARCH )
|
||||
CONFIG_SPECS=( "$CONFIG_PATH"/[0-9][0-9]* )
|
||||
CONFIG_OUTDIR=$SOURCEDIR
|
||||
CONFIG_CACHE=$DISTDIR/workdir/config_cache
|
||||
|
||||
|
||||
_get_config_cross_compiler () {
|
||||
if [[ "$1" == $(get_native_arch) ]]; then
|
||||
:
|
||||
elif [[ -d "$TOPDIR/scripts/dummy-tools/" ]]; then
|
||||
echo "scripts/dummy-tools/"
|
||||
else
|
||||
echo "$DISTDIR/scripts/dummy-tools/"
|
||||
fi
|
||||
}
|
||||
|
||||
get_config_val() {
|
||||
# If it's y/m/n/0-9, return plain text, else get from .config
|
||||
#
|
||||
# To be more accurate, maybe we need to check right/left-value?
|
||||
case $1 in
|
||||
n )
|
||||
;;
|
||||
y|m|[0-9] )
|
||||
echo "$1" ;;
|
||||
* )
|
||||
local _val
|
||||
_val=$(grep "^CONFIG_$1=" "$2")
|
||||
_val=${_val#*=}
|
||||
echo "${_val:-not set}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Eval a Kconfig condition statement
|
||||
kconfig_eval() {
|
||||
local _line=$1
|
||||
|
||||
local _if
|
||||
# Convert Kconfig cond statement to bash syntax then eval it
|
||||
_if=$(echo "$_line" | sed -E \
|
||||
-e "s/(\|\||&&|=|!=|<|<=|>|>=|!|\(|\))/ \1 /g" \
|
||||
-e "s/([[:alnum:]_-]+)/ \"\$(get_kconf_val \'\1\')\" /g")
|
||||
eval "[[ $_if ]]"
|
||||
}
|
||||
|
||||
get_depends() {
|
||||
local _conf=$1
|
||||
local _deps _line
|
||||
|
||||
sed -nE "s/^[[:space:]]*depends on //p;" "$CONFIG_CACHE/$_conf"
|
||||
}
|
||||
|
||||
# $1: Parsed Kconfig file
|
||||
get_all_depends() {
|
||||
local _dep
|
||||
local _deps=( )
|
||||
|
||||
[[ ! -e "$CONFIG_CACHE/$1" ]] && return 1
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
while read -r _dep; do
|
||||
if ! [[ "$_dep" ]]; then
|
||||
continue
|
||||
elif [[ "$_dep" =~ y|n|m ]]; then
|
||||
_deps+=( "$_dep" )
|
||||
elif [[ "$_dep" =~ [a-zA-Z0-9] ]]; then
|
||||
_deps+=( "$_dep[=$(get_config_val "$_dep" "$2")]" )
|
||||
else
|
||||
_deps+=( "$_dep" )
|
||||
fi
|
||||
done <<< "$(get_depends "$1" | sed -E \
|
||||
-e 's/^([^\(])/(\1/' \
|
||||
-e 's/([^\)])$/\1)/' \
|
||||
-e '2,$s/^/\&\&/' \
|
||||
-e 's/(\|\||&&|=|!=|<|<=|>|>=|!|\(|\)|([[:alnum:]_-]+))/\n\1\n/g')"
|
||||
# The regex above simply tokenize the Kconfig expression
|
||||
|
||||
echo "${_deps[@]}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
kconfig_parser() {
|
||||
local _arch=$1 _kconfig=$2 _config=$3
|
||||
|
||||
[[ -s $_kconfig ]] || error "Invalid Kconfig '$_kconfig'"
|
||||
[[ -s $_config ]] || error "Invalid config file '$_kconfig'"
|
||||
|
||||
rm -r "${CONFIG_CACHE:?}" 2>/dev/null
|
||||
mkdir -p "$CONFIG_CACHE"
|
||||
|
||||
local _CONFIG_FILE=$CONFIG_CACHE/_invalid
|
||||
local _PARSE_DEPS=()
|
||||
|
||||
_reader() {
|
||||
local _f=$1
|
||||
|
||||
if [[ $_f == *"\$(SRCARCH)"* ]]; then
|
||||
_f=${_f/\$(SRCARCH)/$(get_kernel_src_arch "$_arch")}
|
||||
fi
|
||||
|
||||
local _line
|
||||
while :; do
|
||||
_line=${_line%%#*}
|
||||
case $_line in
|
||||
"config "* | "menuconfig "* )
|
||||
_CONFIG_FILE=${_line#* }
|
||||
_CONFIG_FILE=${_CONFIG_FILE## }
|
||||
_CONFIG_FILE=$CONFIG_CACHE/$_CONFIG_FILE
|
||||
for _dep in "${_PARSE_DEPS[@]}"; do [[ $_dep ]] && echo "depends on $_dep"; done >> "$_CONFIG_FILE"
|
||||
;;
|
||||
"source "* )
|
||||
_line=${_line#* }
|
||||
_line=${_line#\"}
|
||||
_line=${_line%\"}
|
||||
_reader "$_line"
|
||||
;;
|
||||
"if "* )
|
||||
_line=${_line#if }
|
||||
_PARSE_DEPS+=( "${_line}" )
|
||||
;;
|
||||
"menu "* | "choice" )
|
||||
local _sub_dep=""
|
||||
while read -r _line; do
|
||||
case $_line in
|
||||
if*|menu*|config*|end*|source*|choice* ) break ;;
|
||||
"depends on"* )
|
||||
_line="${_line#depends on}"
|
||||
_sub_dep="${_sub_dep:+$_sub_dep && }(${_line## })"
|
||||
;;
|
||||
"visible if"* )
|
||||
_line="${_line#visible if}"
|
||||
_sub_dep="${_sub_dep:+$_sub_dep && }(${_line## })"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
_PARSE_DEPS+=( "${_sub_dep## }" )
|
||||
continue
|
||||
;;
|
||||
"end"* )
|
||||
# We don't care about correctness,
|
||||
# it's always paired with previous if/menu/choice
|
||||
unset '_PARSE_DEPS[${#_PARSE_DEPS[@]}-1]'
|
||||
;;
|
||||
'' | ' ' )
|
||||
;;
|
||||
* )
|
||||
echo "$_line" >> "$_CONFIG_FILE"
|
||||
esac
|
||||
IFS='' read -r _line || break
|
||||
done <<< "$(<"$_f")"
|
||||
}
|
||||
|
||||
pushd "$(dirname "$_kconfig")" > /dev/null || die "Failed pushd to '$TOPDIR'"
|
||||
|
||||
_reader "$_kconfig"
|
||||
|
||||
popd || die
|
||||
}
|
||||
|
||||
# Call make for config related make target. Will set proper cross compiler and kernel arch name.
|
||||
# $1: Target arch.
|
||||
config_make() {
|
||||
local arch=$1; shift
|
||||
local config_cross_compiler config_arch
|
||||
|
||||
pushd "$TOPDIR" >/dev/null || die "Not in a valid git repo."
|
||||
|
||||
config_cross_compiler=$(_get_config_cross_compiler "$arch")
|
||||
config_arch=$(get_kernel_arch "$arch")
|
||||
|
||||
if [[ -z "$config_arch" ]]; then
|
||||
die "Unsupported arch $arch"
|
||||
fi
|
||||
|
||||
make ARCH="$config_arch" CROSS_COMPILE="$config_cross_compiler" "$@"
|
||||
|
||||
popd >/dev/null || die "Failed popd"
|
||||
}
|
||||
|
||||
# Dedup, and filter valid config lines, print the sanitized content sorted by config name.
|
||||
config_sanitizer() {
|
||||
# AWK will add an extra column of CONFIG_NAME for sort to work properly
|
||||
LC_ALL=C
|
||||
awk '
|
||||
/is not set/ {
|
||||
split($0, val, "#");
|
||||
split(val[2], val);
|
||||
configs[val[1]]=$0
|
||||
}
|
||||
/^CONFIG.*=/ {
|
||||
split($0, val, "=");
|
||||
if (val[2] == "n")
|
||||
configs[val[1]]="# "val[1]" is not set"
|
||||
else
|
||||
configs[val[1]]=$0
|
||||
}
|
||||
END {
|
||||
for (config in configs) {
|
||||
print config " " configs[config]
|
||||
}
|
||||
}' \
|
||||
| LC_ALL=C sort -k 1 \
|
||||
| cut -d ' ' -f 2-
|
||||
}
|
||||
|
||||
# Iterate the dot product of all config options
|
||||
# param: <callback> [<filter>... ]
|
||||
# [<filter>... ]: Filters config targets to use. eg. kernel-default-*, kernel-minimal-debug
|
||||
# <callback>: A callback function, see below for <callback> params.
|
||||
#
|
||||
# Will generate a matrix, and call <callback> like this:
|
||||
# <callback> <config-target> [ <dir entry of configs in inherit order> ... ]
|
||||
#
|
||||
# eg.
|
||||
# <callback> "kernel-generic-release" "$TOPDIR/00pending/kernel" "$TOPDIR/20preset/generic" "$TOPDIR/50variant/release"
|
||||
# <callback> "kernel-generic-debug" "$TOPDIR/00pending/kernel" "$TOPDIR/20preset/generic" "$TOPDIR/50variant/debug"
|
||||
# ...
|
||||
#
|
||||
for_each_config_target () {
|
||||
local filters callback
|
||||
local target cur_target i j
|
||||
|
||||
callback=$1; shift
|
||||
filters=("$@")
|
||||
|
||||
_match () {
|
||||
[[ ${#filters[@]} -eq 0 ]] && return 0
|
||||
|
||||
for _f in "${filters[@]}"; do
|
||||
# shellcheck disable=SC2053
|
||||
[[ $1 == $_f ]] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# The '_' is used to bootstrap the file loop
|
||||
local -a hierarchy=( _ ) prev_hierarchy target_conf prev_target_conf
|
||||
|
||||
for folder in "${CONFIG_SPECS[@]}"; do
|
||||
prev_hierarchy=( "${hierarchy[@]}" )
|
||||
prev_target_conf=( "${target_conf[@]}" )
|
||||
|
||||
hierarchy=( )
|
||||
target_conf=( )
|
||||
|
||||
i=0
|
||||
for config in "$folder"/*; do
|
||||
if ! [[ -e "$config/default.config" ]]; then
|
||||
error "Invalid config folder $config"
|
||||
return 1
|
||||
fi
|
||||
|
||||
j=0
|
||||
for target in "${prev_hierarchy[@]}"; do
|
||||
cur_target=$target-$(basename "$config")
|
||||
hierarchy+=( "$cur_target" )
|
||||
# config files can't have spece in their path since the
|
||||
# list is split by space, seems no better way
|
||||
target_conf[$i]="${prev_target_conf[$j]} $config"
|
||||
i=$(( i + 1 ))
|
||||
j=$(( j + 1 ))
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
i=0
|
||||
for target in "${hierarchy[@]}"; do
|
||||
# split target_conf by space is what we want here
|
||||
target="${target#_-}"
|
||||
# shellcheck disable=SC2086
|
||||
_match $target && "$callback" "${target#_-}" ${target_conf[$i]}
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
}
|
||||
|
||||
# Iterate populated config files
|
||||
# param: <callback> [<filter>... ]
|
||||
# [<filter>... ]: Filters config targets to use. eg. kernel-default-*, kernel-minimal-debug
|
||||
# <callback>: A callback function, see below for <callback> params.
|
||||
#
|
||||
# Will generate a matrix, and call <callback> like this:
|
||||
# <callback> <arch> <config-file> [ <backing config files in inherit order>... ]
|
||||
#
|
||||
# eg.
|
||||
# <callback> "x86_64" "kernel-generic-release" \
|
||||
# "$TOPDIR/00pending/kernel/default.config" "$TOPDIR/00pending/kernel/x86_64.config" \
|
||||
# "$TOPDIR/20preset/generic/default.config" "$TOPDIR/20preset/generic/x86_64.config" \
|
||||
# "$TOPDIR/50variant/release/default.config" "$TOPDIR/50variant/release/x86_64.config"
|
||||
# <callback> "aarch64" "kernel-generic-release" \
|
||||
# "$TOPDIR/00pending/kernel/default.config" "$TOPDIR/00pending/kernel/aarch64.config" \
|
||||
# "$TOPDIR/20preset/generic/default.config" "$TOPDIR/20preset/generic/aarch64.config" \
|
||||
# "$TOPDIR/50variant/release/default.config" "$TOPDIR/50variant/release/aarch64.config"
|
||||
# ...
|
||||
#
|
||||
for_each_config_product () {
|
||||
local _wrapper_cb=$1; shift
|
||||
|
||||
_wrapper () {
|
||||
local target=$1; shift
|
||||
local files=( "$@" )
|
||||
|
||||
for arch in "${CONFIG_ARCH[@]}"; do
|
||||
local config_basename="$target.$arch.config"
|
||||
local config_product="$CONFIG_OUTDIR/$config_basename"
|
||||
local config_files=( )
|
||||
|
||||
for _conf in "${files[@]}"; do
|
||||
config_files+=( "$_conf/default.config" )
|
||||
if [[ -e "$_conf/$arch.config" ]]; then
|
||||
config_files+=( "$_conf/$arch.config" )
|
||||
fi
|
||||
done
|
||||
|
||||
$_wrapper_cb "$arch" "$config_product" "${config_files[@]}"
|
||||
done
|
||||
}
|
||||
|
||||
for_each_config_target _wrapper "$@"
|
||||
}
|
||||
|
||||
# Simply concat the backing config files in order into a single files for each config target
|
||||
populate_configs () {
|
||||
_merge_config () {
|
||||
local target=$1; shift
|
||||
local config_basename output_config
|
||||
for arch in "${CONFIG_ARCH[@]}"; do
|
||||
config_basename="$target.$arch.config"
|
||||
output_config="$CONFIG_OUTDIR/$config_basename"
|
||||
|
||||
echo "Populating $config_basename from base configs..."
|
||||
|
||||
for conf in "$@"; do
|
||||
cat "$conf/default.config"
|
||||
if [[ -e "$conf/$arch.config" ]]; then
|
||||
cat "$conf/$arch.config"
|
||||
fi
|
||||
done | config_sanitizer > "$output_config"
|
||||
done
|
||||
}
|
||||
|
||||
for_each_config_target _merge_config "$@"
|
||||
}
|
||||
|
||||
makedef_configs () {
|
||||
_makedef_config() {
|
||||
local target=$1; shift
|
||||
local populated_config
|
||||
|
||||
for arch in "${CONFIG_ARCH[@]}"; do
|
||||
populated_config="$CONFIG_OUTDIR/$target.$arch.config"
|
||||
|
||||
# config base name is always in this format: <name>.<arch>.config
|
||||
echo "Processing $(basename "$populated_config") with make olddefconfig..."
|
||||
|
||||
if ! [ -f "$populated_config" ]; then
|
||||
error "Config not found: '$populated_config'"
|
||||
continue
|
||||
fi
|
||||
|
||||
pushd "$TOPDIR" > /dev/null || exit 1
|
||||
|
||||
config_make "$arch" KCONFIG_CONFIG="$populated_config" olddefconfig
|
||||
|
||||
popd > /dev/null || return
|
||||
done
|
||||
}
|
||||
|
||||
for_each_config_target _makedef_config "$@"
|
||||
}
|
||||
|
|
@ -0,0 +1,496 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Version conversion helpers for building a TK kernel.
|
||||
#
|
||||
# shellcheck source=./lib.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib.sh"
|
||||
|
||||
## Autogenerated version pattern:
|
||||
# <KERNEL_MAJVER>-<KERNEL_RELVER>.<KERNEL_DIST>
|
||||
|
||||
# KERNEL_MAJVER's format: <KVERSION>.<KPATCHLEVEL>.<KSUBLEVEL>
|
||||
# It's the standdard upstream linux kernel release version,
|
||||
# eg. 3.10.0; 5.4.119; 5.16.0
|
||||
#
|
||||
# KERNEL_RELVER's format: <REL>[.<SNAPSHOT>].<KEXTRAVERSION>
|
||||
# If <REL> is 0, indicates it's a snapshot, unofficial release.
|
||||
# If <REL> is >=1, indicates it the n'th release of that kernel version.
|
||||
#
|
||||
# KERNEL_DIST: <none>/tks/tlinux4/...
|
||||
# Indicates this is a special build kernel.
|
||||
|
||||
# NOTE: This versioning script fully respects the git tag if tag's
|
||||
# major kernel version matches the version numbers in kernel Makefile
|
||||
|
||||
# This naming style is compatible with Tencent Kernel public naming style.
|
||||
# Take TK4 for example:
|
||||
#
|
||||
# Merge base: git describe --tag make install version Generate version:
|
||||
# 5.4.119 (master) 5.4.119-1-tlinux4-0007 5.4.119-1 5.4.119-1-tlinux4-0007
|
||||
# 5.4.119 (master) 5.4.119-1-tlinux4-0007-2-g884a77bf0ba6 5.4.119-1 5.4.119-0.20211115git1135ec008ef3.1-tlinux4-0007
|
||||
# 5.4.119 (master) 5.4.119-1-tlinux4-0007.subrelease 5.4.119-1 5.4.119-1-tlinux4-0007.subrelease
|
||||
# 5.4.119 (master) 5.4.119-1-tlinux4-0007~rc1 5.4.119-1 5.4.119-1-tlinux4-0007~rc1 (*)
|
||||
#
|
||||
# NOTE: Sometime TK4's release version may go backwards, it's a known issue we have to live with.
|
||||
# TK4 used tag like 5.4.119-1-tlinux4-0007.prerelease to indicate a release candidate.
|
||||
# You can check this with `rpmdev-vercmp`:
|
||||
# $ rpmdev-vercmp 5.4.119-1-tlinux4-0007.prerelease 5.4.119-1-tlinux4-0007
|
||||
# $ 5.4.119-1-tlinux4-0007.prerelease > 5.4.119-1-tlinux4-0007
|
||||
# This means RPM thinks the release candidate is higher than the real release, to fix that,
|
||||
# try use tilde symbol to indicate it's a RC.
|
||||
|
||||
## Macros and values:
|
||||
# Standard four-part linux kernel version from kernel's Makefile
|
||||
KVERSION=
|
||||
KPATCHLEVEL=
|
||||
KSUBLEVEL=
|
||||
KEXTRAVERSION=
|
||||
|
||||
# Kernel dist release (eg. <none>/tks/tlinux4)
|
||||
KDIST=
|
||||
|
||||
# KPREMERGEWINDOW: If we are building a commit in the first merge window
|
||||
# In the first merge time window, after a formal kernel release, and before rc1 release of next kernel,
|
||||
# the KPATCHLEVEL will be stuck in lower value, which confuses RPM in many ways. So just bump
|
||||
# KSUBLEVEL upon build in such case.
|
||||
#
|
||||
# For example, after 5.15 release, and before 5.16, upstream will start merging features for 5.16
|
||||
# without bumping KPATCHLEVEL, which is stuck in 15.
|
||||
# As now our build will be newer than 5.15 build, we have to make the version higher than 5.15
|
||||
# To avoid conflict with 5.15 stable build like 5.15.Y-Z, we can't bump the Y part or Z part.
|
||||
# So instead bump to 5.16 and mark it rc0 as 5.16.0-0.rc0. (Just as what Fedora does).
|
||||
KPREMERGEWINDOW=
|
||||
|
||||
# KRCRELEASE: If we are building a rc-release
|
||||
# KSNAPRELEASE: If we are building a snapshot-release
|
||||
# Pre-release means we are building from an RC release
|
||||
# Snap-release means we are building from an git commit without tag
|
||||
export KRCRELEASE=
|
||||
export KSNAPRELEASE=
|
||||
export KTAGRELEASE=
|
||||
|
||||
# git snapshot versioning
|
||||
KGIT_SNAPSHOT=
|
||||
# Set if current commit is tagged with valid release info, force use it.
|
||||
KGIT_FORCE_RELEAE=
|
||||
# Set if current commit is tagged with a valid test tag name
|
||||
KGIT_TESTBUILD_TAG=
|
||||
# Release: Start from 1.0, indicate the release version, info embedded in git tag
|
||||
KGIT_RELEASE=
|
||||
KGIT_RELEASE_NUM=
|
||||
KGIT_SUB_RELEASE_NUM=
|
||||
|
||||
### The formal kernel version and release
|
||||
|
||||
# Simulate `uname -r` output, which is always "$KVERSION.$KPATCHLEVEL.$KSUBLEVEL$KEXTRAVERSION"
|
||||
export KERNEL_UNAMER=
|
||||
# Basically: $KVERSION.$KPATCHLEVEL.$KSUBLEVEL (eg. 5.17.0, 5.16.3)
|
||||
export KERNEL_MAJVER=
|
||||
# Release version, may contain $KEXTRAVERSION (eg. 1, 0.rc0, 0.20220329gita11bf64a6e8f)
|
||||
export KERNEL_RELVER=
|
||||
# Kernel distro variable (eg. tks, tlinux4, <none>), with any leading "." or "-" removed
|
||||
export KERNEL_DIST=
|
||||
# Only used for make-release
|
||||
export KERNEL_PREV_RELREASE_TAG=
|
||||
|
||||
# $1: git tag or git commit, defaults to HEAD
|
||||
# $2: kernel source tree, should be a git repo
|
||||
get_kernel_code_version() {
|
||||
local gitref=${1:-HEAD}
|
||||
local repo=${2:-$TOPDIR}
|
||||
local makefile dist_makefile
|
||||
|
||||
makefile=$(git -C "$repo" show "$gitref:Makefile" 2>/dev/null || cat "$repo/Makefile")
|
||||
dist_makefile=$(git -C "$repo" show "$gitref:$DISTPATH/Makefile" 2>/dev/null || cat "$repo/$DISTPAN/Makefile")
|
||||
|
||||
if [ ! "$makefile" ]; then
|
||||
die "Error: Failed to read Makefile"
|
||||
return 1
|
||||
fi
|
||||
|
||||
KVERSION=$(sed -nE '/^VERSION\s*:?=\s*/{s///;p;q}' <<< "$makefile")
|
||||
KPATCHLEVEL=$(sed -nE '/^PATCHLEVEL\s*:?=\s*/{s///;p;q}' <<< "$makefile")
|
||||
KSUBLEVEL=$(sed -nE '/^SUBLEVEL\s*:?=\s*/{s///;p;q}' <<< "$makefile")
|
||||
KEXTRAVERSION=$(sed -nE '/^EXTRAVERSION\s*:?=\s*/{s///;p;q}' <<< "$makefile")
|
||||
|
||||
if [[ -z "$KVERSION" ]] || [[ -z "$KPATCHLEVEL" ]] || [[ -z "$KSUBLEVEL" ]]; then
|
||||
die "Invalid VERSION, PATCHLEVEL or SUBLEVEL in Makefile"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# RC releases are always considered pre-release
|
||||
if [[ "$KEXTRAVERSION" == "rc"* ]] || [[ $KEXTRAVERSION == "-rc"* ]]; then
|
||||
KRCRELEASE=1
|
||||
fi
|
||||
|
||||
KDIST=$(sed -nE '/^KDIST\s*:?=\s*/{s///;p;q}' <<< "$dist_makefile")
|
||||
KERNEL_DIST="$KDIST"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_first_merge_window_detection() {
|
||||
local gitref=${1:-HEAD}
|
||||
local repo=${2:-$TOPDIR}
|
||||
local upstream_base upstream_lasttag upstream_gitdesc
|
||||
|
||||
# If KSUBLEVEL or KEXTRAVERSION is set, it's not in the first merge window of a major release
|
||||
[[ $KSUBLEVEL -eq 0 ]] || return 1
|
||||
[[ -n $KEXTRAVERSION ]] && return 1
|
||||
[[ $upstream ]] || upstream="@{u}"
|
||||
|
||||
# Get latest merge base if forked from upstream to merge window detection
|
||||
# merge window is an upstream-only thing
|
||||
if upstream_base=$(git -C "$repo" merge-base "$gitref" "$upstream" 2>/dev/null); then
|
||||
upstream_lasttag=$(git -C "$repo" describe --tags --abbrev=0 "$upstream_base" 2>/dev/null)
|
||||
upstream_gitdesc=$(git -C "$repo" describe --tags --abbrev=12 "$upstream_base" 2>/dev/null)
|
||||
|
||||
if \
|
||||
# If last tag is an tagged upstream release
|
||||
[[ $upstream_lasttag == v$KVERSION.$KPATCHLEVEL ]] && \
|
||||
# And if merge base is ahead of the taggewd release
|
||||
[[ $upstream_gitdesc != "$upstream_lasttag" ]]; then
|
||||
# Then it's in first merge window
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
warn "Not tracking a valid upstream, merge window detecting is disabled ."
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Get release info from git tag
|
||||
_get_rel_info_from_tag() {
|
||||
local tag=$1 rel ret=0
|
||||
|
||||
if [[ $tag == *"$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"* ]]; then
|
||||
rel=${tag#*"$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"}
|
||||
elif [[ "$KSUBLEVEL" = "0" ]] && [[ $tag == *"$KVERSION.$KPATCHLEVEL"* ]]; then
|
||||
rel=${tag#*"$KVERSION.$KPATCHLEVEL"}
|
||||
elif [[ $KPREMERGEWINDOW ]] && [[ $tag == *"$KVERSION.$((KPATCHLEVEL + 1)).$KSUBLEVEL"* ]]; then
|
||||
rel=${tag#*"$KVERSION.$((KPATCHLEVEL + 1)).$KSUBLEVEL"}
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
rel=${rel#-}
|
||||
rel=${rel#.}
|
||||
|
||||
local kextraversion=${KEXTRAVERSION#-}
|
||||
|
||||
if [[ -z "$kextraversion" ]]; then
|
||||
# If previous KEXTRAVERSION is not empty but now empty,
|
||||
# still consider it a valid release tag since release candidate mark may get dropped.
|
||||
# But this really should look at the Makefile corresponding to that tag commit
|
||||
:
|
||||
elif [ "$kextraversion" -eq "$kextraversion" ] &>/dev/null; then
|
||||
case $rel in
|
||||
# Extra version is release number, ok
|
||||
$kextraversion | "$kextraversion."* | "$kextraversion-"* ) ;;
|
||||
* ) return 1; ;;
|
||||
esac
|
||||
else
|
||||
# Remove RC liked tag, append them as suffix later.
|
||||
case $rel in
|
||||
# Plain version tag, eg. 5.17-rc3
|
||||
$kextraversion )
|
||||
rel=""
|
||||
;;
|
||||
# Plain version tag plus suffix, eg. 5.17-rc3-*
|
||||
"$kextraversion."* | "$kextraversion-"* )
|
||||
rel=${rel#$kextraversion}
|
||||
rel=${rel#-}
|
||||
rel=${rel#.}
|
||||
;;
|
||||
# Extra tag, eg 5.17-1.rc3*
|
||||
*".$kextraversion"* | *"-$kextraversion"* ) ;;
|
||||
* ) return 1; ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ $rel ]]; then
|
||||
echo "${rel/-/.}"
|
||||
fi
|
||||
}
|
||||
|
||||
_search_for_release_tag() {
|
||||
local tag=$1
|
||||
local repo=$2
|
||||
|
||||
# Look back for 5 commits for a valid tag
|
||||
local limit=5
|
||||
while :; do
|
||||
limit=$((limit - 1))
|
||||
|
||||
if [[ $limit -le 0 ]] || ! tag=$(git -C "$repo" describe --tags --abbrev=0 "$tag^" 2>/dev/null); then
|
||||
warn "No valid tag found that are eligible for versioning, please fix your repo and tag it properly."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if _get_rel_info_from_tag "$tag" > /dev/null; then
|
||||
echo "$tag"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Get release info from git tag
|
||||
#
|
||||
# We try to store the RPM NVR (Name, Version, Release) info's VR part in git tag
|
||||
# N: is always kernel
|
||||
# V: is kernel's major release version (eg. 5.18, 5.18.0, 5.17.2)
|
||||
# R: is a tokens seperated with '.' (eg 1[.KDIST], 2[.KDIST], 2.1[.KDIST], 0.rc1[.KDIST])
|
||||
# could also be 0.YYYYMMDDgit<commit> for snapshot release.
|
||||
# But ideally all git tag are for formal release so snapshot tag shouldn't appear in repo.
|
||||
#
|
||||
# A tag that contains VR is considered a release tag.
|
||||
#
|
||||
# $1: git tag or git commit, defaults to HEAD
|
||||
# $2: kernel source tree, should be a git repo
|
||||
# $3: optional upstream branch, remote branch name current HEAD is tracking
|
||||
get_kernel_git_version()
|
||||
{
|
||||
local gitref=${1:-HEAD}
|
||||
local repo=${2:-$TOPDIR}
|
||||
local upstream=${3:-"@{u}"}
|
||||
|
||||
local last_tag release_tag release_info git_desc
|
||||
local tag
|
||||
|
||||
# Get current commit's snapshot name, format: YYYYMMDDgit<commit>,
|
||||
# or YYYYMMDD (Only if repo is missing, eg. running this script with tarball)
|
||||
if ! KGIT_SNAPSHOT=$(git rev-parse --short=12 "$gitref" 2>/dev/null); then
|
||||
warn "Invalid git reference '$gitref' or git repo is unavailable, versioning it as a dated snapshot"
|
||||
KGIT_SNAPSHOT=$(date +"%Y%m%d")
|
||||
KSNAPRELEASE=1
|
||||
return
|
||||
fi
|
||||
KGIT_SNAPSHOT=$(date +"%Y%m%d")git$KGIT_SNAPSHOT
|
||||
|
||||
# Check if first merge-window, and set KPREMERGEWINDOW, see comment above about KPREMERGEWINDOW
|
||||
if _first_merge_window_detection "$@"; then
|
||||
KPREMERGEWINDOW=1
|
||||
fi
|
||||
|
||||
# Get latest git tag of this commit
|
||||
last_tag=$(git -C "$repo" describe --tags --abbrev=0 "$gitref" 2>/dev/null)
|
||||
# Check and get latest release git tag, in case current tag is a test tag
|
||||
# (eg. current tag is fix_xxxx, rebase_test_xxxx, or user tagged for fun, and previous release tag is 5.18.0-1[.KDIST])
|
||||
if _get_rel_info_from_tag "$last_tag" > /dev/null; then
|
||||
# Latest tag is a release tag, just use it
|
||||
release_tag=$last_tag
|
||||
else
|
||||
warn "Latest git tag '$last_tag' is not a release tag, it does't match Makefile version '$KVERSION.$KPATCHLEVEL.$KSUBLEVEL$KEXTRAVERSION'"
|
||||
if release_tag=$(_search_for_release_tag "$last_tag" "$repo"); then
|
||||
warn "Found release tag '$release_tag'."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$release_tag" ]]; then
|
||||
git_desc=$(git -C "$repo" describe --tags --abbrev=12 "$gitref" 2>/dev/null)
|
||||
release_info=$(_get_rel_info_from_tag "$release_tag")
|
||||
# Remove dist suffix, it'a always added for auto generated tag
|
||||
KGIT_RELEASE=${release_info%".$KDIST"}
|
||||
|
||||
if ! [[ $release_info ]]; then
|
||||
warn "No extra release info in release tag, might be a upstream tag." \
|
||||
"Please make a release commit with 'make dist-release' for a formal release."
|
||||
KGIT_RELEASE_NUM=0
|
||||
KGIT_SUB_RELEASE_NUM=0
|
||||
elif [[ $release_info == 0.* ]]; then
|
||||
KGIT_RELEASE_NUM=${release_info##*.}
|
||||
KGIT_RELEASE_NUM=${KGIT_RELEASE_NUM##*-}
|
||||
KGIT_SUB_RELEASE_NUM=${release_info%."$KGIT_RELEASE_NUM"}
|
||||
KGIT_SUB_RELEASE_NUM=${KGIT_SUB_RELEASE_NUM##*.}
|
||||
else
|
||||
KGIT_RELEASE_NUM=${release_info%%.*}
|
||||
KGIT_RELEASE_NUM=${KGIT_RELEASE_NUM%%-*}
|
||||
KGIT_SUB_RELEASE_NUM=${release_info#"$KGIT_RELEASE_NUM".}
|
||||
KGIT_SUB_RELEASE_NUM=${KGIT_SUB_RELEASE_NUM%%.*}
|
||||
fi
|
||||
|
||||
# Fix release numbers, if it's not a number
|
||||
if ! [ "$KGIT_RELEASE_NUM" -eq "$KGIT_RELEASE_NUM" ] &>/dev/null; then
|
||||
warn "Unrecognizable release number: $KGIT_RELEASE_NUM, resetting to 0"
|
||||
KGIT_RELEASE_NUM=0
|
||||
fi
|
||||
if ! [ "$KGIT_SUB_RELEASE_NUM" -eq "$KGIT_SUB_RELEASE_NUM" ] &>/dev/null; then
|
||||
KGIT_SUB_RELEASE_NUM=0
|
||||
fi
|
||||
|
||||
if [[ "$release_tag" == "$git_desc" ]]; then
|
||||
if [[ $release_info ]] && [[ "$KGIT_RELEASE_NUM" -ne 0 ]]; then
|
||||
# This commit is tagged and it's a valid release tag, juse use it
|
||||
KGIT_FORCE_RELEAE=$release_info
|
||||
KTAGRELEASE=$release_tag
|
||||
fi
|
||||
elif [[ "$last_tag" == "$git_desc" ]]; then
|
||||
# A dumb assumption here, if it's not in *.* format (v5.4, 4.12.0, etc...) it's a test tag
|
||||
if [[ $last_tag != v*.* ]] && [[ $last_tag != *.*.* ]]; then
|
||||
warn "'$last_tag' looks like a test tag, using it as versioning suffix."
|
||||
warn "Please tag properly for release build, now versioning it as a test build."
|
||||
KGIT_TESTBUILD_TAG=testbuild.$last_tag
|
||||
else
|
||||
warn "'$last_tag' looks like a kernel release tag but out-of-sync with Makefile" \
|
||||
"ignoring it and versioning as snapshot."
|
||||
warn "Please tag properly for release build."
|
||||
KSNAPRELEASE=1
|
||||
fi
|
||||
else
|
||||
# Just a simple untagged commit, nothing special
|
||||
KSNAPRELEASE=1
|
||||
fi
|
||||
|
||||
KERNEL_PREV_RELREASE_TAG=$release_tag
|
||||
else
|
||||
KSNAPRELEASE=1
|
||||
KGIT_RELEASE_NUM=0
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
_prepare_kernel_ver() {
|
||||
if ! get_kernel_code_version "$@"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! get_kernel_git_version "$@"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Disable PRE-merge window detection for tagged commit,
|
||||
# We want to following user provided tag strictly
|
||||
if [[ ! $KGIT_FORCE_RELEAE ]]; then
|
||||
if [[ $KPREMERGEWINDOW ]]; then
|
||||
KPATCHLEVEL=$(( KPATCHLEVEL + 1 ))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### Generate a RPM friendly version based on kernel tag and commit info
|
||||
#
|
||||
# Examples:
|
||||
# (Ignoring pre-release window detection, see comments about KPREMERGEWINDOW)
|
||||
# (Also assume Makefile's kernel version info is all correct)
|
||||
#
|
||||
# git describe --tags Generated version (uname -r) Corresponding RPM version
|
||||
# v5.18 5.18.0-0[.KDIST] kernel[-kdist]-5.18.0-0.rc1
|
||||
# v5.18.0 5.18.0-0[.KDIST] kernel[-kdist]-5.18.0-0.rc1
|
||||
# v5.18.1 5.18.1-0[.KDIST] kernel[-kdist]-5.18.1-0.rc1
|
||||
# v5.18.0-1-gac28df2 5.18.0-0.20220428gitac28df2cd5d0[.KDIST] kernel[-kdist]-5.18.0-0.20220428gitac28df2cd5d0 *
|
||||
# v5.18.0-3-g16cadc5 5.18.0-0.20220428git16cadc58d50c[.KDIST] kernel[-kdist]-5.18.0-0.20220428git16cadc58d50c *
|
||||
# v5.18-rc1 5.18.0-0.rc1[.KDIST] kernel[-kdist]-5.18.0-0.rc1
|
||||
# v5.18-rc1-1-g380a504 5.18.0-0.20220428git380a504e42d9.rc1[.KDIST] kernel[-kdist]-5.18.0-0.20220428git380a504e42d9.rc1
|
||||
# 5.18.0-1[.KDIST] 5.18.0-1[.KDIST] kernel[-kdist]-5.18.0-1
|
||||
# 5.18.12-3[.KDIST] 5.18.12-3[.KDIST] kernel[-kdist]-5.18.12-3
|
||||
# 5.18.12-3[.KDIST]-5-g9318b03 5.18.12-0.20220428git9318b0349d5c.3[.KDIST] kernel[-kdist]-5.18.12-0.20220428git9318b0349d5c.3
|
||||
# 5.18.0-12.rc1[.KDIST] 5.18.0-12.rc1[.KDIST] kernel[-kdist]-5.18.0-12.rc1
|
||||
# 5.18.0-12[.KDIST]-2-g551f9cd 5.18.0-0.20220428git551f9cd79ece.12[.KDIST] kernel[-kdist]-5.18.0-0.20220428git551f9cd79ece.12
|
||||
# x86-5.4.119-19-0010.prerelease 5.4.119-19-0010.prerelease kernel[-kdist]-5.4.119-19-0010.prerelease **
|
||||
#
|
||||
# * NOTE: random commit snapshot can't be versioning in non-decreasing since one can always amend/rebase, so only the date stamp matters now.
|
||||
#
|
||||
# As you may have noticed, release always start with '0' unless a git tag have release >= 1,
|
||||
# The tag should be generated by other commands that comes later in this script.
|
||||
prepare_kernel_ver() {
|
||||
_prepare_kernel_ver "$@"
|
||||
|
||||
# If it's a tagged commit, and the release number in tag is non-zero, use that
|
||||
if [[ $KGIT_FORCE_RELEAE ]]; then
|
||||
KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"
|
||||
KERNEL_RELVER="$KGIT_FORCE_RELEAE"
|
||||
else
|
||||
local krelease=0
|
||||
if [[ $KSNAPRELEASE ]]; then
|
||||
krelease=$krelease.$KGIT_SNAPSHOT
|
||||
elif [[ $KGIT_RELEASE ]]; then
|
||||
krelease=$krelease.$KGIT_RELEASE
|
||||
fi
|
||||
|
||||
if [[ $KEXTRAVERSION ]]; then
|
||||
krelease="$krelease.${KEXTRAVERSION##-}"
|
||||
elif [[ $KPREMERGEWINDOW ]]; then
|
||||
krelease="$krelease.rc0"
|
||||
fi
|
||||
|
||||
if [[ $KGIT_TESTBUILD_TAG ]]; then
|
||||
# '-' is not allowed in release name, but commonly used in tag
|
||||
krelease="$krelease.${KGIT_TESTBUILD_TAG//-/_}"
|
||||
fi
|
||||
|
||||
KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"
|
||||
KERNEL_RELVER="$krelease${KDIST:+.$KDIST}"
|
||||
fi
|
||||
|
||||
KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER"
|
||||
}
|
||||
|
||||
### Generate formal release version based on kernel tag and commit info
|
||||
#
|
||||
# Examples:
|
||||
# (Ignoring pre-release window detection, see comments about KPREMERGEWINDOW)
|
||||
# (Also assume Makefile's kernel version info is all correct)
|
||||
#
|
||||
# git describe --tags Generated Version (uname -r) Corresponding RPM version
|
||||
# v5.18 5.18.0-1[.KDIST] kernel[-kdist]-5.18.0-1
|
||||
# v5.18.0 5.18.0-1[.KDIST] kernel[-kdist]-5.18.0-1
|
||||
# v5.18.1 5.18.1-1[.KDIST] kernel[-kdist]-5.18.1-1
|
||||
# v5.18.0-1-gac28df2 5.18.0-1[.KDIST] kernel[-kdist]-5.18.0-1
|
||||
# v5.18.0-3-g16cadc5 5.18.0-1[.KDIST] kernel[-kdist]-5.18.0-1
|
||||
# v5.18-rc1 5.18.0-1.rc1[.KDIST] kernel[-kdist]-5.18.0-1.rc1
|
||||
# v5.18-rc1-1-g380a504 5.18.0-1.rc1[.KDIST] kernel[-kdist]-5.18.0-1.rc1
|
||||
# 5.18.0-1[.KDIST] 5.18.0-2[.KDIST] kernel[-kdist]-5.18.0-2
|
||||
# 5.18.12-3[.KDIST] 5.18.12-4[.KDIST] kernel[-kdist]-5.18.12-4
|
||||
# 5.18.12-3[.KDIST]-5-g9318b03 5.18.12-4[.KDIST] kernel[-kdist]-5.18.12-4
|
||||
# 5.18.0-12.rc1[.KDIST] 5.18.0-12.rc1[.KDIST] kernel[-kdist]-5.18.0-13.rc1
|
||||
# 5.18.0-12[.KDIST]-2-g551f9cd 5.18.0-0.20220428git551f9cd79ece.12[.KDIST] kernel[-kdist]-5.18.0-13
|
||||
# x86-5.4.119-19-0010.prerelease 5.4.119-20[.KDIST] kernel[-kdist]-5.4.119-20[.KDIST]
|
||||
#
|
||||
# * NOTE: random commit snapshot can't be versioning in non-decreasing since one can always amend/rebase, so only the date stamp matters now.
|
||||
# ** NOTE: Yes, this script is compatible with TK4
|
||||
#
|
||||
# As you may have noticed, release always start with '0' unless a git tag have release >= 1,
|
||||
# The tag should be generated by other commands that comes later in this script.
|
||||
prepare_next_kernel_ver() {
|
||||
_prepare_kernel_ver "$@"
|
||||
|
||||
if [[ $KPREMERGEWINDOW ]]; then
|
||||
warn "Upstream is in merge window, forcing a formal release is not recommanded."
|
||||
fi
|
||||
|
||||
krelease=$((KGIT_RELEASE_NUM + 1))
|
||||
|
||||
if [[ $KEXTRAVERSION ]]; then
|
||||
krelease="$krelease.${KEXTRAVERSION##-}"
|
||||
elif [[ $KPREMERGEWINDOW ]]; then
|
||||
krelease="$krelease.rc0"
|
||||
fi
|
||||
|
||||
KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"
|
||||
KERNEL_RELVER="$krelease${KDIST:+.$KDIST}"
|
||||
KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER"
|
||||
}
|
||||
|
||||
# Get next formal kernel version based on previous git tag
|
||||
# Same as prepare_next_kernel_ver, but increase sub version instead.
|
||||
# eg. instead of 5.18.12-3[.KDIST] -> 5.18.12-4[.KDIST], this generates 5.18.12-3[.KDIST] -> 5.18.12-3.1[.KDIST]
|
||||
prepare_next_sub_kernel_ver() {
|
||||
_prepare_kernel_ver "$@"
|
||||
|
||||
if [[ $KPREMERGEWINDOW ]]; then
|
||||
warn "Upstream is in merge window, forcing a formal release is not recommanded."
|
||||
fi
|
||||
|
||||
krelease=$((KGIT_RELEASE_NUM + 0))
|
||||
krelease=$krelease.$((KGIT_SUB_RELEASE_NUM + 1))
|
||||
|
||||
if [[ $KEXTRAVERSION ]]; then
|
||||
krelease="$krelease.${KEXTRAVERSION##-}"
|
||||
elif [[ $KPREMERGEWINDOW ]]; then
|
||||
krelease="$krelease.rc0"
|
||||
fi
|
||||
|
||||
KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"
|
||||
KERNEL_RELVER="$krelease${KDIST:+.$KDIST}"
|
||||
KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER"
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Shell helpers
|
||||
#
|
||||
|
||||
RED="\033[0;31m"
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
NC="\033[0m"
|
||||
|
||||
echo_green() {
|
||||
echo -en "$GREEN"
|
||||
echo "$@"
|
||||
echo -en "$NC"
|
||||
}
|
||||
|
||||
echo_yellow() {
|
||||
echo -en "$YELLOW"
|
||||
echo "$@"
|
||||
echo -en "$NC"
|
||||
}
|
||||
|
||||
echo_red() {
|
||||
echo -en "$RED"
|
||||
echo "$@"
|
||||
echo -en "$NC"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo_green -n "info: " >&2
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo_yellow -n "warn: " >&2
|
||||
echo "$@" >&2
|
||||
}
|
||||
|
||||
error() {
|
||||
echo_red -n "error: " >&2
|
||||
echo "$@" >&2
|
||||
}
|
||||
|
||||
die() {
|
||||
echo_red -n "fatal: " >&2
|
||||
echo "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_dist_makefile_var() {
|
||||
local _lib_source=${BASH_SOURCE[0]}
|
||||
local _val
|
||||
|
||||
# Just one sed call, fast and simple
|
||||
# Match anyline start with "^$1\s*=\s*", strip and remove matching part then store in hold buffer.
|
||||
# Pprint the hold buffer on exit. This ensure the last assigned value is used, matches Makefile syntax well
|
||||
_val=$(sed -nE -e \
|
||||
"/^$1\s*:?=\s*(.*)/{s/^\s*^$1\s*:?=\s*//;h};\${x;p}" \
|
||||
"$(dirname "$(realpath "$_lib_source")")/../Makefile")
|
||||
|
||||
case $_val in
|
||||
*\$* )
|
||||
die "Can't parse Makefile variable '$1', which references to other variables."
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$_val"
|
||||
}
|
||||
|
||||
[ "$TOPDIR" ] || TOPDIR=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
[ "$TOPDIR" ] || TOPDIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
|
||||
[ "$VENDOR" ] || VENDOR=$(get_dist_makefile_var VENDOR)
|
||||
[ "$DISTPATH" ] || DISTPATH=$(get_dist_makefile_var DISTPATH)
|
||||
[ "$DISTDIR" ] || DISTDIR=$TOPDIR/$DISTPATH
|
||||
[ "$SOURCEDIR" ] || SOURCEDIR=$DISTDIR/rpm/SOURCES
|
||||
[ "$SPEC_ARCH" ] || SPEC_ARCH=$(get_dist_makefile_var SPEC_ARCH)
|
||||
|
||||
if ! [ -s "$TOPDIR/Makefile" ]; then
|
||||
echo "Dist tools can only be run within a valid Linux Kernel git workspace." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VENDOR" ] || ! [ -s "$DISTDIR/Makefile" ]; then
|
||||
echo "Dist tools can't work without properly configured dist file." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Just use uname to get native arch
|
||||
get_native_arch () {
|
||||
uname -m
|
||||
}
|
||||
|
||||
# Convert any arch name into linux kernel arch name
|
||||
#
|
||||
# There is an inconsistence between Linux kernel's arch naming and
|
||||
# RPM arch naming. eg. Linux kernel uses arm64 instead of aarch64
|
||||
# used by RPM, i686 vs x86, amd64 vs x86_64. Most are just same things
|
||||
# with different name due to historical reasons.
|
||||
get_kernel_arch () {
|
||||
case $1 in
|
||||
riscv64 )
|
||||
echo "riscv"
|
||||
;;
|
||||
arm64 | aarch64 )
|
||||
echo "arm64"
|
||||
;;
|
||||
i386 | i686 | x86 )
|
||||
echo "x86"
|
||||
;;
|
||||
amd64 | x86_64 )
|
||||
echo "x86_64"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Convert any arch name into linux kernel src arch name
|
||||
#
|
||||
# Similiar to get_kernel_arch but return the corresponding
|
||||
# source code base sub path in arch/
|
||||
get_kernel_src_arch () {
|
||||
case $1 in
|
||||
riscv64 )
|
||||
echo "riscv"
|
||||
;;
|
||||
arm64 | aarch64 )
|
||||
echo "arm64"
|
||||
;;
|
||||
i386 | i686 | x86 | amd64 | x86_64 )
|
||||
echo "x86"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
type git >/dev/null || die 'git is required'
|
||||
type make >/dev/null || die 'make is required'
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash --norc
|
||||
#
|
||||
# List files to be generated for kernel config styles
|
||||
#
|
||||
# Params:
|
||||
# $@: [ <filter>... ] When non-empty, only show kernel configs style matching <filter>
|
||||
|
||||
# shellcheck source=./lib-config.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-config.sh"
|
||||
|
||||
_echo_file() {
|
||||
for arch in "${CONFIG_ARCH[@]}"; do
|
||||
echo "$CONFIG_OUTDIR/$1.$arch.config"
|
||||
done
|
||||
}
|
||||
|
||||
for_each_config_target _echo_file "$@"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash --norc
|
||||
#
|
||||
# List available kernel config styles
|
||||
#
|
||||
# Params:
|
||||
# $@: [ <filter>... ] When non-empty, only show kernel configs style matching <filter>
|
||||
|
||||
# shellcheck source=./lib-config.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-config.sh"
|
||||
|
||||
_echo() {
|
||||
echo "$1" 2>/dev/null || exit 0
|
||||
}
|
||||
|
||||
for_each_config_target _echo "$@"
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash --norc
|
||||
#
|
||||
# Print out the tkernel version based on git commit and work tree.
|
||||
#
|
||||
# shellcheck source=./lib-version.sh
|
||||
. "$(dirname "$(realpath "$0")")/lib-version.sh"
|
||||
|
||||
COMMIT=HEAD
|
||||
case $1 in
|
||||
--sub-release )
|
||||
prepare_next_sub_kernel_ver "$COMMIT" "$TOPDIR" || die "Failed preparing next sub release version info"
|
||||
;;
|
||||
"")
|
||||
prepare_next_kernel_ver "$COMMIT" "$TOPDIR" || die "Failed preparing next release version info"
|
||||
;;
|
||||
*)
|
||||
die "Invalid param $1"
|
||||
;;
|
||||
esac
|
||||
AUTHOR_NAME=$(git config user.name) || die "Failed getting author name info from git config"
|
||||
AUTHOR_MAIL=$(git config user.email) || die "Failed getting author email info from git config"
|
||||
GITLOG=$(git -C "$TOPDIR" log "$KERNEL_PREV_RELREASE_TAG..$COMMIT" --pretty=oneline) || die "Failed getting changelog from git log"
|
||||
|
||||
AUTHOR="$AUTHOR_NAME <$AUTHOR_MAIL>"
|
||||
RELEASE_VERSION="$KERNEL_MAJVER-$KERNEL_RELVER"
|
||||
TAG_VERSION="release-$KERNEL_UNAMER"
|
||||
CHANGELOG="* $(date +"%a %b %e %Y") $AUTHOR - $RELEASE_VERSION
|
||||
$(echo "$GITLOG" | sed -E "s/^\S+/-/g")"
|
||||
|
||||
print_info() {
|
||||
cat << EOF
|
||||
Please review following info:
|
||||
\* DO NOT CHANGE THE FILE FORMAT \*
|
||||
|
||||
Tag: $TAG_VERSION
|
||||
Release Version: $RELEASE_VERSION
|
||||
Release Author: $AUTHOR
|
||||
Changelog:
|
||||
$CHANGELOG
|
||||
EOF
|
||||
}
|
||||
|
||||
dump_info() {
|
||||
print_info > "$DISTDIR/.release.stash"
|
||||
}
|
||||
|
||||
update_info() {
|
||||
${EDITOR:-vi} "$DISTDIR/.release.stash" || die "Failed to call editor to edit the release info"
|
||||
}
|
||||
|
||||
parse_info() {
|
||||
TAG_VERSION=$(sed -E -ne "s/^Tag:\s*(.*)/\1/p" "$DISTDIR/.release.stash")
|
||||
RELEASE_VERSION=$(sed -E -ne "s/\s*Release Version:\s*(.*)/\1/p" "$DISTDIR/.release.stash")
|
||||
AUTHOR=$(sed -E -ne "s/^Release Author:\s*(.*)/\1/p" "$DISTDIR/.release.stash")
|
||||
CHANGELOG=$(sed -n '/^* /,$p' "$DISTDIR/.release.stash")
|
||||
}
|
||||
|
||||
while :; do
|
||||
_res="?"
|
||||
while :; do
|
||||
{
|
||||
print_info
|
||||
echo
|
||||
echo "(Press 'q' to exit preview.)"
|
||||
} | less
|
||||
echo "Is this OK? (y/n/q/e, Y: Do the release, N/Q: quit, E: edit)"
|
||||
read -r -n1 _res
|
||||
case $_res in
|
||||
n|N|q|Q )
|
||||
exit 0
|
||||
;;
|
||||
y|Y )
|
||||
echo "$CHANGELOG" >> "$DISTDIR/templates/changelog.new"
|
||||
echo "" >> "$DISTDIR/templates/changelog.new"
|
||||
cat "$DISTDIR/templates/changelog" >> "$DISTDIR/templates/changelog.new"
|
||||
mv "$DISTDIR/templates/changelog.new" "$DISTDIR/templates/changelog"
|
||||
git -C "$TOPDIR" add "$DISTPATH/templates/changelog"
|
||||
git -C "$TOPDIR" commit -m "$DISTPATH: release $RELEASE_VERSION
|
||||
|
||||
Upstream: no
|
||||
|
||||
Signed-off-by: $AUTHOR"
|
||||
git -C "$TOPDIR" tag "$TAG_VERSION"
|
||||
exit 0
|
||||
;;
|
||||
e|E )
|
||||
dump_info
|
||||
update_info
|
||||
parse_info
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
Binary file not shown.
|
|
@ -0,0 +1,156 @@
|
|||
#!/usr/bin/python3
|
||||
#
|
||||
# check-kabi - Red Hat kABI reference checking tool
|
||||
#
|
||||
# We use this script to check against reference Module.kabi files.
|
||||
#
|
||||
# Author: Jon Masters <jcm@redhat.com>
|
||||
# Copyright (C) 2007-2009 Red Hat, Inc.
|
||||
#
|
||||
# This software may be freely redistributed under the terms of the GNU
|
||||
# General Public License (GPL).
|
||||
|
||||
# Changelog:
|
||||
#
|
||||
# 2018/06/01 - Update for python3 by Petr Oros.
|
||||
# 2009/08/15 - Updated for use in RHEL6.
|
||||
# 2007/06/13 - Initial rewrite in python by Jon Masters.
|
||||
|
||||
__author__ = "Jon Masters <jcm@redhat.com>"
|
||||
__version__ = "2.0"
|
||||
__date__ = "2009/08/15"
|
||||
__copyright__ = "Copyright (C) 2007-2009 Red Hat, Inc"
|
||||
__license__ = "GPL"
|
||||
|
||||
import getopt
|
||||
import string
|
||||
import sys
|
||||
|
||||
true = 1
|
||||
false = 0
|
||||
|
||||
def load_symvers(symvers, filename):
|
||||
"""Load a Module.symvers file."""
|
||||
|
||||
symvers_file = open(filename, "r")
|
||||
|
||||
while true:
|
||||
in_line = symvers_file.readline()
|
||||
if in_line == "":
|
||||
break
|
||||
if in_line == "\n":
|
||||
continue
|
||||
try:
|
||||
checksum, symbol, directory, type = in_line.split()
|
||||
except ValueError:
|
||||
# Firmware symbol may have an extra field
|
||||
checksum, symbol, directory, type, extra = in_line.split()
|
||||
|
||||
symvers[symbol] = " ".join([checksum, symbol, directory, type])
|
||||
|
||||
|
||||
def load_kabi(kabi, filename):
|
||||
"""Load a Module.kabi file."""
|
||||
|
||||
kabi_file = open(filename, "r")
|
||||
|
||||
while true:
|
||||
in_line = kabi_file.readline()
|
||||
if in_line == "":
|
||||
break
|
||||
if in_line == "\n":
|
||||
continue
|
||||
try:
|
||||
checksum, symbol, directory, type = in_line.split()
|
||||
except ValueError:
|
||||
# Firmware symbol may have an extra field
|
||||
checksum, symbol, directory, type, extra = in_line.split()
|
||||
|
||||
kabi[symbol] = " ".join([checksum, symbol, directory, type])
|
||||
|
||||
|
||||
def check_kabi(symvers, kabi):
|
||||
"""Check Module.kabi and Module.symvers files."""
|
||||
|
||||
fail = 0
|
||||
warn = 0
|
||||
changed_symbols = []
|
||||
moved_symbols = []
|
||||
|
||||
for symbol in kabi:
|
||||
abi_hash, abi_sym, abi_dir, abi_type = kabi[symbol].split()
|
||||
if symbol in symvers:
|
||||
sym_hash, sym_sym, sym_dir, sym_type = symvers[symbol].split()
|
||||
if abi_hash != sym_hash:
|
||||
fail = 1
|
||||
changed_symbols.append(symbol)
|
||||
|
||||
if abi_dir != sym_dir:
|
||||
warn = 1
|
||||
moved_symbols.append(symbol)
|
||||
else:
|
||||
fail = 1
|
||||
changed_symbols.append(symbol)
|
||||
|
||||
if fail:
|
||||
print("*** ERROR - ABI BREAKAGE WAS DETECTED ***")
|
||||
print("")
|
||||
print("The following symbols have been changed (this will cause an ABI breakage):")
|
||||
print("")
|
||||
for symbol in changed_symbols:
|
||||
print(symbol)
|
||||
print("")
|
||||
|
||||
if warn:
|
||||
print("*** WARNING - ABI SYMBOLS MOVED ***")
|
||||
print("")
|
||||
print("The following symbols moved (typically caused by moving a symbol from being")
|
||||
print("provided by the kernel vmlinux out to a loadable module):")
|
||||
print("")
|
||||
for symbol in moved_symbols:
|
||||
print(symbol)
|
||||
print("")
|
||||
|
||||
"""Halt the build, if we got errors and/or warnings. In either case,
|
||||
double-checkig is required to avoid introducing / concealing
|
||||
KABI inconsistencies."""
|
||||
if fail or warn:
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def usage():
|
||||
print("""
|
||||
check-kabi: check Module.kabi and Module.symvers files.
|
||||
|
||||
check-kabi [ -k Module.kabi ] [ -s Module.symvers ]
|
||||
|
||||
""")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
symvers_file = ""
|
||||
kabi_file = ""
|
||||
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'hk:s:')
|
||||
|
||||
for o, v in opts:
|
||||
if o == "-s":
|
||||
symvers_file = v
|
||||
if o == "-h":
|
||||
usage()
|
||||
sys.exit(0)
|
||||
if o == "-k":
|
||||
kabi_file = v
|
||||
|
||||
if (symvers_file == "") or (kabi_file == ""):
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
symvers = {}
|
||||
kabi = {}
|
||||
|
||||
load_symvers(symvers, symvers_file)
|
||||
load_kabi(kabi, kabi_file)
|
||||
check_kabi(symvers, kabi)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# See 'cpupower help' and cpupower(1) for more info
|
||||
CPUPOWER_START_OPTS="frequency-set -g performance"
|
||||
CPUPOWER_STOP_OPTS="frequency-set -g ondemand"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Configure CPU power related settings
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=/etc/sysconfig/cpupower
|
||||
ExecStart=/usr/bin/cpupower $CPUPOWER_START_OPTS
|
||||
ExecStop=/usr/bin/cpupower $CPUPOWER_STOP_OPTS
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copied from Fedora
|
||||
|
||||
# This is the aarch64 override file for the core/drivers package split. The
|
||||
# module directories listed here and in the generic list in filter-modules.sh
|
||||
# will be moved to the resulting kernel-modules package for this arch.
|
||||
# Anything not listed in those files will be in the kernel-core package.
|
||||
#
|
||||
# Please review the default list in filter-modules.sh before making
|
||||
# modifications to the overrides below. If something should be removed across
|
||||
# all arches, remove it in the default instead of per-arch.
|
||||
|
||||
driverdirs="atm auxdisplay bcma bluetooth firewire fpga infiniband leds media memstick message mmc mtd nfc ntb pcmcia power ssb soundwire staging tty uio w1 ofed_addon"
|
||||
|
||||
ethdrvs="3com adaptec arc alteon atheros broadcom cadence calxeda chelsio cisco dec dlink emulex marvell micrel myricom neterion nvidia packetengines qlogic rdc sfc silan sis smsc stmicro sun tehuti ti via wiznet xircom"
|
||||
|
||||
drmdrvs="amd arm bridge ast exynos hisilicon i2c imx mgag200 meson msm nouveau panel pl111 radeon rockchip tegra sun4i tiny vc4"
|
||||
|
||||
singlemods="ntb_netdev iscsi_ibft iscsi_boot_sysfs megaraid pmcraid qedi qla1280 9pnet_rdma rpcrdma nvmet-rdma nvme-rdma hid-picolcd hid-prodikeys hwpoison-inject target_core_user sbp_target cxgbit chcr rnbd-client rnbd-server mlx5_ib mlx5_core mlx5_vdpa dfl-emif octeontx2-cpt octeontx2-cptvf spi-altera-dfl rvu_cptpf rvu_cptvf regmap-sdw regmap-sdw-mbq hid-playstation hid-nintendo configs"
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Used Fedora kernel-ark repo as reference.
|
||||
#
|
||||
# Called as filter-modules.sh <depmod base path> <kernel version> <arch> <System.map>
|
||||
#
|
||||
# This script collects modules, and filters modules into the kernel-core and kernel-modules
|
||||
# subpackages. We list out subsystems/subdirs to prune from the installed
|
||||
# module directory. What is left is put into the kernel-core package. What is
|
||||
# pruned is contained in the kernel-modules package.
|
||||
#
|
||||
# This file contains the default subsys/subdirs to prune from all architectures.
|
||||
# If an architecture needs to differ, we source a per-arch filter-<arch>.sh file
|
||||
# that contains the set of override lists to be used instead. If a module or
|
||||
# subsys should be in kernel-modules on all arches, please change the defaults
|
||||
# listed here.
|
||||
|
||||
# Set the default dirs and modules to filter out as external modules
|
||||
|
||||
driverdirs="atm auxdisplay bcma bluetooth firewire fmc fpga iio infiniband isdn leds media memstick message mfd mmc mtd nfc ntb pcmcia platform power powercap ssb soundwire staging thermal tty uio w1 ofed_addon"
|
||||
|
||||
chardrvs="mwave pcmcia"
|
||||
|
||||
netdrvs="appletalk can dsa hamradio ieee802154 irda ppp slip usb wireless"
|
||||
|
||||
ethdrvs="3com adaptec alteon amd aquantia arc atheros broadcom cadence calxeda chelsio cisco dec dlink emulex icplus marvell mellanox micrel myricom neterion nvidia oki-semi packetengines qlogic rdc renesas sfc silan sis smsc stmicro sun tehuti ti wiznet xircom"
|
||||
|
||||
inputdrvs="gameport tablet touchscreen joystick"
|
||||
|
||||
hiddrvs="surface-hid"
|
||||
|
||||
scsidrvs="aacraid aic7xxx aic94xx be2iscsi bfa bnx2i bnx2fc csiostor cxgbi esas2r fcoe fnic hisi_sas isci libsas lpfc megaraid mpt2sas mpt3sas mvsas pm8001 qla2xxx qla4xxx sym53c8xx_2 ufs qedf"
|
||||
|
||||
usbdrvs="atm image misc serial wusbcore"
|
||||
|
||||
drmdrvs="amd ast bridge gma500 i2c i915 mgag200 nouveau panel radeon via"
|
||||
|
||||
netprots="6lowpan appletalk atm ax25 batman-adv bluetooth can dccp dsa ieee802154 irda l2tp mac80211 mac802154 mpls netrom nfc rds rfkill rose sctp smc wireless"
|
||||
|
||||
fsdrvs="affs befs cifs coda cramfs dlm ecryptfs hfs hfsplus jfs jffs2 minix ncpfs nilfs2 ocfs2 reiserfs romfs squashfs sysv ubifs ufs gfs2"
|
||||
|
||||
# .ko files to be filtered
|
||||
singlemods="ntb_netdev iscsi_ibft iscsi_boot_sysfs megaraid pmcraid qedi qla1280 9pnet_rdma rpcrdma nvmet-rdma nvme-rdma hid-picolcd hid-prodikeys hwa-hc hwpoison-inject hid-sensor-hub target_core_user sbp_target cxgbit iw_cxgb3 iw_cxgb4 cxgb3i cxgb3i cxgb3i_ddp cxgb4i chcr chtls parport_serial ism regmap-sdw regmap-sdw-mbq arizona-micsupp hid-asus iTCO_wdt rnbd-client rnbd-server mlx5_ib mlx5_vdpa spi-altera-dfl nct6775 hid-playstation hid-nintendo ntc_thermistor configs"
|
||||
|
||||
# Overrides is individual modules which need to remain in kernel-core due to deps.
|
||||
overrides="cec"
|
||||
|
||||
BASE_DIR=$1
|
||||
KERNEL_UNAMER=$2
|
||||
ARCH=$3
|
||||
SYSTEM_MAP=$(realpath "$4")
|
||||
MODULE_DIR=lib/modules/$KERNEL_UNAMER
|
||||
|
||||
# Grab the arch-specific filter list overrides
|
||||
source "$(dirname "$(realpath "$0")")/filter-$ARCH.sh"
|
||||
|
||||
error() {
|
||||
echo "$@">&2
|
||||
}
|
||||
|
||||
if ! cd "$BASE_DIR"; then
|
||||
error "Invalid base path: '$BASE_DIR'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! cd "$MODULE_DIR"; then
|
||||
error "Invalid kernel module path: '$MODULE_DIR'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# To be read from build path
|
||||
core_modules_list=
|
||||
modules_list=
|
||||
|
||||
# Read all kernel modules in the core modules list at the beginning
|
||||
# filter them into external modules list step by step
|
||||
#
|
||||
# Not filtering internal or vdso so start with kernel/
|
||||
core_modules_list=$(find kernel -name '*.ko')
|
||||
|
||||
filter_mods() {
|
||||
local prefix=$1 mods=$2 suffix=$3
|
||||
local mod filter_list
|
||||
|
||||
for mod in $mods; do
|
||||
if ! filter_list=$(grep "$prefix$mod$suffix" <<< "$core_modules_list"); then
|
||||
error "$prefix$mod$suffix is marked as non-core module but not built, skipping."
|
||||
else
|
||||
core_modules_list=$(grep -v "$prefix$mod$suffix" <<< "$core_modules_list")
|
||||
modules_list+=$filter_list
|
||||
modules_list+=$'\n'
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
filter_override() {
|
||||
local filter_list
|
||||
|
||||
for mod in $1; do
|
||||
if filter_list=$(grep "$mod.ko" <<< "$modules_list"); then
|
||||
modules_list=$(grep -v "$mod.ko" <<< "$modules_list")
|
||||
core_modules_list+=$filter_list
|
||||
core_modules_list+=$'\n'
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
filter_mods "drivers/" "$driverdirs" /
|
||||
filter_mods "drivers/char/" "$chardrvs" /
|
||||
filter_mods "drivers/net/" "$netdrvs" /
|
||||
filter_mods "drivers/net/ethernet/" "$ethdrvs" /
|
||||
filter_mods "drivers/input/" "$inputdrvs" /
|
||||
filter_mods "drivers/hid/" "$hiddrvs" /
|
||||
filter_mods "drivers/scsi/" "$scsidrvs" /
|
||||
filter_mods "drivers/usb"/ "$usbdrvs" /
|
||||
filter_mods "drivers/gpu/drm/" "$drmdrvs" /
|
||||
filter_mods "net/" "$netprots" /
|
||||
filter_mods "fs/" "$fsdrvs" /
|
||||
|
||||
# Just kill sound.
|
||||
filter_mods "" "sound" /
|
||||
filter_mods "drivers" "soundwire" /
|
||||
|
||||
# Filter single modules
|
||||
filter_mods "" "$singlemods"
|
||||
|
||||
# Now process the override list to bring those modules back into core
|
||||
filter_override "$overrides"
|
||||
|
||||
# Mask external mods to do a depmod check
|
||||
for mod in $modules_list; do
|
||||
mv "$mod" "$mod.bak"
|
||||
done
|
||||
|
||||
# Run depmod on the resulting module tree and make sure it isn't broken
|
||||
depmod_err=$(depmod "$KERNEL_UNAMER" -b "$BASE_DIR" -naeF "$SYSTEM_MAP" 2>&1 1>/dev/null)
|
||||
if [ "$depmod_err" ]; then
|
||||
error "Failed to filter out external modules, broken depmod:"
|
||||
error "$depmod_err"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mask external mods to do a depmod check
|
||||
for mod in $modules_list; do
|
||||
mv "$mod.bak" "$mod"
|
||||
done
|
||||
|
||||
# Print the modules_list after sort, and prepend /lib/modules/<KERNEL_UNAMER>/ to each line
|
||||
echo "$modules_list" | sort -n | sed "/^$/d;s/^/\/${MODULE_DIR//\//\\\/}\//"
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Copied from Fedora
|
||||
|
||||
# This is the x86_64 override file for the core/drivers package split. The
|
||||
# module directories listed here and in the generic list in filter-modules.sh
|
||||
# will be moved to the resulting kernel-modules package for this arch.
|
||||
# Anything not listed in those files will be in the kernel-core package.
|
||||
#
|
||||
# Please review the default list in filter-modules.sh before making
|
||||
# modifications to the overrides below. If something should be removed across
|
||||
# all arches, remove it in the default instead of per-arch.
|
||||
|
||||
# Defaults work so no need to override
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Copied from Fedora
|
||||
|
||||
# This is the x86_64 override file for the core/drivers package split. The
|
||||
# module directories listed here and in the generic list in filter-modules.sh
|
||||
# will be moved to the resulting kernel-modules package for this arch.
|
||||
# Anything not listed in those files will be in the kernel-core package.
|
||||
#
|
||||
# Please review the default list in filter-modules.sh before making
|
||||
# modifications to the overrides below. If something should be removed across
|
||||
# all arches, remove it in the default instead of per-arch.
|
||||
|
||||
# Defaults work so no need to override
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Default keygen
|
||||
#
|
||||
# We do nothing here, just check if CONFIG_MODULE_SIG_KEY is set to
|
||||
# "certs/signing_key.pem", this is a special value for kernel config,
|
||||
# Kbuild will automatically generate keys when this value is set.
|
||||
|
||||
KERNEL_UNAMER=$1
|
||||
BUILD_DIR=$2
|
||||
|
||||
KCONFIG_FILE=$BUILD_DIR/.config
|
||||
|
||||
error() {
|
||||
echo "module-keygen: error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ! [[ -f $KCONFIG_FILE ]]; then
|
||||
error "can't find a valid kernel config: $KCONFIG_FILE"
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULES=y' "$KCONFIG_FILE"; then
|
||||
echo "CONFIG_MODULES not enabled, quit. "
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULE_SIG=y' "$KCONFIG_FILE"; then
|
||||
echo "CONFIG_MODULE_SIG not enabled, quit. "
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"' "$KCONFIG_FILE"; then
|
||||
error "CONFIG_MODULE_SIG_KEY=\"certs/signing_key.pem\" is not defined, can't gen keys."
|
||||
fi
|
||||
|
||||
# Don't use Kbuild's signing, use %%{_module_signer} instead, be compatible with debuginfo and compression
|
||||
echo "module-keygen: Disabling CONFIG_MODULE_SIG_FORCE, siginig within temporary builtin key."
|
||||
sed -i -e "s/^CONFIG_MODULE_SIG_FORCE.*/# CONFIG_MODULE_SIG_FORCE is not set/" "$KCONFIG_FILE"
|
||||
|
||||
echo "module-keygen: $KERNEL_UNAMER is using builtin keys."
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Default key-sign
|
||||
#
|
||||
# Just a wrapper for sign-file
|
||||
#
|
||||
# We depend on CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"
|
||||
# for the built-in keys.
|
||||
|
||||
KERNEL_UNAMER=$1
|
||||
BUILD_DIR=$2
|
||||
BASE_DIR=$3
|
||||
|
||||
KCONFIG_FILE=$BUILD_DIR/.config
|
||||
MODULE_DIR=$BASE_DIR/lib/modules/$KERNEL_UNAMER
|
||||
|
||||
error() {
|
||||
echo "module-signer: error: $*" >&2
|
||||
}
|
||||
|
||||
if ! [[ -f $KCONFIG_FILE ]]; then
|
||||
error "can't find a valid kernel config."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULES=y' "$KCONFIG_FILE"; then
|
||||
echo "CONFIG_MODULES=y is not defined in .config, skipping signing."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULE_SIG=y' "$KCONFIG_FILE"; then
|
||||
echo "CONFIG_MODULE_SIG=y is not defined in .config, skipping signing."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [[ -x $BUILD_DIR/scripts/sign-file ]]; then
|
||||
error "$BUILD_DIR/scripts/sign-file is not an executable file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q '^CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"' "$KCONFIG_FILE"; then
|
||||
error "CONFIG_MODULE_SIG_KEY is not defined in .config, can't gen keys."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "module-signer: Signing $KERNEL_UNAMER modules with builtin keys..."
|
||||
PRIKEY="$BUILD_DIR/certs/signing_key.pem"
|
||||
PUBKEY="$BUILD_DIR/certs/signing_key.x509"
|
||||
|
||||
if ! [[ -s $PRIKEY ]]; then
|
||||
error "private key file doesn't exist: $PRIKEY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ -s $PUBKEY ]]; then
|
||||
error "public key file doesn't exist: $PUBKEY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JOB=$(nproc)
|
||||
JOB=${JOB:-2}
|
||||
|
||||
export BUILD_DIR
|
||||
export PRIKEY
|
||||
export PUBKEY
|
||||
# shellcheck disable=2016
|
||||
find "$MODULE_DIR" -type f -name '*.ko' -print0 | xargs -0r -n 1 -P "$JOB" sh -c '
|
||||
$BUILD_DIR/scripts/sign-file sha256 "$PRIKEY" "$PUBKEY" "$1"
|
||||
rm -f $1.sig $1.dig
|
||||
|
||||
if [ "~Module signature appended~" != "$(tail -c 28 "$1")" ]; then
|
||||
echo "module-signer: error: failed to sign $1."
|
||||
exit 1
|
||||
fi
|
||||
' _ || exit $?
|
||||
|
||||
echo "module-signer: Signing $KERNEL_UNAMER done."
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -b /dev/sda -a ! -b /dev/cciss/c0d0 ]; then
|
||||
mkdir -p /dev/cciss
|
||||
set -- 0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p
|
||||
while [ $# -ge 2 ]; do
|
||||
c=/dev/cciss/c0d$1; shift
|
||||
s=/dev/sd$1; shift
|
||||
ln -s ${s} ${c}
|
||||
ln -s ${s}1 ${c}p1
|
||||
ln -s ${s}2 ${c}p2
|
||||
ln -s ${s}3 ${c}p3
|
||||
ln -s ${s}4 ${c}p4
|
||||
done
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
* Wed Oct 05 2022 Kairui Song <kasong@tencent.com> - 5.4.119-19-0009.11
|
||||
- Initial dist port release
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -183,8 +183,8 @@ CONFIG_INITRAMFS_SOURCE=""
|
|||
CONFIG_RD_GZIP=y
|
||||
# CONFIG_RD_BZIP2 is not set
|
||||
CONFIG_RD_LZMA=y
|
||||
# CONFIG_RD_XZ is not set
|
||||
# CONFIG_RD_LZO is not set
|
||||
CONFIG_RD_XZ=y
|
||||
CONFIG_RD_LZO=y
|
||||
CONFIG_RD_LZ4=y
|
||||
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
|
||||
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
|
||||
|
|
@ -3285,9 +3285,9 @@ CONFIG_DRM_I915_SPIN_REQUEST=5
|
|||
# CONFIG_DRM_AST is not set
|
||||
# CONFIG_DRM_MGAG200 is not set
|
||||
# CONFIG_DRM_CIRRUS_QEMU is not set
|
||||
# CONFIG_DRM_QXL is not set
|
||||
# CONFIG_DRM_BOCHS is not set
|
||||
# CONFIG_DRM_VIRTIO_GPU is not set
|
||||
CONFIG_DRM_QXL=m
|
||||
CONFIG_DRM_BOCHS=m
|
||||
CONFIG_DRM_VIRTIO_GPU=m
|
||||
CONFIG_DRM_PANEL=y
|
||||
|
||||
#
|
||||
|
|
@ -3341,7 +3341,7 @@ CONFIG_FB_DEFERRED_IO=y
|
|||
# CONFIG_FB_IMSTT is not set
|
||||
# CONFIG_FB_VGA16 is not set
|
||||
# CONFIG_FB_UVESA is not set
|
||||
# CONFIG_FB_VESA is not set
|
||||
CONFIG_FB_VESA=y
|
||||
CONFIG_FB_EFI=y
|
||||
# CONFIG_FB_N411 is not set
|
||||
# CONFIG_FB_HGA is not set
|
||||
|
|
|
|||
Loading…
Reference in New Issue