124071ac1SMauro Carvalho Chehab#!/usr/bin/perl 2c942fddfSThomas Gleixner# SPDX-License-Identifier: GPL-2.0-or-later 324071ac1SMauro Carvalho Chehabuse strict; 424071ac1SMauro Carvalho Chehab 544f42165SMauro Carvalho Chehab# Copyright (c) 2017-2019 Mauro Carvalho Chehab <mchehab@kernel.org> 624071ac1SMauro Carvalho Chehab# 724071ac1SMauro Carvalho Chehab 88c69b77aSMike Rapoportmy $prefix = "./"; 98c69b77aSMike Rapoport$prefix = "$ENV{'srctree'}/" if ($ENV{'srctree'}); 108c69b77aSMike Rapoport 118c69b77aSMike Rapoportmy $conf = $prefix . "Documentation/conf.py"; 128c69b77aSMike Rapoportmy $requirement_file = $prefix . "Documentation/sphinx/requirements.txt"; 1344f42165SMauro Carvalho Chehabmy $virtenv_prefix = "sphinx_"; 145be33182SMauro Carvalho Chehab 1524071ac1SMauro Carvalho Chehab# 1624071ac1SMauro Carvalho Chehab# Static vars 1724071ac1SMauro Carvalho Chehab# 1824071ac1SMauro Carvalho Chehab 1924071ac1SMauro Carvalho Chehabmy %missing; 2024071ac1SMauro Carvalho Chehabmy $system_release; 2124071ac1SMauro Carvalho Chehabmy $need = 0; 2224071ac1SMauro Carvalho Chehabmy $optional = 0; 2324071ac1SMauro Carvalho Chehabmy $need_symlink = 0; 2424071ac1SMauro Carvalho Chehabmy $need_sphinx = 0; 2577d09ad9SMauro Carvalho Chehabmy $rec_sphinx_upgrade = 0; 2624071ac1SMauro Carvalho Chehabmy $install = ""; 2744f42165SMauro Carvalho Chehabmy $virtenv_dir = ""; 2844f42165SMauro Carvalho Chehabmy $min_version; 2924071ac1SMauro Carvalho Chehab 3024071ac1SMauro Carvalho Chehab# 3124071ac1SMauro Carvalho Chehab# Command line arguments 3224071ac1SMauro Carvalho Chehab# 3324071ac1SMauro Carvalho Chehab 3424071ac1SMauro Carvalho Chehabmy $pdf = 1; 3524071ac1SMauro Carvalho Chehabmy $virtualenv = 1; 369b88ad54SMauro Carvalho Chehabmy $version_check = 0; 3724071ac1SMauro Carvalho Chehab 3824071ac1SMauro Carvalho Chehab# 3924071ac1SMauro Carvalho Chehab# List of required texlive packages on Fedora and OpenSuse 4024071ac1SMauro Carvalho Chehab# 4124071ac1SMauro Carvalho Chehab 4224071ac1SMauro Carvalho Chehabmy %texlive = ( 4324071ac1SMauro Carvalho Chehab 'amsfonts.sty' => 'texlive-amsfonts', 4424071ac1SMauro Carvalho Chehab 'amsmath.sty' => 'texlive-amsmath', 4524071ac1SMauro Carvalho Chehab 'amssymb.sty' => 'texlive-amsfonts', 4624071ac1SMauro Carvalho Chehab 'amsthm.sty' => 'texlive-amscls', 4724071ac1SMauro Carvalho Chehab 'anyfontsize.sty' => 'texlive-anyfontsize', 4824071ac1SMauro Carvalho Chehab 'atbegshi.sty' => 'texlive-oberdiek', 4924071ac1SMauro Carvalho Chehab 'bm.sty' => 'texlive-tools', 5024071ac1SMauro Carvalho Chehab 'capt-of.sty' => 'texlive-capt-of', 5124071ac1SMauro Carvalho Chehab 'cmap.sty' => 'texlive-cmap', 5224071ac1SMauro Carvalho Chehab 'ecrm1000.tfm' => 'texlive-ec', 5324071ac1SMauro Carvalho Chehab 'eqparbox.sty' => 'texlive-eqparbox', 5424071ac1SMauro Carvalho Chehab 'eu1enc.def' => 'texlive-euenc', 5524071ac1SMauro Carvalho Chehab 'fancybox.sty' => 'texlive-fancybox', 5624071ac1SMauro Carvalho Chehab 'fancyvrb.sty' => 'texlive-fancyvrb', 5724071ac1SMauro Carvalho Chehab 'float.sty' => 'texlive-float', 5824071ac1SMauro Carvalho Chehab 'fncychap.sty' => 'texlive-fncychap', 5924071ac1SMauro Carvalho Chehab 'footnote.sty' => 'texlive-mdwtools', 6024071ac1SMauro Carvalho Chehab 'framed.sty' => 'texlive-framed', 6124071ac1SMauro Carvalho Chehab 'luatex85.sty' => 'texlive-luatex85', 6224071ac1SMauro Carvalho Chehab 'multirow.sty' => 'texlive-multirow', 6324071ac1SMauro Carvalho Chehab 'needspace.sty' => 'texlive-needspace', 6424071ac1SMauro Carvalho Chehab 'palatino.sty' => 'texlive-psnfss', 6524071ac1SMauro Carvalho Chehab 'parskip.sty' => 'texlive-parskip', 6624071ac1SMauro Carvalho Chehab 'polyglossia.sty' => 'texlive-polyglossia', 6724071ac1SMauro Carvalho Chehab 'tabulary.sty' => 'texlive-tabulary', 6824071ac1SMauro Carvalho Chehab 'threeparttable.sty' => 'texlive-threeparttable', 6924071ac1SMauro Carvalho Chehab 'titlesec.sty' => 'texlive-titlesec', 7024071ac1SMauro Carvalho Chehab 'ucs.sty' => 'texlive-ucs', 7124071ac1SMauro Carvalho Chehab 'upquote.sty' => 'texlive-upquote', 7224071ac1SMauro Carvalho Chehab 'wrapfig.sty' => 'texlive-wrapfig', 7324071ac1SMauro Carvalho Chehab); 7424071ac1SMauro Carvalho Chehab 7524071ac1SMauro Carvalho Chehab# 7624071ac1SMauro Carvalho Chehab# Subroutines that checks if a feature exists 7724071ac1SMauro Carvalho Chehab# 7824071ac1SMauro Carvalho Chehab 7924071ac1SMauro Carvalho Chehabsub check_missing(%) 8024071ac1SMauro Carvalho Chehab{ 8124071ac1SMauro Carvalho Chehab my %map = %{$_[0]}; 8224071ac1SMauro Carvalho Chehab 8324071ac1SMauro Carvalho Chehab foreach my $prog (sort keys %missing) { 8424071ac1SMauro Carvalho Chehab my $is_optional = $missing{$prog}; 8524071ac1SMauro Carvalho Chehab 8656e5a633SMauro Carvalho Chehab # At least on some LTS distros like CentOS 7, texlive doesn't 8756e5a633SMauro Carvalho Chehab # provide all packages we need. When such distros are 8856e5a633SMauro Carvalho Chehab # detected, we have to disable PDF output. 8956e5a633SMauro Carvalho Chehab # 9056e5a633SMauro Carvalho Chehab # So, we need to ignore the packages that distros would 9156e5a633SMauro Carvalho Chehab # need for LaTeX to work 9256e5a633SMauro Carvalho Chehab if ($is_optional == 2 && !$pdf) { 9356e5a633SMauro Carvalho Chehab $optional--; 9456e5a633SMauro Carvalho Chehab next; 9556e5a633SMauro Carvalho Chehab } 9656e5a633SMauro Carvalho Chehab 9724071ac1SMauro Carvalho Chehab if ($is_optional) { 9824071ac1SMauro Carvalho Chehab print "Warning: better to also install \"$prog\".\n"; 9924071ac1SMauro Carvalho Chehab } else { 10024071ac1SMauro Carvalho Chehab print "ERROR: please install \"$prog\", otherwise, build won't work.\n"; 10124071ac1SMauro Carvalho Chehab } 10224071ac1SMauro Carvalho Chehab if (defined($map{$prog})) { 10324071ac1SMauro Carvalho Chehab $install .= " " . $map{$prog}; 10424071ac1SMauro Carvalho Chehab } else { 10524071ac1SMauro Carvalho Chehab $install .= " " . $prog; 10624071ac1SMauro Carvalho Chehab } 10724071ac1SMauro Carvalho Chehab } 10824071ac1SMauro Carvalho Chehab 10924071ac1SMauro Carvalho Chehab $install =~ s/^\s//; 11024071ac1SMauro Carvalho Chehab} 11124071ac1SMauro Carvalho Chehab 11224071ac1SMauro Carvalho Chehabsub add_package($$) 11324071ac1SMauro Carvalho Chehab{ 11424071ac1SMauro Carvalho Chehab my $package = shift; 11524071ac1SMauro Carvalho Chehab my $is_optional = shift; 11624071ac1SMauro Carvalho Chehab 11724071ac1SMauro Carvalho Chehab $missing{$package} = $is_optional; 11824071ac1SMauro Carvalho Chehab if ($is_optional) { 11924071ac1SMauro Carvalho Chehab $optional++; 12024071ac1SMauro Carvalho Chehab } else { 12124071ac1SMauro Carvalho Chehab $need++; 12224071ac1SMauro Carvalho Chehab } 12324071ac1SMauro Carvalho Chehab} 12424071ac1SMauro Carvalho Chehab 12524071ac1SMauro Carvalho Chehabsub check_missing_file($$$) 12624071ac1SMauro Carvalho Chehab{ 127*ff8fdb36SJeremy MAURO my $files = shift; 12824071ac1SMauro Carvalho Chehab my $package = shift; 12924071ac1SMauro Carvalho Chehab my $is_optional = shift; 13024071ac1SMauro Carvalho Chehab 131*ff8fdb36SJeremy MAURO for (@$files) { 132*ff8fdb36SJeremy MAURO return if(-e $_); 133*ff8fdb36SJeremy MAURO } 13424071ac1SMauro Carvalho Chehab 13524071ac1SMauro Carvalho Chehab add_package($package, $is_optional); 13624071ac1SMauro Carvalho Chehab} 13724071ac1SMauro Carvalho Chehab 13824071ac1SMauro Carvalho Chehabsub findprog($) 13924071ac1SMauro Carvalho Chehab{ 14024071ac1SMauro Carvalho Chehab foreach(split(/:/, $ENV{PATH})) { 14124071ac1SMauro Carvalho Chehab return "$_/$_[0]" if(-x "$_/$_[0]"); 14224071ac1SMauro Carvalho Chehab } 14324071ac1SMauro Carvalho Chehab} 14424071ac1SMauro Carvalho Chehab 14524071ac1SMauro Carvalho Chehabsub check_program($$) 14624071ac1SMauro Carvalho Chehab{ 14724071ac1SMauro Carvalho Chehab my $prog = shift; 14824071ac1SMauro Carvalho Chehab my $is_optional = shift; 14924071ac1SMauro Carvalho Chehab 15024071ac1SMauro Carvalho Chehab return if findprog($prog); 15124071ac1SMauro Carvalho Chehab 15224071ac1SMauro Carvalho Chehab add_package($prog, $is_optional); 15324071ac1SMauro Carvalho Chehab} 15424071ac1SMauro Carvalho Chehab 15524071ac1SMauro Carvalho Chehabsub check_perl_module($$) 15624071ac1SMauro Carvalho Chehab{ 15724071ac1SMauro Carvalho Chehab my $prog = shift; 15824071ac1SMauro Carvalho Chehab my $is_optional = shift; 15924071ac1SMauro Carvalho Chehab 16024071ac1SMauro Carvalho Chehab my $err = system("perl -M$prog -e 1 2>/dev/null /dev/null"); 16124071ac1SMauro Carvalho Chehab return if ($err == 0); 16224071ac1SMauro Carvalho Chehab 16324071ac1SMauro Carvalho Chehab add_package($prog, $is_optional); 16424071ac1SMauro Carvalho Chehab} 16524071ac1SMauro Carvalho Chehab 16624071ac1SMauro Carvalho Chehabsub check_python_module($$) 16724071ac1SMauro Carvalho Chehab{ 16824071ac1SMauro Carvalho Chehab my $prog = shift; 16924071ac1SMauro Carvalho Chehab my $is_optional = shift; 17024071ac1SMauro Carvalho Chehab 17124071ac1SMauro Carvalho Chehab my $err = system("python3 -c 'import $prog' 2>/dev/null /dev/null"); 17224071ac1SMauro Carvalho Chehab return if ($err == 0); 17324071ac1SMauro Carvalho Chehab my $err = system("python -c 'import $prog' 2>/dev/null /dev/null"); 17424071ac1SMauro Carvalho Chehab return if ($err == 0); 17524071ac1SMauro Carvalho Chehab 17624071ac1SMauro Carvalho Chehab add_package($prog, $is_optional); 17724071ac1SMauro Carvalho Chehab} 17824071ac1SMauro Carvalho Chehab 17924071ac1SMauro Carvalho Chehabsub check_rpm_missing($$) 18024071ac1SMauro Carvalho Chehab{ 18124071ac1SMauro Carvalho Chehab my @pkgs = @{$_[0]}; 18224071ac1SMauro Carvalho Chehab my $is_optional = $_[1]; 18324071ac1SMauro Carvalho Chehab 18424071ac1SMauro Carvalho Chehab foreach my $prog(@pkgs) { 18524071ac1SMauro Carvalho Chehab my $err = system("rpm -q '$prog' 2>/dev/null >/dev/null"); 18624071ac1SMauro Carvalho Chehab add_package($prog, $is_optional) if ($err); 18724071ac1SMauro Carvalho Chehab } 18824071ac1SMauro Carvalho Chehab} 18924071ac1SMauro Carvalho Chehab 19024071ac1SMauro Carvalho Chehabsub check_pacman_missing($$) 19124071ac1SMauro Carvalho Chehab{ 19224071ac1SMauro Carvalho Chehab my @pkgs = @{$_[0]}; 19324071ac1SMauro Carvalho Chehab my $is_optional = $_[1]; 19424071ac1SMauro Carvalho Chehab 19524071ac1SMauro Carvalho Chehab foreach my $prog(@pkgs) { 19624071ac1SMauro Carvalho Chehab my $err = system("pacman -Q '$prog' 2>/dev/null >/dev/null"); 19724071ac1SMauro Carvalho Chehab add_package($prog, $is_optional) if ($err); 19824071ac1SMauro Carvalho Chehab } 19924071ac1SMauro Carvalho Chehab} 20024071ac1SMauro Carvalho Chehab 20124071ac1SMauro Carvalho Chehabsub check_missing_tex($) 20224071ac1SMauro Carvalho Chehab{ 20324071ac1SMauro Carvalho Chehab my $is_optional = shift; 20424071ac1SMauro Carvalho Chehab my $kpsewhich = findprog("kpsewhich"); 20524071ac1SMauro Carvalho Chehab 20624071ac1SMauro Carvalho Chehab foreach my $prog(keys %texlive) { 20724071ac1SMauro Carvalho Chehab my $package = $texlive{$prog}; 20824071ac1SMauro Carvalho Chehab if (!$kpsewhich) { 20924071ac1SMauro Carvalho Chehab add_package($package, $is_optional); 21024071ac1SMauro Carvalho Chehab next; 21124071ac1SMauro Carvalho Chehab } 21224071ac1SMauro Carvalho Chehab my $file = qx($kpsewhich $prog); 21324071ac1SMauro Carvalho Chehab add_package($package, $is_optional) if ($file =~ /^\s*$/); 21424071ac1SMauro Carvalho Chehab } 21524071ac1SMauro Carvalho Chehab} 21624071ac1SMauro Carvalho Chehab 21777d09ad9SMauro Carvalho Chehabsub get_sphinx_fname() 21824071ac1SMauro Carvalho Chehab{ 21977d09ad9SMauro Carvalho Chehab my $fname = "sphinx-build"; 22077d09ad9SMauro Carvalho Chehab return $fname if findprog($fname); 22124071ac1SMauro Carvalho Chehab 22277d09ad9SMauro Carvalho Chehab $fname = "sphinx-build-3"; 22377d09ad9SMauro Carvalho Chehab if (findprog($fname)) { 22424071ac1SMauro Carvalho Chehab $need_symlink = 1; 22577d09ad9SMauro Carvalho Chehab return $fname; 22624071ac1SMauro Carvalho Chehab } 22724071ac1SMauro Carvalho Chehab 22824071ac1SMauro Carvalho Chehab if ($virtualenv) { 229800d408aSMauro Carvalho Chehab my $prog = findprog("virtualenv-3"); 230800d408aSMauro Carvalho Chehab $prog = findprog("virtualenv-3.5") if (!$prog); 231800d408aSMauro Carvalho Chehab 232800d408aSMauro Carvalho Chehab check_program("virtualenv", 0) if (!$prog); 23324071ac1SMauro Carvalho Chehab $need_sphinx = 1; 23424071ac1SMauro Carvalho Chehab } else { 23524071ac1SMauro Carvalho Chehab add_package("python-sphinx", 0); 23624071ac1SMauro Carvalho Chehab } 23777d09ad9SMauro Carvalho Chehab 23877d09ad9SMauro Carvalho Chehab return ""; 23977d09ad9SMauro Carvalho Chehab} 24077d09ad9SMauro Carvalho Chehab 24177d09ad9SMauro Carvalho Chehabsub check_sphinx() 24277d09ad9SMauro Carvalho Chehab{ 24377d09ad9SMauro Carvalho Chehab my $rec_version; 24477d09ad9SMauro Carvalho Chehab my $cur_version; 24577d09ad9SMauro Carvalho Chehab 24677d09ad9SMauro Carvalho Chehab open IN, $conf or die "Can't open $conf"; 24777d09ad9SMauro Carvalho Chehab while (<IN>) { 24877d09ad9SMauro Carvalho Chehab if (m/^\s*needs_sphinx\s*=\s*[\'\"]([\d\.]+)[\'\"]/) { 24977d09ad9SMauro Carvalho Chehab $min_version=$1; 25077d09ad9SMauro Carvalho Chehab last; 25177d09ad9SMauro Carvalho Chehab } 25277d09ad9SMauro Carvalho Chehab } 25377d09ad9SMauro Carvalho Chehab close IN; 25477d09ad9SMauro Carvalho Chehab 25577d09ad9SMauro Carvalho Chehab die "Can't get needs_sphinx version from $conf" if (!$min_version); 25677d09ad9SMauro Carvalho Chehab 25777d09ad9SMauro Carvalho Chehab open IN, $requirement_file or die "Can't open $requirement_file"; 25877d09ad9SMauro Carvalho Chehab while (<IN>) { 25977d09ad9SMauro Carvalho Chehab if (m/^\s*Sphinx\s*==\s*([\d\.]+)$/) { 26077d09ad9SMauro Carvalho Chehab $rec_version=$1; 26177d09ad9SMauro Carvalho Chehab last; 26277d09ad9SMauro Carvalho Chehab } 26377d09ad9SMauro Carvalho Chehab } 26477d09ad9SMauro Carvalho Chehab close IN; 26577d09ad9SMauro Carvalho Chehab 26677d09ad9SMauro Carvalho Chehab die "Can't get recommended sphinx version from $requirement_file" if (!$min_version); 26777d09ad9SMauro Carvalho Chehab 26844f42165SMauro Carvalho Chehab $virtenv_dir = $virtenv_prefix . $rec_version; 26977d09ad9SMauro Carvalho Chehab 27077d09ad9SMauro Carvalho Chehab my $sphinx = get_sphinx_fname(); 27177d09ad9SMauro Carvalho Chehab return if ($sphinx eq ""); 27277d09ad9SMauro Carvalho Chehab 27377d09ad9SMauro Carvalho Chehab open IN, "$sphinx --version 2>&1 |" or die "$sphinx returned an error"; 27477d09ad9SMauro Carvalho Chehab while (<IN>) { 27577d09ad9SMauro Carvalho Chehab if (m/^\s*sphinx-build\s+([\d\.]+)$/) { 27677d09ad9SMauro Carvalho Chehab $cur_version=$1; 27777d09ad9SMauro Carvalho Chehab last; 27877d09ad9SMauro Carvalho Chehab } 27977d09ad9SMauro Carvalho Chehab # Sphinx 1.2.x uses a different format 28077d09ad9SMauro Carvalho Chehab if (m/^\s*Sphinx.*\s+([\d\.]+)$/) { 28177d09ad9SMauro Carvalho Chehab $cur_version=$1; 28277d09ad9SMauro Carvalho Chehab last; 28377d09ad9SMauro Carvalho Chehab } 28477d09ad9SMauro Carvalho Chehab } 28577d09ad9SMauro Carvalho Chehab close IN; 28677d09ad9SMauro Carvalho Chehab 28777d09ad9SMauro Carvalho Chehab die "$sphinx didn't return its version" if (!$cur_version); 28877d09ad9SMauro Carvalho Chehab 28977d09ad9SMauro Carvalho Chehab if ($cur_version lt $min_version) { 2909b88ad54SMauro Carvalho Chehab printf "ERROR: Sphinx version is %s. It should be >= %s (recommended >= %s)\n", 2919b88ad54SMauro Carvalho Chehab $cur_version, $min_version, $rec_version;; 29277d09ad9SMauro Carvalho Chehab $need_sphinx = 1; 29377d09ad9SMauro Carvalho Chehab return; 29477d09ad9SMauro Carvalho Chehab } 29577d09ad9SMauro Carvalho Chehab 29677d09ad9SMauro Carvalho Chehab if ($cur_version lt $rec_version) { 2979b88ad54SMauro Carvalho Chehab printf "Sphinx version %s\n", $cur_version; 29877d09ad9SMauro Carvalho Chehab print "Warning: It is recommended at least Sphinx version $rec_version.\n"; 29977d09ad9SMauro Carvalho Chehab $rec_sphinx_upgrade = 1; 3009b88ad54SMauro Carvalho Chehab return; 30177d09ad9SMauro Carvalho Chehab } 3029b88ad54SMauro Carvalho Chehab 3039b88ad54SMauro Carvalho Chehab # On version check mode, just assume Sphinx has all mandatory deps 3049b88ad54SMauro Carvalho Chehab exit (0) if ($version_check); 30524071ac1SMauro Carvalho Chehab} 30624071ac1SMauro Carvalho Chehab 30724071ac1SMauro Carvalho Chehab# 30824071ac1SMauro Carvalho Chehab# Ancillary subroutines 30924071ac1SMauro Carvalho Chehab# 31024071ac1SMauro Carvalho Chehab 31124071ac1SMauro Carvalho Chehabsub catcheck($) 31224071ac1SMauro Carvalho Chehab{ 31324071ac1SMauro Carvalho Chehab my $res = ""; 31424071ac1SMauro Carvalho Chehab $res = qx(cat $_[0]) if (-r $_[0]); 31524071ac1SMauro Carvalho Chehab return $res; 31624071ac1SMauro Carvalho Chehab} 31724071ac1SMauro Carvalho Chehab 31824071ac1SMauro Carvalho Chehabsub which($) 31924071ac1SMauro Carvalho Chehab{ 32024071ac1SMauro Carvalho Chehab my $file = shift; 32124071ac1SMauro Carvalho Chehab my @path = split ":", $ENV{PATH}; 32224071ac1SMauro Carvalho Chehab 32324071ac1SMauro Carvalho Chehab foreach my $dir(@path) { 32424071ac1SMauro Carvalho Chehab my $name = $dir.'/'.$file; 32524071ac1SMauro Carvalho Chehab return $name if (-x $name ); 32624071ac1SMauro Carvalho Chehab } 32724071ac1SMauro Carvalho Chehab return undef; 32824071ac1SMauro Carvalho Chehab} 32924071ac1SMauro Carvalho Chehab 33024071ac1SMauro Carvalho Chehab# 33124071ac1SMauro Carvalho Chehab# Subroutines that check distro-specific hints 33224071ac1SMauro Carvalho Chehab# 33324071ac1SMauro Carvalho Chehab 33424071ac1SMauro Carvalho Chehabsub give_debian_hints() 33524071ac1SMauro Carvalho Chehab{ 33624071ac1SMauro Carvalho Chehab my %map = ( 33724071ac1SMauro Carvalho Chehab "python-sphinx" => "python3-sphinx", 33824071ac1SMauro Carvalho Chehab "sphinx_rtd_theme" => "python3-sphinx-rtd-theme", 33924071ac1SMauro Carvalho Chehab "virtualenv" => "virtualenv", 34024071ac1SMauro Carvalho Chehab "dot" => "graphviz", 34124071ac1SMauro Carvalho Chehab "convert" => "imagemagick", 34224071ac1SMauro Carvalho Chehab "Pod::Usage" => "perl-modules", 34324071ac1SMauro Carvalho Chehab "xelatex" => "texlive-xetex", 3448e7d5d15SMauro Carvalho Chehab "rsvg-convert" => "librsvg2-bin", 34524071ac1SMauro Carvalho Chehab ); 34624071ac1SMauro Carvalho Chehab 34724071ac1SMauro Carvalho Chehab if ($pdf) { 348*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"], 34956e5a633SMauro Carvalho Chehab "fonts-dejavu", 2); 35027eed923SMauro Carvalho Chehab 351*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], 35227eed923SMauro Carvalho Chehab "fonts-noto-cjk", 2); 35324071ac1SMauro Carvalho Chehab } 35424071ac1SMauro Carvalho Chehab 35556e5a633SMauro Carvalho Chehab check_program("dvipng", 2) if ($pdf); 35624071ac1SMauro Carvalho Chehab check_missing(\%map); 35724071ac1SMauro Carvalho Chehab 35824071ac1SMauro Carvalho Chehab return if (!$need && !$optional); 35924071ac1SMauro Carvalho Chehab printf("You should run:\n\n\tsudo apt-get install $install\n"); 36024071ac1SMauro Carvalho Chehab} 36124071ac1SMauro Carvalho Chehab 36224071ac1SMauro Carvalho Chehabsub give_redhat_hints() 36324071ac1SMauro Carvalho Chehab{ 36424071ac1SMauro Carvalho Chehab my %map = ( 36524071ac1SMauro Carvalho Chehab "python-sphinx" => "python3-sphinx", 36624071ac1SMauro Carvalho Chehab "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 36724071ac1SMauro Carvalho Chehab "virtualenv" => "python3-virtualenv", 36824071ac1SMauro Carvalho Chehab "dot" => "graphviz", 36924071ac1SMauro Carvalho Chehab "convert" => "ImageMagick", 37024071ac1SMauro Carvalho Chehab "Pod::Usage" => "perl-Pod-Usage", 37124071ac1SMauro Carvalho Chehab "xelatex" => "texlive-xetex-bin", 3728e7d5d15SMauro Carvalho Chehab "rsvg-convert" => "librsvg2-tools", 37324071ac1SMauro Carvalho Chehab ); 37424071ac1SMauro Carvalho Chehab 3755d88953cSMauro Carvalho Chehab my @fedora26_opt_pkgs = ( 3765d88953cSMauro Carvalho Chehab "graphviz-gd", # Fedora 26: needed for PDF support 3775d88953cSMauro Carvalho Chehab ); 3785d88953cSMauro Carvalho Chehab 37924071ac1SMauro Carvalho Chehab my @fedora_tex_pkgs = ( 38024071ac1SMauro Carvalho Chehab "texlive-collection-fontsrecommended", 38124071ac1SMauro Carvalho Chehab "texlive-collection-latex", 38227eed923SMauro Carvalho Chehab "texlive-xecjk", 38324071ac1SMauro Carvalho Chehab "dejavu-sans-fonts", 38424071ac1SMauro Carvalho Chehab "dejavu-serif-fonts", 38524071ac1SMauro Carvalho Chehab "dejavu-sans-mono-fonts", 38624071ac1SMauro Carvalho Chehab ); 38724071ac1SMauro Carvalho Chehab 3889b756a9dSMauro Carvalho Chehab # 3899b756a9dSMauro Carvalho Chehab # Checks valid for RHEL/CentOS version 7.x. 3909b756a9dSMauro Carvalho Chehab # 39156e5a633SMauro Carvalho Chehab my $old = 0; 39256e5a633SMauro Carvalho Chehab my $rel; 39356e5a633SMauro Carvalho Chehab $rel = $1 if ($system_release =~ /release\s+(\d+)/); 39456e5a633SMauro Carvalho Chehab 395b308467cSMauro Carvalho Chehab if (!($system_release =~ /Fedora/)) { 3969b756a9dSMauro Carvalho Chehab $map{"virtualenv"} = "python-virtualenv"; 39756e5a633SMauro Carvalho Chehab 39856e5a633SMauro Carvalho Chehab if ($rel && $rel < 8) { 39956e5a633SMauro Carvalho Chehab $old = 1; 40056e5a633SMauro Carvalho Chehab $pdf = 0; 40156e5a633SMauro Carvalho Chehab 40256e5a633SMauro Carvalho Chehab printf("Note: texlive packages on RHEL/CENTOS <= 7 are incomplete. Can't support PDF output\n"); 40356e5a633SMauro Carvalho Chehab printf("If you want to build PDF, please read:\n"); 40456e5a633SMauro Carvalho Chehab printf("\thttps://www.systutorials.com/241660/how-to-install-tex-live-on-centos-7-linux/\n"); 40556e5a633SMauro Carvalho Chehab } 40656e5a633SMauro Carvalho Chehab } else { 40756e5a633SMauro Carvalho Chehab if ($rel && $rel < 26) { 40856e5a633SMauro Carvalho Chehab $old = 1; 40956e5a633SMauro Carvalho Chehab } 41056e5a633SMauro Carvalho Chehab } 41156e5a633SMauro Carvalho Chehab if (!$rel) { 41256e5a633SMauro Carvalho Chehab printf("Couldn't identify release number\n"); 41356e5a633SMauro Carvalho Chehab $old = 1; 41456e5a633SMauro Carvalho Chehab $pdf = 0; 4159b756a9dSMauro Carvalho Chehab } 4169b756a9dSMauro Carvalho Chehab 41727eed923SMauro Carvalho Chehab if ($pdf) { 418*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc"], 41927eed923SMauro Carvalho Chehab "google-noto-sans-cjk-ttc-fonts", 2); 42027eed923SMauro Carvalho Chehab } 42127eed923SMauro Carvalho Chehab 42256e5a633SMauro Carvalho Chehab check_rpm_missing(\@fedora26_opt_pkgs, 2) if ($pdf && !$old); 42356e5a633SMauro Carvalho Chehab check_rpm_missing(\@fedora_tex_pkgs, 2) if ($pdf); 42456e5a633SMauro Carvalho Chehab check_missing_tex(2) if ($pdf); 42524071ac1SMauro Carvalho Chehab check_missing(\%map); 42624071ac1SMauro Carvalho Chehab 42724071ac1SMauro Carvalho Chehab return if (!$need && !$optional); 4289b756a9dSMauro Carvalho Chehab 42956e5a633SMauro Carvalho Chehab if (!$old) { 4309b756a9dSMauro Carvalho Chehab # dnf, for Fedora 18+ 43124071ac1SMauro Carvalho Chehab printf("You should run:\n\n\tsudo dnf install -y $install\n"); 4329b756a9dSMauro Carvalho Chehab } else { 4339b756a9dSMauro Carvalho Chehab # yum, for RHEL (and clones) or Fedora version < 18 4349b756a9dSMauro Carvalho Chehab printf("You should run:\n\n\tsudo yum install -y $install\n"); 4359b756a9dSMauro Carvalho Chehab } 43624071ac1SMauro Carvalho Chehab} 43724071ac1SMauro Carvalho Chehab 43824071ac1SMauro Carvalho Chehabsub give_opensuse_hints() 43924071ac1SMauro Carvalho Chehab{ 44024071ac1SMauro Carvalho Chehab my %map = ( 44124071ac1SMauro Carvalho Chehab "python-sphinx" => "python3-sphinx", 44224071ac1SMauro Carvalho Chehab "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 44324071ac1SMauro Carvalho Chehab "virtualenv" => "python3-virtualenv", 44424071ac1SMauro Carvalho Chehab "dot" => "graphviz", 44524071ac1SMauro Carvalho Chehab "convert" => "ImageMagick", 44624071ac1SMauro Carvalho Chehab "Pod::Usage" => "perl-Pod-Usage", 44724071ac1SMauro Carvalho Chehab "xelatex" => "texlive-xetex-bin", 4488e7d5d15SMauro Carvalho Chehab "rsvg-convert" => "rsvg-view", 44924071ac1SMauro Carvalho Chehab ); 45024071ac1SMauro Carvalho Chehab 45124071ac1SMauro Carvalho Chehab my @suse_tex_pkgs = ( 45224071ac1SMauro Carvalho Chehab "texlive-babel-english", 45324071ac1SMauro Carvalho Chehab "texlive-caption", 45424071ac1SMauro Carvalho Chehab "texlive-colortbl", 45524071ac1SMauro Carvalho Chehab "texlive-courier", 45624071ac1SMauro Carvalho Chehab "texlive-dvips", 45724071ac1SMauro Carvalho Chehab "texlive-helvetic", 45824071ac1SMauro Carvalho Chehab "texlive-makeindex", 45924071ac1SMauro Carvalho Chehab "texlive-metafont", 46024071ac1SMauro Carvalho Chehab "texlive-metapost", 46124071ac1SMauro Carvalho Chehab "texlive-palatino", 46224071ac1SMauro Carvalho Chehab "texlive-preview", 46324071ac1SMauro Carvalho Chehab "texlive-times", 46424071ac1SMauro Carvalho Chehab "texlive-zapfchan", 46524071ac1SMauro Carvalho Chehab "texlive-zapfding", 46624071ac1SMauro Carvalho Chehab ); 46724071ac1SMauro Carvalho Chehab 468353290a9SMauro Carvalho Chehab $map{"latexmk"} = "texlive-latexmk-bin"; 469353290a9SMauro Carvalho Chehab 47027eed923SMauro Carvalho Chehab # FIXME: add support for installing CJK fonts 47127eed923SMauro Carvalho Chehab # 47227eed923SMauro Carvalho Chehab # I tried hard, but was unable to find a way to install 47327eed923SMauro Carvalho Chehab # "Noto Sans CJK SC" on openSUSE 47427eed923SMauro Carvalho Chehab 47556e5a633SMauro Carvalho Chehab check_rpm_missing(\@suse_tex_pkgs, 2) if ($pdf); 47656e5a633SMauro Carvalho Chehab check_missing_tex(2) if ($pdf); 47724071ac1SMauro Carvalho Chehab check_missing(\%map); 47824071ac1SMauro Carvalho Chehab 47924071ac1SMauro Carvalho Chehab return if (!$need && !$optional); 48024071ac1SMauro Carvalho Chehab printf("You should run:\n\n\tsudo zypper install --no-recommends $install\n"); 48124071ac1SMauro Carvalho Chehab} 48224071ac1SMauro Carvalho Chehab 483800d408aSMauro Carvalho Chehabsub give_mageia_hints() 484800d408aSMauro Carvalho Chehab{ 485800d408aSMauro Carvalho Chehab my %map = ( 486800d408aSMauro Carvalho Chehab "python-sphinx" => "python3-sphinx", 487800d408aSMauro Carvalho Chehab "sphinx_rtd_theme" => "python3-sphinx_rtd_theme", 488800d408aSMauro Carvalho Chehab "virtualenv" => "python3-virtualenv", 489800d408aSMauro Carvalho Chehab "dot" => "graphviz", 490800d408aSMauro Carvalho Chehab "convert" => "ImageMagick", 491800d408aSMauro Carvalho Chehab "Pod::Usage" => "perl-Pod-Usage", 492800d408aSMauro Carvalho Chehab "xelatex" => "texlive", 493800d408aSMauro Carvalho Chehab "rsvg-convert" => "librsvg2-tools", 494800d408aSMauro Carvalho Chehab ); 495800d408aSMauro Carvalho Chehab 496800d408aSMauro Carvalho Chehab my @tex_pkgs = ( 497800d408aSMauro Carvalho Chehab "texlive-fontsextra", 498800d408aSMauro Carvalho Chehab ); 499800d408aSMauro Carvalho Chehab 500353290a9SMauro Carvalho Chehab $map{"latexmk"} = "texlive-collection-basic"; 501353290a9SMauro Carvalho Chehab 50227eed923SMauro Carvalho Chehab if ($pdf) { 503*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc"], 50427eed923SMauro Carvalho Chehab "google-noto-sans-cjk-ttc-fonts", 2); 50527eed923SMauro Carvalho Chehab } 50627eed923SMauro Carvalho Chehab 50756e5a633SMauro Carvalho Chehab check_rpm_missing(\@tex_pkgs, 2) if ($pdf); 508800d408aSMauro Carvalho Chehab check_missing(\%map); 509800d408aSMauro Carvalho Chehab 510800d408aSMauro Carvalho Chehab return if (!$need && !$optional); 511800d408aSMauro Carvalho Chehab printf("You should run:\n\n\tsudo urpmi $install\n"); 512800d408aSMauro Carvalho Chehab} 513800d408aSMauro Carvalho Chehab 51424071ac1SMauro Carvalho Chehabsub give_arch_linux_hints() 51524071ac1SMauro Carvalho Chehab{ 51624071ac1SMauro Carvalho Chehab my %map = ( 51724071ac1SMauro Carvalho Chehab "sphinx_rtd_theme" => "python-sphinx_rtd_theme", 51824071ac1SMauro Carvalho Chehab "virtualenv" => "python-virtualenv", 51924071ac1SMauro Carvalho Chehab "dot" => "graphviz", 52024071ac1SMauro Carvalho Chehab "convert" => "imagemagick", 52124071ac1SMauro Carvalho Chehab "xelatex" => "texlive-bin", 5228e7d5d15SMauro Carvalho Chehab "rsvg-convert" => "extra/librsvg", 52324071ac1SMauro Carvalho Chehab ); 52424071ac1SMauro Carvalho Chehab 52524071ac1SMauro Carvalho Chehab my @archlinux_tex_pkgs = ( 52624071ac1SMauro Carvalho Chehab "texlive-core", 52724071ac1SMauro Carvalho Chehab "texlive-latexextra", 52824071ac1SMauro Carvalho Chehab "ttf-dejavu", 52924071ac1SMauro Carvalho Chehab ); 53056e5a633SMauro Carvalho Chehab check_pacman_missing(\@archlinux_tex_pkgs, 2) if ($pdf); 53156e5a633SMauro Carvalho Chehab 53227eed923SMauro Carvalho Chehab if ($pdf) { 533*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], 53427eed923SMauro Carvalho Chehab "noto-fonts-cjk", 2); 53527eed923SMauro Carvalho Chehab } 53627eed923SMauro Carvalho Chehab 53724071ac1SMauro Carvalho Chehab check_missing(\%map); 53824071ac1SMauro Carvalho Chehab 53924071ac1SMauro Carvalho Chehab return if (!$need && !$optional); 54024071ac1SMauro Carvalho Chehab printf("You should run:\n\n\tsudo pacman -S $install\n"); 54124071ac1SMauro Carvalho Chehab} 54224071ac1SMauro Carvalho Chehab 54324071ac1SMauro Carvalho Chehabsub give_gentoo_hints() 54424071ac1SMauro Carvalho Chehab{ 54524071ac1SMauro Carvalho Chehab my %map = ( 54624071ac1SMauro Carvalho Chehab "sphinx_rtd_theme" => "dev-python/sphinx_rtd_theme", 54724071ac1SMauro Carvalho Chehab "virtualenv" => "dev-python/virtualenv", 54824071ac1SMauro Carvalho Chehab "dot" => "media-gfx/graphviz", 54924071ac1SMauro Carvalho Chehab "convert" => "media-gfx/imagemagick", 55024071ac1SMauro Carvalho Chehab "xelatex" => "dev-texlive/texlive-xetex media-fonts/dejavu", 5518e7d5d15SMauro Carvalho Chehab "rsvg-convert" => "gnome-base/librsvg", 55224071ac1SMauro Carvalho Chehab ); 55324071ac1SMauro Carvalho Chehab 554*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/dejavu/DejaVuSans.ttf"], 55556e5a633SMauro Carvalho Chehab "media-fonts/dejavu", 2) if ($pdf); 55624071ac1SMauro Carvalho Chehab 55727eed923SMauro Carvalho Chehab if ($pdf) { 558*ff8fdb36SJeremy MAURO check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf"], 55927eed923SMauro Carvalho Chehab "media-fonts/noto-cjk", 2); 56027eed923SMauro Carvalho Chehab } 56127eed923SMauro Carvalho Chehab 56224071ac1SMauro Carvalho Chehab check_missing(\%map); 56324071ac1SMauro Carvalho Chehab 56424071ac1SMauro Carvalho Chehab return if (!$need && !$optional); 565bba1e4cbSMauro Carvalho Chehab 566bba1e4cbSMauro Carvalho Chehab printf("You should run:\n\n"); 5674ea96d57SMauro Carvalho Chehab 5684ea96d57SMauro Carvalho Chehab my $imagemagick = "media-gfx/imagemagick svg png"; 5694ea96d57SMauro Carvalho Chehab my $cairo = "media-gfx/graphviz cairo pdf"; 5704ea96d57SMauro Carvalho Chehab my $portage_imagemagick = "/etc/portage/package.use/imagemagick"; 5714ea96d57SMauro Carvalho Chehab my $portage_cairo = "/etc/portage/package.use/graphviz"; 5724ea96d57SMauro Carvalho Chehab 5734ea96d57SMauro Carvalho Chehab if (qx(cat $portage_imagemagick) ne "$imagemagick\n") { 5744ea96d57SMauro Carvalho Chehab printf("\tsudo su -c 'echo \"$imagemagick\" > $portage_imagemagick'\n") 5754ea96d57SMauro Carvalho Chehab } 5764ea96d57SMauro Carvalho Chehab if (qx(cat $portage_cairo) ne "$cairo\n") { 5774ea96d57SMauro Carvalho Chehab printf("\tsudo su -c 'echo \"$cairo\" > $portage_cairo'\n"); 5784ea96d57SMauro Carvalho Chehab } 5794ea96d57SMauro Carvalho Chehab 580bba1e4cbSMauro Carvalho Chehab printf("\tsudo emerge --ask $install\n"); 581bba1e4cbSMauro Carvalho Chehab 58224071ac1SMauro Carvalho Chehab} 58324071ac1SMauro Carvalho Chehab 58424071ac1SMauro Carvalho Chehabsub check_distros() 58524071ac1SMauro Carvalho Chehab{ 58624071ac1SMauro Carvalho Chehab # Distro-specific hints 58724071ac1SMauro Carvalho Chehab if ($system_release =~ /Red Hat Enterprise Linux/) { 58824071ac1SMauro Carvalho Chehab give_redhat_hints; 58924071ac1SMauro Carvalho Chehab return; 59024071ac1SMauro Carvalho Chehab } 5919b756a9dSMauro Carvalho Chehab if ($system_release =~ /CentOS/) { 5929b756a9dSMauro Carvalho Chehab give_redhat_hints; 5939b756a9dSMauro Carvalho Chehab return; 5949b756a9dSMauro Carvalho Chehab } 5959b756a9dSMauro Carvalho Chehab if ($system_release =~ /Scientific Linux/) { 5969b756a9dSMauro Carvalho Chehab give_redhat_hints; 5979b756a9dSMauro Carvalho Chehab return; 5989b756a9dSMauro Carvalho Chehab } 5999b756a9dSMauro Carvalho Chehab if ($system_release =~ /Oracle Linux Server/) { 6009b756a9dSMauro Carvalho Chehab give_redhat_hints; 6019b756a9dSMauro Carvalho Chehab return; 6029b756a9dSMauro Carvalho Chehab } 60324071ac1SMauro Carvalho Chehab if ($system_release =~ /Fedora/) { 60424071ac1SMauro Carvalho Chehab give_redhat_hints; 60524071ac1SMauro Carvalho Chehab return; 60624071ac1SMauro Carvalho Chehab } 60724071ac1SMauro Carvalho Chehab if ($system_release =~ /Ubuntu/) { 60824071ac1SMauro Carvalho Chehab give_debian_hints; 60924071ac1SMauro Carvalho Chehab return; 61024071ac1SMauro Carvalho Chehab } 61124071ac1SMauro Carvalho Chehab if ($system_release =~ /Debian/) { 61224071ac1SMauro Carvalho Chehab give_debian_hints; 61324071ac1SMauro Carvalho Chehab return; 61424071ac1SMauro Carvalho Chehab } 61524071ac1SMauro Carvalho Chehab if ($system_release =~ /openSUSE/) { 61624071ac1SMauro Carvalho Chehab give_opensuse_hints; 61724071ac1SMauro Carvalho Chehab return; 61824071ac1SMauro Carvalho Chehab } 619800d408aSMauro Carvalho Chehab if ($system_release =~ /Mageia/) { 620800d408aSMauro Carvalho Chehab give_mageia_hints; 621800d408aSMauro Carvalho Chehab return; 622800d408aSMauro Carvalho Chehab } 62324071ac1SMauro Carvalho Chehab if ($system_release =~ /Arch Linux/) { 62424071ac1SMauro Carvalho Chehab give_arch_linux_hints; 62524071ac1SMauro Carvalho Chehab return; 62624071ac1SMauro Carvalho Chehab } 62724071ac1SMauro Carvalho Chehab if ($system_release =~ /Gentoo/) { 62824071ac1SMauro Carvalho Chehab give_gentoo_hints; 62924071ac1SMauro Carvalho Chehab return; 63024071ac1SMauro Carvalho Chehab } 63124071ac1SMauro Carvalho Chehab 63224071ac1SMauro Carvalho Chehab # 63324071ac1SMauro Carvalho Chehab # Fall-back to generic hint code for other distros 63424071ac1SMauro Carvalho Chehab # That's far from ideal, specially for LaTeX dependencies. 63524071ac1SMauro Carvalho Chehab # 63624071ac1SMauro Carvalho Chehab my %map = ( 63724071ac1SMauro Carvalho Chehab "sphinx-build" => "sphinx" 63824071ac1SMauro Carvalho Chehab ); 63956e5a633SMauro Carvalho Chehab check_missing_tex(2) if ($pdf); 64024071ac1SMauro Carvalho Chehab check_missing(\%map); 64124071ac1SMauro Carvalho Chehab print "I don't know distro $system_release.\n"; 64224071ac1SMauro Carvalho Chehab print "So, I can't provide you a hint with the install procedure.\n"; 64324071ac1SMauro Carvalho Chehab print "There are likely missing dependencies.\n"; 64424071ac1SMauro Carvalho Chehab} 64524071ac1SMauro Carvalho Chehab 64624071ac1SMauro Carvalho Chehab# 64724071ac1SMauro Carvalho Chehab# Common dependencies 64824071ac1SMauro Carvalho Chehab# 64924071ac1SMauro Carvalho Chehab 6502730ce01SShuah Khansub deactivate_help() 6512730ce01SShuah Khan{ 6522730ce01SShuah Khan printf "\tIf you want to exit the virtualenv, you can use:\n"; 6532730ce01SShuah Khan printf "\tdeactivate\n"; 6542730ce01SShuah Khan} 6552730ce01SShuah Khan 65624071ac1SMauro Carvalho Chehabsub check_needs() 65724071ac1SMauro Carvalho Chehab{ 65824071ac1SMauro Carvalho Chehab # Check for needed programs/tools 65924071ac1SMauro Carvalho Chehab check_sphinx(); 6609b88ad54SMauro Carvalho Chehab 6619b88ad54SMauro Carvalho Chehab if ($system_release) { 6629b88ad54SMauro Carvalho Chehab print "Detected OS: $system_release.\n\n"; 6639b88ad54SMauro Carvalho Chehab } else { 6649b88ad54SMauro Carvalho Chehab print "Unknown OS\n\n"; 6659b88ad54SMauro Carvalho Chehab } 6669b88ad54SMauro Carvalho Chehab 6679b88ad54SMauro Carvalho Chehab print "To upgrade Sphinx, use:\n\n" if ($rec_sphinx_upgrade); 6689b88ad54SMauro Carvalho Chehab 6699b88ad54SMauro Carvalho Chehab # Check for needed programs/tools 67024071ac1SMauro Carvalho Chehab check_perl_module("Pod::Usage", 0); 67124071ac1SMauro Carvalho Chehab check_program("make", 0); 67224071ac1SMauro Carvalho Chehab check_program("gcc", 0); 67324071ac1SMauro Carvalho Chehab check_python_module("sphinx_rtd_theme", 1) if (!$virtualenv); 67424071ac1SMauro Carvalho Chehab check_program("dot", 1); 67524071ac1SMauro Carvalho Chehab check_program("convert", 1); 67656e5a633SMauro Carvalho Chehab 67756e5a633SMauro Carvalho Chehab # Extra PDF files - should use 2 for is_optional 67856e5a633SMauro Carvalho Chehab check_program("xelatex", 2) if ($pdf); 67956e5a633SMauro Carvalho Chehab check_program("rsvg-convert", 2) if ($pdf); 68056e5a633SMauro Carvalho Chehab check_program("latexmk", 2) if ($pdf); 68124071ac1SMauro Carvalho Chehab 68224071ac1SMauro Carvalho Chehab check_distros(); 68324071ac1SMauro Carvalho Chehab 68424071ac1SMauro Carvalho Chehab if ($need_symlink) { 68524071ac1SMauro Carvalho Chehab printf "\tsudo ln -sf %s /usr/bin/sphinx-build\n\n", 68624071ac1SMauro Carvalho Chehab which("sphinx-build-3"); 68724071ac1SMauro Carvalho Chehab } 68877d09ad9SMauro Carvalho Chehab if ($need_sphinx || $rec_sphinx_upgrade) { 68944f42165SMauro Carvalho Chehab my $min_activate = "$ENV{'PWD'}/${virtenv_prefix}${min_version}/bin/activate"; 69044f42165SMauro Carvalho Chehab my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; 69144f42165SMauro Carvalho Chehab 69244f42165SMauro Carvalho Chehab @activates = sort {$b cmp $a} @activates; 69344f42165SMauro Carvalho Chehab 6949b88ad54SMauro Carvalho Chehab if ($need_sphinx && scalar @activates > 0 && $activates[0] ge $min_activate) { 6959b88ad54SMauro Carvalho Chehab printf "\nNeed to activate a compatible Sphinx version on virtualenv with:\n"; 69644f42165SMauro Carvalho Chehab printf "\t. $activates[0]\n"; 6972730ce01SShuah Khan deactivate_help(); 6989b88ad54SMauro Carvalho Chehab exit (1); 6995be33182SMauro Carvalho Chehab } else { 70044f42165SMauro Carvalho Chehab my $rec_activate = "$virtenv_dir/bin/activate"; 70124071ac1SMauro Carvalho Chehab my $virtualenv = findprog("virtualenv-3"); 702800d408aSMauro Carvalho Chehab $virtualenv = findprog("virtualenv-3.5") if (!$virtualenv); 70324071ac1SMauro Carvalho Chehab $virtualenv = findprog("virtualenv") if (!$virtualenv); 70424071ac1SMauro Carvalho Chehab $virtualenv = "virtualenv" if (!$virtualenv); 70524071ac1SMauro Carvalho Chehab 7065be33182SMauro Carvalho Chehab printf "\t$virtualenv $virtenv_dir\n"; 70744f42165SMauro Carvalho Chehab printf "\t. $rec_activate\n"; 708fb947f3fSMauro Carvalho Chehab printf "\tpip install -r $requirement_file\n"; 7092730ce01SShuah Khan deactivate_help(); 71077d09ad9SMauro Carvalho Chehab 71177d09ad9SMauro Carvalho Chehab $need++ if (!$rec_sphinx_upgrade); 71224071ac1SMauro Carvalho Chehab } 7135be33182SMauro Carvalho Chehab } 71424071ac1SMauro Carvalho Chehab printf "\n"; 71524071ac1SMauro Carvalho Chehab 71654002b56SBjorn Helgaas print "All optional dependencies are met.\n" if (!$optional); 71724071ac1SMauro Carvalho Chehab 71824071ac1SMauro Carvalho Chehab if ($need == 1) { 71924071ac1SMauro Carvalho Chehab die "Can't build as $need mandatory dependency is missing"; 72024071ac1SMauro Carvalho Chehab } elsif ($need) { 72124071ac1SMauro Carvalho Chehab die "Can't build as $need mandatory dependencies are missing"; 72224071ac1SMauro Carvalho Chehab } 72324071ac1SMauro Carvalho Chehab 72424071ac1SMauro Carvalho Chehab print "Needed package dependencies are met.\n"; 72524071ac1SMauro Carvalho Chehab} 72624071ac1SMauro Carvalho Chehab 72724071ac1SMauro Carvalho Chehab# 72824071ac1SMauro Carvalho Chehab# Main 72924071ac1SMauro Carvalho Chehab# 73024071ac1SMauro Carvalho Chehab 73124071ac1SMauro Carvalho Chehabwhile (@ARGV) { 73224071ac1SMauro Carvalho Chehab my $arg = shift(@ARGV); 73324071ac1SMauro Carvalho Chehab 73424071ac1SMauro Carvalho Chehab if ($arg eq "--no-virtualenv") { 73524071ac1SMauro Carvalho Chehab $virtualenv = 0; 73624071ac1SMauro Carvalho Chehab } elsif ($arg eq "--no-pdf"){ 73724071ac1SMauro Carvalho Chehab $pdf = 0; 7389b88ad54SMauro Carvalho Chehab } elsif ($arg eq "--version-check"){ 7399b88ad54SMauro Carvalho Chehab $version_check = 1; 74024071ac1SMauro Carvalho Chehab } else { 7419b88ad54SMauro Carvalho Chehab print "Usage:\n\t$0 <--no-virtualenv> <--no-pdf> <--version-check>\n\n"; 7429b88ad54SMauro Carvalho Chehab print "Where:\n"; 7439b88ad54SMauro Carvalho Chehab print "\t--no-virtualenv\t- Recommend installing Sphinx instead of using a virtualenv\n"; 7449b88ad54SMauro Carvalho Chehab print "\t--version-check\t- if version is compatible, don't check for missing dependencies\n"; 7459b88ad54SMauro Carvalho Chehab print "\t--no-pdf\t- don't check for dependencies required to build PDF docs\n\n"; 74624071ac1SMauro Carvalho Chehab exit -1; 74724071ac1SMauro Carvalho Chehab } 74824071ac1SMauro Carvalho Chehab} 74924071ac1SMauro Carvalho Chehab 75024071ac1SMauro Carvalho Chehab# 75124071ac1SMauro Carvalho Chehab# Determine the system type. There's no standard unique way that would 75224071ac1SMauro Carvalho Chehab# work with all distros with a minimal package install. So, several 75324071ac1SMauro Carvalho Chehab# methods are used here. 75424071ac1SMauro Carvalho Chehab# 75524071ac1SMauro Carvalho Chehab# By default, it will use lsb_release function. If not available, it will 75624071ac1SMauro Carvalho Chehab# fail back to reading the known different places where the distro name 75724071ac1SMauro Carvalho Chehab# is stored 75824071ac1SMauro Carvalho Chehab# 75924071ac1SMauro Carvalho Chehab 76024071ac1SMauro Carvalho Chehab$system_release = qx(lsb_release -d) if which("lsb_release"); 76124071ac1SMauro Carvalho Chehab$system_release =~ s/Description:\s*// if ($system_release); 76224071ac1SMauro Carvalho Chehab$system_release = catcheck("/etc/system-release") if !$system_release; 76324071ac1SMauro Carvalho Chehab$system_release = catcheck("/etc/redhat-release") if !$system_release; 76424071ac1SMauro Carvalho Chehab$system_release = catcheck("/etc/lsb-release") if !$system_release; 76524071ac1SMauro Carvalho Chehab$system_release = catcheck("/etc/gentoo-release") if !$system_release; 76624071ac1SMauro Carvalho Chehab$system_release = catcheck("/etc/issue") if !$system_release; 76724071ac1SMauro Carvalho Chehab$system_release =~ s/\s+$//; 76824071ac1SMauro Carvalho Chehab 76924071ac1SMauro Carvalho Chehabcheck_needs; 770