From nobody Wed Feb 11 17:21:23 2026 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 01074C6FA99 for ; Sun, 12 Mar 2023 20:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbjCLUHp (ORCPT ); Sun, 12 Mar 2023 16:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjCLUHl (ORCPT ); Sun, 12 Mar 2023 16:07:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E806C2B2AE; Sun, 12 Mar 2023 13:07:38 -0700 (PDT) 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 7094B60F24; Sun, 12 Mar 2023 20:07:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FF8AC4339E; Sun, 12 Mar 2023 20:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651657; bh=EWFebzRJB5EaxVLme/XjbtAAgfIoo8j3Er0mUNianiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0dH1LT2PXEwchZ/rueoW/DQqvaJDkllGUZkdXIixOGajbaD5SCS4qUhncrdQvbtY SPARZCTRL+1SssomEofLmBctMBryXtmNv3wkX/oWOcr8HVgKcZxrZtRra00UFlnkil Nj6RUU2MPoJ+PE+WLUkp3Dy2BohBROntjHN0wejGNArsHb02jxq+lYK0lVt7cPRXlD 9PHJorZD87nhzNpZMYJYmrhJYDOFBzco6FuaKDG9EeZMcrZ1+RnEx3Kunr8ATIVQxT /SowIYZ3D3Q31xX29Gnwr0bDb3l6FNe5NQNsQCF0iThAPN6Y4xYpW706vZq3ijEJHC xNR/E0irVu7Zw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 1/6] kbuild: deb-pkg: make debian source package working again Date: Mon, 13 Mar 2023 05:07:26 +0900 Message-Id: <20230312200731.599706-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since commit c5bf2efb058d ("kbuild: deb-pkg: fix binary-arch and clean in debian/rules"), the source package generated by 'make deb-pkg' fails to build. I terribly missed the fact that the intdeb-pkg target may regenerate include/config/kernel.release due to the following in the top Makefile: %pkg: include/config/kernel.release FORCE Restore KERNELRELEASE=3D option to avoid the kernel.release disagreement between build-arch and binary-arch. Fixes: c5bf2efb058d ("kbuild: deb-pkg: fix binary-arch and clean in debian/= rules") Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky --- scripts/package/mkdebian | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index f74380036bb5..c6fbfb9f74ba 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -239,6 +239,7 @@ cat < debian/rules #!$(command -v $MAKE) -f =20 srctree ?=3D . +KERNELRELEASE =3D ${KERNELRELEASE} =20 build-indep: build-arch: @@ -250,7 +251,9 @@ build: build-arch =20 binary-indep: binary-arch: build-arch - \$(MAKE) -f \$(srctree)/Makefile ARCH=3D${ARCH} intdeb-pkg + \$(MAKE) -f \$(srctree)/Makefile ARCH=3D${ARCH} \ + KERNELRELEASE=3D\$(KERNELRELEASE) intdeb-pkg + clean: rm -rf debian/files debian/linux-* \$(MAKE) -f \$(srctree)/Makefile ARCH=3D${ARCH} clean --=20 2.34.1 From nobody Wed Feb 11 17:21:23 2026 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 D2F3EC7618A for ; Sun, 12 Mar 2023 20:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbjCLUHt (ORCPT ); Sun, 12 Mar 2023 16:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbjCLUHq (ORCPT ); Sun, 12 Mar 2023 16:07:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B899F2B62A; Sun, 12 Mar 2023 13:07:42 -0700 (PDT) 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 621F1B800C1; Sun, 12 Mar 2023 20:07:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47CAFC433D2; Sun, 12 Mar 2023 20:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651659; bh=SI4KrO3CvzpG6Y/Rp16w4y1l1Nd7kr9KP+ChdCjrOeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+2+5fa4v5cYlQ+p8KguN3K7xXgWQIobJ2DE5WgySuLDWDLzGbbxshaX1ghB0jkr7 m3YLN0RteXm6hDcZg3v4FZ7sjF3qtdIAarJBhPULG8oOhBmCZjttqV9Xoo/yuxgMSN Ol6FN4QbtZsX7d+vECxsqA2KNkxFs15uW2nutkX6JpdxCj5aSlcLsDrYR0+pRfTOAt VDc5HxOrtSQqiYyEE700/fGWmCputAxGbFNAiRStl8mkidc21cnpt9/eE+0M4lKRh5 eY6qdcgHPd2flcem3+Bsxn56zAY0U/GjbZYvctLX8dd/w3X2Ho65J6G++DvzmEUSRb qfuY7rkhyEwHw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 2/6] kbuild: deb-pkg: do not take KERNELRELEASE from the source version Date: Mon, 13 Mar 2023 05:07:27 +0900 Message-Id: <20230312200731.599706-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KERNELRELEASE does not need to match the package version in changelog. Rather, it conventially matches what is called 'ABINAME', which is a part of the binary package names. Both are the same by default, but the former might be overridden by KDEB_PKGVERSION. In this case, the resulting package would not boot because /lib/modules/$(uname -r) does not point the module directory. Partially revert 3ab18a625ce4 ("kbuild: deb-pkg: improve the usability of source package"). Reported-by: P=C3=A9ter Ujfalusi Fixes: 3ab18a625ce4 ("kbuild: deb-pkg: improve the usability of source pack= age") Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky Tested-by: Peter Ujfalusi --- scripts/package/deb-build-option | 9 ++++----- scripts/package/mkdebian | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-o= ption index b079b0d121d4..bd53624318f2 100755 --- a/scripts/package/deb-build-option +++ b/scripts/package/deb-build-option @@ -8,9 +8,8 @@ if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST= _ARCH}" !=3D "${DEB_BUI fi =20 version=3D$(dpkg-parsechangelog -S Version) -version_upstream=3D"${version%-*}" -debian_revision=3D"${version#${version_upstream}}" -debian_revision=3D"${debian_revision#*-}" +debian_revision=3D"${version##*-}" =20 -echo KERNELRELEASE=3D${version_upstream} -echo KBUILD_BUILD_VERSION=3D${debian_revision} +if [ "${version}" !=3D "${debian_revision}" ]; then + echo KBUILD_BUILD_VERSION=3D${debian_revision} +fi diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index c6fbfb9f74ba..31b050368cd0 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -244,6 +244,7 @@ KERNELRELEASE =3D ${KERNELRELEASE} build-indep: build-arch: \$(MAKE) -f \$(srctree)/Makefile ARCH=3D${ARCH} \ + KERNELRELEASE=3D\$(KERNELRELEASE) \ \$(shell \$(srctree)/scripts/package/deb-build-option) \ olddefconfig all =20 --=20 2.34.1 From nobody Wed Feb 11 17:21:23 2026 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 BCEE6C74A4B for ; Sun, 12 Mar 2023 20:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbjCLUHw (ORCPT ); Sun, 12 Mar 2023 16:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjCLUHq (ORCPT ); Sun, 12 Mar 2023 16:07:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B892BEEE; Sun, 12 Mar 2023 13:07:43 -0700 (PDT) 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 B4FF7B80C63; Sun, 12 Mar 2023 20:07:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42B51C433A0; Sun, 12 Mar 2023 20:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651661; bh=eb6XlOAtcwsmZEKl2YAULQA72a4PFBl0XG4e86AOG7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICqCjNzlG7BWQLdlKpX31emGfOIsOxMXT6zT8FxpAHcTHChHGk0bYhF7OmPqOuw2D 2DyHUx7FZSQUNOUCXpCahhEGayoWM1xj87lExVQTn3tSkaGQSIH8Hn6aTG1F/fcWKq e7pE0cI5aErc9gg5AvEW6rBZ36cqmoc0dX7YvuBNp6T2YsOQyqyuYG31063hO2fqlS dgNPxn7QGynCuOUARe0F5qqKCChLundrYQ564n5WW+8112tkYIC7l+5pbcahPc7Bn7 n7zjuBzgIP33jBSLtNR3MUeuF4auXvgn8sc2vhyHJ3DC7YASAdPxeKZNWQ0B0f28cV uAfScRKIPDnHQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 3/6] kbuild: deb-pkg: set CROSS_COMPILE only when undefined Date: Mon, 13 Mar 2023 05:07:28 +0900 Message-Id: <20230312200731.599706-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit 3ab18a625ce4 ("kbuild: deb-pkg: improve the usability of source package") set needless CROSS_COMPILE. For example, 'make allnoconfig bindeb-pkg' on a x86_64 system will set CROSS_COMPILE=3Di686-linux-gnu-, where the biarch compiler 'gcc' should work for building the i386 kernel. $ uname -m x86_64 $ make allnoconfig bindeb-pkg >/dev/null dpkg-architecture: warning: specified GNU system type i686-linux-gnu does= not match CC system type x86_64-linux-gnu, try setting a correct CC enviro= nment variable dpkg-source --before-build . debian/rules binary scripts/Kconfig.include:39: C compiler 'i686-linux-gnu-gcc' not found make[6]: *** [scripts/kconfig/Makefile:77: olddefconfig] Error 1 make[5]: *** [Makefile:693: olddefconfig] Error 2 make[4]: *** [Makefile:358: __build_one_by_one] Error 2 make[3]: *** [debian/rules:7: build-arch] Error 2 dpkg-buildpackage: error: debian/rules binary subprocess returned exit st= atus 2 make[2]: *** [scripts/Makefile.package:127: bindeb-pkg] Error 2 make[1]: *** [Makefile:1657: bindeb-pkg] Error 2 make: *** [Makefile:358: __build_one_by_one] Error 2 Check whether CROSS_COMPILE is defined, instead of whether it is non-empty. If you invoke debian/rules via Kbuild, CROSS_COMPILE is always defined in the top Makefile. Fixes: 3ab18a625ce4 ("kbuild: deb-pkg: improve the usability of source pack= age") Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky --- scripts/package/deb-build-option | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-o= ption index bd53624318f2..7950eff01781 100755 --- a/scripts/package/deb-build-option +++ b/scripts/package/deb-build-option @@ -1,9 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-only =20 -# 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}" !=3D "$= {DEB_BUILD_ARCH}" ]; then +# Set up CROSS_COMPILE if not defined yet +if [ "${CROSS_COMPILE+set}" !=3D "set" -a "${DEB_HOST_ARCH}" !=3D "${DEB_B= UILD_ARCH}" ]; then echo CROSS_COMPILE=3D${DEB_HOST_GNU_TYPE}- fi =20 --=20 2.34.1 From nobody Wed Feb 11 17:21:23 2026 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 05E24C74A5B for ; Sun, 12 Mar 2023 20:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbjCLUHy (ORCPT ); Sun, 12 Mar 2023 16:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbjCLUHr (ORCPT ); Sun, 12 Mar 2023 16:07:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8076B2C645; Sun, 12 Mar 2023 13:07:44 -0700 (PDT) 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 0554E60FB8; Sun, 12 Mar 2023 20:07:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8147C4339B; Sun, 12 Mar 2023 20:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651663; bh=7GkS17GKl3ZNTSvkKca585P/2hq5bbCvfZPAnQXncoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCjMvfW9dYEoxWjXpcJfSb5m8XT2UYoAZQmu4xJNfqkg2qYD4b6AkH0CVULZsSyvM wngTq1IEnZK7wOyjmH1739oHUSphgSTLwG2lrmrCLHsWQncsaSJvyEbftczpbjn3Zv j5slAF4km3GbLTn5Y2Shl2M8So+WBDgql9RLsFahIg4RsDVNwTnHivQCWDlEhzX5uW PImJGbSrw+Z6Uki8Hnd+bsinwqE1CMd88kAMK41xUcEZQIn7LGOlVjxiQ/xfhe6ImY COxxaK04Je7w1m2DMJirsYvi9CRsDOHp79/lvyu/Zzu7W3oYATId4YDmM9bgig6mw+ sPkb54lHvRGZw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 4/6] kbuild: deb-pkg: split image and debug objects staging out into functions Date: Mon, 13 Mar 2023 05:07:29 +0900 Message-Id: <20230312200731.599706-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Prepare for the refactoring in the next commit. Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky --- scripts/package/builddeb | 222 ++++++++++++++++++++------------------- 1 file changed, 116 insertions(+), 106 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index ff5e7d8e380b..906889b304a4 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -51,6 +51,115 @@ create_package() { dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir= " .. } =20 +install_linux_image () { + pdir=3D$1 + pname=3D$2 + + rm -rf ${pdir} + + # Only some architectures with OF support have this target + if is_enabled CONFIG_OF_EARLY_FLATTREE && [ -d "${srctree}/arch/${SRCARCH= }/boot/dts" ]; then + ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH=3D"${pdir}/usr/lib/linu= x-image-${KERNELRELEASE}" dtbs_install + fi + + if is_enabled CONFIG_MODULES; then + ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH=3D"${pdir}" modules_inst= all + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" + if [ "${SRCARCH}" =3D um ] ; then + mkdir -p "${pdir}/usr/lib/uml/modules" + mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/= ${KERNELRELEASE}" + fi + fi + + # Install the kernel + if [ "${ARCH}" =3D um ] ; then + mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}" + cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map" + cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config" + gzip "${pdir}/usr/share/doc/${pname}/config" + else + mkdir -p "${pdir}/boot" + cp System.map "${pdir}/boot/System.map-${KERNELRELEASE}" + cp ${KCONFIG_CONFIG} "${pdir}/boot/config-${KERNELRELEASE}" + fi + + # Not all arches have the same installed path in debian + # XXX: have each arch Makefile export a variable of the canonical image i= nstall + # path instead + case "${SRCARCH}" in + um) + installed_image_path=3D"usr/bin/linux-${KERNELRELEASE}";; + parisc|mips|powerpc) + installed_image_path=3D"boot/vmlinux-${KERNELRELEASE}";; + *) + installed_image_path=3D"boot/vmlinuz-${KERNELRELEASE}";; + esac + cp "$(${MAKE} -s -f ${srctree}/Makefile image_name)" "${pdir}/${installed= _image_path}" + + # Install the maintainer scripts + # Note: hook scripts under /etc/kernel are also executed by official Debi= an + # kernel packages, as well as kernel packages built using make-kpkg. + # make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and + # so do we; recent versions of dracut and initramfs-tools will obey this. + debhookdir=3D${KDEB_HOOKDIR:-/etc/kernel} + for script in postinst postrm preinst prerm; do + mkdir -p "${pdir}${debhookdir}/${script}.d" + + mkdir -p "${pdir}/DEBIAN" + cat <<-EOF > "${pdir}/DEBIAN/${script}" + + #!/bin/sh + + set -e + + # Pass maintainer script parameters to hook scripts + export DEB_MAINT_PARAMS=3D"\$*" + + # Tell initramfs builder whether it's wanted + export INITRD=3D$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) + + test -d ${debhookdir}/${script}.d && run-parts --arg=3D"${KERNELRELEASE}= " --arg=3D"/${installed_image_path}" ${debhookdir}/${script}.d + exit 0 + EOF + chmod 755 "${pdir}/DEBIAN/${script}" + done +} + +install_linux_image_dbg () { + pdir=3D$1 + image_pdir=3D$2 + + rm -rf ${pdir} + + for module in $(find ${image_pdir}/lib/modules/ -name *.ko -printf '%P\n'= ); do + module=3Dlib/modules/${module} + mkdir -p $(dirname ${pdir}/usr/lib/debug/${module}) + # only keep debug symbols in the debug file + ${OBJCOPY} --only-keep-debug ${image_pdir}/${module} ${pdir}/usr/lib/deb= ug/${module} + # strip original module from debug symbols + ${OBJCOPY} --strip-debug ${image_pdir}/${module} + # then add a link to those + ${OBJCOPY} --add-gnu-debuglink=3D${pdir}/usr/lib/debug/${module} ${image= _pdir}/${module} + done + + # re-sign stripped modules + if is_enabled CONFIG_MODULE_SIG_ALL; then + ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH=3D"${image_pdir}" module= s_sign + fi + + # Build debug package + # Different tools want the image in different locations + # perf + mkdir -p ${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/ + cp vmlinux ${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/ + # systemtap + mkdir -p ${pdir}/usr/lib/debug/boot/ + ln -s ../lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/boot/= vmlinux-${KERNELRELEASE} + # kdump-tools + ln -s lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/vmlinux-= ${KERNELRELEASE} +} + deploy_kernel_headers () { pdir=3D$1 =20 @@ -105,8 +214,6 @@ deploy_libc_headers () { } =20 version=3D$KERNELRELEASE -tmpdir=3Ddebian/linux-image -dbg_dir=3Ddebian/linux-image-dbg packagename=3Dlinux-image-$version dbg_packagename=3D$packagename-dbg =20 @@ -114,97 +221,7 @@ if [ "$ARCH" =3D "um" ] ; then packagename=3Duser-mode-linux-$version fi =20 -# Not all arches have the same installed path in debian -# XXX: have each arch Makefile export a variable of the canonical image in= stall -# path instead -case $ARCH in -um) - installed_image_path=3D"usr/bin/linux-$version" - ;; -parisc|mips|powerpc) - installed_image_path=3D"boot/vmlinux-$version" - ;; -*) - installed_image_path=3D"boot/vmlinuz-$version" -esac - -BUILD_DEBUG=3D$(if_enabled_echo CONFIG_DEBUG_INFO Yes) - -# Setup the directory structure -rm -rf "$tmpdir" "$dbg_dir" debian/files -mkdir -m 755 -p "$tmpdir/DEBIAN" -mkdir -p "$tmpdir/lib" "$tmpdir/boot" - -# Install the kernel -if [ "$ARCH" =3D "um" ] ; then - mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdi= r/usr/share/doc/$packagename" - cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" - cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" - gzip "$tmpdir/usr/share/doc/$packagename/config" -else - cp System.map "$tmpdir/boot/System.map-$version" - cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" -fi -cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image= _path" - -if is_enabled CONFIG_OF_EARLY_FLATTREE; then - # Only some architectures with OF support have this target - if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then - $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH=3D"$tmpdir/usr/lib/$package= name" dtbs_install - fi -fi - -if is_enabled CONFIG_MODULES; then - INSTALL_MOD_PATH=3D"$tmpdir" $MAKE -f $srctree/Makefile modules_install - rm -f "$tmpdir/lib/modules/$version/build" - rm -f "$tmpdir/lib/modules/$version/source" - if [ "$ARCH" =3D "um" ] ; then - mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$versio= n/" - rmdir "$tmpdir/lib/modules/$version" - fi - if [ -n "$BUILD_DEBUG" ] ; then - for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do - module=3Dlib/modules/$module - mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) - # only keep debug symbols in the debug file - $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$modu= le - # strip original module from debug symbols - $OBJCOPY --strip-debug $tmpdir/$module - # then add a link to those - $OBJCOPY --add-gnu-debuglink=3D$dbg_dir/usr/lib/debug/$module $tmpdir/$= module - done - - # resign stripped modules - if is_enabled CONFIG_MODULE_SIG_ALL; then - INSTALL_MOD_PATH=3D"$tmpdir" $MAKE -f $srctree/Makefile modules_sign - fi - fi -fi - -# Install the maintainer scripts -# Note: hook scripts under /etc/kernel are also executed by official Debian -# kernel packages, as well as kernel packages built using make-kpkg. -# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and -# so do we; recent versions of dracut and initramfs-tools will obey this. -debhookdir=3D${KDEB_HOOKDIR:-/etc/kernel} -for script in postinst postrm preinst prerm ; do - mkdir -p "$tmpdir$debhookdir/$script.d" - cat < "$tmpdir/DEBIAN/$script" -#!/bin/sh - -set -e - -# Pass maintainer script parameters to hook scripts -export DEB_MAINT_PARAMS=3D"\$*" - -# Tell initramfs builder whether it's wanted -export INITRD=3D$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) - -test -d $debhookdir/$script.d && run-parts --arg=3D"$version" --arg=3D"/$i= nstalled_image_path" $debhookdir/$script.d -exit 0 -EOF - chmod 755 "$tmpdir/DEBIAN/$script" -done +rm -f debian/files =20 if [ "$ARCH" !=3D "um" ]; then if is_enabled CONFIG_MODULES; then @@ -216,20 +233,13 @@ if [ "$ARCH" !=3D "um" ]; then create_package linux-libc-dev debian/linux-libc-dev fi =20 -create_package "$packagename" "$tmpdir" +install_linux_image debian/linux-image "$packagename" =20 -if [ -n "$BUILD_DEBUG" ] ; then - # Build debug package - # Different tools want the image in different locations - # perf - mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ - cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/ - # systemtap - mkdir -p $dbg_dir/usr/lib/debug/boot/ - ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux= -$version - # kdump-tools - ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version - create_package "$dbg_packagename" "$dbg_dir" +if is_enabled CONFIG_DEBUG_INFO; then + install_linux_image_dbg debian/linux-image-dbg debian/linux-image + create_package "$dbg_packagename" debian/linux-image-dbg fi =20 +create_package "$packagename" debian/linux-image + exit 0 --=20 2.34.1 From nobody Wed Feb 11 17:21:23 2026 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 B422CC6FA99 for ; Sun, 12 Mar 2023 20:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231138AbjCLUH5 (ORCPT ); Sun, 12 Mar 2023 16:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbjCLUHs (ORCPT ); Sun, 12 Mar 2023 16:07:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6583E2CC5D; Sun, 12 Mar 2023 13:07:46 -0700 (PDT) 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 E93FF60FC5; Sun, 12 Mar 2023 20:07:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1771C433D2; Sun, 12 Mar 2023 20:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651665; bh=Su3scJdModDm3BhC+wn0A6LlLdEtZxRokwKcfkvWOrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ULNIk25MY76i+mXjqaTN97EPLT7kw60H1du0XM3KfO28bJ7QN8BgB+aLY1ai5Bu6v AnG8xseYbhG5pYAVOgcVd8dB5OTyyoTwyO+fe0HR1B87MFL0DdLm+JTIfDSxe1rUyN 8W8bbdm1hIQXAqJF0bI3xDDAIUtXumGGSeyXSH4Swnn0cpkDG83Z0SZaDUz/5CLbWP Zn5tD48H6tCEsWD42N1JsnI6tagQrtaAs1qJL0m0osszJlnAFQwhxPB4jpM/eYuiY/ eskA0SrxTdmiJl9P+J3+OBgUzV+n80B2hmjVbuGj8I8Vse/YSKphF97+Sa0EnGaO0S zZ16H3Ht7edAg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 5/6] kbuild: deb-pkg: use dh_listpackages to know enabled packages Date: Mon, 13 Mar 2023 05:07:30 +0900 Message-Id: <20230312200731.599706-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use dh_listpackages to get a list of all binary packages. With this, debian/control lists which binary packages will be produced. Previously, ARCH=3Dum listed linux-libc-dev in debian/control, but it was not generated because each of mkdebian and builddeb independently maintained the if-conditionals. Another motivation is to allow scripts/package/builddeb to get the package name (linux-image-*, etc.) dynamically from debian/control. This will also allow the BuildProfile to control the generation of the binary packages. Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky --- scripts/package/builddeb | 61 ++++++++++++++++++++++------------------ scripts/package/mkdebian | 7 ++++- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 906889b304a4..c5ae57167d7c 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -160,7 +160,7 @@ install_linux_image_dbg () { ln -s lib/modules/${KERNELRELEASE}/vmlinux ${pdir}/usr/lib/debug/vmlinux-= ${KERNELRELEASE} } =20 -deploy_kernel_headers () { +install_kernel_headers () { pdir=3D$1 =20 rm -rf $pdir @@ -198,7 +198,7 @@ deploy_kernel_headers () { ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build } =20 -deploy_libc_headers () { +install_libc_headers () { pdir=3D$1 =20 rm -rf $pdir @@ -213,33 +213,38 @@ deploy_libc_headers () { mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ } =20 -version=3D$KERNELRELEASE -packagename=3Dlinux-image-$version -dbg_packagename=3D$packagename-dbg - -if [ "$ARCH" =3D "um" ] ; then - packagename=3Duser-mode-linux-$version -fi - rm -f debian/files =20 -if [ "$ARCH" !=3D "um" ]; then - if is_enabled CONFIG_MODULES; then - deploy_kernel_headers debian/linux-headers - create_package linux-headers-$version debian/linux-headers - fi - - deploy_libc_headers debian/linux-libc-dev - create_package linux-libc-dev debian/linux-libc-dev -fi - -install_linux_image debian/linux-image "$packagename" - -if is_enabled CONFIG_DEBUG_INFO; then - install_linux_image_dbg debian/linux-image-dbg debian/linux-image - create_package "$dbg_packagename" debian/linux-image-dbg -fi - -create_package "$packagename" debian/linux-image +packages_enabled=3D$(dh_listpackages) + +for package in ${packages_enabled} +do + case ${package} in + *-dbg) + # This must be done after linux-image, that is, we expect the + # debug package appears after linux-image in debian/control. + install_linux_image_dbg debian/linux-image-dbg debian/linux-image;; + linux-image-*|user-mode-linux-*) + install_linux_image debian/linux-image ${package};; + linux-libc-dev) + install_libc_headers debian/linux-libc-dev;; + linux-headers-*) + install_kernel_headers debian/linux-headers;; + esac +done + +for package in ${packages_enabled} +do + case ${package} in + *-dbg) + create_package ${package} debian/linux-image-dbg;; + linux-image-*|user-mode-linux-*) + create_package ${package} debian/linux-image;; + linux-libc-dev) + create_package ${package} debian/linux-libc-dev;; + linux-headers-*) + create_package ${package} debian/linux-headers;; + esac +done =20 exit 0 diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index 31b050368cd0..e80a661a79ee 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -192,7 +192,7 @@ Section: kernel Priority: optional Maintainer: $maintainer Rules-Requires-Root: no -Build-Depends: bc, rsync, kmod, cpio, bison, flex $extra_build_depends +Build-Depends: bc, debhelper, rsync, kmod, cpio, bison, flex $extra_build_= depends Homepage: https://www.kernel.org/ =20 Package: $packagename-$version @@ -200,6 +200,10 @@ Architecture: $debarch Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other files, version: $version. +EOF + +if [ "${SRCARCH}" !=3D um ]; then +cat <> debian/control =20 Package: linux-libc-dev Section: devel @@ -222,6 +226,7 @@ Description: Linux kernel headers for $version on $deba= rch This is useful for people who need to build external modules EOF fi +fi =20 if is_enabled CONFIG_DEBUG_INFO; then cat <> debian/control --=20 2.34.1 From nobody Wed Feb 11 17:21:23 2026 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 6E301C6FA99 for ; Sun, 12 Mar 2023 20:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjCLUIN (ORCPT ); Sun, 12 Mar 2023 16:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbjCLUIF (ORCPT ); Sun, 12 Mar 2023 16:08:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005DB2CC71; Sun, 12 Mar 2023 13:07:50 -0700 (PDT) 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 DC808B800C1; Sun, 12 Mar 2023 20:07:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6711C433A0; Sun, 12 Mar 2023 20:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678651667; bh=FWQWNE1Bz5pRijEBNpGLSnSa9DL74FFCmGUVougn03E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lOVuWRXb87AEOE7WeXl+qelPWxoZSP88pwf5mxaTd2VmQLJAv943iN3JFT/m0Dl57 KKn0tBRF6bA6NQXBHLGWn1J12g+lYyXnddkPW66V1SxYqOvbPIyQFQLJ/SF/UrUVQC dirp3gm8pSdIAnKcnUJFnA3THqemrfY5fsrN2tGgng0U4j3zhHpdF90Fe/G7gEzyEr R+nkxKFn6tYYblAUNZGwSBO4I9wxm9mJvk2Zn9pHIpXalJ/PlA8UfUJTDBcde1LtP7 X4wj0KulelHl6AyRW+5736jEbkXHcNS7c7UTGMlv5BQurXPY6Ng8KcmGwxbG4AYa6E Hpazcr7Lagqpg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nick Terrell , Nicolas Schier Subject: [PATCH 6/6] kbuild: use git-archive for source package creation Date: Mon, 13 Mar 2023 05:07:31 +0900 Message-Id: <20230312200731.599706-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230312200731.599706-1-masahiroy@kernel.org> References: <20230312200731.599706-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git") added a new tool, scripts/list-gitignored. My intention was to create source packages without cleaning the source tree, without relying on git. Linus strongly objected to it, and suggested using 'git archive'. [1] [2] [= 3] This commit goes in that direction. Remove scripts/list-gitignored.c and rewrites Makefiles and scripts to use 'git archive'. Going forward, building source packages is only possible in a git-managed tree. Building binary packages does not require git. [1]: https://lore.kernel.org/lkml/CAHk-=3Dwi49sMaC7vY1yMagk7eqLK=3D1jHeHQ= =3DyZ_k45P=3DxBccnmA@mail.gmail.com/ [2]: https://lore.kernel.org/lkml/CAHk-=3Dwh5AixGsLeT0qH2oZHKq0FLUTbyTw4qY9= 21L=3DPwYgoGVw@mail.gmail.com/ [3]: https://lore.kernel.org/lkml/CAHk-=3DwgM-W6Fu=3D=3DEoAVCabxyX8eYBz9kNC= 88-tm9ExRQwA79UQ@mail.gmail.com/ Fixes: 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git") Fixes: e0ca16749ac3 ("kbuild: make perf-tar*-src-pkg work without relying o= n git") Suggested-by: Linus Torvalds Signed-off-by: Masahiro Yamada Tested-by: Leon Romanovsky --- .gitignore | 1 + Makefile | 9 +- scripts/.gitignore | 1 - scripts/Makefile | 2 +- scripts/Makefile.package | 113 ++-- scripts/check-git | 14 + scripts/list-gitignored.c | 1057 -------------------------------- scripts/package/gen-diff-patch | 44 ++ scripts/package/mkdebian | 11 +- scripts/package/mkspec | 17 +- scripts/setlocalversion | 45 +- 11 files changed, 176 insertions(+), 1138 deletions(-) create mode 100755 scripts/check-git delete mode 100644 scripts/list-gitignored.c create mode 100755 scripts/package/gen-diff-patch diff --git a/.gitignore b/.gitignore index 8fe465f251c0..70ec6037fa7a 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ modules.order # RPM spec file (make rpm-pkg) # /*.spec +/rpmbuild/ =20 # # Debian directory (make deb-pkg) diff --git a/Makefile b/Makefile index d7bd0eb9b346..7b29ba6cb293 100644 --- a/Makefile +++ b/Makefile @@ -274,8 +274,7 @@ no-dot-config-targets :=3D $(clean-targets) \ cscope gtags TAGS tags help% %docs check% coccicheck \ $(version_h) headers headers_% archheaders archscripts \ %asm-generic kernelversion %src-pkg dt_binding_check \ - outputmakefile rustavailable rustfmt rustfmtcheck \ - scripts_package + outputmakefile rustavailable rustfmt rustfmtcheck # Installation targets should not require compiler. Unfortunately, vdso_in= stall # is an exception where build artifacts may be updated. This must be fixed. no-compiler-targets :=3D $(no-dot-config-targets) install dtbs_install \ @@ -1605,7 +1604,7 @@ MRPROPER_FILES +=3D include/config include/generated = \ certs/signing_key.pem \ certs/x509.genkey \ vmlinux-gdb.py \ - *.spec \ + *.spec rpmbuild \ rust/libmacros.so =20 # clean - Delete most, but leave enough to build external modules @@ -1656,10 +1655,6 @@ distclean: mrproper %pkg: include/config/kernel.release FORCE $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ =20 -PHONY +=3D scripts_package -scripts_package: scripts_basic - $(Q)$(MAKE) $(build)=3Dscripts scripts/list-gitignored - # Brief documentation of the typical targets used # ------------------------------------------------------------------------= --- =20 diff --git a/scripts/.gitignore b/scripts/.gitignore index feb43045d1b1..6e9ce6720a05 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -3,7 +3,6 @@ /generate_rust_target /insert-sys-cert /kallsyms -/list-gitignored /module.lds /recordmcount /sign-file diff --git a/scripts/Makefile b/scripts/Makefile index e8917975905c..32b6ba722728 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -38,7 +38,7 @@ HOSTCFLAGS_sorttable.o +=3D -DMCOUNT_SORT_ENABLED endif =20 # The following programs are only built on demand -hostprogs +=3D list-gitignored unifdef +hostprogs +=3D unifdef =20 # The module linker script is preprocessed on demand targets +=3D module.lds diff --git a/scripts/Makefile.package b/scripts/Makefile.package index b941e6341b36..768295f530f6 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -2,6 +2,7 @@ # Makefile for the different targets used to generate full packages of a k= ernel =20 include $(srctree)/scripts/Kbuild.include +include $(srctree)/scripts/Makefile.lib =20 KERNELPATH :=3D kernel-$(subst -,_,$(KERNELRELEASE)) KBUILD_PKG_ROOTCMD ?=3D"fakeroot -u" @@ -26,54 +27,46 @@ fi ; \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) =20 -# .tmp_filelist .tmp_filelist_exclude +# tarball compression # ------------------------------------------------------------------------= --- =20 -scripts/list-gitignored: FORCE - $(Q)$(MAKE) -f $(srctree)/Makefile scripts_package +%.tar.gz: %.tar + $(call cmd,gzip) =20 -# 1f5d3a6b6532e25a5cdf1f311956b2b03d343a48 removed '*.rej' from .gitignore, -# but it is definitely a generated file. -filechk_filelist =3D \ - $< --exclude=3D'*.rej' --output=3D$@_exclude --prefix=3D./ --rootdir=3D$(= srctree) --stat=3D- +%.tar.bz2: %.tar + $(call cmd,bzip2) =20 -.tmp_filelist: scripts/list-gitignored FORCE - $(call filechk,filelist) +%.tar.xz: %.tar + $(call cmd,xzmisc) =20 -# tarball -# ------------------------------------------------------------------------= --- - -quiet_cmd_tar =3D TAR $@ - cmd_tar =3D tar -c -f $@ $(tar-compress-opt) $(tar-exclude-opt) \ - --owner=3D0 --group=3D0 --sort=3Dname \ - --transform 's:^\.:$*:S' -C $(tar-rootdir) . - -tar-rootdir :=3D $(srctree) - -%.tar: - $(call cmd,tar) +%.tar.zst: %.tar + $(call cmd,zstd) =20 -%.tar.gz: private tar-compress-opt :=3D -I $(KGZIP) -%.tar.gz: - $(call cmd,tar) +# Git +# ------------------------------------------------------------------------= --- =20 -%.tar.bz2: private tar-compress-opt :=3D -I $(KBZIP2) -%.tar.bz2: - $(call cmd,tar) +filechk_HEAD =3D git -C $(srctree) rev-parse --verify HEAD 2>/dev/null =20 -%.tar.xz: private tar-compress-opt :=3D -I $(XZ) -%.tar.xz: - $(call cmd,tar) +.tmp_HEAD: check-git FORCE + $(call filechk,HEAD) =20 -%.tar.zst: private tar-compress-opt :=3D -I $(ZSTD) -%.tar.zst: - $(call cmd,tar) +PHONY +=3D check-git +check-git: + @if ! $(srctree)/scripts/check-git; then \ + echo >&2 "error: creating source package requires git repository"; \ + false; \ + fi =20 # Linux source tarball # ------------------------------------------------------------------------= --- =20 -linux.tar.gz: tar-exclude-opt =3D --exclude=3D./$@ --exclude-from=3D$<_exc= lude -linux.tar.gz: .tmp_filelist +quiet_cmd_archive_linux =3D ARCHIVE $@ + cmd_archive_linux =3D \ + git -C $(srctree) archive --output=3D$$(realpath $@) --prefix=3D$(basenam= e $@)/ $$(cat $<) + +targets +=3D linux.tar +linux.tar: .tmp_HEAD FORCE + $(call if_changed,archive_linux) =20 # rpm-pkg # ------------------------------------------------------------------------= --- @@ -88,8 +81,10 @@ rpm-pkg: srcrpm-pkg PHONY +=3D srcrpm-pkg srcrpm-pkg: linux.tar.gz $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec + mkdir -p rpmbuild/SOURCES + cp $< rpmbuild/SOURCES +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \ - --define=3D'_smp_mflags %{nil}' --define=3D'_sourcedir .' --define=3D'_sr= crpmdir .' + --define=3D'_smp_mflags %{nil}' --define=3D'_sourcedir rpmbuild/SOURCES' = --define=3D'_srcrpmdir .' =20 # binrpm-pkg # ------------------------------------------------------------------------= --- @@ -176,43 +171,36 @@ $(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eva= l $(call tar-pkg-rule,$(x)) perf-tar-src-pkg-tarball =3D perf-$(KERNELVERSION).$(1) perf-tar-src-pkg-phony =3D perf-$(subst .,,$(1))-src-pkg =20 -quiet_cmd_stage_perf_src =3D STAGE $@ - cmd_stage_perf_src =3D \ - rm -rf $@; \ - mkdir -p $@; \ - tar -c -f - --exclude-from=3D$<_exclude -C $(srctree) --files-from=3D$(sr= ctree)/tools/perf/MANIFEST | \ - tar -x -f - -C $@ +quiet_cmd_archive_perf =3D ARCHIVE $@ + cmd_archive_perf =3D \ + git -C $(srctree) archive --output=3D$$(realpath $@) --prefix=3D$(basenam= e $@)/ \ + --add-file=3D$$(realpath $(word 3, $^)) \ + --add-file=3D$$(realpath $(word 4, $^)) \ + $$(cat $<)^{tree} $$(cat $(word 2, $^)) =20 -.tmp_perf: .tmp_filelist - $(call cmd,stage_perf_src) +targets +=3D perf-$(KERNELVERSION).tar +perf-$(KERNELVERSION).tar: .tmp_HEAD tools/perf/MANIFEST .tmp_perf/HEAD .t= mp_perf/PERF-VERSION-FILE FORCE + $(call if_changed,archive_perf) =20 -filechk_perf_head =3D \ - if test -z "$(git -C $(srctree) rev-parse --show-cdup 2>/dev/null)" && \ - head=3D$$(git -C $(srctree) rev-parse --verify HEAD 2>/dev/null); = then \ - echo $$head; \ - else \ - echo "not a git tree"; \ - fi +.tmp_perf: + $(Q)mkdir .tmp_perf =20 -.tmp_perf/HEAD: .tmp_perf FORCE - $(call filechk,perf_head) +.tmp_perf/HEAD: .tmp_HEAD | .tmp_perf + $(call cmd,copy) =20 quiet_cmd_perf_version_file =3D GEN $@ cmd_perf_version_file =3D cd $(srctree)/tools/perf; util/PERF-VERSIO= N-GEN $(dir $(abspath $@)) =20 -# PERF-VERSION-FILE and HEAD are independent, but this avoids updating the +# PERF-VERSION-FILE and .tmp_HEAD are independent, but this avoids updatin= g the # timestamp of PERF-VERSION-FILE. # The best is to fix tools/perf/util/PERF-VERSION-GEN. -.tmp_perf/PERF-VERSION-FILE: .tmp_perf/HEAD $(srctree)/tools/perf/util/PER= F-VERSION-GEN +.tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VER= SION-GEN | .tmp_perf $(call cmd,perf_version_file) =20 define perf-tar-src-pkg-rule PHONY +=3D $(perf-tar-src-pkg-phony) $(perf-tar-src-pkg-phony): $(perf-tar-src-pkg-tarball) @: - -$(perf-tar-src-pkg-tarball): private tar-rootdir :=3D .tmp_perf -$(perf-tar-src-pkg-tarball): .tmp_filelist .tmp_perf/HEAD .tmp_perf/PERF-V= ERSION-FILE endef =20 $(foreach x, tar tar.gz tar.bz2 tar.xz tar.zst, $(eval $(call perf-tar-src= -pkg-rule,$(x)))) @@ -243,4 +231,13 @@ help: PHONY +=3D FORCE FORCE: =20 +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +existing-targets :=3D $(wildcard $(sort $(targets))) + +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) + .PHONY: $(PHONY) diff --git a/scripts/check-git b/scripts/check-git new file mode 100755 index 000000000000..e9dd82eddcf7 --- /dev/null +++ b/scripts/check-git @@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only +# +# succeed if this script is in the git-managed repository + +srctree=3D"$(dirname $0)/.." + +if ! git -C "${srctree}" rev-parse --verify HEAD >/dev/null 2>/dev/null; t= hen + exit 1 +fi + +if ! test -z $(git -C "${srctree}" rev-parse --show-cdup 2>/dev/null); then + exit 1 +fi diff --git a/scripts/list-gitignored.c b/scripts/list-gitignored.c deleted file mode 100644 index f9941f8dcd2b..000000000000 --- a/scripts/list-gitignored.c +++ /dev/null @@ -1,1057 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -// -// Traverse the source tree, parsing all .gitignore files, and print file = paths -// that are ignored by git. -// The output is suitable to the --exclude-from option of tar. -// This is useful until the --exclude-vcs-ignores option gets working corr= ectly. -// -// Copyright (C) 2023 Masahiro Yamada -// (a lot of code imported from GIT) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Imported from commit 23c56f7bd5f1667f8b793d796bf30e39545920f6 in GIT -// -//---------------------------(IMPORT FROM GIT BEGIN)----------------------= ----- - -// Copied from environment.c - -static bool ignore_case; - -// Copied from git-compat-util.h - -/* Sane ctype - no locale, and works with signed chars */ -#undef isascii -#undef isspace -#undef isdigit -#undef isalpha -#undef isalnum -#undef isprint -#undef islower -#undef isupper -#undef tolower -#undef toupper -#undef iscntrl -#undef ispunct -#undef isxdigit - -static const unsigned char sane_ctype[256]; -#define GIT_SPACE 0x01 -#define GIT_DIGIT 0x02 -#define GIT_ALPHA 0x04 -#define GIT_GLOB_SPECIAL 0x08 -#define GIT_REGEX_SPECIAL 0x10 -#define GIT_PATHSPEC_MAGIC 0x20 -#define GIT_CNTRL 0x40 -#define GIT_PUNCT 0x80 -#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != =3D 0) -#define isascii(x) (((x) & ~0x7f) =3D=3D 0) -#define isspace(x) sane_istest(x,GIT_SPACE) -#define isdigit(x) sane_istest(x,GIT_DIGIT) -#define isalpha(x) sane_istest(x,GIT_ALPHA) -#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) -#define isprint(x) ((x) >=3D 0x20 && (x) <=3D 0x7e) -#define islower(x) sane_iscase(x, 1) -#define isupper(x) sane_iscase(x, 0) -#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL) -#define iscntrl(x) (sane_istest(x,GIT_CNTRL)) -#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \ - GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC) -#define isxdigit(x) (hexval_table[(unsigned char)(x)] !=3D -1) -#define tolower(x) sane_case((unsigned char)(x), 0x20) -#define toupper(x) sane_case((unsigned char)(x), 0) - -static inline int sane_case(int x, int high) -{ - if (sane_istest(x, GIT_ALPHA)) - x =3D (x & ~0x20) | high; - return x; -} - -static inline int sane_iscase(int x, int is_lower) -{ - if (!sane_istest(x, GIT_ALPHA)) - return 0; - - if (is_lower) - return (x & 0x20) !=3D 0; - else - return (x & 0x20) =3D=3D 0; -} - -// Copied from ctype.c - -enum { - S =3D GIT_SPACE, - A =3D GIT_ALPHA, - D =3D GIT_DIGIT, - G =3D GIT_GLOB_SPECIAL, /* *, ?, [, \\ */ - R =3D GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | */ - P =3D GIT_PATHSPEC_MAGIC, /* other non-alnum, except for ] and } */ - X =3D GIT_CNTRL, - U =3D GIT_PUNCT, - Z =3D GIT_CNTRL | GIT_SPACE -}; - -static const unsigned char sane_ctype[256] =3D { - X, X, X, X, X, X, X, X, X, Z, Z, X, X, Z, X, X, /* 0.. 15 */ - X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 16.. 31 */ - S, P, P, P, R, P, P, P, R, R, G, R, P, P, R, P, /* 32.. 47 */ - D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G, /* 48.. 63 */ - P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */ - A, A, A, A, A, A, A, A, A, A, A, G, G, U, R, P, /* 80.. 95 */ - P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */ - A, A, A, A, A, A, A, A, A, A, A, R, R, U, P, X, /* 112..127 */ - /* Nothing in the 128.. range */ -}; - -// Copied from hex.c - -static const signed char hexval_table[256] =3D { - -1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 08-0f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 10-17 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 18-1f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 20-27 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 28-2f */ - 0, 1, 2, 3, 4, 5, 6, 7, /* 30-37 */ - 8, 9, -1, -1, -1, -1, -1, -1, /* 38-3f */ - -1, 10, 11, 12, 13, 14, 15, -1, /* 40-47 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 48-4f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 50-57 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 58-5f */ - -1, 10, 11, 12, 13, 14, 15, -1, /* 60-67 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 68-67 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 70-77 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 78-7f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 80-87 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 88-8f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 90-97 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 98-9f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* a0-a7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* a8-af */ - -1, -1, -1, -1, -1, -1, -1, -1, /* b0-b7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* b8-bf */ - -1, -1, -1, -1, -1, -1, -1, -1, /* c0-c7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* c8-cf */ - -1, -1, -1, -1, -1, -1, -1, -1, /* d0-d7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* d8-df */ - -1, -1, -1, -1, -1, -1, -1, -1, /* e0-e7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* e8-ef */ - -1, -1, -1, -1, -1, -1, -1, -1, /* f0-f7 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* f8-ff */ -}; - -// Copied from wildmatch.h - -#define WM_CASEFOLD 1 -#define WM_PATHNAME 2 - -#define WM_NOMATCH 1 -#define WM_MATCH 0 -#define WM_ABORT_ALL -1 -#define WM_ABORT_TO_STARSTAR -2 - -// Copied from wildmatch.c - -typedef unsigned char uchar; - -// local modification: remove NEGATE_CLASS(2) - -#define CC_EQ(class, len, litmatch) ((len) =3D=3D sizeof (litmatch)-1 \ - && *(class) =3D=3D *(litmatch) \ - && strncmp((char*)class, litmatch, len) =3D=3D 0) - -// local modification: simpilify macros -#define ISBLANK(c) ((c) =3D=3D ' ' || (c) =3D=3D '\t') -#define ISGRAPH(c) (isprint(c) && !isspace(c)) -#define ISPRINT(c) isprint(c) -#define ISDIGIT(c) isdigit(c) -#define ISALNUM(c) isalnum(c) -#define ISALPHA(c) isalpha(c) -#define ISCNTRL(c) iscntrl(c) -#define ISLOWER(c) islower(c) -#define ISPUNCT(c) ispunct(c) -#define ISSPACE(c) isspace(c) -#define ISUPPER(c) isupper(c) -#define ISXDIGIT(c) isxdigit(c) - -/* Match pattern "p" against "text" */ -static int dowild(const uchar *p, const uchar *text, unsigned int flags) -{ - uchar p_ch; - const uchar *pattern =3D p; - - for ( ; (p_ch =3D *p) !=3D '\0'; text++, p++) { - int matched, match_slash, negated; - uchar t_ch, prev_ch; - if ((t_ch =3D *text) =3D=3D '\0' && p_ch !=3D '*') - return WM_ABORT_ALL; - if ((flags & WM_CASEFOLD) && ISUPPER(t_ch)) - t_ch =3D tolower(t_ch); - if ((flags & WM_CASEFOLD) && ISUPPER(p_ch)) - p_ch =3D tolower(p_ch); - switch (p_ch) { - case '\\': - /* Literal match with following character. Note that the test - * in "default" handles the p[1] =3D=3D '\0' failure case. */ - p_ch =3D *++p; - /* FALLTHROUGH */ - default: - if (t_ch !=3D p_ch) - return WM_NOMATCH; - continue; - case '?': - /* Match anything but '/'. */ - if ((flags & WM_PATHNAME) && t_ch =3D=3D '/') - return WM_NOMATCH; - continue; - case '*': - if (*++p =3D=3D '*') { - const uchar *prev_p =3D p - 2; - while (*++p =3D=3D '*') {} - if (!(flags & WM_PATHNAME)) - /* without WM_PATHNAME, '*' =3D=3D '**' */ - match_slash =3D 1; - else if ((prev_p < pattern || *prev_p =3D=3D '/') && - (*p =3D=3D '\0' || *p =3D=3D '/' || - (p[0] =3D=3D '\\' && p[1] =3D=3D '/'))) { - /* - * Assuming we already match 'foo/' and are at - * , just assume it matches - * nothing and go ahead match the rest of the - * pattern with the remaining string. This - * helps make foo/<*><*>/bar (<> because - * otherwise it breaks C comment syntax) match - * both foo/bar and foo/a/bar. - */ - if (p[0] =3D=3D '/' && - dowild(p + 1, text, flags) =3D=3D WM_MATCH) - return WM_MATCH; - match_slash =3D 1; - } else /* WM_PATHNAME is set */ - match_slash =3D 0; - } else - /* without WM_PATHNAME, '*' =3D=3D '**' */ - match_slash =3D flags & WM_PATHNAME ? 0 : 1; - if (*p =3D=3D '\0') { - /* Trailing "**" matches everything. Trailing "*" matches - * only if there are no more slash characters. */ - if (!match_slash) { - if (strchr((char *)text, '/')) - return WM_NOMATCH; - } - return WM_MATCH; - } else if (!match_slash && *p =3D=3D '/') { - /* - * _one_ asterisk followed by a slash - * with WM_PATHNAME matches the next - * directory - */ - const char *slash =3D strchr((char*)text, '/'); - if (!slash) - return WM_NOMATCH; - text =3D (const uchar*)slash; - /* the slash is consumed by the top-level for loop */ - break; - } - while (1) { - if (t_ch =3D=3D '\0') - break; - /* - * Try to advance faster when an asterisk is - * followed by a literal. We know in this case - * that the string before the literal - * must belong to "*". - * If match_slash is false, do not look past - * the first slash as it cannot belong to '*'. - */ - if (!is_glob_special(*p)) { - p_ch =3D *p; - if ((flags & WM_CASEFOLD) && ISUPPER(p_ch)) - p_ch =3D tolower(p_ch); - while ((t_ch =3D *text) !=3D '\0' && - (match_slash || t_ch !=3D '/')) { - if ((flags & WM_CASEFOLD) && ISUPPER(t_ch)) - t_ch =3D tolower(t_ch); - if (t_ch =3D=3D p_ch) - break; - text++; - } - if (t_ch !=3D p_ch) - return WM_NOMATCH; - } - if ((matched =3D dowild(p, text, flags)) !=3D WM_NOMATCH) { - if (!match_slash || matched !=3D WM_ABORT_TO_STARSTAR) - return matched; - } else if (!match_slash && t_ch =3D=3D '/') - return WM_ABORT_TO_STARSTAR; - t_ch =3D *++text; - } - return WM_ABORT_ALL; - case '[': - p_ch =3D *++p; - if (p_ch =3D=3D '^') - p_ch =3D '!'; - /* Assign literal 1/0 because of "matched" comparison. */ - negated =3D p_ch =3D=3D '!' ? 1 : 0; - if (negated) { - /* Inverted character class. */ - p_ch =3D *++p; - } - prev_ch =3D 0; - matched =3D 0; - do { - if (!p_ch) - return WM_ABORT_ALL; - if (p_ch =3D=3D '\\') { - p_ch =3D *++p; - if (!p_ch) - return WM_ABORT_ALL; - if (t_ch =3D=3D p_ch) - matched =3D 1; - } else if (p_ch =3D=3D '-' && prev_ch && p[1] && p[1] !=3D ']') { - p_ch =3D *++p; - if (p_ch =3D=3D '\\') { - p_ch =3D *++p; - if (!p_ch) - return WM_ABORT_ALL; - } - if (t_ch <=3D p_ch && t_ch >=3D prev_ch) - matched =3D 1; - else if ((flags & WM_CASEFOLD) && ISLOWER(t_ch)) { - uchar t_ch_upper =3D toupper(t_ch); - if (t_ch_upper <=3D p_ch && t_ch_upper >=3D prev_ch) - matched =3D 1; - } - p_ch =3D 0; /* This makes "prev_ch" get set to 0. */ - } else if (p_ch =3D=3D '[' && p[1] =3D=3D ':') { - const uchar *s; - int i; - for (s =3D p +=3D 2; (p_ch =3D *p) && p_ch !=3D ']'; p++) {} /*SHARED= ITERATOR*/ - if (!p_ch) - return WM_ABORT_ALL; - i =3D p - s - 1; - if (i < 0 || p[-1] !=3D ':') { - /* Didn't find ":]", so treat like a normal set. */ - p =3D s - 2; - p_ch =3D '['; - if (t_ch =3D=3D p_ch) - matched =3D 1; - continue; - } - if (CC_EQ(s,i, "alnum")) { - if (ISALNUM(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "alpha")) { - if (ISALPHA(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "blank")) { - if (ISBLANK(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "cntrl")) { - if (ISCNTRL(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "digit")) { - if (ISDIGIT(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "graph")) { - if (ISGRAPH(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "lower")) { - if (ISLOWER(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "print")) { - if (ISPRINT(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "punct")) { - if (ISPUNCT(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "space")) { - if (ISSPACE(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "upper")) { - if (ISUPPER(t_ch)) - matched =3D 1; - else if ((flags & WM_CASEFOLD) && ISLOWER(t_ch)) - matched =3D 1; - } else if (CC_EQ(s,i, "xdigit")) { - if (ISXDIGIT(t_ch)) - matched =3D 1; - } else /* malformed [:class:] string */ - return WM_ABORT_ALL; - p_ch =3D 0; /* This makes "prev_ch" get set to 0. */ - } else if (t_ch =3D=3D p_ch) - matched =3D 1; - } while (prev_ch =3D p_ch, (p_ch =3D *++p) !=3D ']'); - if (matched =3D=3D negated || - ((flags & WM_PATHNAME) && t_ch =3D=3D '/')) - return WM_NOMATCH; - continue; - } - } - - return *text ? WM_NOMATCH : WM_MATCH; -} - -/* Match the "pattern" against the "text" string. */ -static int wildmatch(const char *pattern, const char *text, unsigned int f= lags) -{ - // local modification: move WM_CASEFOLD here - if (ignore_case) - flags |=3D WM_CASEFOLD; - - return dowild((const uchar*)pattern, (const uchar*)text, flags); -} - -// Copied from dir.h - -#define PATTERN_FLAG_NODIR 1 -#define PATTERN_FLAG_ENDSWITH 4 -#define PATTERN_FLAG_MUSTBEDIR 8 -#define PATTERN_FLAG_NEGATIVE 16 - -// Copied from dir.c - -static int fspathncmp(const char *a, const char *b, size_t count) -{ - return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count); -} - -static int simple_length(const char *match) -{ - int len =3D -1; - - for (;;) { - unsigned char c =3D *match++; - len++; - if (c =3D=3D '\0' || is_glob_special(c)) - return len; - } -} - -static int no_wildcard(const char *string) -{ - return string[simple_length(string)] =3D=3D '\0'; -} - -static void parse_path_pattern(const char **pattern, - int *patternlen, - unsigned *flags, - int *nowildcardlen) -{ - const char *p =3D *pattern; - size_t i, len; - - *flags =3D 0; - if (*p =3D=3D '!') { - *flags |=3D PATTERN_FLAG_NEGATIVE; - p++; - } - len =3D strlen(p); - if (len && p[len - 1] =3D=3D '/') { - len--; - *flags |=3D PATTERN_FLAG_MUSTBEDIR; - } - for (i =3D 0; i < len; i++) { - if (p[i] =3D=3D '/') - break; - } - if (i =3D=3D len) - *flags |=3D PATTERN_FLAG_NODIR; - *nowildcardlen =3D simple_length(p); - /* - * we should have excluded the trailing slash from 'p' too, - * but that's one more allocation. Instead just make sure - * nowildcardlen does not exceed real patternlen - */ - if (*nowildcardlen > len) - *nowildcardlen =3D len; - if (*p =3D=3D '*' && no_wildcard(p + 1)) - *flags |=3D PATTERN_FLAG_ENDSWITH; - *pattern =3D p; - *patternlen =3D len; -} - -static void trim_trailing_spaces(char *buf) -{ - char *p, *last_space =3D NULL; - - for (p =3D buf; *p; p++) - switch (*p) { - case ' ': - if (!last_space) - last_space =3D p; - break; - case '\\': - p++; - if (!*p) - return; - /* fallthrough */ - default: - last_space =3D NULL; - } - - if (last_space) - *last_space =3D '\0'; -} - -static int match_basename(const char *basename, int basenamelen, - const char *pattern, int prefix, int patternlen, - unsigned flags) -{ - if (prefix =3D=3D patternlen) { - if (patternlen =3D=3D basenamelen && - !fspathncmp(pattern, basename, basenamelen)) - return 1; - } else if (flags & PATTERN_FLAG_ENDSWITH) { - /* "*literal" matching against "fooliteral" */ - if (patternlen - 1 <=3D basenamelen && - !fspathncmp(pattern + 1, - basename + basenamelen - (patternlen - 1), - patternlen - 1)) - return 1; - } else { - // local modification: call wildmatch() directly - if (!wildmatch(pattern, basename, flags)) - return 1; - } - return 0; -} - -static int match_pathname(const char *pathname, int pathlen, - const char *base, int baselen, - const char *pattern, int prefix, int patternlen) -{ - // local modification: remove local variables - - /* - * match with FNM_PATHNAME; the pattern has base implicitly - * in front of it. - */ - if (*pattern =3D=3D '/') { - pattern++; - patternlen--; - prefix--; - } - - /* - * baselen does not count the trailing slash. base[] may or - * may not end with a trailing slash though. - */ - if (pathlen < baselen + 1 || - (baselen && pathname[baselen] !=3D '/') || - fspathncmp(pathname, base, baselen)) - return 0; - - // local modification: simplified because always baselen > 0 - pathname +=3D baselen + 1; - pathlen -=3D baselen + 1; - - if (prefix) { - /* - * if the non-wildcard part is longer than the - * remaining pathname, surely it cannot match. - */ - if (prefix > pathlen) - return 0; - - if (fspathncmp(pattern, pathname, prefix)) - return 0; - pattern +=3D prefix; - patternlen -=3D prefix; - pathname +=3D prefix; - pathlen -=3D prefix; - - /* - * If the whole pattern did not have a wildcard, - * then our prefix match is all we need; we - * do not need to call fnmatch at all. - */ - if (!patternlen && !pathlen) - return 1; - } - - // local modification: call wildmatch() directly - return !wildmatch(pattern, pathname, WM_PATHNAME); -} - -// Copied from git/utf8.c - -static const char utf8_bom[] =3D "\357\273\277"; - -//----------------------------(IMPORT FROM GIT END)-----------------------= ----- - -struct pattern { - unsigned int flags; - int nowildcardlen; - int patternlen; - int dirlen; - char pattern[]; -}; - -static struct pattern **pattern_list; -static int nr_patterns, alloced_patterns; - -// Remember the number of patterns at each directory level -static int *nr_patterns_at; -// Track the current/max directory level; -static int depth, max_depth; -static bool debug_on; -static FILE *out_fp, *stat_fp; -static char *prefix =3D ""; -static char *progname; - -static void __attribute__((noreturn)) perror_exit(const char *s) -{ - perror(s); - - exit(EXIT_FAILURE); -} - -static void __attribute__((noreturn)) error_exit(const char *fmt, ...) -{ - va_list args; - - fprintf(stderr, "%s: error: ", progname); - - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - - exit(EXIT_FAILURE); -} - -static void debug(const char *fmt, ...) -{ - va_list args; - int i; - - if (!debug_on) - return; - - fprintf(stderr, "[DEBUG] "); - - for (i =3D 0; i < depth * 2; i++) - fputc(' ', stderr); - - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); -} - -static void *xrealloc(void *ptr, size_t size) -{ - ptr =3D realloc(ptr, size); - if (!ptr) - perror_exit(progname); - - return ptr; -} - -static void *xmalloc(size_t size) -{ - return xrealloc(NULL, size); -} - -// similar to last_matching_pattern_from_list() in GIT -static bool is_ignored(const char *path, int pathlen, int dirlen, bool is_= dir) -{ - int i; - - // Search in the reverse order because the last matching pattern wins. - for (i =3D nr_patterns - 1; i >=3D 0; i--) { - struct pattern *p =3D pattern_list[i]; - unsigned int flags =3D p->flags; - const char *gitignore_dir =3D p->pattern + p->patternlen + 1; - bool ignored; - - if ((flags & PATTERN_FLAG_MUSTBEDIR) && !is_dir) - continue; - - if (flags & PATTERN_FLAG_NODIR) { - if (!match_basename(path + dirlen + 1, - pathlen - dirlen - 1, - p->pattern, - p->nowildcardlen, - p->patternlen, - p->flags)) - continue; - } else { - if (!match_pathname(path, pathlen, - gitignore_dir, p->dirlen, - p->pattern, - p->nowildcardlen, - p->patternlen)) - continue; - } - - debug("%s: matches %s%s%s (%s/.gitignore)\n", path, - flags & PATTERN_FLAG_NEGATIVE ? "!" : "", p->pattern, - flags & PATTERN_FLAG_MUSTBEDIR ? "/" : "", - gitignore_dir); - - ignored =3D (flags & PATTERN_FLAG_NEGATIVE) =3D=3D 0; - if (ignored) - debug("Ignore: %s\n", path); - - return ignored; - } - - debug("%s: no match\n", path); - - return false; -} - -static void add_pattern(const char *string, const char *dir, int dirlen) -{ - struct pattern *p; - int patternlen, nowildcardlen; - unsigned int flags; - - parse_path_pattern(&string, &patternlen, &flags, &nowildcardlen); - - if (patternlen =3D=3D 0) - return; - - p =3D xmalloc(sizeof(*p) + patternlen + dirlen + 2); - - memcpy(p->pattern, string, patternlen); - p->pattern[patternlen] =3D 0; - memcpy(p->pattern + patternlen + 1, dir, dirlen); - p->pattern[patternlen + 1 + dirlen] =3D 0; - - p->patternlen =3D patternlen; - p->nowildcardlen =3D nowildcardlen; - p->dirlen =3D dirlen; - p->flags =3D flags; - - debug("Add pattern: %s%s%s\n", - flags & PATTERN_FLAG_NEGATIVE ? "!" : "", p->pattern, - flags & PATTERN_FLAG_MUSTBEDIR ? "/" : ""); - - if (nr_patterns >=3D alloced_patterns) { - alloced_patterns +=3D 128; - pattern_list =3D xrealloc(pattern_list, - sizeof(*pattern_list) * alloced_patterns); - } - - pattern_list[nr_patterns++] =3D p; -} - -// similar to add_patterns_from_buffer() in GIT -static void add_patterns_from_gitignore(const char *dir, int dirlen) -{ - struct stat st; - char path[PATH_MAX], *buf, *entry; - size_t size; - int fd, pathlen, i; - - pathlen =3D snprintf(path, sizeof(path), "%s/.gitignore", dir); - if (pathlen >=3D sizeof(path)) - error_exit("%s: too long path was truncated\n", path); - - fd =3D open(path, O_RDONLY | O_NOFOLLOW); - if (fd < 0) { - if (errno !=3D ENOENT) - return perror_exit(path); - return; - } - - if (fstat(fd, &st) < 0) - perror_exit(path); - - size =3D st.st_size; - - buf =3D xmalloc(size + 1); - if (read(fd, buf, st.st_size) !=3D st.st_size) - perror_exit(path); - - buf[st.st_size] =3D '\n'; - if (close(fd)) - perror_exit(path); - - debug("Parse %s\n", path); - - entry =3D buf; - - // skip utf8 bom - if (!strncmp(entry, utf8_bom, strlen(utf8_bom))) - entry +=3D strlen(utf8_bom); - - for (i =3D entry - buf; i < size; i++) { - if (buf[i] =3D=3D '\n') { - if (entry !=3D buf + i && entry[0] !=3D '#') { - buf[i - (i && buf[i-1] =3D=3D '\r')] =3D 0; - trim_trailing_spaces(entry); - add_pattern(entry, dir, dirlen); - } - entry =3D buf + i + 1; - } - } - - free(buf); -} - -// Save the current number of patterns and increment the depth -static void increment_depth(void) -{ - if (depth >=3D max_depth) { - max_depth +=3D 1; - nr_patterns_at =3D xrealloc(nr_patterns_at, - sizeof(*nr_patterns_at) * max_depth); - } - - nr_patterns_at[depth] =3D nr_patterns; - depth++; -} - -// Decrement the depth, and free up the patterns of this directory level. -static void decrement_depth(void) -{ - depth--; - assert(depth >=3D 0); - - while (nr_patterns > nr_patterns_at[depth]) - free(pattern_list[--nr_patterns]); -} - -static void print_path(const char *path) -{ - // The path always starts with "./" - assert(strlen(path) >=3D 2); - - // Replace the root directory with a preferred prefix. - // This is useful for the tar command. - fprintf(out_fp, "%s%s\n", prefix, path + 2); -} - -static void print_stat(const char *path, struct stat *st) -{ - if (!stat_fp) - return; - - if (!S_ISREG(st->st_mode) && !S_ISLNK(st->st_mode)) - return; - - assert(strlen(path) >=3D 2); - - fprintf(stat_fp, "%c %9ld %10ld %s\n", - S_ISLNK(st->st_mode) ? 'l' : '-', - st->st_size, st->st_mtim.tv_sec, path + 2); -} - -// Traverse the entire directory tree, parsing .gitignore files. -// Print file paths that are not tracked by git. -// -// Return true if all files under the directory are ignored, false otherwi= se. -static bool traverse_directory(const char *dir, int dirlen) -{ - bool all_ignored =3D true; - DIR *dirp; - - debug("Enter[%d]: %s\n", depth, dir); - increment_depth(); - - add_patterns_from_gitignore(dir, dirlen); - - dirp =3D opendir(dir); - if (!dirp) - perror_exit(dir); - - while (1) { - struct dirent *d; - struct stat st; - char path[PATH_MAX]; - int pathlen; - bool ignored; - - errno =3D 0; - d =3D readdir(dirp); - if (!d) { - if (errno) - perror_exit(dir); - break; - } - - if (!strcmp(d->d_name, "..") || !strcmp(d->d_name, ".")) - continue; - - pathlen =3D snprintf(path, sizeof(path), "%s/%s", dir, d->d_name); - if (pathlen >=3D sizeof(path)) - error_exit("%s: too long path was truncated\n", path); - - if (lstat(path, &st) < 0) - perror_exit(path); - - if ((!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode= )) || - is_ignored(path, pathlen, dirlen, S_ISDIR(st.st_mode))) { - ignored =3D true; - } else { - if (S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode)) - // If all the files in a directory are ignored, - // let's ignore that directory as well. This - // will avoid empty directories in the tarball. - ignored =3D traverse_directory(path, pathlen); - else - ignored =3D false; - } - - if (ignored) { - print_path(path); - } else { - print_stat(path, &st); - all_ignored =3D false; - } - } - - if (closedir(dirp)) - perror_exit(dir); - - decrement_depth(); - debug("Leave[%d]: %s\n", depth, dir); - - return all_ignored; -} - -static void usage(void) -{ - fprintf(stderr, - "usage: %s [options]\n" - "\n" - "Show files that are ignored by git\n" - "\n" - "options:\n" - " -d, --debug print debug messages to stderr\n" - " -e, --exclude PATTERN add the given exclude pattern\n" - " -h, --help show this help message and exit\n" - " -i, --ignore-case Ignore case differences between the patt= erns and the files\n" - " -o, --output FILE output the ignored files to a file (defa= ult: '-', i.e. stdout)\n" - " -p, --prefix PREFIX prefix added to each path (default: empt= y string)\n" - " -r, --rootdir DIR root of the source tree (default: curren= t working directory)\n" - " -s, --stat FILE output the file stat of non-ignored file= s to a file\n", - progname); -} - -static void open_output(const char *pathname, FILE **fp) -{ - if (strcmp(pathname, "-")) { - *fp =3D fopen(pathname, "w"); - if (!*fp) - perror_exit(pathname); - } else { - *fp =3D stdout; - } -} - -static void close_output(const char *pathname, FILE *fp) -{ - fflush(fp); - - if (ferror(fp)) - error_exit("not all data was written to the output\n"); - - if (fclose(fp)) - perror_exit(pathname); -} - -int main(int argc, char *argv[]) -{ - const char *output =3D "-"; - const char *rootdir =3D "."; - const char *stat =3D NULL; - - progname =3D strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname =3D argv[0]; - - while (1) { - static struct option long_options[] =3D { - {"debug", no_argument, NULL, 'd'}, - {"help", no_argument, NULL, 'h'}, - {"ignore-case", no_argument, NULL, 'i'}, - {"output", required_argument, NULL, 'o'}, - {"prefix", required_argument, NULL, 'p'}, - {"rootdir", required_argument, NULL, 'r'}, - {"stat", required_argument, NULL, 's'}, - {"exclude", required_argument, NULL, 'x'}, - {}, - }; - - int c =3D getopt_long(argc, argv, "dhino:p:r:s:x:", long_options, NULL); - - if (c =3D=3D -1) - break; - - switch (c) { - case 'd': - debug_on =3D true; - break; - case 'h': - usage(); - exit(0); - case 'i': - ignore_case =3D true; - break; - case 'o': - output =3D optarg; - break; - case 'p': - prefix =3D optarg; - break; - case 'r': - rootdir =3D optarg; - break; - case 's': - stat =3D optarg; - break; - case 'x': - add_pattern(optarg, ".", strlen(".")); - break; - case '?': - usage(); - /* fallthrough */ - default: - exit(EXIT_FAILURE); - } - } - - open_output(output, &out_fp); - if (stat && stat[0]) - open_output(stat, &stat_fp); - - if (chdir(rootdir)) - perror_exit(rootdir); - - add_pattern(".git/", ".", strlen(".")); - - if (traverse_directory(".", strlen("."))) - print_path("./"); - - assert(depth =3D=3D 0); - - while (nr_patterns > 0) - free(pattern_list[--nr_patterns]); - free(pattern_list); - free(nr_patterns_at); - - close_output(output, out_fp); - if (stat_fp) - close_output(stat, stat_fp); - - return 0; -} diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch new file mode 100755 index 000000000000..f842ab50a780 --- /dev/null +++ b/scripts/package/gen-diff-patch @@ -0,0 +1,44 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +diff_patch=3D"${1}" +untracked_patch=3D"${2}" +srctree=3D$(dirname $0)/../.. + +rm -f ${diff_patch} ${untracked_patch} + +if ! ${srctree}/scripts/check-git; then + exit +fi + +mkdir -p "$(dirname ${diff_patch})" "$(dirname ${untracked_patch})" + +git -C "${srctree}" diff HEAD > "${diff_patch}" + +if [ ! -s "${diff_patch}" ]; then + rm -f "${diff_patch}" + exit +fi + +git -C ${srctree} status --porcelain --untracked-files=3Dall | +while read stat path +do + if [ "${stat}" =3D '??' ]; then + + if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && + ! head -n1 .tmp_diff | grep -q "Binary files"; then + { + echo "--- /dev/null" + echo "+++ linux/$path" + cat .tmp_diff | tail -n +3 + } >> ${untracked_patch} + fi + fi +done + +rm -f .tmp_diff + +if [ ! -s "${diff_patch}" ]; then + rm -f "${diff_patch}" + exit +fi diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index e80a661a79ee..65f6c1abe660 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -88,10 +88,11 @@ rm -rf debian =20 # Some variables and settings used throughout the script version=3D$KERNELRELEASE + if [ -n "$KDEB_PKGVERSION" ]; then packageversion=3D$KDEB_PKGVERSION else - packageversion=3D$version-$($srctree/init/build-version) + packageversion=3D$(${srctree}/scripts/setlocalversion --no-local ${srctre= e})-$($srctree/init/build-version) fi sourcename=3D${KDEB_SOURCENAME:-linux-upstream} =20 @@ -152,6 +153,14 @@ mkdir -p debian/patches } > debian/patches/config echo config > debian/patches/series =20 +$(dirname $0)/gen-diff-patch debian/patches/diff.patch debian/patches/untr= acked.patch +if [ -f debian/patches/diff.patch ]; then + echo diff.patch >> debian/patches/series +fi +if [ -f debian/patches/untracked.patch ]; then + echo untracked.patch >> debian/patches/series +fi + echo $debarch > debian/arch extra_build_depends=3D", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:= native)" extra_build_depends=3D"$extra_build_depends, $(if_enabled_echo CONFIG_SYST= EM_TRUSTED_KEYRING libssl-dev:native)" diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 3c550960dd39..a80d0483c655 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -15,6 +15,11 @@ if [ "$1" =3D prebuilt ]; then MAKE=3D"$MAKE -f $srctree/Makefile" else S=3D + + mkdir -p rpmbuild/SOURCES + cp .config rpmbuild/SOURCES/config + $(dirname $0)/gen-diff-patch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES= /untracked.patch + touch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch fi =20 if grep -q CONFIG_MODULES=3Dy .config; then @@ -48,7 +53,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <&2 + echo "Usage: $0 [--no-local] [srctree]" >&2 exit 1 } =20 +no_local=3Dfalse +if test "$1" =3D "--no-local"; then + no_local=3Dtrue + shift +fi + srctree=3D. if test $# -gt 0; then srctree=3D$1 @@ -26,14 +32,22 @@ fi =20 scm_version() { - local short + local short=3Dfalse + local no_dirty=3Dfalse local tag - short=3Dfalse + + while [ $# -gt 0 ]; + do + case "$1" in + --short) + short=3Dtrue;; + --no-dirty) + no_dirty=3Dtrue;; + esac + shift + done =20 cd "$srctree" - if test "$1" =3D "--short"; then - short=3Dtrue - fi =20 if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then return @@ -75,6 +89,10 @@ scm_version() printf '%s%s' -g "$(echo $head | cut -c1-12)" fi =20 + if ${no_dirty}; then + return + fi + # Check for uncommitted changes. # This script must avoid any write attempt to the source tree, which # might be read-only. @@ -110,11 +128,6 @@ collect_files() echo "$res" } =20 -if ! test -e include/config/auto.conf; then - echo "Error: kernelrelease not valid - run 'make prepare' to update it" >= &2 - exit 1 -fi - if [ -z "${KERNELVERSION}" ]; then echo "KERNELVERSION is not set" >&2 exit 1 @@ -126,6 +139,16 @@ if test ! "$srctree" -ef .; then file_localversion=3D"${file_localversion}$(collect_files "$srctree"/local= version*)" fi =20 +if ${no_local}; then + echo "${KERNELVERSION}$(scm_version --no-dirty)" + 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 +fi + # version string from CONFIG_LOCALVERSION config_localversion=3D$(sed -n 's/^CONFIG_LOCALVERSION=3D\(.*\)$/\1/p' inc= lude/config/auto.conf) =20 --=20 2.34.1