From de3ab79a0f433dc2a7bcd6be18c1829e8d0e73be Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 28 Nov 2022 03:05:26 +0800 Subject: [PATCH 01/24] dist: Erase LOCALVERSION on build Upstream: no It's harmful for a formal build to set LOCALVERSION, as some kernel subpackage will look at it and assume the kernel is using a different SCM naming style, so erase it on build. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index 3db838dd4c2e..ac65b128e076 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -562,6 +562,9 @@ BuildConfig() { # Ensures build-ids are unique to allow parallel debuginfo sed -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"$KernUnameR\"/" .config + # Erase LOCALVERSION to prevent it from mucking with our version numbers + sed -i -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' .config + # Call olddefconfig before make all, set all unset config to default value. # The packager uses CROSS_COMPILE=scripts/dummy-tools for generating .config # so compiler related config are always unset, let's just use defconfig for them for now -- Gitee From d67b9bbb2cccaa118d0d156ad9c1c51ebc700d75 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 27 Nov 2022 19:13:02 +0800 Subject: [PATCH 02/24] dist: simplify the modules filtering script Upstream: no Use a single script to handle different archs and extent the script. Remove boliplates in spec template. Signed-off-by: Kairui Song --- dist/scripts/gen-spec.sh | 7 -- dist/sources/filter-aarch64.sh | 20 ----- dist/sources/filter-modules.sh | 113 +++++++++++++++++----------- dist/sources/filter-riscv64.sh | 14 ---- dist/sources/filter-x86_64.sh | 14 ---- dist/templates/kernel.template.spec | 7 +- 6 files changed, 74 insertions(+), 101 deletions(-) delete mode 100755 dist/sources/filter-aarch64.sh delete mode 100755 dist/sources/filter-riscv64.sh delete mode 100755 dist/sources/filter-x86_64.sh diff --git a/dist/scripts/gen-spec.sh b/dist/scripts/gen-spec.sh index 86262a8362a1..c3b15995f559 100755 --- a/dist/scripts/gen-spec.sh +++ b/dist/scripts/gen-spec.sh @@ -125,13 +125,6 @@ _gen_arch_source() { 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() { diff --git a/dist/sources/filter-aarch64.sh b/dist/sources/filter-aarch64.sh deleted file mode 100755 index ba038907715d..000000000000 --- a/dist/sources/filter-aarch64.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/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" - -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_vdpa dfl-emif octeontx2-cpt octeontx2-cptvf spi-altera-dfl rvu_cptpf rvu_cptvf regmap-sdw regmap-sdw-mbq hid-playstation hid-nintendo configs" diff --git a/dist/sources/filter-modules.sh b/dist/sources/filter-modules.sh index 9389d48e0808..8f6d66892669 100755 --- a/dist/sources/filter-modules.sh +++ b/dist/sources/filter-modules.sh @@ -49,13 +49,11 @@ BASE_DIR=$1 KERNEL_UNAMER=$2 ARCH=$3 SYSTEM_MAP=$(realpath "$4") +MODULEPKG=$5 MODULE_DIR=lib/modules/$KERNEL_UNAMER -# Grab the arch-specific filter list overrides -source "$(dirname "$(realpath "$0")")/filter-$ARCH.sh" - error() { - echo "$@">&2 + echo "filter-modules.sh: $@">&2 } if ! cd "$BASE_DIR"; then @@ -105,47 +103,78 @@ filter_override() { 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 +# Check if modules dependency are still sane after splitting these mods out +# args: moduled to be spliited out +check_modules_dependency_after_split() { + # 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 + + # Move the mods back + for mod in "$modules_list"; do + mv "$mod.bak" "$mod" + done +} -# Mask external mods to do a depmod check -for mod in $modules_list; do - mv "$mod.bak" "$mod" -done +# Modules override for differnet arch +case $ARCH in + aarch64 ) + 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" + ;; + riscv64 ) + ;; + x86_64 ) + ;; + * ) + error "Unknown arch '$ARCH'" + ;; +esac + +# Filter for split and verify +case $MODULEPKG in + non-core-modules ) + 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" + ;; + * ) + error "Invalid module packaging param '$1'" + exit 1 + ;; +esac + +# Ensure this packaging splitting won't break core modules dependency +check_modules_dependency_after_split # Print the modules_list after sort, and prepend /lib/modules// to each line +echo "%dir /lib/modules/$KERNEL_UNAMER/" echo "$modules_list" | sort -n | sed "/^$/d;s/^/\/${MODULE_DIR//\//\\\/}\//" exit 0 diff --git a/dist/sources/filter-riscv64.sh b/dist/sources/filter-riscv64.sh deleted file mode 100755 index c98da7f1dfb2..000000000000 --- a/dist/sources/filter-riscv64.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /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 diff --git a/dist/sources/filter-x86_64.sh b/dist/sources/filter-x86_64.sh deleted file mode 100755 index c98da7f1dfb2..000000000000 --- a/dist/sources/filter-x86_64.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /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 diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index ac65b128e076..8edf63487282 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -187,7 +187,6 @@ Source30: check-kabi ### Arch speficied kernel configs and kABI # Start from Source1000 to Source1199, for kernel config # Start from Source1200 to Source1399, for kabi -# Start from Source1400 to Source1599, for filter-.sh {{ARCHSOURCESPEC}} ### Userspace tools @@ -939,8 +938,7 @@ CollectKernelFile() { # Do module splitting, filter-modules.sh will generate a list of # modules to be split into external module package # Rest of the modules stay in core package - echo "%dir /lib/modules/$KernUnameR/" >> modules.list - %SOURCE10 "%{buildroot}" "$KernUnameR" "%{_target_cpu}" "$_KernBuild/System.map" >> modules.list || exit $? + %SOURCE10 "%{buildroot}" "$KernUnameR" "%{_target_cpu}" "$_KernBuild/System.map" non-core-modules >> modules.list || exit $? comm -23 core.list modules.list > core.list.tmp mv core.list.tmp core.list @@ -948,7 +946,8 @@ CollectKernelFile() { popd # Make these file list usable in rpm build dir - mv %{buildroot}/{core.list,modules.list} ../ + mv %{buildroot}/core.list ../ + mv %{buildroot}/modules.list ../ } ###### Start Kernel Install -- Gitee From 3b052cd44e82f02d5490f9cf56189768e415d66c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 25 Nov 2022 19:33:11 +0800 Subject: [PATCH 03/24] dist: use more wildcard for file list Upstream: no Some utils are trivial and may change, so use wildcard to match them. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index 8edf63487282..323d33323cfb 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -1227,8 +1227,7 @@ fi %{_bindir}/iio_generic_buffer %{_bindir}/lsiio %{_bindir}/lsgpio -%{_bindir}/gpio-hammer -%{_bindir}/gpio-event-mon +%{_bindir}/gpio-* %{_bindir}/page_owner_sort %{_bindir}/slabinfo @@ -1254,18 +1253,8 @@ fi %defattr(-,root,root) %{_sbindir}/bpftool %{_sysconfdir}/bash_completion.d/bpftool -%{_mandir}/man8/bpftool-cgroup.8.gz -%{_mandir}/man8/bpftool-gen.8.gz -%{_mandir}/man8/bpftool-iter.8.gz -%{_mandir}/man8/bpftool-link.8.gz -%{_mandir}/man8/bpftool-map.8.gz -%{_mandir}/man8/bpftool-prog.8.gz -%{_mandir}/man8/bpftool-perf.8.gz %{_mandir}/man8/bpftool.8.gz -%{_mandir}/man8/bpftool-net.8.gz -%{_mandir}/man8/bpftool-feature.8.gz -%{_mandir}/man8/bpftool-btf.8.gz -%{_mandir}/man8/bpftool-struct_ops.8.gz +%{_mandir}/man8/bpftool-*.8.gz %{_mandir}/man7/bpf-helpers.7.gz %if %{with_debuginfo} -- Gitee From b4a6f90e584ae29d3b46b56506132b4d8cc56c5c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 28 Nov 2022 15:01:07 +0800 Subject: [PATCH 04/24] dist: make-release: fix "Warning: Output not to a terminal" Upstream: no Make it easier to make a new release. Signed-off-by: Kairui Song --- dist/scripts/make-release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/scripts/make-release.sh b/dist/scripts/make-release.sh index 7d66a65db093..47b27c718ded 100755 --- a/dist/scripts/make-release.sh +++ b/dist/scripts/make-release.sh @@ -45,7 +45,8 @@ dump_info() { } update_info() { - ${EDITOR:-vi} "$DISTDIR/.release.stash" || die "Failed to call editor to edit the release info" + ${EDITOR:-vi} "$DISTDIR/.release.stash" >/dev/tty + [[ $? -eq 0 ]] || die "Failed to call editor to edit the release info" } parse_info() { -- Gitee From 7799f396f35a86621a89c0a2f0d8718210f858e8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 30 Nov 2022 16:41:34 +0800 Subject: [PATCH 05/24] dist: prefer user specified tag if a commit have multiple commit Upstream: no When building using a tag, dist build may use another tag that have a higher alphabet order. Fix this make the package versioning more reliable. Signed-off-by: Kairui Song --- dist/Makefile | 10 +++++++--- dist/scripts/gen-spec.sh | 6 +++--- dist/scripts/lib-version.sh | 37 ++++++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/dist/Makefile b/dist/Makefile index c2baebc1fba1..34c56012189a 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -62,13 +62,17 @@ override ARCH := $(shell echo $(BUILD_ARCH) | sed -e 's/amd64/x86_64/;s/aarch64/ ### Check if TAG is valid TAG := HEAD +# If COMMIT is specified, this line won't take effect COMMIT := $(shell git rev-parse --verify --quiet $(TAG)) ifeq ($(COMMIT),) $(error Invalid git reference, tag '$(TAG)' commit '$(COMMIT)', aborting) endif +# Prefer using TAG, if not set, use COMMIT +TAG := $(COMMIT) +GITREF := $(TAG) ### Build files -KFULLVER := $(shell $(DISTDIR)/scripts/get-version.sh $(COMMIT)) +KFULLVER := $(shell $(DISTDIR)/scripts/get-version.sh $(GITREF)) 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 @@ -132,7 +136,7 @@ default: dist-help $(TARFILE): @echo "Generating kernel source tar: $(TARFILE)" - @cd $(TOPDIR); git archive $(COMMIT) $(TOPDIR) --format=tar --prefix=kernel-$(KFULLVER)/ --output $(TARFILE) + @cd $(TOPDIR); git archive $(GITREF) $(TOPDIR) --format=tar --prefix=kernel-$(KFULLVER)/ --output $(TARFILE) dist-tarball: $(TARFILE) @echo "$(TARFILE)" @@ -158,7 +162,7 @@ dist-config: dist-configs $(SPECFILE): always-rebuild @echo "Generating kernel RPM spec: $(SPECFILE)" @$(DISTDIR)/scripts/gen-spec.sh \ - --commit "$(COMMIT)" \ + --gitref "$(GITREF)" \ --build-arch "$(SRPM_ARCH)" \ --kernel-config "$(CONFIG)" \ --kernel-variant "$(VARIANT)" \ diff --git a/dist/scripts/gen-spec.sh b/dist/scripts/gen-spec.sh index c3b15995f559..922aadeab540 100755 --- a/dist/scripts/gen-spec.sh +++ b/dist/scripts/gen-spec.sh @@ -31,8 +31,8 @@ while [[ $# -gt 0 ]]; do BUILD_ARCH=$2 shift 2 ;; - --commit ) - COMMIT=$2 + --gitref ) + GITREF=$2 shift 2 ;; --set-default-disabled ) @@ -54,7 +54,7 @@ while [[ $# -gt 0 ]]; do done # This function will prepare $KERNEL_MAJVER, $KERNEL_RELVER -prepare_kernel_ver "${COMMIT:-HEAD}" +prepare_kernel_ver "${GITREF:-HEAD}" BUILD_ARCH="${BUILD_ARCH:-$SPEC_ARCH}" diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index ecc0a41e29c9..2386a3054867 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -93,6 +93,30 @@ export KERNEL_DIST= # Only used for make-release export KERNEL_PREV_RELREASE_TAG= +# Get the tag of a git ref, if the git ref itself is a valid tag, just return itself +# else, search latest tag before this git ref. +_get_last_git_tag_of() { + local gitref=$1; shift + local last_tag tag + local tagged + + for tag in $(git "$@" tag --points-at "$gitref"); do + tagged=1 + last_tag="$tag" + if [[ "$last_tag" == "$gitref" ]]; then + break + fi + done + + if [[ -z "$last_tag" ]]; then + tagged=0 + last_tag=$(git "$@" describe --tags --abbrev=0 "$gitref" 2>/dev/null) + fi + + echo "$last_tag" + return $tagged +} + # $1: git tag or git commit, defaults to HEAD # $2: kernel source tree, should be a git repo get_kernel_code_version() { @@ -133,6 +157,7 @@ _first_merge_window_detection() { local gitref=${1:-HEAD} local repo=${2:-$TOPDIR} local upstream_base upstream_lasttag upstream_gitdesc + local tagged # If KSUBLEVEL or KEXTRAVERSION is set, it's not in the first merge window of a major release [[ $KSUBLEVEL -eq 0 ]] || return 1 @@ -142,14 +167,15 @@ _first_merge_window_detection() { # 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) + upstream_lasttag=$(_get_last_git_tag_of "$upstream_base" -C "$repo") + tagged=$? 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 + [[ "$tagged" -eq 1 ]]; then # Then it's in first merge window return 0 fi @@ -255,7 +281,7 @@ get_kernel_git_version() local upstream=${3:-"@{u}"} local last_tag release_tag release_info git_desc - local tag + local tag tagged # Get current commit's snapshot name, format: YYYYMMDDgit, # or YYYYMMDD (Only if repo is missing, eg. running this script with tarball) @@ -273,7 +299,8 @@ get_kernel_git_version() fi # Get latest git tag of this commit - last_tag=$(git -C "$repo" describe --tags --abbrev=0 "$gitref" 2>/dev/null) + last_tag=$(_get_last_git_tag_of "$gitref" -C "$repo") + tagged=$? # 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 @@ -318,7 +345,7 @@ get_kernel_git_version() KGIT_SUB_RELEASE_NUM=0 fi - if [[ "$release_tag" == "$git_desc" ]]; then + if [[ "$tagged" -eq 1 ]] && [[ "$release_tag" == "$last_tag" ]]; 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 -- Gitee From df311f946a66a70dbbf8619ec1ce9309f311c712 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 20 Dec 2022 20:53:37 +0800 Subject: [PATCH 06/24] dist: add script option to reset repo metadata Upstream: no Signed-off-by: Kairui Song --- dist/scripts/helper/dist-repo-init.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/scripts/helper/dist-repo-init.sh b/dist/scripts/helper/dist-repo-init.sh index 3e1d5bbd201a..0ebdf301431c 100755 --- a/dist/scripts/helper/dist-repo-init.sh +++ b/dist/scripts/helper/dist-repo-init.sh @@ -26,6 +26,21 @@ KMAKEFILE_CONTENT="" die "Dist files are not properly configured, aborting." } +if [[ $1 == "--reset" ]]; then + ### Clean up changelog + echo -n > "$DISTDIR"/templates/changelog + + ### Clean up kABI + for i in $SPEC_ARCH; do + echo -n > "$DISTDIR"/kabi/Module.kabi_$i + done + + ### Clean up generic-default config + echo -n > "$DISTDIR"/configs/00base/generic/default.config + for i in $SPEC_ARCH; do + echo -n > "$DISTDIR"/configs/00base/generic/$i.config + done +fi ### Patch .gitignore grep -qF "# ${VENDOR_CAPITALIZED:+${VENDOR_CAPITALIZED} }dist files" "$TOPDIR/.gitignore" || { -- Gitee From d688923939536769e536ca1f7a457a8c4406c54e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 21 Dec 2022 17:16:10 +0800 Subject: [PATCH 07/24] dist: fix code typo of target dist-install-buildrequires Upstream: no Signed-off-by: Kairui Song --- dist/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/Makefile b/dist/Makefile index 34c56012189a..6866ba3d4c42 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -229,8 +229,8 @@ dist-check-buildrequires: $(SPECFILE) dist-install-buildrequires: $(SPECFILE) @if [ -n "$(MISSINGDEPS)" ]; then \ - echo "Installing kernel build dependency "$(MISSINGDEPS)" using yum..." \ - echo "Missing dependency packages: $(MISSINGDEPS)..."; \ + 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; \ -- Gitee From 58545f2f47af5ca0dfb50f10a4c5a1dfefa3a6ba Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 20 Dec 2022 20:27:24 +0800 Subject: [PATCH 08/24] dist: add support for loongarch64 Upstream: no Signed-off-by: Kairui Song --- dist/scripts/lib.sh | 6 ++++++ dist/sources/filter-modules.sh | 2 ++ dist/templates/kernel.template.spec | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/dist/scripts/lib.sh b/dist/scripts/lib.sh index 2bc6cbdd9b9b..a6848b6c23db 100755 --- a/dist/scripts/lib.sh +++ b/dist/scripts/lib.sh @@ -101,6 +101,9 @@ get_kernel_arch () { riscv64 ) echo "riscv" ;; + loongarch64 ) + echo "loongarch64" + ;; arm64 | aarch64 ) echo "arm64" ;; @@ -119,6 +122,9 @@ get_kernel_arch () { # source code base sub path in arch/ get_kernel_src_arch () { case $1 in + loongarch64 ) + echo "loongarch" + ;; riscv64 ) echo "riscv" ;; diff --git a/dist/sources/filter-modules.sh b/dist/sources/filter-modules.sh index 8f6d66892669..0700bac47b19 100755 --- a/dist/sources/filter-modules.sh +++ b/dist/sources/filter-modules.sh @@ -135,6 +135,8 @@ case $ARCH in ;; riscv64 ) ;; + loongarch64 ) + ;; x86_64 ) ;; * ) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index 323d33323cfb..a758f9807036 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -750,6 +750,10 @@ InstKernelBasic() { install -m 644 $_KernBuild/arch/x86/boot/bzImage vmlinuz %endif + %ifarch loongarch64 + install -m 644 $_KernBuild/vmlinuz vmlinuz + %endif + install -m 644 vmlinuz %{buildroot}/boot/vmlinuz-$KernUnameR sha512hmac %{buildroot}/boot/vmlinuz-$KernUnameR | sed -e "s,%{buildroot},," > .vmlinuz.hmac -- Gitee From c6c451e6f150c3a41d10bc6608e16ea6e8d5ce75 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 21 Dec 2022 17:40:07 +0800 Subject: [PATCH 09/24] dist: skip btf dump if bpftool doesn't support it Upstream: no Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index a758f9807036..b6826a31a8c3 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -614,10 +614,13 @@ BuildKernel() { %{host_make} -C $_KernSrc/tools/bpf/bpftool/ VMLINUX_BTF= VMLINUX_H= # Prefer to extract the vmlinux.h from the vmlinux that were just compiled # fallback to use host's vmlinux - if grep -q "CONFIG_DEBUG_INFO_BTF=y" ".config"; then - $_KernSrc/tools/bpf/bpftool/bpftool btf dump file vmlinux format c > $_KernVmlinuxH - else - $_KernSrc/tools/bpf/bpftool/bpftool btf dump file /sys/kernel/btf/vmlinux format c > $_KernVmlinuxH + # Skip this if bpftools is too old and doesn't support BTF dump + if $_KernSrc/tools/bpf/bpftool/bpftool btf help 2>&1 | grep -q "\bdump\b"; then + if grep -q "CONFIG_DEBUG_INFO_BTF=y" ".config"; then + $_KernSrc/tools/bpf/bpftool/bpftool btf dump file vmlinux format c > $_KernVmlinuxH + else + $_KernSrc/tools/bpf/bpftool/bpftool btf dump file /sys/kernel/btf/vmlinux format c > $_KernVmlinuxH + fi fi %{host_make} -C $_KernSrc/tools/bpf/bpftool/ clean fi -- Gitee From ba4ef61b784a122ffc84584972a971339a2883a8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 25 Dec 2022 18:14:36 +0800 Subject: [PATCH 10/24] dist: support using same build/src path during rpmbuild by default Upstream: no The split was inherited from TK4, but it breaks older/third part kernel repos. Keep it by default since it does make the build progress cleaner. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index b6826a31a8c3..d9e8e0cd5f0a 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -456,7 +456,7 @@ This package provides debug information for the bpftool package. ### Prepare common build vars to share by %%prep, %%build and %%install section # _KernSrc: Path to kernel source, located in _buildir -# _KernBuild: Path to the built kernel objects, located in _buildir +# _KernBuild: Path to the built kernel objects, could be same as $_KernSrc (just like source points to build under /lib/modules/) # _KernVmlinuxH: path to vmlinux.h for BTF, located in _buildir # KernUnameR: Get `uname -r` output of the built kernel # KernExtVer: Kernel EXTRAVERSION plus debug/kasan/syzkaller marker @@ -554,9 +554,9 @@ sed -i "/^SUBLEVEL/cSUBLEVEL = $(echo %{kernel_majver} | cut -d '.' -f 3)" $_Ker BuildConfig() { mkdir -p $_KernBuild pushd $_KernBuild - cp $1 .config - echo "include $_KernSrc/Makefile" > Makefile + + [ "$_KernBuild" != "$_KernSrc" ] && echo "include $_KernSrc/Makefile" > Makefile # Ensures build-ids are unique to allow parallel debuginfo sed -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"$KernUnameR\"/" .config -- Gitee From 505fafa2ced49d1af56bfd8cd5917d08899c84ec Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 27 Dec 2022 17:36:38 +0800 Subject: [PATCH 11/24] dist: replace all '-' with '.' Upstream: no There is a code error that only first '-' is converted to '.'. Fix it. Signed-off-by: Kairui Song --- dist/scripts/lib-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index 2386a3054867..2e5032df2263 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -235,7 +235,7 @@ _get_rel_info_from_tag() { fi if [[ $rel ]]; then - echo "${rel/-/.}" + echo "${rel//-/.}" fi } -- Gitee From 062c0bc4ad639c795151d3484b0e5a44b6632a3f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 27 Dec 2022 19:24:18 +0800 Subject: [PATCH 12/24] dist: simplify _get_rel_info_from_tag Upstream: no Move the '-' to '.' convert to top of the function so redundant '-' related code can be dropped. Signed-off-by: Kairui Song --- dist/scripts/lib-version.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index 2e5032df2263..d6e8c773fb57 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -189,6 +189,7 @@ _first_merge_window_detection() { # Get release info from git tag _get_rel_info_from_tag() { local tag=$1 rel ret=0 + local kextraversion=${KEXTRAVERSION#-} if [[ $tag == *"$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"* ]]; then rel=${tag#*"$KVERSION.$KPATCHLEVEL.$KSUBLEVEL"} @@ -199,10 +200,9 @@ _get_rel_info_from_tag() { else return 1 fi - rel=${rel#-} - rel=${rel#.} - local kextraversion=${KEXTRAVERSION#-} + rel=${rel//-/.} + rel=${rel#.} if [[ -z "$kextraversion" ]]; then # If previous KEXTRAVERSION is not empty but now empty, @@ -212,7 +212,7 @@ _get_rel_info_from_tag() { elif [ "$kextraversion" -eq "$kextraversion" ] &>/dev/null; then case $rel in # Extra version is release number, ok - $kextraversion | "$kextraversion."* | "$kextraversion-"* ) ;; + $kextraversion | "$kextraversion."* ) ;; * ) return 1; ;; esac else @@ -222,11 +222,9 @@ _get_rel_info_from_tag() { $kextraversion ) rel="" ;; - # Plain version tag plus suffix, eg. 5.17-rc3-* - "$kextraversion."* | "$kextraversion-"* ) - rel=${rel#$kextraversion} - rel=${rel#-} - rel=${rel#.} + # Plain version tag plus suffix, eg. 5.17-rc3.* + "$kextraversion."* ) + rel=${rel#$kextraversion.} ;; # Extra tag, eg 5.17-1.rc3* *".$kextraversion"* | *"-$kextraversion"* ) ;; @@ -234,9 +232,7 @@ _get_rel_info_from_tag() { esac fi - if [[ $rel ]]; then - echo "${rel//-/.}" - fi + echo "$rel" } _search_for_release_tag() { -- Gitee From c8127b4f22251672b73040d06fe5d48b359a0462 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Dec 2022 09:37:17 +0800 Subject: [PATCH 13/24] dist: support retrieving variable from a git commit Upstream: no Support retrieving a variable from git commit, eg. get value from the dist/Makefile checked out from a git commit/tag. Signed-off-by: Kairui Song --- dist/scripts/lib.sh | 57 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/dist/scripts/lib.sh b/dist/scripts/lib.sh index a6848b6c23db..0e921b4b6b31 100755 --- a/dist/scripts/lib.sh +++ b/dist/scripts/lib.sh @@ -47,20 +47,59 @@ die() { exit 1 } +# $1: relative dir path +# $2: optional git ref, if not set current worktree is used +# $3: optional git repo +ls_repo_dir() { + local _path=$1 + local _gitref=$2 + local _repo=${3:-$TOPDIR} + local _gitshow + + # If git reference is set and git repo is valid, try use the versioned Makefile + if [[ "$_gitref" ]]; then + if _gitshow=$(git -C "$_repo" show "$_gitref:$_path" 2>/dev/null); then + echo "$_gitshow" | tail -n +3 + return 0 + fi + warn "Failed to ls '$_path' from git reference '$_gitref', using current worktree as build source." + fi + + ls -1ap "$_repo/$_path/" +} + +# $1: relative file path +# $2: optional git ref, if not set current worktree is used +# $3: optional git repo +cat_repo_file() { + local _path=$1 + local _gitref=$2 + local _repo=${3:-$TOPDIR} + + # If git reference is set and git repo is valid, try use the versioned Makefile + if [[ "$_gitref" ]]; then + if git -C "$_repo" show "$_gitref:$_path" 2>/dev/null; then + return 0 + fi + warn "Failed to retrive '$_path' from git reference '$_gitref', using current worktree as build source." + fi + + cat $_repo/$1 +} + +# $1: keyword +# $2: optional git ref, if not set current Makefile is used +# $3: optional git repo get_dist_makefile_var() { - local _lib_source=${BASH_SOURCE[0]} + local _sedexp="/^$1\s*:?=\s*(.*)/{s/^\s*^$1\s*:?=\s*//;h};\${x;p}" + local _gitref=$2 + local _repo=${3:-$TOPDIR} 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") - + _val=$(cat_repo_file "dist/Makefile" | sed -nE -e "$_sedexp") case $_val in *\$* ) - die "Can't parse Makefile variable '$1', which references to other variables." + die "Can't parse Makefile variable '$1', it references to other variables." ;; esac -- Gitee From 37fbf45036f577681a7113b5c4f940074049bf72 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Dec 2022 12:13:29 +0800 Subject: [PATCH 14/24] dist: fix initramfs build order with -core and -modules package Upstream: no When kernel-modules package is installed separately, it need to rebuild the iniramfs. If it's installed together with kernel-core, it should avoid the redundant build. Use rpm-state to track it. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index d9e8e0cd5f0a..8e0893a0b329 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -1040,6 +1040,9 @@ if command -v uname > /dev/null; then fi fi +%post core +touch %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.installing_core + %posttrans core # Weak modules if command -v weak-modules > /dev/null; then @@ -1079,6 +1082,8 @@ fi # Just in case kernel-install didn't depmod depmod -A %{kernel_unamer} +# Core install done +rm -f %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.installing_core %preun core # Boot entry and depmod files @@ -1098,6 +1103,15 @@ fi ### Module package %post modules depmod -a %{kernel_unamer} +if [ ! -f %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.installing_core ]; then + touch %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.need_to_run_dracut +fi + +%posttrans modules +if [ -f %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.need_to_run_dracut ]; then\ + dracut -f --kver "%{kernel_unamer}" + rm -f %{_localstatedir}/lib/rpm-state/%{rpm_name}-%{rpm_version}-%{rpm_release}%{?dist}.need_to_run_dracut +fi %postun modules depmod -a %{kernel_unamer} -- Gitee From 1baae1f1c78f84affab37475006a58759e0d25ca Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Dec 2022 13:36:21 +0800 Subject: [PATCH 15/24] dist: provide kernel-uname-r package Upstream: no Some third part package requires this. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index 8e0893a0b329..f8202a249d41 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -227,6 +227,7 @@ This is the meta package of %{?rpm_vendor:%{rpm_vendor} }Linux kernel, the core Summary: %{rpm_vendor} Linux Kernel Provides: installonlypkg(kernel) Provides: kernel-core = %{version}-%{release} +Provides: kernel-uname-r = %{kernel_unamer} Requires(pre): coreutils Requires(post): coreutils kmod dracut Requires(preun): coreutils kmod -- Gitee From 782b6ef3e4b414feb7dfa1e89988e90ecc830c55 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 30 Dec 2022 00:40:43 +0800 Subject: [PATCH 16/24] dist: fix filter-modules.sh Upstream: no Fix the for loop, files need to be moved one by one or the later depmod check will be useless. Signed-off-by: Kairui Song --- dist/sources/filter-modules.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/sources/filter-modules.sh b/dist/sources/filter-modules.sh index 0700bac47b19..ea98a88c8015 100755 --- a/dist/sources/filter-modules.sh +++ b/dist/sources/filter-modules.sh @@ -53,7 +53,7 @@ MODULEPKG=$5 MODULE_DIR=lib/modules/$KERNEL_UNAMER error() { - echo "filter-modules.sh: $@">&2 + echo "filter-modules.sh: $*" >&2 } if ! cd "$BASE_DIR"; then @@ -107,7 +107,7 @@ filter_override() { # args: moduled to be spliited out check_modules_dependency_after_split() { # Mask external mods to do a depmod check - for mod in "$modules_list"; do + for mod in $modules_list; do mv "$mod" "$mod.bak" done @@ -120,7 +120,7 @@ check_modules_dependency_after_split() { fi # Move the mods back - for mod in "$modules_list"; do + for mod in $modules_list; do mv "$mod.bak" "$mod" done } -- Gitee From 10d4343e788fdb5bf7e0197b538fb25b33d5d5db Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Jan 2023 11:08:09 +0800 Subject: [PATCH 17/24] dist: correct installonly usage and meta info Upstream: no Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index f8202a249d41..fe10d392c7fa 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -211,6 +211,8 @@ AutoReq: no AutoProv: yes # Kernel requirements +# installonlypkg(kernel) is a hint for RPM that this package shouldn't be auto-cleaned. +Provides: installonlypkg(kernel) Provides: kernel = %{version}-%{release} Provides: %{rpm_name} = %{version}-%{release} Requires: %{rpm_name}-core = %{version}-%{release} @@ -222,7 +224,6 @@ This is the meta package of %{?rpm_vendor:%{rpm_vendor} }Linux kernel, the core %if %{with_core} ### Kernel core package -# installonlypkg(kernel) is a hint for RPM that this package shouldn't be auto-cleaned. %package core Summary: %{rpm_vendor} Linux Kernel Provides: installonlypkg(kernel) @@ -266,10 +267,10 @@ This package provides commonly used kernel modules for the %{?2:%{2}-}core kerne %package devel Summary: Development package for building kernel modules to match the %{version}-%{release} kernel Release: %{release} -Provides: installonlypkg(kernel-devel) +Provides: installonlypkg(kernel) Provides: kernel-devel = %{version}-%{release} Provides: kernel-devel-%{_target_cpu} = %{version}-%{release} -Provides: kernel-devel-uname-r = %{version}-%{release} +Provides: kernel-devel-uname-r = %{kernel_unamer} AutoReqprov: no %description devel This package provides kernel headers and makefiles sufficient to build modules @@ -280,7 +281,7 @@ against the %{version}-%{release} kernel package. %package debuginfo Summary: Debug information for package %{rpm_name} Requires: %{rpm_name}-debuginfo-common-%{_target_cpu} -Provides: installonlypkg(kernel-debuginfo) +Provides: installonlypkg(kernel) Provides: kernel-debuginfo = %{version}-%{release} AutoReqProv: no %description debuginfo @@ -304,7 +305,7 @@ This is required to use SystemTap with %{rpm_name}. ### Common debuginfo package %package debuginfo-common-%{_target_cpu} Summary: Kernel source files used by %{rpm_name}-debuginfo packages -Provides: installonlypkg(kernel-debuginfo-common) +Provides: installonlypkg(kernel) Provides: kernel-debuginfo-common = %{version}-%{release} %description debuginfo-common-%{_target_cpu} This package is required by %{rpm_name}-debuginfo subpackages. -- Gitee From 0693ae376013954226f59f74ab34cfae1a832c32 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 29 Dec 2022 14:28:57 +0800 Subject: [PATCH 18/24] dist: fix a rare corner case when HEAD is tagged multiple time Upstream: no If HEAD is tagged multiple times with valid and invalid tags, prefer the valid tags. Signed-off-by: Kairui Song --- dist/scripts/lib-version.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index d6e8c773fb57..b16f504fee82 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -103,7 +103,12 @@ _get_last_git_tag_of() { for tag in $(git "$@" tag --points-at "$gitref"); do tagged=1 last_tag="$tag" - if [[ "$last_tag" == "$gitref" ]]; then + if [[ "$tag" == "$gitref" ]]; then + break + fi + # If HEAD is tagged with multiple tags and user is not asking to use one of them, + # use the first one found matching release info. + if [[ "$gitref" == HEAD ]] && _get_rel_info_from_tag "$tag" > /dev/null; then break fi done -- Gitee From 427ea5770d4b4d246df7248ae120e1ec317b9dac Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Jan 2023 01:40:48 +0800 Subject: [PATCH 19/24] dist: make check-tag.sh print more useful info for invalid tag Upstream: no Invalid tag can still build, just it can't make a release. So print more useful info for such tag. Signed-off-by: Kairui Song --- dist/scripts/check-tag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/scripts/check-tag.sh b/dist/scripts/check-tag.sh index 5d7220641e13..dbf3c29b6ad8 100755 --- a/dist/scripts/check-tag.sh +++ b/dist/scripts/check-tag.sh @@ -12,8 +12,8 @@ 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'" + warn "Invalid tag, will override with Kernel uname-r '$KERNEL_UNAMER', RPM NVR version '${KERNEL_NAME}-${KERNEL_MAJVER}-${KERNEL_RELVER}'" exit 1 else - info "Tag '$KTAGRELEASE' OK, Kernel version '$KERNEL_UNAMER', RPM version '${KERNEL_MAJVER//-/.}-${KERNEL_RELVER//-/.}'" + info "Tag '$KTAGRELEASE' OK, Kernel uname-r '$KERNEL_UNAMER', RPM NVR version '${KERNEL_NAME}-${KERNEL_MAJVER}-${KERNEL_RELVER}'" fi -- Gitee From 25f801115e7cb6ceb811ce48a34697c588b18f4c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Jan 2023 00:45:00 +0800 Subject: [PATCH 20/24] dist: allow override KDIST for a one time build Upstream: no Make it possible to use: make KDIST= dist-rpm/dist-srpm To override KDIST for a one time build. Also rename DISTRO= to DIST=, which is easier to memorize. Signed-off-by: Kairui Song --- dist/Makefile | 15 +++++++++------ dist/scripts/gen-spec.sh | 4 ++-- dist/scripts/get-version.sh | 20 ++++++++++++++++---- dist/scripts/lib-version.sh | 36 +++++++++++++++++++++++------------- dist/scripts/lib.sh | 6 ++++-- 5 files changed, 54 insertions(+), 27 deletions(-) diff --git a/dist/Makefile b/dist/Makefile index 6866ba3d4c42..958d85a02aca 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -16,6 +16,8 @@ endif ### Downstream marker, update this when forking to another downstream KDIST = stable +### NOTE: This export only applies to sub targets, for global commands, export KDIST explicitly in shell. +export KDIST := $(KDIST) ### Vendor mark VENDOR = opencloudos @@ -72,8 +74,8 @@ TAG := $(COMMIT) GITREF := $(TAG) ### Build files -KFULLVER := $(shell $(DISTDIR)/scripts/get-version.sh $(GITREF)) -CONFIGFILE := $(shell $(DISTDIR)/scripts/ls-config-files.sh $(CONFIG)) +KFULLVER := $(shell KDIST=$(KDIST) $(DISTDIR)/scripts/get-version.sh $(GITREF) vr) +CONFIGFILE := $(shell KDIST=$(KDIST) $(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 @@ -123,9 +125,9 @@ 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)") +ifneq ($(DIST),) +override RPMFLAGS := --define "dist .$(DIST)" $(RPMFLAGS) +$(info "NOTE: DIST is set, building for another distro $(DIST)") $(info " You shoudn't do this unless you know what you are doing.") endif @@ -179,7 +181,8 @@ dist-sources: dist-configs $(TARFILE) $(DISTSOURCES) $(DISTKABIS) $(SPECFILE) define DO_RPMBUILD @echo "=== DISTBUILD ===" -@echo "Building kernel: $(KFULLVER)" +@echo "Building kernel: $(shell rpmspec -q --qf "%{name}-%{version}-%{release}\n" --srpm $(SPECFILE))" +@echo "Kernel uname-r: $(shell rpmspec -q --provides $(SPECFILE) | grep kernel-uname-r | awk -F ' = ' '{print $$2}')" @echo "Config style: $(CONFIG)" @echo "RPM build flags: $(1)" @echo "=== RPMBULID ===" diff --git a/dist/scripts/gen-spec.sh b/dist/scripts/gen-spec.sh index 922aadeab540..54ba9c0f714f 100755 --- a/dist/scripts/gen-spec.sh +++ b/dist/scripts/gen-spec.sh @@ -58,10 +58,10 @@ prepare_kernel_ver "${GITREF:-HEAD}" BUILD_ARCH="${BUILD_ARCH:-$SPEC_ARCH}" -RPM_NAME="kernel${KERNEL_VARIANT:+-$KERNEL_VARIANT}${KERNEL_DIST:+-$KERNEL_DIST}" +RPM_NAME="kernel${KERNEL_VARIANT:+-$KERNEL_VARIANT}${KDIST:+-$KDIST}" RPM_VERSION=${KERNEL_MAJVER//-/.} RPM_RELEASE=${KERNEL_RELVER//-/.} -RPM_RELEASE=${RPM_RELEASE%".$KERNEL_DIST"} +RPM_RELEASE=${RPM_RELEASE%".$KDIST"} RPM_VENDOR=$(get_dist_makefile_var VENDOR_CAPITALIZED) RPM_URL=$(get_dist_makefile_var URL) diff --git a/dist/scripts/get-version.sh b/dist/scripts/get-version.sh index 047c0db79e9e..c49f7de28324 100755 --- a/dist/scripts/get-version.sh +++ b/dist/scripts/get-version.sh @@ -2,10 +2,22 @@ # SPDX-License-Identifier: GPL-2.0 # # Print out the tkernel version based on git commit and work tree. - +# +# $1: git reference, tag or commit +# $2: version type, 'nvr' or 'unamer', defaults to 'unamer' +# # shellcheck source=./lib-version.sh . "$(dirname "$(realpath "$0")")/lib-version.sh" -prepare_kernel_ver "$@" - -echo "$KERNEL_UNAMER" +prepare_kernel_ver "$1" +case $2 in + vr ) + echo "$KERNEL_MAJVER"-"$KERNEL_RELVER" + ;; + nvr ) + echo "$KERNEL_NAME"-"$KERNEL_MAJVER"-"$KERNEL_RELVER" + ;; + * | unamer ) + echo "$KERNEL_UNAMER" + ;; +esac diff --git a/dist/scripts/lib-version.sh b/dist/scripts/lib-version.sh index b16f504fee82..7b37d43bcb47 100755 --- a/dist/scripts/lib-version.sh +++ b/dist/scripts/lib-version.sh @@ -46,9 +46,6 @@ KPATCHLEVEL= KSUBLEVEL= KEXTRAVERSION= -# Kernel dist release (eg. /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 @@ -127,10 +124,9 @@ _get_last_git_tag_of() { get_kernel_code_version() { local gitref=${1:-HEAD} local repo=${2:-$TOPDIR} - local makefile dist_makefile + local 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" @@ -152,8 +148,8 @@ get_kernel_code_version() { KRCRELEASE=1 fi - KDIST=$(sed -nE '/^KDIST\s*:?=\s*/{s///;p;q}' <<< "$dist_makefile") - KERNEL_DIST="$KDIST" + # Read KDIST using gitref for historical accurate value. + KERNEL_DIST=$(get_dist_makefile_var KDIST "$gitref" "$repo") return 0 } @@ -237,6 +233,22 @@ _get_rel_info_from_tag() { esac fi + # If KERNEL_DIST is added as prefix/semi-prefix/suffix, remove it from rel + if [[ $KERNEL_DIST ]]; then + case $rel in + $KERNEL_DIST.*) + rel=${rel#$KERNEL_DIST.} + ;; + $kextraversion.$KERNEL_DIST.*) + rel=${rel#$kextraversion.$KERNEL_DIST.} + rel=$kextraversion.$rel + ;; + *.$KERNEL_DIST) + rel=${rel%.$KERNEL_DIST} + ;; + esac + fi + echo "$rel" } @@ -317,8 +329,6 @@ get_kernel_git_version() 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." \ @@ -495,8 +505,8 @@ prepare_next_kernel_ver() { fi KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL" - KERNEL_RELVER="$krelease${KDIST:+.$KDIST}" - KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER" + KERNEL_RELVER="$krelease" + KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER${KDIST:+.$KDIST}" } # Get next formal kernel version based on previous git tag @@ -519,6 +529,6 @@ prepare_next_sub_kernel_ver() { fi KERNEL_MAJVER="$KVERSION.$KPATCHLEVEL.$KSUBLEVEL" - KERNEL_RELVER="$krelease${KDIST:+.$KDIST}" - KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER" + KERNEL_RELVER="$krelease" + KERNEL_UNAMER="$KERNEL_MAJVER-$KERNEL_RELVER${KDIST:+.$KDIST}" } diff --git a/dist/scripts/lib.sh b/dist/scripts/lib.sh index 0e921b4b6b31..f9af8f494c5e 100755 --- a/dist/scripts/lib.sh +++ b/dist/scripts/lib.sh @@ -84,14 +84,14 @@ cat_repo_file() { warn "Failed to retrive '$_path' from git reference '$_gitref', using current worktree as build source." fi - cat $_repo/$1 + cat "$_repo"/"$1" } # $1: keyword # $2: optional git ref, if not set current Makefile is used # $3: optional git repo get_dist_makefile_var() { - local _sedexp="/^$1\s*:?=\s*(.*)/{s/^\s*^$1\s*:?=\s*//;h};\${x;p}" + local _sedexp="/^$1\s*[:?]?=\s*(.*)/{s/^\s*^$1\s*[:?]?=\s*//;h};\${x;p}" local _gitref=$2 local _repo=${3:-$TOPDIR} local _val @@ -113,6 +113,8 @@ get_dist_makefile_var() { [ "$DISTDIR" ] || DISTDIR=$TOPDIR/$DISTPATH [ "$SOURCEDIR" ] || SOURCEDIR=$DISTDIR/rpm/SOURCES [ "$SPEC_ARCH" ] || SPEC_ARCH=$(get_dist_makefile_var SPEC_ARCH) +# If KDIST is not set (or it's set to "-" wnich is illegal value for KDIST), read from dist Makefile. +[ "${KDIST--}" == - ] && KDIST=$(get_dist_makefile_var KDIST) if ! [ -s "$TOPDIR/Makefile" ]; then echo "Dist tools can only be run within a valid Linux Kernel git workspace." >&2 -- Gitee From caea89b0b08660b7c88e501d4d5026905186b418 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 8 Dec 2022 15:55:56 +0800 Subject: [PATCH 21/24] ceph: fix memory out of bound on module load Upstream: no A ctl_table wasn't cloesed properly, and lead to memory out of bound, just fix it. Fixes: 796cc40e87bf ('ceph: add sysctl to ignore error epoch barrier') Signed-off-by: Kairui Song --- net/ceph/ceph_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 9a8de6ef451a..8e9964b7ec6b 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -810,6 +810,7 @@ static struct ctl_table ceph_table[] = { .mode = 0644, .proc_handler = proc_douintvec_minmax, }, + {} }; static struct ctl_table ceph_dir_table[] = { -- Gitee From c108d693ade389d31d74c21267fcbf93c7671e50 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Jan 2023 16:33:51 +0800 Subject: [PATCH 22/24] Revert "dist: tk4: add the function of disabling selinux" Upstream: no This reverts commit 83267df9d18d1bdac697b4bfef502a5f78dd154a. Don't disable SELINUX if previous kernel have it disabled. This commit was introduced to avoid boot failure (some systems have flawed SELINUX rule and will fail once kernel enable it). We assume OC8 won't suffer from such problem so drop this workaround. Signed-off-by: Kairui Song --- dist/templates/kernel.template.spec | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index fe10d392c7fa..9bf560f03a3e 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -1059,29 +1059,6 @@ elif command -v new-kernel-pkg > /dev/null; then else echo "NOTICE: No available kernel install handler found. Please make sure boot loader and initramfs are properly configured after the installation." > /dev/stderr fi - -# If match, the selinux will be disabled. -is_set_selinux=0 -if [ -e /proc/config.gz ]; then - zcat /proc/config.gz | grep -q "^CONFIG_SECURITY_SELINUX=y" - is_set_selinux=$? -elif [ -e /boot/config-$(uname -r) ]; then - cat /boot/config-$(uname -r) | grep -q "^CONFIG_SECURITY_SELINUX=y" - is_set_selinux=$? -elif [ -e /proc/kallsyms ]; then - cat /proc/kallsyms | grep -q " selinux_init$" - is_set_selinux=$? -else - echo "Ignore selinux adjustments" -fi - -# if CONFIG_SECURITY_SELINUX is not set, we should disable selinux. -[ $is_set_selinux -ne 0 ] && { - echo "Selinux is not supported by current running kernel, disabling SELinux globally to avoid potential system failure." - echo "Please update /etc/selinux/config manually after testing SELinux functionality. Now setting SELINUX=disabled" - grep -q "^SELINUX *= *.*$" /etc/selinux/config && sed -ri "s/^ *SELINUX *= *enforcing *$/SELINUX=disabled/" /etc/selinux/config || echo "SELINUX=disabled" >> /etc/selinux/config -} - # Just in case kernel-install didn't depmod depmod -A %{kernel_unamer} # Core install done -- Gitee From 2c49a9b099dc693a594d20a206d54f15d6f72589 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Jan 2023 15:55:37 +0800 Subject: [PATCH 23/24] pci: drop the legacy boot delay Upstream: no Nowadays udev rules are capable of naming the devices in unique ways and all userspace utilities should use persistent naming of devices, using boot delay to stablize the device order is not a good idea. Signed-off-by: Kairui Song --- drivers/pci/pci-driver.c | 42 +--------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index c353c5bfad87..5ea612a15550 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -26,8 +26,6 @@ struct pci_dynid { struct pci_device_id id; }; -static int network_strict_sort; - /** * pci_add_dynid - add a new PCI device ID to this driver and re-probe devices * @drv: target pci driver @@ -366,32 +364,6 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, return error; } -#define STORAGE_PROBE_DELAY (5*HZ) -static void -storage_probe_delay(struct device *dev) { - static long lastprobe = 0; - long delta = lastprobe + STORAGE_PROBE_DELAY - jiffies; - if(lastprobe && delta > 0 && delta < STORAGE_PROBE_DELAY) { - dev_info(dev, "probe delay %ld ms\n", delta * 1000 / HZ); - while(delta > 0) - delta = schedule_timeout_interruptible(delta); - } - lastprobe = jiffies; -} - -#define NETWORK_PROBE_DELAY (5*HZ) -static void -network_probe_delay(struct device *dev) { - static long lastprobe = 0; - long delta = lastprobe + NETWORK_PROBE_DELAY - jiffies; - if(lastprobe && delta > 0 && delta < NETWORK_PROBE_DELAY) { - dev_info(dev, "probe delay %ld ms\n", delta * 1000 / HZ); - while(delta > 0) - delta = schedule_timeout_interruptible(delta); - } - lastprobe = jiffies; -} - /** * __pci_device_probe - check if a driver wants to claim a specific PCI device * @drv: driver to call to check if it wants the PCI device @@ -409,13 +381,8 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) error = -ENODEV; id = pci_match_device(drv, pci_dev); - if (id) { - if((pci_dev->class>>16) == PCI_BASE_CLASS_STORAGE && pci_dev->vendor != 0x1af4) - storage_probe_delay(&pci_dev->dev); - if((pci_dev->class>>16) == PCI_BASE_CLASS_NETWORK && network_strict_sort) - network_probe_delay(&pci_dev->dev); + if (id) error = pci_call_probe(drv, pci_dev, id); - } } return error; } @@ -1747,10 +1714,3 @@ static int __init pci_driver_init(void) return 0; } postcore_initcall(pci_driver_init); - -static int parse_network_strict_sort(char *arg) -{ - network_strict_sort = 1; - return 0; -} -early_param("network-strict-sort", parse_network_strict_sort); -- Gitee From 770ac0524ba0f6b26b10a38686930c8712964840 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Jan 2023 16:18:16 +0800 Subject: [PATCH 24/24] config: enable IGC and DRM_VMWGFX_FBCON Upstream: no Signed-off-by: Kairui Song --- package/arm/config.default | 2 +- package/default/config.default | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package/arm/config.default b/package/arm/config.default index 684a175a44dc..1baee548f9f9 100644 --- a/package/arm/config.default +++ b/package/arm/config.default @@ -2576,7 +2576,7 @@ CONFIG_IAVF=m CONFIG_I40EVF=m # CONFIG_ICE is not set CONFIG_FM10K=m -# CONFIG_IGC is not set +CONFIG_IGC=m # CONFIG_JME is not set # CONFIG_NET_VENDOR_MARVELL is not set CONFIG_NET_VENDOR_MELLANOX=y diff --git a/package/default/config.default b/package/default/config.default index 858d11fc45f7..c8f4f42f1ef9 100644 --- a/package/default/config.default +++ b/package/default/config.default @@ -2365,7 +2365,7 @@ CONFIG_IAVF=m CONFIG_I40EVF=m # CONFIG_ICE is not set # CONFIG_FM10K is not set -# CONFIG_IGC is not set +CONFIG_IGC=m CONFIG_JME=m CONFIG_NET_VENDOR_MARVELL=y CONFIG_MVMDIO=m @@ -3290,6 +3290,7 @@ CONFIG_DRM_I915_SPIN_REQUEST=5 # CONFIG_DRM_VGEM is not set # CONFIG_DRM_VKMS is not set CONFIG_DRM_VMWGFX=m +CONFIG_DRM_VMWGFX_FBCON=y # CONFIG_DRM_GMA500 is not set # CONFIG_DRM_UDL is not set CONFIG_DRM_AST=m -- Gitee