From patchwork Fri Mar 8 09:56:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 159965 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8504979jad; Fri, 8 Mar 2019 01:57:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyz7KpFin/jQbVqWhPAayGf1OZEQF23rZyfgFrdphocQnlK+mq47leX4PcbrsS3mfGSEGa0 X-Received: by 2002:a17:902:e5:: with SMTP id a92mr7400951pla.326.1552039028284; Fri, 08 Mar 2019 01:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552039028; cv=none; d=google.com; s=arc-20160816; b=K+QZ4Nh1Ml5dIKsEtqDFZxgjTSGweVYX4r0i/DETFEusoSpxxTubKMz4T5UMDS5evD ASy53/B1g4+8TOMdASc5TShAjR9Z7lt8PCUv/Z4b6XjKjKCuPXqgklNsaiRLkYOXADxI zsEBiZN3eaC1z7cDASttAQoP3l0UJyepSbYpfNeQDVuec7uRn0BZhDmpGxF89KkC5YVK MdrCzvQYcnoJksohwt7Z86x60oPDYilLgqF317GaWHmhQFOdN49k7yj6evfZ9qwO4KdV GIacj3AzAc6GDhUNHHNKCYzkjIWiEjfng2PYDZHq3mC2J+F+NKD4kBF+ouQcn0jqDP/N 91XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=RgPK6RyeZQS/j5UUx+A+6DjCZHX16Ul3T0bN38trg6A=; b=B5uGhSS+4NMQ+lXD47yZMKFGdJWnqJdkV/jf459NXLffMdj6b6kEloFt3pKEcepz4Q +efuKKle/0yIXRqOQHqsEBCiRJrs9PJXX5dzevXpK3EcY5n0Sl7pa4whsPU3zO4AVCZD Wf7NOHFVLS9Xp9Zwhzuamhz0f0qCOGb8lgxlc2l6QVeZ4tRAXJdS4oxWk6YY3GVzRmyr Piy7r1u+cceZ3oQ+JAJ+2shM8LIWdgNr9ywddG4GhjMla5uSuHRBk4ezEOvOLg58DHRM MNSFNpxd3N7DErou3t9co0/mJsgGVtHhwwt6i0gEInsdXv+l0kUi6GcAmAcewbYZLLeA 12Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=U5Mf7vt2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si3432047pgk.158.2019.03.08.01.57.08; Fri, 08 Mar 2019 01:57:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=U5Mf7vt2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbfCHJ5G (ORCPT + 31 others); Fri, 8 Mar 2019 04:57:06 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:58422 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbfCHJ5E (ORCPT ); Fri, 8 Mar 2019 04:57:04 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x289uSqb003883; Fri, 8 Mar 2019 18:56:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x289uSqb003883 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552038989; bh=RgPK6RyeZQS/j5UUx+A+6DjCZHX16Ul3T0bN38trg6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5Mf7vt2Lj55D8v4cq5ylCQruTnP6JnFCKh6LKWQK2HqEBRvbN/FDiOjClhBDTklG x9BMLQElIweMk+QLXy8OTWdcCSurHVgmXR6X0RMXC9hrZWkIi8BNhU6ASmN4JV9d+G 53I3XxLaze+i0kTenvYW0oQYAXM+8d8gLVIeblYuGnyIFX/mrGRb+JnEcVzH4hfJ2J ee2vMtOpsE0J6hK7R/rXaVqSv/VsUcHNPtrbui+NumMxeWPL1QZXIJfNPJxFnjItJ3 JBNupGhbtx7a9LS84ZeLAuYe+TYpNXQCcxlOiBoFqcIYKUJAFXiLHCMNYyc6MPAGII vz2mzdjqsqB/A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] kbuild: deb-pkg: introduce is_enabled and if_enabled_echo to builddeb Date: Fri, 8 Mar 2019 18:56:24 +0900 Message-Id: <1552038985-10473-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552038985-10473-1-git-send-email-yamada.masahiro@socionext.com> References: <1552038985-10473-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think is_enabled() and if_enable_echo() in scripts/package/mkdebian are useful. builddeb also has many repetitive greps over the kernel config, so I borrowed the idea to clean it up. Signed-off-by: Masahiro Yamada --- scripts/package/builddeb | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 8ac25d1..e2cb438 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -12,6 +12,18 @@ set -e +is_enabled() { + grep -q "^$1=y" $KCONFIG_CONFIG +} + +if_enabled_echo() { + if is_enabled "$1"; then + echo -n "$2" + elif [ $# -ge 3 ]; then + echo -n "$3" + fi +} + create_package() { local pname="$1" pdir="$2" @@ -62,7 +74,7 @@ parisc|mips|powerpc) installed_image_path="boot/vmlinuz-$version" esac -BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" +BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes) # Setup the directory structure rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files @@ -83,14 +95,14 @@ else fi cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path" -if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then +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="$tmpdir/usr/lib/$packagename" dtbs_install fi fi -if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then +if is_enabled CONFIG_MODULES; then INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install rm -f "$tmpdir/lib/modules/$version/build" rm -f "$tmpdir/lib/modules/$version/source" @@ -111,8 +123,7 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then done # resign stripped modules - MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" - if [ -n "$MODULE_SIG_ALL" ]; then + if is_enabled CONFIG_MODULE_SIG_ALL; then INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign fi fi @@ -129,11 +140,6 @@ fi # 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=${KDEB_HOOKDIR:-/etc/kernel} -if grep -q '^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG; then - want_initrd=Yes -else - want_initrd=No -fi for script in postinst postrm preinst prerm ; do mkdir -p "$tmpdir$debhookdir/$script.d" cat < "$tmpdir/DEBIAN/$script" @@ -145,7 +151,7 @@ set -e export DEB_MAINT_PARAMS="\$*" # Tell initramfs builder whether it's wanted -export INITRD=$want_initrd +export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d exit 0 @@ -158,11 +164,11 @@ done (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" -if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then +if is_enabled CONFIG_STACK_VALIDATION; then (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" fi (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" -if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then +if is_enabled CONFIG_GCC_PLUGINS; then (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" fi destdir=$kernel_headers_dir/usr/src/linux-headers-$version