Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts/sphinx-pre-install: add minimum support for RHEL

RHEL 7.x and clone distros are shipped with Sphinx 1.1.x,
with is incompatible with Kernel ReST markups.

So, on those systems, the only alternative is to install
it via a Python virtual environment.

While seeking for "pip" on CentOS 7.3, I noticed that it
is not really needed, as python-virtualenv has its version
packaged there already. So, remove this from the list of
requirements for all distributions.

With regards to PDF, we need at least texlive-tabulary
extension, but that is not shipped there (at least on
CentOS). So, disable PDF packages as a whole.

Please notice, however, that texlive + amsmath is needed for
ReST to properly handle ReST ".. math::" tags. Yet, Sphinx
fall back to display the LaTeX math expressions as-is, if
such extension is not available.

So, let's just disable all texlive packages as a whole.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
9b756a9d 3d91a353

+42 -12
+42 -12
scripts/sphinx-pre-install
··· 216 216 $prog = findprog("virtualenv-3.5") if (!$prog); 217 217 218 218 check_program("virtualenv", 0) if (!$prog); 219 - check_program("pip", 0) if (!findprog("pip3")); 220 219 $need_sphinx = 1; 221 220 } else { 222 221 add_package("python-sphinx", 0); ··· 255 256 "python-sphinx" => "python3-sphinx", 256 257 "sphinx_rtd_theme" => "python3-sphinx-rtd-theme", 257 258 "virtualenv" => "virtualenv", 258 - "pip" => "python3-pip", 259 259 "dot" => "graphviz", 260 260 "convert" => "imagemagick", 261 261 "Pod::Usage" => "perl-modules", ··· 280 282 "python-sphinx" => "python3-sphinx", 281 283 "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 282 284 "virtualenv" => "python3-virtualenv", 283 - "pip" => "python3-pip", 284 285 "dot" => "graphviz", 285 286 "convert" => "ImageMagick", 286 287 "Pod::Usage" => "perl-Pod-Usage", ··· 299 302 "dejavu-sans-mono-fonts", 300 303 ); 301 304 305 + # 306 + # Checks valid for RHEL/CentOS version 7.x. 307 + # 308 + if (! $system_release =~ /Fedora/) { 309 + $map{"virtualenv"} = "python-virtualenv"; 310 + } 311 + 302 312 my $release; 303 313 304 314 $release = $1 if ($system_release =~ /Fedora\s+release\s+(\d+)/); ··· 316 312 check_missing(\%map); 317 313 318 314 return if (!$need && !$optional); 319 - printf("You should run:\n\n\tsudo dnf install -y $install\n"); 315 + 316 + if ($release >= 18) { 317 + # dnf, for Fedora 18+ 318 + printf("You should run:\n\n\tsudo dnf install -y $install\n"); 319 + } else { 320 + # yum, for RHEL (and clones) or Fedora version < 18 321 + printf("You should run:\n\n\tsudo yum install -y $install\n"); 322 + } 320 323 } 321 324 322 325 sub give_opensuse_hints() ··· 332 321 "python-sphinx" => "python3-sphinx", 333 322 "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 334 323 "virtualenv" => "python3-virtualenv", 335 - "pip" => "python3-pip", 336 324 "dot" => "graphviz", 337 325 "convert" => "ImageMagick", 338 326 "Pod::Usage" => "perl-Pod-Usage", ··· 370 360 "python-sphinx" => "python3-sphinx", 371 361 "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 372 362 "virtualenv" => "python3-virtualenv", 373 - "pip" => "python3-pip", 374 363 "dot" => "graphviz", 375 364 "convert" => "ImageMagick", 376 365 "Pod::Usage" => "perl-Pod-Usage", ··· 380 371 my @tex_pkgs = ( 381 372 "texlive-fontsextra", 382 373 ); 383 - 384 - my $release; 385 374 386 375 check_rpm_missing(\@tex_pkgs, 1) if ($pdf); 387 376 check_missing(\%map); ··· 393 386 my %map = ( 394 387 "sphinx_rtd_theme" => "python-sphinx_rtd_theme", 395 388 "virtualenv" => "python-virtualenv", 396 - "pip" => "python-pip", 397 389 "dot" => "graphviz", 398 390 "convert" => "imagemagick", 399 391 "xelatex" => "texlive-bin", ··· 416 410 my %map = ( 417 411 "sphinx_rtd_theme" => "dev-python/sphinx_rtd_theme", 418 412 "virtualenv" => "dev-python/virtualenv", 419 - "pip" => "dev-python/pip", 420 413 "dot" => "media-gfx/graphviz", 421 414 "convert" => "media-gfx/imagemagick", 422 415 "xelatex" => "dev-texlive/texlive-xetex media-fonts/dejavu", ··· 440 435 { 441 436 # Distro-specific hints 442 437 if ($system_release =~ /Red Hat Enterprise Linux/) { 438 + give_redhat_hints; 439 + return; 440 + } 441 + if ($system_release =~ /CentOS/) { 442 + give_redhat_hints; 443 + return; 444 + } 445 + if ($system_release =~ /Scientific Linux/) { 446 + give_redhat_hints; 447 + return; 448 + } 449 + if ($system_release =~ /Oracle Linux Server/) { 443 450 give_redhat_hints; 444 451 return; 445 452 } ··· 505 488 sub check_needs() 506 489 { 507 490 if ($system_release) { 508 - print "Checking if the needed tools for $system_release are available\n"; 491 + print "Detected OS: $system_release.\n"; 509 492 } else { 510 - print "Checking if the needed tools are present\n"; 493 + print "Unknown OS\n"; 494 + } 495 + 496 + # RHEL 7.x and clones have Sphinx version 1.1.x and incomplete texlive 497 + if (($system_release =~ /Red Hat Enterprise Linux/) || 498 + ($system_release =~ /CentOS/) || 499 + ($system_release =~ /Scientific Linux/) || 500 + ($system_release =~ /Oracle Linux Server/)) { 501 + $virtualenv = 1; 502 + $pdf = 0; 503 + 504 + printf("NOTE: On this distro, Sphinx and TexLive shipped versions are incompatible\n"); 505 + printf("with doc build. So, use Sphinx via a Python virtual environment.\n\n"); 506 + printf("This script can't install a TexLive version that would provide PDF.\n"); 511 507 } 512 508 513 509 # Check for needed programs/tools