From patchwork Thu Jul 26 10:21:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 10545545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55F6814E2 for ; Thu, 26 Jul 2018 10:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4419B2B014 for ; Thu, 26 Jul 2018 10:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38CB92B017; Thu, 26 Jul 2018 10:21:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA1F2B013 for ; Thu, 26 Jul 2018 10:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729111AbeGZLhM (ORCPT ); Thu, 26 Jul 2018 07:37:12 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:59839 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728956AbeGZLhM (ORCPT ); Thu, 26 Jul 2018 07:37:12 -0400 Received: from ben by shadbolt.decadent.org.uk with local (Exim 4.84_2) (envelope-from ) id 1fidOH-0004r0-Bw; Thu, 26 Jul 2018 11:21:01 +0100 Date: Thu, 26 Jul 2018 11:21:01 +0100 From: Ben Hutchings To: linux-kbuild@vger.kernel.org Cc: debian-kernel@lists.debian.org Message-ID: <20180726102101.GX14131@decadent.org.uk> References: <20180726101934.GT14131@decadent.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180726101934.GT14131@decadent.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ben@decadent.org.uk Subject: [PATCH 04/12] builddeb: Introduce functions to simplify kconfig tests in set_debarch X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We now have many repetitive greps over the kernel config. Refactor them into functions. Signed-off-by: Ben Hutchings --- scripts/package/mkdebian | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index f4449b575379..ada3c73d1493 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -6,6 +6,18 @@ set -e +is_enabled() { + grep -q "^CONFIG_$1=y" $KCONFIG_CONFIG +} + +if_enabled_echo() { + if is_enabled "$1"; then + echo -n "$2" + elif [ $# -ge 3 ]; then + echo -n "$3" + fi +} + set_debarch() { if [ -n "$KBUILD_DEBARCH" ] ; then debarch="$KBUILD_DEBARCH" @@ -23,22 +35,18 @@ set_debarch() { s390*) debarch=s390x ;; ppc*) - debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; + debarch=$(if_enabled_echo CPU_LITTLE_ENDIAN ppc64el powerpc) ;; parisc*) debarch=hppa ;; mips*) - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;; + debarch=mips$(if_enabled_echo CPU_LITTLE_ENDIAN el) ;; aarch64|arm64) debarch=arm64 ;; arm*) - if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then - if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then - debarch=armhf - else - debarch=armel - fi + if is_enabled AEABI; then + debarch=arm$(if_enabled_echo VFP hf el) else - debarch=arm + debarch=arm fi ;; *)