Message ID | 20230215012034.403356-11-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3300382wrn; Tue, 14 Feb 2023 17:25:49 -0800 (PST) X-Google-Smtp-Source: AK7set8S+z1mr3tpBRw6JVD5gPZ9WLh0BxqIgJp2fUovPtViJI0cJST8bv61NpGw/veKFK+rqFpc X-Received: by 2002:a05:6a20:3c8c:b0:c2:addd:b508 with SMTP id b12-20020a056a203c8c00b000c2adddb508mr1079740pzj.2.1676424349285; Tue, 14 Feb 2023 17:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676424349; cv=none; d=google.com; s=arc-20160816; b=guiKmdFhv+TzPiCZjCgC/eWEQbuRAVSKByVbykGuLJfT42fcU6ylcLQNHwXSBas6jR I7lT/5g2NhHlLi7QTYevHiLlKTG9a8+c9F2pgKAj/CBVBZ8CJBd93h9KLr6uo2vCKW+/ nHfRRMkRTMpTE4+hiIxJO7CBv5/JxwW3mUoYppFyJtxCTY3Rw/WOa/NINmWtwhNCVDFS KCffuqyh6sHhD54W0G+RETyl+CJZl+CbIBqpTP7/Ieo92qT4KPV86c4ZH9jYBz0ji6wG OBMOTk7NFnhu1jwOAjGc1FrTiAIzlyHF3uhqL0sKarKN+JqRoosesNN33AmNqiV3aAVJ 4aWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1bfCTXUhzrZqKlO7dw9YIzQg+6VamE8FJ0H7m/YWrP0=; b=xnHvzy2iHPWfFAZ/ayMOgzWieyfSG+5fHeMN+W9S3gWkFJFxsFoFRVp7kfR0L2c9kE Rkpi4TkBW+Re9j67MZAwhtU8sNFM8nUzrj6av3torRv3FcGH0AY7OpHOMxSyhUgS1axp 0t8N7bjF/jUuqbjCG0Ew6svWuMpaDlfJVqOD3MxqBWHsl0vJYdkw0JfhcHYd+FkYuoM5 yZ6UJspib1x7Pm8tWzCoIqlKyWjK3PS7zQtKvJ8V/gt1qu4CQedKuhWWOR5kHiBTU0zE Ou9hYLXitOqpxPZ4c77gJ07uL96taemyDnWMLgP+evPRGQQkmfBkErXRITI24+3zy6eG mlow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qt+Wbrl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a637d54000000b004fab8543f06si3979846pgn.687.2023.02.14.17.25.32; Tue, 14 Feb 2023 17:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qt+Wbrl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233569AbjBOBWw (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 20:22:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233501AbjBOBWg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 20:22:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B9C34C12; Tue, 14 Feb 2023 17:21:53 -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 A83B86197C; Wed, 15 Feb 2023 01:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7EBC433D2; Wed, 15 Feb 2023 01:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676424112; bh=FeChVdeQN1bgxPs5mJTWw9fvEMDfbK6uQA/n72DiAws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qt+Wbrl84eyJmA99AQr0Rc42SzoZMETg5jj+aNK2ecAcg9UgANmfkOzMx0T2tyv65 ocSizuZyPfTEP/xmMxWDl4W/eloh2O5XS3oa/CfxvSxMN84fBM9z6l6xl+ij6QN5Xi vec+W3pKT/qGSrjvDAUiSrpbiJ3X9xMHrxmiZ/+aizfmYChNr2NNGmOJ0PehTYDBIB 4Kz3jnJiKsGyIt9z6zud54ybNgnKzhUW9ObsLR1Obon13/0gUN+DsA9x+L0/3al2IN 9Tf54kcEwAQBueHHZJ7zsnk+Oe6pg1eFi/rKCd4xxYpIF9rbh8bXh7Dbjd9ZkKMJys ztUvcGsY3T/EQ== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ben Hutchings <ben@decadent.org.uk>, Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu> Subject: [PATCH v6 11/12] kbuild: deb-pkg: improve the usability of source package Date: Wed, 15 Feb 2023 10:20:33 +0900 Message-Id: <20230215012034.403356-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230215012034.403356-1-masahiroy@kernel.org> References: <20230215012034.403356-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757858338421652951?= X-GMAIL-MSGID: =?utf-8?q?1757858338421652951?= |
Series |
[v6,01/12] kbuild: add a tool to list files ignored by git
|
|
Commit Message
Masahiro Yamada
Feb. 15, 2023, 1:20 a.m. UTC
Improve the source package support in case the dpkg-buildpackage is
directly used to build binary packages.
For cross-compiling, you can set CROSS_COMPILE via the environment
variable, but it is better to set it automatically - set it to
${DEB_HOST_GNU_TYPE}- if we are cross-compiling but not from the top
Makefile.
The generated source package may be carried to a different build
environment, which may have a different compiler installed.
Run olddefconfig first to set new CONFIG options to their default
values without prompting.
Take KERNELRELEASE and KBUILD_BUILD_VERSION from the version field of
debian/changelog in case it is updated afterwards.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Changes in v6:
- New patch
scripts/package/deb-build-option | 16 ++++++++++++++++
scripts/package/mkdebian | 9 ++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
create mode 100755 scripts/package/deb-build-option
Comments
On 15/02/2023 03:20, Masahiro Yamada wrote: > Improve the source package support in case the dpkg-buildpackage is > directly used to build binary packages. > > For cross-compiling, you can set CROSS_COMPILE via the environment > variable, but it is better to set it automatically - set it to > ${DEB_HOST_GNU_TYPE}- if we are cross-compiling but not from the top > Makefile. > > The generated source package may be carried to a different build > environment, which may have a different compiler installed. > Run olddefconfig first to set new CONFIG options to their default > values without prompting. > > Take KERNELRELEASE and KBUILD_BUILD_VERSION from the version field of > debian/changelog in case it is updated afterwards. I just arrived to this patch when trying to update the kernel for SOF from 6.2.0 base to 6.3.0-rc1: https://github.com/thesofproject/linux/pull/4223#issuecomment-1459997676 Our CI is building a kernel deb package from PRs to test with this command: make bindeb-pkg LOCALVERSION=-$PRIDV-default KDEB_PKGVERSION=$(make kernelversion)-$GITSHA The files, directories and the name of the deb package follows the rule set up by scripts/setlocalversion, taking into account the LOCALVERSION, CONFIG_LOCALVERSION and CONFIG_LOCALVERSION_AUTO, but the built kernel is using the version derived from KDEB_PKGVERSION and the system is not able to boot up since the modules are in a different directory then they should be. Something like this: make bindeb-pkg LOCALVERSION=-testbuild vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty /lib/modules/6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty/ strings vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty | grep 6.3 6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty Then with the KDEB_PKGVERSION: make bindeb-pkg LOCALVERSION=-testbuild KDEB_PKGVERSION=$(make kernelversion)-notworking vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty /lib/modules/6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty/ strings vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty | grep 6.3 6.3.0-rc1 in this case modprobe will not find the modules, it is looking for them under /lib/modules/6.3.0-rc1 Reverting this patch makes the created deb package usable, the system is bootable. We use the LOCALVERSION to feed in PR inforamtion and the KDEB_PKGVERSION is used fro additional information, like build ID. Do you have any suggestion on how to get the functionality back or we must stop using the KDEB_PKGVERSION altogether? Thank you,
On Wed, Mar 8, 2023 at 9:29 PM Péter Ujfalusi <peter.ujfalusi@linux.intel.com> wrote: > > > > On 15/02/2023 03:20, Masahiro Yamada wrote: > > Improve the source package support in case the dpkg-buildpackage is > > directly used to build binary packages. > > > > For cross-compiling, you can set CROSS_COMPILE via the environment > > variable, but it is better to set it automatically - set it to > > ${DEB_HOST_GNU_TYPE}- if we are cross-compiling but not from the top > > Makefile. > > > > The generated source package may be carried to a different build > > environment, which may have a different compiler installed. > > Run olddefconfig first to set new CONFIG options to their default > > values without prompting. > > > > Take KERNELRELEASE and KBUILD_BUILD_VERSION from the version field of > > debian/changelog in case it is updated afterwards. > > I just arrived to this patch when trying to update the kernel for SOF > from 6.2.0 base to 6.3.0-rc1: > https://github.com/thesofproject/linux/pull/4223#issuecomment-1459997676 > > Our CI is building a kernel deb package from PRs to test with this command: > make bindeb-pkg LOCALVERSION=-$PRIDV-default KDEB_PKGVERSION=$(make > kernelversion)-$GITSHA > > The files, directories and the name of the deb package follows the rule > set up by scripts/setlocalversion, taking into account the LOCALVERSION, > CONFIG_LOCALVERSION and CONFIG_LOCALVERSION_AUTO, but the built kernel > is using the version derived from KDEB_PKGVERSION and the system is not > able to boot up since the modules are in a different directory then they > should be. > > Something like this: > make bindeb-pkg LOCALVERSION=-testbuild > vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty > /lib/modules/6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty/ > > strings vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty | grep 6.3 > 6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty > > Then with the KDEB_PKGVERSION: > make bindeb-pkg LOCALVERSION=-testbuild KDEB_PKGVERSION=$(make > kernelversion)-notworking > vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty > /lib/modules/6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty/ > > strings vmlinuz-6.3.0-rc1-testbuild-05827-g863ad81a6aa9-dirty | grep 6.3 > 6.3.0-rc1 > > in this case modprobe will not find the modules, it is looking for them > under /lib/modules/6.3.0-rc1 > > Reverting this patch makes the created deb package usable, the system > is bootable. > > We use the LOCALVERSION to feed in PR inforamtion and the > KDEB_PKGVERSION is used fro additional information, like build ID. > > Do you have any suggestion on how to get the functionality back or we > must stop using the KDEB_PKGVERSION altogether? I am aware of this issue. KERNELVERSION does not need to match the package version. I should have taken it from the <abiver> in the package name (linux-image-<abiver>_<origver>-<rev>_<arch>.deb) if I had wanted to do this dynamically by debian/control. I wrongly took it from <origver>. I will change this when I solve another issue required by Linus Tolvalds. Please wait. > > Thank you, > -- > Péter > > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > --- > > > > Changes in v6: > > - New patch > > > > scripts/package/deb-build-option | 16 ++++++++++++++++ > > scripts/package/mkdebian | 9 ++++----- > > 2 files changed, 20 insertions(+), 5 deletions(-) > > create mode 100755 scripts/package/deb-build-option > > > > diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-option > > new file mode 100755 > > index 000000000000..b079b0d121d4 > > --- /dev/null > > +++ b/scripts/package/deb-build-option > > @@ -0,0 +1,16 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0-only > > + > > +# Set up CROSS_COMPILE if we are cross-compiling, but not called from the > > +# kernel toplevel Makefile > > +if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then > > + echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}- > > +fi > > + > > +version=$(dpkg-parsechangelog -S Version) > > +version_upstream="${version%-*}" > > +debian_revision="${version#${version_upstream}}" > > +debian_revision="${debian_revision#*-}" > > + > > +echo KERNELRELEASE=${version_upstream} > > +echo KBUILD_BUILD_VERSION=${debian_revision} > > diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian > > index eef20d5dc288..f74380036bb5 100755 > > --- a/scripts/package/mkdebian > > +++ b/scripts/package/mkdebian > > @@ -90,10 +90,8 @@ rm -rf debian > > version=$KERNELRELEASE > > if [ -n "$KDEB_PKGVERSION" ]; then > > packageversion=$KDEB_PKGVERSION > > - revision=${packageversion##*-} > > else > > - revision=$($srctree/init/build-version) > > - packageversion=$version-$revision > > + packageversion=$version-$($srctree/init/build-version) > > fi > > sourcename=${KDEB_SOURCENAME:-linux-upstream} > > > > @@ -244,8 +242,9 @@ srctree ?= . > > > > build-indep: > > build-arch: > > - \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ > > - KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile > > + \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \ > > + \$(shell \$(srctree)/scripts/package/deb-build-option) \ > > + olddefconfig all > > > > build: build-arch > > > > -- > Péter
diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-option new file mode 100755 index 000000000000..b079b0d121d4 --- /dev/null +++ b/scripts/package/deb-build-option @@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +# Set up CROSS_COMPILE if we are cross-compiling, but not called from the +# kernel toplevel Makefile +if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then + echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}- +fi + +version=$(dpkg-parsechangelog -S Version) +version_upstream="${version%-*}" +debian_revision="${version#${version_upstream}}" +debian_revision="${debian_revision#*-}" + +echo KERNELRELEASE=${version_upstream} +echo KBUILD_BUILD_VERSION=${debian_revision} diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index eef20d5dc288..f74380036bb5 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -90,10 +90,8 @@ rm -rf debian version=$KERNELRELEASE if [ -n "$KDEB_PKGVERSION" ]; then packageversion=$KDEB_PKGVERSION - revision=${packageversion##*-} else - revision=$($srctree/init/build-version) - packageversion=$version-$revision + packageversion=$version-$($srctree/init/build-version) fi sourcename=${KDEB_SOURCENAME:-linux-upstream} @@ -244,8 +242,9 @@ srctree ?= . build-indep: build-arch: - \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ - KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile + \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \ + \$(shell \$(srctree)/scripts/package/deb-build-option) \ + olddefconfig all build: build-arch