From patchwork Thu Mar 9 11:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B6rg_Krause?= X-Patchwork-Id: 736975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vf80h5P9tz9s7f for ; Thu, 9 Mar 2017 22:53:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=embedded.rocks header.i=@embedded.rocks header.b="3N/pvMgw"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A04E930D71; Thu, 9 Mar 2017 11:53:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iCrSGV4IZ+mD; Thu, 9 Mar 2017 11:53:02 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 3F40E306E6; Thu, 9 Mar 2017 11:53:02 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id DED731BFFCA for ; Thu, 9 Mar 2017 11:53:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DA6A888C60 for ; Thu, 9 Mar 2017 11:53:00 +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 z62Bss6ibe6p for ; Thu, 9 Mar 2017 11:52:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 34EE088C5E for ; Thu, 9 Mar 2017 11:52:59 +0000 (UTC) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 3vf80R3Xx4zyy6; Thu, 9 Mar 2017 12:52:55 +0100 (CET) Authentication-Results: mail.embedded.rocks (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=embedded.rocks DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embedded.rocks; h=content-transfer-encoding:content-type:content-type :mime-version:x-mailer:message-id:date:date:subject:subject:from :from:received:received; s=default; t=1489060373; x=1489665174; bh=Jw4O9MMazwIFDPmDRQ8p5xJBPiY6mLWXr7wAnUBd3wA=; b=3N/pvMgwIxTx HXHjgQQiEMoNuhzFS5CQiLfFLWlBkXlHTPDMWnuHdgKUq7ZVM1fQBz5k+KreZrnt RfIrBWBo6UheWizCMrvHrAmCM6G7J6t4kVWhkyX7JE8mhuGNnb3mbW+jurVwUJdD ALtO3Ugj7asbaFVrWmbta0LCsZaNRXBFV8+CY1c5JZQG0IJG/rOjNmZ68op3d7E/ vPfAZMeB9KW691sqy0uxEIz6TcRw1DnIGnEesthQVi3ps3Zib+8IGYVR7Gr1kf7c XI3jqv30CX1+faMbES6xebDD0LxH7WAJH0p+hh66fafr6qAeXqfpByLeiPramLuh kPME6SneVg== Received: from mail.embedded.rocks ([127.0.0.1]) by localhost (mail.embedded.rocks [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id VxFLkKgbJOta; Thu, 9 Mar 2017 12:52:53 +0100 (CET) Received: from nzxt.fritz.box (xd9bade61.dyn.telefonica.de [217.186.222.97]) (Authenticated sender: joerg.krause@embedded.rocks) by mail.embedded.rocks (Postfix) with ESMTPSA; Thu, 9 Mar 2017 12:52:53 +0100 (CET) From: =?UTF-8?q?J=C3=B6rg=20Krause?= To: buildroot@buildroot.org Date: Thu, 9 Mar 2017 12:52:47 +0100 Message-Id: <20170309115247.16981-1-joerg.krause@embedded.rocks> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 Cc: Thomas Petazzoni Subject: [Buildroot] [PATCH v3] boot/uboot: fix build for sunxi targets X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 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" Since version 2017.01 U-Boot needs to run the binman tool on the host machine for building the 'u-boot-sunxi-with-spl.bin' target. The binman tool is written in Python 2 and therefore needs a Python 2 interpreter. The python scripts sets the shebang to: `#!/usr/bin/env python`. For modern Linux distributions `python` is set to the Python 3 interpreter. In this case, building U-Boot for a sunxi-based target fails: ``` BINMAN u-boot-sunxi-with-spl.bin File "./tools/binman/binman", line 49 print result ^ SyntaxError: Missing parentheses in call to 'print' make[1]: *** [Makefile:1090: u-boot-sunxi-with-spl.bin] Error 1 ``` Add a post patch hook to force the shebang to python2 in case the binman file exists. Reported upstream: https://lists.denx.de/pipermail/u-boot/2017-March/283164.html Tested for U-Boot versions: * 2016.07 (no binman tool, custom version) * 2017.01 (binman tool, latest version) * 2017.03-rc3 (binman tool, custom version) Signed-off-by: Jörg Krause Cc: Peter Korsgaard Cc: Thomas Petazzoni --- v3: * use a post patch hook to support custom U-Boot versions (suggested by Thomas) v2: * add patch to fix shebang instead of adding a host dependency for python (suggested by Peter Korsgaard) --- boot/uboot/uboot.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk index 1e22eaa8e..bbf61fca5 100644 --- a/boot/uboot/uboot.mk +++ b/boot/uboot/uboot.mk @@ -36,6 +36,18 @@ BR_NO_CHECK_HASH_FOR += $(UBOOT_SOURCE) endif endif +# The binman tool was introduced in version 2017.01. The tool is a set +# python scripts and requires a python2 interpreter. Force the shebang +# python2 to ensure the correct interpreter is used on host systems +# where python defaults to the python3 interpreter. +define UBOOT_TRY_SED_SHEBANG_BINMAN + if test -f $(@D)/tools/binman/binman; then \ + sed -i '1s_^\(#!/usr/bin/env \).*_\1python2_' \ + $(@D)/tools/binman/binman; \ + fi +endef +UBOOT_POST_PATCH_HOOKS += UBOOT_TRY_SED_SHEBANG_BINMAN + ifeq ($(BR2_TARGET_UBOOT_FORMAT_BIN),y) UBOOT_BINS += u-boot.bin endif