From patchwork Wed May 22 20:50:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Corbet X-Patchwork-Id: 164896 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1328338ili; Wed, 22 May 2019 13:51:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfvXw8nYnKT0QJYxaMSSw1aLt9EbMbH/rAyzWGgdO1Cpo2XgUQe6Cw4q08AXjzMEUmfbER X-Received: by 2002:a17:902:e683:: with SMTP id cn3mr69871560plb.86.1558558268848; Wed, 22 May 2019 13:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558558268; cv=none; d=google.com; s=arc-20160816; b=wFBV2KIcfjlmrkn62arnG73Q/tcP8x+evrkFKv5kN619aRPFv1dzu2FUK12fS0U1hr HX+gT8CeIvio1gHcoQXIfvLpyrudx61Ml+vkRYMTVoF6Pp2dVfya5wCNWnqJIp6CKNJr PghfVOiWCOHDMGaOr4Guy4OGDj8/zOeL+DLNPczH1l/YOfu9bgY7I3BdSi1eu+QJPSdn DbXomHZVCnZOYRG46O4DKyTa7GC8ea1oa4ukdBzb9NY2Ml7VDY8Tkd5rsLLLGxOiViYm OwO+NHpSzQojmTpFZ4ztIEE5EqEM9wn1Q3QnJxeTSipWeeJ+M7kMqzfQueooDSoexr1Y IgSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ARC5Fk56aYrZSDtuk2/hMcqIxkgBmE5uwnJJ48nDdcg=; b=jAIh0rd08VAkFyEXqhRMrUUfWYyf/2ltA9KyiXvzVAtLUqjfLORJscUAPpbpPI2sXN JdlwYREcEbwkB8Kc6Fc6JmdZzhck2O6LwlxccTypQKMqO+uwh9/1APK1dlnkqq/PAB4I MKy6XZrYX1iVg09BkScl41OSF5H/KdX24wb1l86plA6RgrulHzYwUz1yvMqBC64vXIhN Lh5xJ/IcXHm8nkG0F7ZiAPDSzaHteJQh2y8bGXsOO2OP9O+MXw12RkZWkvWIe4OGV3qG w2391hbgUP5nZU4HeRd/tneti/IEIzny4ER2cSPsvFWC0Rl6NrbSC2PuiLJWORYQVoGJ nErQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si28220476pga.385.2019.05.22.13.51.08; Wed, 22 May 2019 13:51:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730435AbfEVUvH (ORCPT + 30 others); Wed, 22 May 2019 16:51:07 -0400 Received: from ms.lwn.net ([45.79.88.28]:49398 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730341AbfEVUvA (ORCPT ); Wed, 22 May 2019 16:51:00 -0400 Received: from meer.lwn.net (localhost [127.0.0.1]) by ms.lwn.net (Postfix) with ESMTPA id 8DC681429; Wed, 22 May 2019 20:50:59 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jani Nikula , Markus Heiser , Mauro Carvalho Chehab , Oleksandr Natalenko , Mauro Carvalho Chehab , Jonathan Corbet Subject: [PATCH 8/8] scripts/sphinx-pre-install: make it handle Sphinx versions Date: Wed, 22 May 2019 14:50:34 -0600 Message-Id: <20190522205034.25724-9-corbet@lwn.net> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522205034.25724-1-corbet@lwn.net> References: <20190522205034.25724-1-corbet@lwn.net> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab As we want to switch to a newer Sphinx version in the future, add some version detected logic, checking if the current version meets the requirement and suggesting upgrade it the version is supported but too old. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Corbet --- scripts/sphinx-pre-install | 81 ++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 7 deletions(-) -- 2.21.0 diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index f6a5c0bae31e..e667db230d0a 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -13,7 +13,7 @@ use strict; # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -my $virtenv_dir = "sphinx_1.4"; +my $conf = "Documentation/conf.py"; my $requirement_file = "Documentation/sphinx/requirements.txt"; # @@ -26,7 +26,9 @@ my $need = 0; my $optional = 0; my $need_symlink = 0; my $need_sphinx = 0; +my $rec_sphinx_upgrade = 0; my $install = ""; +my $virtenv_dir = "sphinx_"; # # Command line arguments @@ -201,13 +203,15 @@ sub check_missing_tex($) } } -sub check_sphinx() +sub get_sphinx_fname() { - return if findprog("sphinx-build"); + my $fname = "sphinx-build"; + return $fname if findprog($fname); - if (findprog("sphinx-build-3")) { + $fname = "sphinx-build-3"; + if (findprog($fname)) { $need_symlink = 1; - return; + return $fname; } if ($virtualenv) { @@ -219,6 +223,68 @@ sub check_sphinx() } else { add_package("python-sphinx", 0); } + + return ""; +} + +sub check_sphinx() +{ + my $min_version; + my $rec_version; + my $cur_version; + + open IN, $conf or die "Can't open $conf"; + while () { + if (m/^\s*needs_sphinx\s*=\s*[\'\"]([\d\.]+)[\'\"]/) { + $min_version=$1; + last; + } + } + close IN; + + die "Can't get needs_sphinx version from $conf" if (!$min_version); + + open IN, $requirement_file or die "Can't open $requirement_file"; + while () { + if (m/^\s*Sphinx\s*==\s*([\d\.]+)$/) { + $rec_version=$1; + last; + } + } + close IN; + + die "Can't get recommended sphinx version from $requirement_file" if (!$min_version); + + my $sphinx = get_sphinx_fname(); + return if ($sphinx eq ""); + + open IN, "$sphinx --version 2>&1 |" or die "$sphinx returned an error"; + while () { + if (m/^\s*sphinx-build\s+([\d\.]+)$/) { + $cur_version=$1; + last; + } + } + close IN; + + $virtenv_dir .= $rec_version; + + die "$sphinx didn't return its version" if (!$cur_version); + + printf "Sphinx version %s (minimal: %s, recommended >= %s)\n", + $cur_version, $min_version, $rec_version; + + if ($cur_version lt $min_version) { + print "Warning: Sphinx version should be >= $min_version\n\n"; + $need_sphinx = 1; + return; + } + + if ($cur_version lt $rec_version) { + print "Warning: It is recommended at least Sphinx version $rec_version.\n"; + print " To upgrade, use:\n\n"; + $rec_sphinx_upgrade = 1; + } } # @@ -540,7 +606,7 @@ sub check_needs() printf "\tsudo ln -sf %s /usr/bin/sphinx-build\n\n", which("sphinx-build-3"); } - if ($need_sphinx) { + if ($need_sphinx || $rec_sphinx_upgrade) { my $activate = "$virtenv_dir/bin/activate"; if (-e "$ENV{'PWD'}/$activate") { printf "\nNeed to activate virtualenv with:\n"; @@ -554,7 +620,8 @@ sub check_needs() printf "\t$virtualenv $virtenv_dir\n"; printf "\t. $activate\n"; printf "\tpip install -r $requirement_file\n"; - $need++; + + $need++ if (!$rec_sphinx_upgrade); } } printf "\n";