From patchwork Wed Oct 16 11:19:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Lange X-Patchwork-Id: 1177815 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fpbgLQzA"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46tVFV4FTRz9sCJ for ; Wed, 16 Oct 2019 22:19:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 835E68830F; Wed, 16 Oct 2019 11:19:53 +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 yOmvWXCQW6i1; Wed, 16 Oct 2019 11:19:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id D772B882FC; Wed, 16 Oct 2019 11:19:50 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 571951BF484 for ; Wed, 16 Oct 2019 11:19:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4BC9F23236 for ; Wed, 16 Oct 2019 11:19:47 +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 FJoke20YOM8R for ; Wed, 16 Oct 2019 11:19:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by silver.osuosl.org (Postfix) with ESMTPS id 5821F204B5 for ; Wed, 16 Oct 2019 11:19:43 +0000 (UTC) Received: by mail-wm1-f51.google.com with SMTP id m18so2338092wmc.1 for ; Wed, 16 Oct 2019 04:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HwMDNYVonaBreRGzVH5l2pCzZuWfiMF/jNAM9AdINtk=; b=fpbgLQzAo/OEzlTF9kIOLp1tcZwuHchgEyob9oA+VZCB0sbPnUWubXX88OfK05UoWz 0ZsX8rk4WvuC8GqnNVhnx9yB3Loxls40R1JLbI+ybdSbD1Hl1hhoP5kueM4GITJFmwXV qouGq3sRtp12JZDkKcKkBD4/aiXGl0FpsKel2iSH044DEFYfkL2Wlq1WVTQXe1plVCKs cB5CvEha4Jnfi6vHW0yQf2Px+fSHqPjqpmtt8CWRUCRkzzXNHdxBzu3ibr5k6oslujiq TD8aN1to/4DsX02B10XvcEUFtgc7f3Nk3DL4u0GcdPrH99BTdZYoF0uv2VVyvcuuWOgn gJlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HwMDNYVonaBreRGzVH5l2pCzZuWfiMF/jNAM9AdINtk=; b=hMdvCmfepw/b7OdZOGfdRr1L2cFvD9i+yYTUynM7X22TO9Mq09SjrA3bky6OTanLag igB66qYhdUBlWORAKA78698PpQUbK6i9DMGRBy9zZyxAVn13CgHowO+9Y303AKzg4Mgf gbcXDtDKpf7lR8L0eRupPOPUgydsMU4W5MqLMNNhkBfKdzda4mqGMVw7Igo4UG/e3uQ8 T/CmW85z01xIK9qTi8UUd3W8fpOLqFNwW1u9ekMhzE1tEOF+KOJxwMFPvjj6d9myVsWL +xaNcSHXCqMKvuGoOWwWL8LZSvm6j8aPgVBYCAMGl4X9ztwtUj4flIkaiveRG1poCcF/ KI3Q== X-Gm-Message-State: APjAAAUTxbs6mbnMfC/kGm3Ra1uolLqklg88k1h2U3X8bZw4Jhq8qlep 1fgGgPJUdDnMAr26vKQdxWmMYmRa X-Google-Smtp-Source: APXvYqw7prvjEt2WDX60CkknuPwy7cDZmOVdGwyAtZftazKA2HA1BT9H19kHacQA09YwN8H4EIuS8w== X-Received: by 2002:a1c:5408:: with SMTP id i8mr2886254wmb.149.1571224781244; Wed, 16 Oct 2019 04:19:41 -0700 (PDT) Received: from lano-work.andritz.com ([80.120.136.76]) by smtp.gmail.com with ESMTPSA id e18sm34118311wrv.63.2019.10.16.04.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 04:19:40 -0700 (PDT) From: Norbert Lange To: buildroot@buildroot.org Date: Wed, 16 Oct 2019 13:19:27 +0200 Message-Id: <20191016111927.14208-5-nolange79@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016111927.14208-1-nolange79@gmail.com> References: <20191016111927.14208-1-nolange79@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 4/4] support/dependencies: use a helper script for common checks X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Le Bihan , Norbert Lange Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Signed-off-by: Norbert Lange --- support/dependencies/check-host-cmake.sh | 47 +++--------------------- support/dependencies/check-host-make.sh | 39 +++----------------- support/dependencies/check-host-meson.sh | 44 ++-------------------- support/dependencies/check-host-ninja.sh | 44 ++-------------------- support/dependencies/versioncheck.sh | 45 +++++++++++++++++++++++ 5 files changed, 61 insertions(+), 158 deletions(-) create mode 100755 support/dependencies/versioncheck.sh diff --git a/support/dependencies/check-host-cmake.sh b/support/dependencies/check-host-cmake.sh index fadeae9f6b..0699ddf571 100755 --- a/support/dependencies/check-host-cmake.sh +++ b/support/dependencies/check-host-cmake.sh @@ -1,45 +1,8 @@ #!/bin/sh -# prevent shift error -[ $# -lt 2 ] && exit 1 +readversion() { + "$1" --version | + sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' -e 's//\1/' +} -major_min="${1%.*}" -minor_min="${1#*.}" - -shift - -for candidate; do - - # Try to locate the candidate. Discard it if not located. - cmake=`which "${candidate}" 2>/dev/null` - [ -n "${cmake}" ] || continue - - # Extract version X.Y from versions in the form X.Y or X.Y.Z - # with X, Y and Z numbers with one or more digits each, e.g. - # 3.2 -> 3.2 - # 3.2.3 -> 3.2 - # 3.2.42 -> 3.2 - # 3.10 -> 3.10 - # 3.10.4 -> 3.10 - # 3.10.42 -> 3.10 - # Discard the candidate if no version can be obtained - version="$(${cmake} --version \ - |sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' \ - -e 's//\1/' - )" - [ -n "${version}" ] || continue - - major="${version%.*}" - minor="${version#*.}" - - if [ ${major} -gt ${major_min} ]; then - echo "${cmake}" - exit - elif [ ${major} -eq ${major_min} -a ${minor} -ge ${minor_min} ]; then - echo "${cmake}" - exit - fi -done - -# echo nothing: no suitable cmake found -exit 1 +. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh diff --git a/support/dependencies/check-host-make.sh b/support/dependencies/check-host-make.sh index 0de7e9f6fa..77bfc5123d 100755 --- a/support/dependencies/check-host-make.sh +++ b/support/dependencies/check-host-make.sh @@ -1,37 +1,8 @@ #!/bin/sh -# prevent shift error -[ $# -lt 2 ] && exit 1 +readversion() { + "$1" --version 2>&1 | + sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-].*//g' -e '1q' +} -major_min="${1%.*}" -minor_min="${1#*.}" - -shift - -# The host make program is already checked by dependencies.sh but we -# want to check the version number even if Buildroot is able to use -# GNU make >= 3.81 but some packages may require a more recent version. -make="$1" - -# Output of 'make --version' examples: -# GNU Make 4.2.1 -# GNU Make 4.0 -# GNU Make 3.81 -version=`$make --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ -].*//g' -e '1q'` - -major=`echo "$version" | cut -d. -f1` -minor=`echo "$version" | cut -d. -f2` - -if [ $major -lt $major_min ]; then - # echo nothing: no suitable make found - exit 1 -fi - -if [ $major -eq $major_min -a $minor -lt $minor_min ]; then - # echo nothing: no suitable make found - exit 1 -fi - -# valid -echo $make +. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh diff --git a/support/dependencies/check-host-meson.sh b/support/dependencies/check-host-meson.sh index 62746822cc..bec7bf4505 100755 --- a/support/dependencies/check-host-meson.sh +++ b/support/dependencies/check-host-meson.sh @@ -1,45 +1,7 @@ #!/bin/sh -# prevent shift error -[ $# -ge 2 ] && [ -n "$1" ] || exit 1 - -split_version() { - local VARPREFIX - local NUMBERS - local major - local minor - - VARPREFIX=$1 - NUMBERS=$2 - - major=${NUMBERS%%\.*} - NUMBERS=${NUMBERS#$major}; NUMBERS=${NUMBERS#\.} - minor=${NUMBERS%%\.*} - NUMBERS=${NUMBERS#$minor}; NUMBERS=${NUMBERS#\.} - - # ensure that missing values are 0 - eval "${VARPREFIX}_major=\$major; ${VARPREFIX}_minor=\$((minor + 0)); ${VARPREFIX}_bugfix=\$((NUMBERS + 0));" +readversion() { + "$1" --version } -split_version req "$1" - -shift - -for candidate; do - - # Try to locate the candidate. Discard it if not located. - tool=$(which "${candidate}" 2>/dev/null) - [ -n "${tool}" ] || continue - - split_version cur "$("${tool}" --version)" - - [ -n "${cur_major}" -a "${cur_major}" -ge "${req_major}" ] || continue - [ "${cur_major}" -gt "${req_major}" ] || [ "${cur_minor}" -ge "${req_minor}" ] || continue - [ "${cur_minor}" -gt "${req_minor}" ] || [ "${cur_bugfix}" -ge "${req_bugfix}" ] || continue - - echo "${tool}" - exit -done - -# echo nothing: no suitable tool found -exit 1 +. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh diff --git a/support/dependencies/check-host-ninja.sh b/support/dependencies/check-host-ninja.sh index 62746822cc..bec7bf4505 100755 --- a/support/dependencies/check-host-ninja.sh +++ b/support/dependencies/check-host-ninja.sh @@ -1,45 +1,7 @@ #!/bin/sh -# prevent shift error -[ $# -ge 2 ] && [ -n "$1" ] || exit 1 - -split_version() { - local VARPREFIX - local NUMBERS - local major - local minor - - VARPREFIX=$1 - NUMBERS=$2 - - major=${NUMBERS%%\.*} - NUMBERS=${NUMBERS#$major}; NUMBERS=${NUMBERS#\.} - minor=${NUMBERS%%\.*} - NUMBERS=${NUMBERS#$minor}; NUMBERS=${NUMBERS#\.} - - # ensure that missing values are 0 - eval "${VARPREFIX}_major=\$major; ${VARPREFIX}_minor=\$((minor + 0)); ${VARPREFIX}_bugfix=\$((NUMBERS + 0));" +readversion() { + "$1" --version } -split_version req "$1" - -shift - -for candidate; do - - # Try to locate the candidate. Discard it if not located. - tool=$(which "${candidate}" 2>/dev/null) - [ -n "${tool}" ] || continue - - split_version cur "$("${tool}" --version)" - - [ -n "${cur_major}" -a "${cur_major}" -ge "${req_major}" ] || continue - [ "${cur_major}" -gt "${req_major}" ] || [ "${cur_minor}" -ge "${req_minor}" ] || continue - [ "${cur_minor}" -gt "${req_minor}" ] || [ "${cur_bugfix}" -ge "${req_bugfix}" ] || continue - - echo "${tool}" - exit -done - -# echo nothing: no suitable tool found -exit 1 +. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh diff --git a/support/dependencies/versioncheck.sh b/support/dependencies/versioncheck.sh new file mode 100755 index 0000000000..e606da87e4 --- /dev/null +++ b/support/dependencies/versioncheck.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# prevent shift error +[ $# -ge 2 ] && [ -n "$1" ] || exit 1 + +split_version() { + local VARPREFIX + local NUMBERS + local major + local minor + + VARPREFIX=$1 + NUMBERS=$2 + + major=${NUMBERS%%\.*} + NUMBERS=${NUMBERS#$major}; NUMBERS=${NUMBERS#\.} + minor=${NUMBERS%%\.*} + NUMBERS=${NUMBERS#$minor}; NUMBERS=${NUMBERS#\.} + + # ensure that missing values are 0 + eval "${VARPREFIX}_major=\$major; ${VARPREFIX}_minor=\$((minor + 0)); ${VARPREFIX}_bugfix=\$((NUMBERS + 0));" +} + +split_version req "$1" + +shift + +for candidate; do + + # Try to locate the candidate. Discard it if not located. + tool=$(which "${candidate}" 2>/dev/null) + [ -n "${tool}" ] || continue + + split_version cur "$(readversion "${tool}")" + + [ -n "${cur_major}" -a "${cur_major}" -ge "${req_major}" ] || continue + [ "${cur_major}" -gt "${req_major}" ] || [ "${cur_minor}" -ge "${req_minor}" ] || continue + [ "${cur_minor}" -gt "${req_minor}" ] || [ "${cur_bugfix}" -ge "${req_bugfix}" ] || continue + + echo "${tool}" + exit +done + +# echo nothing: no suitable tool found +exit 1