From patchwork Mon Jul 16 21:38:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Martin X-Patchwork-Id: 171269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 09FFD2C012A for ; Tue, 17 Jul 2012 07:39:46 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 17867A01EE; Mon, 16 Jul 2012 21:39:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cyd4v-R2kkfC; Mon, 16 Jul 2012 21:39:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id A172CA01CE; Mon, 16 Jul 2012 21:39:29 +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 220CA8F753 for ; Mon, 16 Jul 2012 21:39:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 197ED80597 for ; Mon, 16 Jul 2012 21:39:29 +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 w4mV09cag+qp for ; Mon, 16 Jul 2012 21:39:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) by whitealder.osuosl.org (Postfix) with ESMTPS id 89D9E854BD for ; Mon, 16 Jul 2012 21:39:27 +0000 (UTC) Received: by mail-we0-f171.google.com with SMTP id x43so8345129wey.16 for ; Mon, 16 Jul 2012 14:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=hRU4zIWBNZ+rPISYdvDAyw515XyRR62UbWmlwSkTUME=; b=tXqmPLlQzoZ+oKXwOvZbqinPM/+wpCGW8qVuMAcIi/Ix/eh0Vjqn4emEpJItPUiIT0 oj394hvHIY1TWIEBOQhruKboq6rMSXVLer6N5NOKN1GpIzIFHESQN6Plk2K0zojGbxFL 3I2G3blhjXp5BavZ5H/dMmY8HSG90n2N72QRGou/pKKHkieZqbVRKhVJ39DSEbX65vLj p00PnSlceWDqYdYstvOaFqOtYXkebLvRZaFZki3CyFFSMN82wBv3YC/ykAa9Ni7WUN1+ speuAkJ5n5GeiegH3Yn5tKm1mcZphF/HcF2G51IcFsiJyF/dWqo4DlVOA2leum8p4ik0 +kCQ== Received: by 10.180.106.137 with SMTP id gu9mr21254546wib.20.1342474767179; Mon, 16 Jul 2012 14:39:27 -0700 (PDT) Received: from localhost.localdomain (ivr94-4-82-229-165-48.fbx.proxad.net. [82.229.165.48]) by mx.google.com with ESMTPS id o2sm34727917wiz.11.2012.07.16.14.39.25 (version=SSLv3 cipher=OTHER); Mon, 16 Jul 2012 14:39:26 -0700 (PDT) From: Samuel Martin To: buildroot@busybox.net Date: Mon, 16 Jul 2012 23:38:05 +0200 Message-Id: <1342474686-10167-1-git-send-email-s.martin49@gmail.com> X-Mailer: git-send-email 1.7.11.2 Subject: [Buildroot] [PATCH v4 1/2] 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 choose to change the /usr/bin/python binary, making it pointed to python3 instead of python2. This may have some bad consequences for packages that uses some non-python3-compliant python 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 declares the following variables: - PYTHON2: pointing to the host python2 binary; - NEED_PYTHON2: sets to "host-python" if no python2 binary has been found. This way, a package using some python2 scripts must: - adds $(NEED_PYTHON2) to its dependency list; - sets $(PYTHON2) as the python binary to be used. A side effect of this patch is getting rid of any host python. Buildroot can runs on a host without python, or with a too old python2 version, or with only python3; in such case, $(NEED_PYTHON2) should be added to the dependency list. So, we can get rid of the python dependency check. Signed-off-by: Samuel Martin --- Changelog: Changes since v3: - minor fix Changes since v2: - misc. fixes and cleanup Changes since v1: - use support/dependency infrastructure - rename some symbols 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..ddae701 --- /dev/null +++ b/support/dependencies/check-host-python2.mk @@ -0,0 +1,6 @@ +PYTHON2 = $(call suitable-host-package,python2) + +ifeq ($(PYTHON2),) + NEED_PYTHON2 = host-python + PYTHON2 = $(HOST_DIR)/usr/bin/python +endif diff --git a/support/dependencies/check-host-python2.sh b/support/dependencies/check-host-python2.sh new file mode 100755 index 0000000..6ad4b3a --- /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 9f0f6a9..ec175f5 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