From patchwork Mon Oct 7 13:15:08 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: 281122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 46B4D2C00A9 for ; Tue, 8 Oct 2013 02:00:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B208F8A803; Mon, 7 Oct 2013 15:00:08 +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 WGLfPuat9gkU; Mon, 7 Oct 2013 15:00:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 5AC928A3B3; Mon, 7 Oct 2013 15:00:07 +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 0A6C71CE6F2 for ; Mon, 7 Oct 2013 15:00:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 03AE68A74A for ; Mon, 7 Oct 2013 15:00:06 +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 n-E8JwLHLojg for ; Mon, 7 Oct 2013 15:00:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by whitealder.osuosl.org (Postfix) with ESMTPS id C700B8A3B3 for ; Mon, 7 Oct 2013 15:00:01 +0000 (UTC) Received: by mail-wi0-f174.google.com with SMTP id hj3so4956068wib.1 for ; Mon, 07 Oct 2013 08:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:content-transfer-encoding:subject :message-id:in-reply-to:references:user-agent:date:from:to:cc; bh=MWF4h9Eb0X4WB6sjiOAKHvvyybGpEa/xDS1RJWN4b04=; b=PV8ZiJQtty/XnbTdF5x7v8+NRoyp49XhGiTlu5UYyjPREt8jkEg02DjR9qyvv41jkp lbtofVzuHsIx9FU9jWZ17T+M6+SirEsWMKWqdUloo05QVsYvT24K/RzA6oDGdzWfknAc KoCT2k4auLHF3yqRZxiAzal0RWplzomPrt2jE2k4JMTKB0jzfJKyfdd81uibHKUt2Hbq QenMDZ6O2X+21rF3Z2wpiBcP1U6oStDXYZJ22v2vz5ktIs1j7cgLW8iUsr/uetTh03Vu 0lY4RwpLabdDq5i2YCatxLE5mS19gHz4Pb9eFCLcJiVaH+9zRT7dDv2bo8sNptD+vnXg JsbQ== X-Received: by 10.194.21.104 with SMTP id u8mr1908311wje.63.1381158000160; Mon, 07 Oct 2013 08:00:00 -0700 (PDT) Received: from [127.0.1.1] (alc112.alcatel.be. [195.207.101.112]) by mx.google.com with ESMTPSA id mw9sm10036510wib.0.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Oct 2013 07:59:59 -0700 (PDT) MIME-Version: 1.0 X-Mercurial-Node: e07dc5f55104adb4a1713089f47cf96dd39960ca Message-Id: In-Reply-To: References: User-Agent: Mercurial-patchbomb/2.2.2 Date: Mon, 07 Oct 2013 15:15:08 +0200 From: Thomas De Schampheleire To: buildroot@busybox.net Cc: luca@lucaceresoli.net, thomas.petazzoni@free-electrons.com, jacmet@uclibc.org Subject: [Buildroot] [PATCH 1 of 6 v2] legal info: fix saving of host package licenses 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 Due to some tricky make behavior, the license texts of host packages that did not provide an explicit HOST_FOO_LICENSE_FILES definition was not saved. The problem is that you cannot correctly use a variable defined/updated inside a call'ed block as input to a foreach statement. If you try to use $(FOO) then only the original value of FOO is used for foreach, any update inside the call'ed block is ignored. However, if you use $$(FOO), the entire contents of FOO (typically a list of items) is passed as one item to foreach, thus causing just one iteration instead of several. To fix the problem, one should only use values in foreach that have not changed inside the call'ed block. In the case of (HOST_)FOO_LICENSE_FILES, this means repeating the checks for a valid HOST_FOO_X and using FOO_X as fallback. Additionally, a few empty lines have been added to the legal-info-foo block for clarity, as the amount of nested ifdef/ifeq statements have become very high. Signed-off-by: Thomas De Schampheleire Acked-by: Luca Ceresoli Tested-by: Luca Ceresoli --- v2: - implement a solution for packages that have multiple license files. - fix accidental mixup of code from another patch package/pkg-generic.mk | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -499,26 +499,43 @@ endif $(1)-legal-info: # Packages without a source are assumed to be part of Buildroot, skip them. ifneq ($(call qstrip,$$($(2)_SOURCE)),) + ifeq ($$($(2)_SITE_METHOD),local) # Packages without a tarball: don't save and warn @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),local) + else ifneq ($$($(2)_OVERRIDE_SRCDIR),) @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),override) + else # Other packages + # Save license files if defined ifeq ($(call qstrip,$$($(2)_LICENSE_FILES)),) @$(call legal-license-nofiles,$$($(2)_RAWNAME)) @$(call legal-warning-pkg,$$($(2)_RAWNAME),cannot save license ($(2)_LICENSE_FILES not defined)) else +# We cannot use $$($(2)_LICENSE_FILES) in the foreach below because it fails +# for host packages that have no explicit HOST_FOO_LICENSE_FILES set. We have +# to explicitly repeat the check for HOST_FOO_X and FOO_X. +ifeq ($($(2)_LICENSE_FILES),) +ifneq ($($(3)_LICENSE_FILES),) +# Host package with no explicit HOST_FOO_LICENSE_FILES + @$(foreach F,$($(3)_LICENSE_FILES),$(call legal-license-file,$$($(2)_RAWNAME),$(F),$$($(2)_DIR)/$(F))$$(sep)) +endif +else +# Target package, or host package with explicit HOST_FOO_LICENSE_FILES @$(foreach F,$($(2)_LICENSE_FILES),$(call legal-license-file,$$($(2)_RAWNAME),$(F),$$($(2)_DIR)/$(F))$$(sep)) -endif +endif # host/target distinction +endif # license files + ifeq ($$($(2)_REDISTRIBUTE),YES) # Copy the source tarball (just hardlink if possible) @cp -l $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR) 2>/dev/null || \ cp $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR) -endif -endif +endif # redistribute + +endif # other packages @$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_MANIFEST_TARBALL)) endif # ifneq ($(call qstrip,$$($(2)_SOURCE)),) $(foreach hook,$($(2)_POST_LEGAL_INFO_HOOKS),$(call $(hook))$(sep))