From patchwork Sun Dec 30 22:54:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Martin X-Patchwork-Id: 208803 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 ADA282C00AA for ; Mon, 31 Dec 2012 09:55:14 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EB1F41017BC; Sun, 30 Dec 2012 22:55:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iN80AVNWMFzx; Sun, 30 Dec 2012 22:54:55 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id CA2551017DF; Sun, 30 Dec 2012 22:54:42 +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 2E4488F74B for ; Sun, 30 Dec 2012 22:54:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 418D881695 for ; Sun, 30 Dec 2012 22:54:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D8iDnCBYMUrr for ; Sun, 30 Dec 2012 22:54:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3CD1F8569F for ; Sun, 30 Dec 2012 22:54:34 +0000 (UTC) Received: by mail-wi0-f182.google.com with SMTP id hn14so6785375wib.3 for ; Sun, 30 Dec 2012 14:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=n2fy4ZoglTSX4dsZhr0JsyFfyJoPzbQrslfH6OrHup8=; b=I/GMqB2locnIauc8MxJD9gW14kSAAprN9Ubg9+ebjtiQoskZwNkjWe4g4SMPf9flDt 5GZxd9Wy0xQMeJFHyZtp3w65ko/kzMiBTu2TsWVcm9NHnnIBV1/wxtXpmxufHdyqeleC NU/kDpVtnoXNRlPHu+/NgIKGsG442RI/Ca3OZSTVnx4tlBCoKmtVgeEHBzCuHcszbRfk fpP3antk2k3gbSZ+KZS6+NSOFu5/igA+aQA93AOrVTkvUXmYoSt/rgDSaZJ9HLhaj9xg 9jFfPZHhl1r1fZDscPmiIiA2uZZa9k1Jf9hiqEwt8ZoPFnRoi2Y01almsIIeZj0UL+Sh copQ== X-Received: by 10.180.101.104 with SMTP id ff8mr60362434wib.11.1356908072453; Sun, 30 Dec 2012 14:54:32 -0800 (PST) Received: from localhost.localdomain (ANantes-557-1-155-237.w2-1.abo.wanadoo.fr. [2.1.170.237]) by mx.google.com with ESMTPS id g2sm66911211wiy.0.2012.12.30.14.54.30 (version=SSLv3 cipher=OTHER); Sun, 30 Dec 2012 14:54:31 -0800 (PST) From: Samuel Martin To: buildroot@busybox.net Date: Sun, 30 Dec 2012 23:54:12 +0100 Message-Id: <8e1d83962e16dc1391f96eab724150d47a6ebe8f.1356907750.git.s.martin49@gmail.com> X-Mailer: git-send-email 1.8.0.3 In-Reply-To: References: In-Reply-To: References: Subject: [Buildroot] [PATCH 5/8] dependencies: build a host python2 if no suitable one can be found 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: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Some distros now comes with only python3 installed, with or without a /usr/bin/python pointing to python3. So, /usr/bin/python may refer to either python2 or python3. This may have some bad consequences for packages that uses some non python{2,3}-friendly scripts in their build system (eg. in install or post-install scripts). This patch checks for a suitable python2 version (2.6 or 2.7) on the host system, and: * if a valid python2 interperter is found on the host system, then: - a symlink pointing to the found python2 interpreter is created in the buildroot host tree at the beginning of the build; - a make target host-python2-if-needed is set to '$(HOST_DIR)/usr/bin/python'. This way, if the host-python package is built later, the symlink will be automatically overriden by the host-python install rules. * if no valid python2 interperter is found on the host system, then: - a make target host-python2-if-needed is set to 'host-python'. Note 1: The symlink is checked and created if necessary at the beginning of each build. Note 2: Since there is no target named '$(HOST_DIR)/usr/bin/python' in the python makefiles, there is no need for removing the symlink before installing the host-pyhton package. Note 3: The host-python is only built when necessary. This also means that in the case there is no python2 interperter available on the host system, there won't any host python2 interperter until the host-python package is built. Note 4: Any package containing some non python{2,3}-friendly scripts should: - have 'host-python2-if-needed' in its *_DEPENDENCIES list; - set and add to their build/install environment, either PATH="$(HOST_PATH)" or PATH="$(TARGET_PATH)". A (good) side effect of this patch is getting rid of any host python dependency. Buildroot can run on a host without python, or with a too old python2 version, or with only python3. In any case where a host python2 interpreter is expected to run some build or install scripts, 'host-python2-if-needed' should be added to the dependency list. With this patch, the host python2 interpreter is either found in the host system, or build by Buildroot. So, we can drop the python dependency check. Signed-off-by: Samuel Martin --- support/dependencies/check-host-python2.mk | 18 ++++++++++++++++++ support/dependencies/check-host-python2.sh | 13 +++++++++++++ support/dependencies/dependencies.sh | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 support/dependencies/check-host-python2.mk create mode 100755 support/dependencies/check-host-python2.sh diff --git a/support/dependencies/check-host-python2.mk b/support/dependencies/check-host-python2.mk new file mode 100644 index 0000000..5bc2986 --- /dev/null +++ b/support/dependencies/check-host-python2.mk @@ -0,0 +1,18 @@ +PYTHON2 = $(call suitable-host-package,python2,$(HOST_DIR)/usr/bin/python) + +ifeq ($(PYTHON2),) +host-python2-if-needed: host-python +else +host-python2-if-needed: $(HOST_DIR)/usr/bin/python +# Create the python symlink once for all at the beginning of the build. +DEPENDENCIES_HOST_PREREQ += host-python2-symlink +endif + +# host-python install rules override the symlink created here. +# So, there is no need to patch the python package to remove the symlink +# before installing itself. +host-python2-symlink: + @mkdir -p $(HOST_DIR)/usr/bin + test -x "$(HOST_DIR)/usr/bin/python" -a \ + "$(PYTHON2)" = "$(HOST_DIR)/usr/bin/python" || \ + $(HOSTLN) -sf "$(PYTHON2)" "$(HOST_DIR)/usr/bin/python" diff --git a/support/dependencies/check-host-python2.sh b/support/dependencies/check-host-python2.sh new file mode 100755 index 0000000..a340674 --- /dev/null +++ b/support/dependencies/check-host-python2.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +candidates="${@} python python2" + +for candidate in ${candidates} ; do + which "${candidate}" &>/dev/null || continue + # restrict version of python2 to 2.6 or 2.7 + if "${candidate}" --version 2>&1 | grep -q 'Python 2\.[6-7]\..*' ; then + # found a valid candidate, so quit now + echo $(which "${candidate}") + exit + fi +done diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh index eb5a481..1427ce3 100755 --- a/support/dependencies/dependencies.sh +++ b/support/dependencies/dependencies.sh @@ -131,7 +131,7 @@ if ! $SHELL --version 2>&1 | grep -q '^GNU bash'; then fi; # Check that a few mandatory programs are installed -for prog in awk bison flex msgfmt makeinfo patch gzip bzip2 perl tar wget cpio python unzip rsync ${DL_TOOLS} ; do +for prog in awk bison flex msgfmt makeinfo patch gzip bzip2 perl tar wget cpio unzip rsync ${DL_TOOLS} ; do if ! which $prog > /dev/null ; then /bin/echo -e "\nYou must install '$prog' on your build machine"; if test $prog = "makeinfo" ; then