From patchwork Fri Aug 2 09:05:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas De Schampheleire X-Patchwork-Id: 264231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 566162C0091 for ; Fri, 2 Aug 2013 19:05:52 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id BC8CF8BEEB; Fri, 2 Aug 2013 09:05:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dawIIkDrUhvf; Fri, 2 Aug 2013 09:05:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 67A1D8BA0A; Fri, 2 Aug 2013 09:05:49 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id BFC101C2DD7 for ; Fri, 2 Aug 2013 09:06:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 65DC98CE0D for ; Fri, 2 Aug 2013 09:05:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LfEwXrm4QBci for ; Fri, 2 Aug 2013 09:05:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com [209.85.215.172]) by whitealder.osuosl.org (Postfix) with ESMTPS id 636948C64A for ; Fri, 2 Aug 2013 09:05:47 +0000 (UTC) Received: by mail-ea0-f172.google.com with SMTP id r16so196221ead.3 for ; Fri, 02 Aug 2013 02:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:in-reply-to:references:user-agent:date :from:to:cc; bh=88RIhVUe4MkWDAqPdVtqcCBjOxQOuSILq+sxpG91TmU=; b=mY7Uqy9tD2es+7B8VJru4zda7CB1iYEMfksF6D0pD8dvK6G13Me+d8NCvf1s8/PJo3 W0lzlFgRlHezdS7rpMQIYc2Nl8Efx1qSrU3z18SA6mup21NXFoX9iZ3XkHw2+05iHw2U QcentXF/5cRqulhYiaLOh67fBxxTd6JUDdQcXr1I1qrgcF5atTKaP37MpCPrPr2Yz0xH b/0UQK2AQp2YGNAo4CwpFkVX+gcvns0KpJowyfjIXqP1/UAcxUPaTMuRFy/uesCLUs65 zLSsp6n+Y+lAkd2Ncg2eLUHbUzg2Y9PcsGl0VjNOVBg0vNO1gir8uMBzJVBxgf1iPbME ARSg== X-Received: by 10.15.111.136 with SMTP id cj8mr4850265eeb.91.1375434345787; Fri, 02 Aug 2013 02:05:45 -0700 (PDT) Received: from [127.0.1.1] (d54C62EEB.access.telenet.be. [84.198.46.235]) by mx.google.com with ESMTPSA id cg12sm10499662eeb.7.2013.08.02.02.05.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:05:45 -0700 (PDT) MIME-Version: 1.0 X-Mercurial-Node: bb19f03cbc968ff3c2a48c3a3638248f6c6e27ef Message-Id: In-Reply-To: References: User-Agent: Mercurial-patchbomb/2.2.2 Date: Fri, 02 Aug 2013 11:05:14 +0200 From: Thomas De Schampheleire To: buildroot@busybox.net Cc: thomas.petazzoni@free-electrons.com Subject: [Buildroot] [PATCH 1 of 2 v3] infra: introduce suitable-extractor helper function X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net In order to simplify determining the right extractor tool for a given file type, this patch introduces a make function 'suitable-extractor'. Its usage is $(call suitable-extractor,filename), and it returns the path to the suitable extractor. Signed-off-by: Thomas De Schampheleire --- v3: Correct $(firstword) usage (v2): new patch in series Note: one remaining direct usage of the INFLATE variables is in package/pkg-generic.mk, but it's in the inner block where dollar signs are thrown around your ears. I'm not sure if it's possible to use the function there... package/lsof/lsof.mk | 2 +- package/perl/perl.mk | 2 +- package/pkg-generic.mk | 4 +++- package/pkg-utils.mk | 2 ++ package/tar/tar.mk | 2 +- toolchain/toolchain-external/ext-tool.mk | 6 +++--- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package/lsof/lsof.mk b/package/lsof/lsof.mk --- a/package/lsof/lsof.mk +++ b/package/lsof/lsof.mk @@ -41,7 +41,7 @@ endif # The .tar.bz2 contains another .tar, which contains the source code. define LSOF_EXTRACT_CMDS - $(INFLATE.bz2) $(DL_DIR)/$(LSOF_SOURCE) | \ + $(call suitable-extractor,$(LSOF_SOURCE)) $(DL_DIR)/$(LSOF_SOURCE) | \ $(TAR) -O $(TAR_OPTIONS) - lsof_$(LSOF_VERSION)/lsof_$(LSOF_VERSION)_src.tar | \ $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(LSOF_DIR) $(TAR_OPTIONS) - endef diff --git a/package/perl/perl.mk b/package/perl/perl.mk --- a/package/perl/perl.mk +++ b/package/perl/perl.mk @@ -30,7 +30,7 @@ endef PERL_POST_DOWNLOAD_HOOKS += PERL_CROSS_DOWNLOAD define PERL_CROSS_EXTRACT - $(INFLATE$(suffix $(PERL_CROSS_SOURCE))) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \ + $(call suitable-extractor,$(PERL_CROSS_SOURCE)) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \ $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) - endef PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -539,7 +539,9 @@ else ifeq ($$($(2)_SITE_METHOD),hg) DL_TOOLS_DEPENDENCIES += hg endif # SITE_METHOD -DL_TOOLS_DEPENDENCIES += $(firstword $(INFLATE$(suffix $($(2)_SOURCE)))) +# $(firstword) is used here because the extractor can have arguments, like +# ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'. +DL_TOOLS_DEPENDENCIES += $(firstword $(call suitable-extractor,$($(2)_SOURCE))) endif # $(2)_KCONFIG_VAR endef # inner-generic-package diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk --- a/package/pkg-utils.mk +++ b/package/pkg-utils.mk @@ -62,6 +62,8 @@ INFLATE.tbz2 = $(BZCAT) INFLATE.tgz = $(ZCAT) INFLATE.xz = $(XZCAT) INFLATE.tar = cat +# suitable-extractor(filename): returns extractor based on suffix +suitable-extractor = $(INFLATE$(suffix $(1))) # MESSAGE Macro -- display a message in bold type MESSAGE = echo "$(TERM_BOLD)>>> $($(PKG)_NAME) $($(PKG)_VERSION) $(1)$(TERM_RESET)" diff --git a/package/tar/tar.mk b/package/tar/tar.mk --- a/package/tar/tar.mk +++ b/package/tar/tar.mk @@ -23,7 +23,7 @@ HOST_TAR_SOURCE = tar-$(TAR_VERSION).cpi define HOST_TAR_EXTRACT_CMDS mkdir -p $(@D) cd $(@D) && \ - $(INFLATE.gz) $(DL_DIR)/$(HOST_TAR_SOURCE) | cpio -i + $(call suitable-extractor,$(HOST_TAR_SOURCE)) $(DL_DIR)/$(HOST_TAR_SOURCE) | cpio -i mv $(@D)/tar-$(TAR_VERSION)/* $(@D) rmdir $(@D)/tar-$(TAR_VERSION) endef diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk --- a/toolchain/toolchain-external/ext-tool.mk +++ b/toolchain/toolchain-external/ext-tool.mk @@ -337,9 +337,9 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_ $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) mkdir -p $(@D) - $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_1))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) | \ + $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE_1)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) | \ $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) - - $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_2))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) | \ + $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE_2)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) | \ $(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) - $(Q)touch $@ else @@ -349,7 +349,7 @@ else $(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) mkdir -p $(@D) - $(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE))) $^ | \ + $(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $^ | \ $(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(@D) $(TAR_OPTIONS) - $(TOOLCHAIN_EXTERNAL_FIXUP_CMDS) $(Q)touch $@