From patchwork Sun Jan 22 14:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52EF6C25B4E for ; Sun, 22 Jan 2023 14:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbjAVOOi (ORCPT ); Sun, 22 Jan 2023 09:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbjAVOOh (ORCPT ); Sun, 22 Jan 2023 09:14:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6E6FF0A; Sun, 22 Jan 2023 06:14:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2848CB80AC6; Sun, 22 Jan 2023 14:14:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390B3C433D2; Sun, 22 Jan 2023 14:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396873; bh=UAb92+qz5f4FAlarsxoJmAqQlkj41WIegpJbo4Iliyk=; h=From:To:Cc:Subject:Date:From; b=LkGO/5gK8yhGB1ezwFoTxm/hSmjzyI2MSP4Cw/WkIh2H5yyBlsgsARWLY/7fimRuh EyopLDwPdL47fpaXVZbvApWy25rPFMk5PW2xQsV74K0GjBsRJY/lsEKqv5tPIpAYVN 0o6FLc8KHvjnaedyqa3x06l9rFtzAGqJw65neo6iJZKPDLEWMGDAzqeDbjpcEDrxKp hmO03s4QLEKKFjON8xw4L63wdoarOrUDNZq9d5h/Gm2U0VJ/Tynj05RjgaqteTpi35 wuMe5Z6IAwqIXqMcVOBunlnZvnTSuQKQTX+jupMp7yjTlK3UFSX/x3/tLhxXNBVsUB GQzsOXM7axs3g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 1/7] kbuild: do not put .scmversion into the source tarball Date: Sun, 22 Jan 2023 23:14:21 +0900 Message-Id: <20230122141428.115372-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org .scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE. In fact, deb-pkg does not rely on it any more because the generated debian/rules specifies KERNELRELEASE from the command line. Do likwise for (src)rpm-pkg, and remove this feature. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/Makefile.package | 6 ++---- scripts/package/mkspec | 6 +++--- scripts/setlocalversion | 19 +------------------ 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 525a2820976f..e84c4e8ceb8e 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -32,7 +32,7 @@ export KDEB_SOURCENAME TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \ include init io_uring ipc kernel lib mm net rust \ samples scripts security sound tools usr virt \ - .config .scmversion Makefile \ + .config Makefile \ Kbuild Kconfig COPYING $(wildcard localversion*) MKSPEC := $(srctree)/scripts/package/mkspec @@ -47,10 +47,8 @@ if test "$(objtree)" != "$(srctree)"; then \ echo >&2; \ false; \ fi ; \ -$(srctree)/scripts/setlocalversion --save-scmversion; \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \ -rm -f $(objtree)/.scmversion + --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) # rpm-pkg # --------------------------------------------------------------------------- diff --git a/scripts/package/mkspec b/scripts/package/mkspec index adab28fa7f89..d3c6701b7769 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -90,7 +90,7 @@ $S rm -f scripts/basic/fixdep scripts/kconfig/conf $S rm -f tools/objtool/{fixdep,objtool} $S $S %build -$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} +$S $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} KBUILD_BUILD_VERSION=%{release} $S %install mkdir -p %{buildroot}/boot @@ -101,8 +101,8 @@ $S %else cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE %endif -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +$M $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_MOD_PATH=%{buildroot} modules_install + $MAKE %{?_smp_mflags} KERNELRELEASE=%{version} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE cp .config %{buildroot}/boot/config-$KERNELRELEASE $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build diff --git a/scripts/setlocalversion b/scripts/setlocalversion index af4754a35e66..3b31702b4a4a 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -11,16 +11,11 @@ # usage() { - echo "Usage: $0 [--save-scmversion] [srctree]" >&2 + echo "Usage: $0 [srctree]" >&2 exit 1 } -scm_only=false srctree=. -if test "$1" = "--save-scmversion"; then - scm_only=true - shift -fi if test $# -gt 0; then srctree=$1 shift @@ -35,10 +30,6 @@ scm_version() short=false cd "$srctree" - if test -e .scmversion; then - cat .scmversion - return - fi if test "$1" = "--short"; then short=true fi @@ -103,14 +94,6 @@ collect_files() echo "$res" } -if $scm_only; then - if test ! -e .scmversion; then - res=$(scm_version) - echo "$res" >.scmversion - fi - exit -fi - if ! test -e include/config/auto.conf; then echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2 exit 1 From patchwork Sun Jan 22 14:14:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E16CC54EAA for ; Sun, 22 Jan 2023 14:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbjAVOOl (ORCPT ); Sun, 22 Jan 2023 09:14:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjAVOOj (ORCPT ); Sun, 22 Jan 2023 09:14:39 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735A6FF0A; Sun, 22 Jan 2023 06:14:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id DC2F6CE0EC5; Sun, 22 Jan 2023 14:14:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CCC5C4339E; Sun, 22 Jan 2023 14:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396875; bh=AmzoAcLy4rVEa77Srrddz7lY2JGQMKi8x97/XkEnqeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLLlojZsj6x7FqINSenhdIbYC7OHbmRHXOcA6JV2STTfF+QnTgBZL8qNlP573q0yU O+dSLE/V2X+z44PpM+BLmNKSOUEcShsLCbRgvq4mQ8qs/TOEv0gkOaLs8I1hsxdVt4 ezvO91yNvNgxD0iK5FhpnmCD+DNdLnRG4mNggGmZUJTn5QpSo51kSDdZbddndZxN+C hlFc3pU8oMygG2hJWE2XDpDxg6pA84Gd+gC7yItazOmZR/NEUhJK2EcwnynLjGXvpn 4XUlHe5NCCwsNjQAlV6taU3h7Yv6oSykSi3v9cETu+g1dxiBzzR/sR8VVofDfltGWS iym6csGpqZOWg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada Subject: [PATCH 2/7] setlocalversion: simplify the construction of the short version Date: Sun, 22 Jan 2023 23:14:22 +0900 Message-Id: <20230122141428.115372-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org With the --short option given, scm_version() prints "+". Just append it. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/setlocalversion | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 3b31702b4a4a..5cdf409204aa 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -121,8 +121,7 @@ elif [ "${LOCALVERSION+set}" != "set" ]; then # # If the variable LOCALVERSION is set (including being set # to an empty string), we don't want to append a plus sign. - scm=$(scm_version --short) - res="$res${scm:++}" + res="$res$(scm_version --short)" fi echo "$res" From patchwork Sun Jan 22 14:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82468C25B4E for ; Sun, 22 Jan 2023 14:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbjAVOOm (ORCPT ); Sun, 22 Jan 2023 09:14:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbjAVOOk (ORCPT ); Sun, 22 Jan 2023 09:14:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D7610406; Sun, 22 Jan 2023 06:14:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 96ADAB80AE0; Sun, 22 Jan 2023 14:14:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6661BC433D2; Sun, 22 Jan 2023 14:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396876; bh=SlZozu6ilR07Tjhnx/kZyFTMO+EN6Gn/UTedC9bFFfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJ0O049/CuHxs0De475Oabnp1r21608SN07nlFaFJlkyHVEzeMQ4/Z3E0P+a0z1jh NLX2aRwzUDqOP2P35CBFj7fbVuQl6mqGevmRlXVKernXyqTdyZfw12V+KoY0Moxq1Q 1DtqvrMY7zDrmiAnPD/Y2fKSs3HT9GRXaHiZHcIDI2wM1se8CEje/TrLhVtdmSjsl+ /gv789zFRyK86qCAamcAPM2sH6Afgo/Kz1VqhXY49zzC0FoIYU5HOOe8yHyTSHi+O8 aGGk9ZYGVX//PKLoXvFoGoW+C892PNj+SfnEKKEz8Cc8JejPXcxEYcnTB91nGpXZ9Q Q4n2tYDf3gNUg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada Subject: [PATCH 3/7] setlocalversion: make indentation shallower Date: Sun, 22 Jan 2023 23:14:23 +0900 Message-Id: <20230122141428.115372-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Return earlier if we are not in the correct git repository. This makes the code more readable. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/setlocalversion | 79 +++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 5cdf409204aa..b8e1018d611e 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -34,46 +34,49 @@ scm_version() short=true fi - # Check for git and a git repo. - if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && - head=$(git rev-parse --verify HEAD 2>/dev/null); then - - # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore - # it, because this version is defined in the top level Makefile. - if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then - - # If only the short version is requested, don't bother - # running further git commands - if $short; then - echo "+" - return - fi - # If we are past a tagged commit (like - # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="$(git describe 2>/dev/null)"; then - echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}' - fi - - # Add -g and exactly 12 hex chars. - printf '%s%s' -g "$(echo $head | cut -c1-12)" - fi + if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then + return + fi + + if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then + return + fi + + # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it + # because this version is defined in the top level Makefile. + if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then - # Check for uncommitted changes. - # This script must avoid any write attempt to the source tree, - # which might be read-only. - # You cannot use 'git describe --dirty' because it tries to - # create .git/index.lock . - # First, with git-status, but --no-optional-locks is only - # supported in git >= 2.14, so fall back to git-diff-index if - # it fails. Note that git-diff-index does not refresh the - # index, so it may give misleading results. See - # git-update-index(1), git-diff-index(1), and git-status(1). - if { - git --no-optional-locks status -uno --porcelain 2>/dev/null || - git diff-index --name-only HEAD - } | read dummy; then - printf '%s' -dirty + # If only the short version is requested, don't bother + # running further git commands + if $short; then + echo "+" + return fi + # If we are past a tagged commit (like + # "v2.6.30-rc5-302-g72357d5"), we pretty print it. + if atag="$(git describe 2>/dev/null)"; then + echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}' + fi + + # Add -g and exactly 12 hex chars. + printf '%s%s' -g "$(echo $head | cut -c1-12)" + fi + + # Check for uncommitted changes. + # This script must avoid any write attempt to the source tree, which + # might be read-only. + # You cannot use 'git describe --dirty' because it tries to create + # .git/index.lock . + # First, with git-status, but --no-optional-locks is only supported in + # git >= 2.14, so fall back to git-diff-index if it fails. Note that + # git-diff-index does not refresh the index, so it may give misleading + # results. + # See git-update-index(1), git-diff-index(1), and git-status(1). + if { + git --no-optional-locks status -uno --porcelain 2>/dev/null || + git diff-index --name-only HEAD + } | read dummy; then + printf '%s' -dirty fi } From patchwork Sun Jan 22 14:14:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E204CC54EED for ; Sun, 22 Jan 2023 14:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbjAVOOm (ORCPT ); Sun, 22 Jan 2023 09:14:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbjAVOOj (ORCPT ); Sun, 22 Jan 2023 09:14:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 633911027D; Sun, 22 Jan 2023 06:14:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 09F5860C27; Sun, 22 Jan 2023 14:14:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A678AC433EF; Sun, 22 Jan 2023 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396877; bh=y+Ug4suYHYeIMApo2ZM/VY4lgUs7HsilGboGF3UyoLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S8M+/49bxCSUvlkbHHFeQYPCjAx0oTxw9MI29v3hNlenmYLHrCc8ueuI8kZW9C1b+ Y8YhtCIJ+TQcdYKrpbp4AafnL51606dLNskej/AJKFXEe3YLU7JsloNheDIdJjDzxJ Rdzep00ey8GjRSuHWWskMiO1Jh1qi7H+ZESkNeHQIOX763R+cDXOBvwUCyI/CULCyi nlExDe4M8WHRDHxqAdin1ui8ewn3jYUYY8fLyEmwFp1WhPrVfRt0diF33CvSBr2dxN BhId8tgSSJPS3uX3RLtvdm+TKz/XJqS4L8PlWMEyenOc0HWCMjeAdQBHTOMFxg5F9N Pp+tjPJ3K0pIA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada Subject: [PATCH 4/7] setlocalversion: use only the correct release tag for git-describe Date: Sun, 22 Jan 2023 23:14:24 +0900 Message-Id: <20230122141428.115372-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, setlocalversion uses any annotated tag for git-describe. If we are at a tagged commit, it will not append the commit hash. $ git checkout v6.2-rc1^ $ make -s defconfig prepare $ make kernelrelease 6.1.0-14595-g292a089d78d3 $ git tag -a foo -m foo $ make kernelrelease 6.1.0 If a local tag 'foo' exists, it pretends to be a released version '6.1.0', while there are many commits on top of it. The output should be consistent irrespective of such a local tag. Pass the correct release tag to --match option of git-describe. In the mainline kernel, the SUBLEVEL is always '0' but it is omitted from the tag. version tag 6.1.0 -> v6.1 (mainline) 6.2.0-rc5 -> v6.2-rc5 (mainline, release candidate) 6.1.7 -> v6.1.7 (stable) Signed-off-by: Masahiro Yamada --- scripts/setlocalversion | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index b8e1018d611e..a4c9a61b0665 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -27,6 +27,7 @@ fi scm_version() { local short + local tag short=false cd "$srctree" @@ -42,9 +43,14 @@ scm_version() return fi - # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it - # because this version is defined in the top level Makefile. - if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then + # convert the version to a tag + # mainline kernel: 6.2.0-rc5 -> v6.2-rc5 + # stable kernel: 6.1.7 -> v6.1.7 + tag=v$(echo "${KERNELVERSION}" | sed 's/^\(.*\..*\)\.0\(.*\)$/\1\2/') + + # If we are at a tagged commit and the tag matches the version defined + # in the top level Makefile, we ignore it. + if [ -z "$(git describe --exact-match --match=$tag 2>/dev/null)" ]; then # If only the short version is requested, don't bother # running further git commands @@ -52,9 +58,9 @@ scm_version() echo "+" return fi - # If we are past a tagged commit (like - # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="$(git describe 2>/dev/null)"; then + # If we are past the release tag, we pretty print it. + # (like 6.1.0-14595-g292a089d78d3) + if atag="$(git describe --match=$tag 2>/dev/null)"; then echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}' fi @@ -102,6 +108,11 @@ if ! test -e include/config/auto.conf; then exit 1 fi +if [ -z "${KERNELVERSION}" ]; then + echo "KERNELVERSION is not set" >&2 + exit 1 +fi + # localversion* files in the build and source directory res="$(collect_files localversion*)" if test ! "$srctree" -ef .; then From patchwork Sun Jan 22 14:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15BD5C27C76 for ; Sun, 22 Jan 2023 14:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbjAVOOn (ORCPT ); Sun, 22 Jan 2023 09:14:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjAVOOl (ORCPT ); Sun, 22 Jan 2023 09:14:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 795FD113C5; Sun, 22 Jan 2023 06:14:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A36C60C35; Sun, 22 Jan 2023 14:14:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D056DC4339C; Sun, 22 Jan 2023 14:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396879; bh=9IUwo+QWRIianpkKIsxTKg2IUwJbi7Os01Md0K+GfMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P2hHapDYpEu8VY7fMIr1T3wE/FRmZnEcrE6k/V1Vm6LVNCxC35dqXP4U8xcZ9SxMG uyj18Z9o8yT07+6lbYWKsDCDpg84eR4NGdoUQ/OIk71JkIHyMsPCkv0XhCxW8FK8dk nEIZNBTarPSWqZKHEu4E/jme0kw5oxKLOoT/ernhNbEuqGsyTqElF1fZhZci9hXXIp svbUQ0brQzBphYXOyCtlMA6viyAN6K9Ms1XXdEqgdavZjtcKLaczPgZp/DFliBBlXA wu3zrLlZqsSkXSRsrinOwo7IoL0LOy/WNFeGxih2cP9t1RPhleUAzLME10ntl1dddT SJIMkdiF1vjsQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 5/7] setlocalversion: absorb $(KERNELVERSION) Date: Sun, 22 Jan 2023 23:14:25 +0900 Message-Id: <20230122141428.115372-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Print $(KERNELVERSION) in setlocalversion so that the callers get simpler. Signed-off-by: Masahiro Yamada --- Makefile | 5 ++--- scripts/setlocalversion | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ed3294c7be97..d0a95277f08a 100644 --- a/Makefile +++ b/Makefile @@ -1247,8 +1247,7 @@ vmlinux: vmlinux.o $(KBUILD_LDS) modpost # make sure no implicit rule kicks in $(sort $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)): . ; -filechk_kernel.release = \ - echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" +filechk_kernel.release = $(srctree)/scripts/setlocalversion $(srctree) # Store (new) KERNELRELEASE string in include/config/kernel.release include/config/kernel.release: FORCE @@ -2112,7 +2111,7 @@ checkstack: $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) kernelrelease: - @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" + @$(srctree)/scripts/setlocalversion $(srctree) kernelversion: @echo $(KERNELVERSION) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index a4c9a61b0665..7c7cbefa5aa4 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -113,8 +113,10 @@ if [ -z "${KERNELVERSION}" ]; then exit 1 fi +res="${KERNELVERSION}" + # localversion* files in the build and source directory -res="$(collect_files localversion*)" +res="${res}$(collect_files localversion*)" if test ! "$srctree" -ef .; then res="$res$(collect_files "$srctree"/localversion*)" fi From patchwork Sun Jan 22 14:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E40EC27C76 for ; Sun, 22 Jan 2023 14:14:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbjAVOOy (ORCPT ); Sun, 22 Jan 2023 09:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjAVOOo (ORCPT ); Sun, 22 Jan 2023 09:14:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045851A95C; Sun, 22 Jan 2023 06:14:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8DBB0B80AE1; Sun, 22 Jan 2023 14:14:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B363C433A0; Sun, 22 Jan 2023 14:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396880; bh=ndQFjq+/ARkN/T9TsVQmpqH/FBFem7P2bRf0kXnGi0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gfpg+zWBgdzmkdnkHK9/GrSCoWM3Hj9M9JV2l5W7qy8P8ImFYoKFGZuJlj5KnUOY1 /hkbB+HVpmjvhYrRj7/MlNLGcbn/UFt871v/FsOs2COBs9nrITy03kdlx59oS2bZeL BVMhNEPLfLRwALVZYlxxpSHo1trUHNj/E9we8SKFznL6BxuWB2r9m6ybhUaIkh4Mm6 VhkbSNQsaZAJsFEw6x0/U3XGx62UqqJM9Ip4s6Z5aWdjfxjwp1OyiXCHzUYGLzE05f Y1J4M7d6eCdExpo6dYqh5tKsrGhpw98scizwcvXrWLyk0uLJLNlUCRUBNnTTcrrDVp 82EFSMtcZD4yQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada Subject: [PATCH 6/7] setlocalversion: print ${KERNELRELEASE} if set Date: Sun, 22 Jan 2023 23:14:26 +0900 Message-Id: <20230122141428.115372-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When KERNELRELEASE is overridden, include/config/kernel.release still stores the string would be returned by the script if KERNELRELEASE had not been overridden. This is not strange. include/config/kernel.release should store KERNELRELEASE that was used for building the kernel. Signed-off-by: Masahiro Yamada --- scripts/setlocalversion | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 7c7cbefa5aa4..eff8cc831571 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -103,6 +103,11 @@ collect_files() echo "$res" } +if [ -n "${KERNELRELEASE}" ]; then + echo "${KERNELRELEASE}" + exit 0 +fi + if ! test -e include/config/auto.conf; then echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2 exit 1 From patchwork Sun Jan 22 14:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13111475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A23C25B4E for ; Sun, 22 Jan 2023 14:14:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjAVOOx (ORCPT ); Sun, 22 Jan 2023 09:14:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjAVOOq (ORCPT ); Sun, 22 Jan 2023 09:14:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0466D1A960; Sun, 22 Jan 2023 06:14:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84D9160C33; Sun, 22 Jan 2023 14:14:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE931C433EF; Sun, 22 Jan 2023 14:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674396881; bh=54/WoMZ8YydDCjSCHnhXruffaj7Qo/EOB9FpfM9dfE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKaHTJNU+lxxXBEbp3aV2wH/EkaNYfJE0weeBS2a9lRuj9k8T63GLvWo6LHMY2Tft oTXgc7CPLEpt92WRC5w5S8c+73JSshZYcMdQHtoCVHHdcU5SWECLLW/mKJW8L+vanI VtuiHWbP5iG6BBFnT0QLXB4fS648rna4lgLV8xGEiYtro0jyDtIpoeb7W+rj/n6kr9 itpHQkz+yqnSQsocunshqIBDu51acPdu6+dxuCXrBHNXGnMQXHypkt1kKWgWkpkLB+ 2xh0HqQuPQcz/pC7LMwtCwm4+F+EfVFIosNv67uPBjVvRWRchbqkjRhaLGnoF2Xe7D Sdos3Z3ba/ktw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 7/7] kbuild: do not re-run setlocalversion for kernelrelease Date: Sun, 22 Jan 2023 23:14:27 +0900 Message-Id: <20230122141428.115372-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230122141428.115372-1-masahiroy@kernel.org> References: <20230122141428.115372-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Revert: - 7b8ea53d7f18 ("makefile: not need to regenerate kernel.release file when make kernelrelease") - 01ab17887f4c ("Makefile: "make kernelrelease" should show the correct full kernel version") I think the original behavior was better - 'make kernelrelease' should print $(KERNELRELEASE) used in the last build, not the one that will be used in the next build. Therefore, it is an error if you run it in the pristine source tree. Signed-off-by: Masahiro Yamada --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d0a95277f08a..de402d415d5f 100644 --- a/Makefile +++ b/Makefile @@ -281,13 +281,13 @@ clean-targets := %clean mrproper cleandocs no-dot-config-targets := $(clean-targets) \ cscope gtags TAGS tags help% %docs check% coccicheck \ $(version_h) headers headers_% archheaders archscripts \ - %asm-generic kernelversion %src-pkg dt_binding_check \ + %asm-generic kernelrelease kernelversion %src-pkg dt_binding_check \ outputmakefile rustavailable rustfmt rustfmtcheck # Installation targets should not require compiler. Unfortunately, vdso_install # is an exception where build artifacts may be updated. This must be fixed. no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ - headers_install modules_install kernelrelease image_name -no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ + headers_install modules_install image_name +no-sync-config-targets := $(no-dot-config-targets) %install \ image_name single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/ @@ -1677,7 +1677,7 @@ help: @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' gtags - Generate GNU GLOBAL index' - @echo ' kernelrelease - Output the release version string (use with make -s)' + @echo ' kernelrelease - Output the release version string used in the last build (use with make -s)' @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' @echo ' image_name - Output the image name (use with make -s)' @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ @@ -2111,7 +2111,7 @@ checkstack: $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) kernelrelease: - @$(srctree)/scripts/setlocalversion $(srctree) + @echo $(or $(KERNELRELEASE),$(error kernelrelease not valid - run 'make prepare' to update it)) kernelversion: @echo $(KERNELVERSION)