c25ce589dca10 (Finn Behrens 2020-11-23 15:15:33 +0100 1) #!/usr/bin/env perl
c942fddf8793b (Thomas Gleixner 2019-05-27 08:55:06 +0200 2) # SPDX-License-Identifier: GPL-2.0-or-later
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 3) use strict;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 4)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 5) # Copyright (c) 2017-2020 Mauro Carvalho Chehab <mchehab@kernel.org>
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 6) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 7)
8c69b77a0175d (Mike Rapoport 2019-06-24 08:25:07 +0300 8) my $prefix = "./";
8c69b77a0175d (Mike Rapoport 2019-06-24 08:25:07 +0300 9) $prefix = "$ENV{'srctree'}/" if ($ENV{'srctree'});
8c69b77a0175d (Mike Rapoport 2019-06-24 08:25:07 +0300 10)
8c69b77a0175d (Mike Rapoport 2019-06-24 08:25:07 +0300 11) my $conf = $prefix . "Documentation/conf.py";
8c69b77a0175d (Mike Rapoport 2019-06-24 08:25:07 +0300 12) my $requirement_file = $prefix . "Documentation/sphinx/requirements.txt";
44f42165177e6 (Mauro Carvalho Chehab 2019-05-29 20:09:24 -0300 13) my $virtenv_prefix = "sphinx_";
5be33182d4e22 (Mauro Carvalho Chehab 2017-07-17 18:46:37 -0300 14)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 15) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 16) # Static vars
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 17) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 18)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 19) my %missing;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 20) my $system_release;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 21) my $need = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 22) my $optional = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 23) my $need_symlink = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 24) my $need_sphinx = 0;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 25) my $need_pip = 0;
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 26) my $need_virtualenv = 0;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 27) my $rec_sphinx_upgrade = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 28) my $install = "";
44f42165177e6 (Mauro Carvalho Chehab 2019-05-29 20:09:24 -0300 29) my $virtenv_dir = "";
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 30) my $python_cmd = "";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 31) my $activate_cmd;
44f42165177e6 (Mauro Carvalho Chehab 2019-05-29 20:09:24 -0300 32) my $min_version;
2834a7412bb1a (Mauro Carvalho Chehab 2020-04-21 16:31:07 +0200 33) my $cur_version;
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 34) my $rec_version = "1.7.9"; # PDF won't build here
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 35) my $min_pdf_version = "2.4.4"; # Min version where pdf builds
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 36) my $latest_avail_ver;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 37)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 38) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 39) # Command line arguments
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 40) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 41)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 42) my $pdf = 1;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 43) my $virtualenv = 1;
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 44) my $version_check = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 45)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 46) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 47) # List of required texlive packages on Fedora and OpenSuse
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 48) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 49)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 50) my %texlive = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 51) 'amsfonts.sty' => 'texlive-amsfonts',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 52) 'amsmath.sty' => 'texlive-amsmath',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 53) 'amssymb.sty' => 'texlive-amsfonts',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 54) 'amsthm.sty' => 'texlive-amscls',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 55) 'anyfontsize.sty' => 'texlive-anyfontsize',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 56) 'atbegshi.sty' => 'texlive-oberdiek',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 57) 'bm.sty' => 'texlive-tools',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 58) 'capt-of.sty' => 'texlive-capt-of',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 59) 'cmap.sty' => 'texlive-cmap',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 60) 'ecrm1000.tfm' => 'texlive-ec',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 61) 'eqparbox.sty' => 'texlive-eqparbox',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 62) 'eu1enc.def' => 'texlive-euenc',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 63) 'fancybox.sty' => 'texlive-fancybox',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 64) 'fancyvrb.sty' => 'texlive-fancyvrb',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 65) 'float.sty' => 'texlive-float',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 66) 'fncychap.sty' => 'texlive-fncychap',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 67) 'footnote.sty' => 'texlive-mdwtools',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 68) 'framed.sty' => 'texlive-framed',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 69) 'luatex85.sty' => 'texlive-luatex85',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 70) 'multirow.sty' => 'texlive-multirow',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 71) 'needspace.sty' => 'texlive-needspace',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 72) 'palatino.sty' => 'texlive-psnfss',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 73) 'parskip.sty' => 'texlive-parskip',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 74) 'polyglossia.sty' => 'texlive-polyglossia',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 75) 'tabulary.sty' => 'texlive-tabulary',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 76) 'threeparttable.sty' => 'texlive-threeparttable',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 77) 'titlesec.sty' => 'texlive-titlesec',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 78) 'ucs.sty' => 'texlive-ucs',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 79) 'upquote.sty' => 'texlive-upquote',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 80) 'wrapfig.sty' => 'texlive-wrapfig',
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 81) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 82)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 83) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 84) # Subroutines that checks if a feature exists
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 85) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 86)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 87) sub check_missing(%)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 88) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 89) my %map = %{$_[0]};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 90)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 91) foreach my $prog (sort keys %missing) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 92) my $is_optional = $missing{$prog};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 93)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 94) # At least on some LTS distros like CentOS 7, texlive doesn't
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 95) # provide all packages we need. When such distros are
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 96) # detected, we have to disable PDF output.
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 97) #
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 98) # So, we need to ignore the packages that distros would
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 99) # need for LaTeX to work
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 100) if ($is_optional == 2 && !$pdf) {
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 101) $optional--;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 102) next;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 103) }
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 104)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 105) if ($is_optional) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 106) print "Warning: better to also install \"$prog\".\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 107) } else {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 108) print "ERROR: please install \"$prog\", otherwise, build won't work.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 109) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 110) if (defined($map{$prog})) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 111) $install .= " " . $map{$prog};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 112) } else {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 113) $install .= " " . $prog;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 114) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 115) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 116)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 117) $install =~ s/^\s//;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 118) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 119)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 120) sub add_package($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 121) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 122) my $package = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 123) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 124)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 125) $missing{$package} = $is_optional;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 126) if ($is_optional) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 127) $optional++;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 128) } else {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 129) $need++;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 130) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 131) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 132)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 133) sub check_missing_file($$$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 134) {
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 135) my $files = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 136) my $package = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 137) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 138)
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 139) for (@$files) {
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 140) return if(-e $_);
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 141) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 142)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 143) add_package($package, $is_optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 144) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 145)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 146) sub findprog($)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 147) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 148) foreach(split(/:/, $ENV{PATH})) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 149) return "$_/$_[0]" if(-x "$_/$_[0]");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 150) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 151) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 152)
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 153) sub find_python_no_venv()
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 154) {
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 155) my $prog = shift;
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 156)
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 157) my $cur_dir = qx(pwd);
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 158) $cur_dir =~ s/\s+$//;
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 159)
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 160) foreach my $dir (split(/:/, $ENV{PATH})) {
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 161) next if ($dir =~ m,($cur_dir)/sphinx,);
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 162) return "$dir/python3" if(-x "$dir/python3");
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 163) }
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 164) foreach my $dir (split(/:/, $ENV{PATH})) {
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 165) next if ($dir =~ m,($cur_dir)/sphinx,);
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 166) return "$dir/python" if(-x "$dir/python");
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 167) }
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 168) return "python";
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 169) }
412b09ddadd34 (Mauro Carvalho Chehab 2020-04-21 16:31:08 +0200 170)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 171) sub check_program($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 172) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 173) my $prog = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 174) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 175)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 176) return $prog if findprog($prog);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 177)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 178) add_package($prog, $is_optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 179) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 180)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 181) sub check_perl_module($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 182) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 183) my $prog = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 184) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 185)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 186) my $err = system("perl -M$prog -e 1 2>/dev/null /dev/null");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 187) return if ($err == 0);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 188)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 189) add_package($prog, $is_optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 190) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 191)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 192) sub check_python_module($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 193) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 194) my $prog = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 195) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 196)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 197) return if (!$python_cmd);
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 198)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 199) my $err = system("$python_cmd -c 'import $prog' 2>/dev/null /dev/null");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 200) return if ($err == 0);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 201)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 202) add_package($prog, $is_optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 203) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 204)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 205) sub check_rpm_missing($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 206) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 207) my @pkgs = @{$_[0]};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 208) my $is_optional = $_[1];
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 209)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 210) foreach my $prog(@pkgs) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 211) my $err = system("rpm -q '$prog' 2>/dev/null >/dev/null");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 212) add_package($prog, $is_optional) if ($err);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 213) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 214) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 215)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 216) sub check_pacman_missing($$)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 217) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 218) my @pkgs = @{$_[0]};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 219) my $is_optional = $_[1];
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 220)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 221) foreach my $prog(@pkgs) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 222) my $err = system("pacman -Q '$prog' 2>/dev/null >/dev/null");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 223) add_package($prog, $is_optional) if ($err);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 224) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 225) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 226)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 227) sub check_missing_tex($)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 228) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 229) my $is_optional = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 230) my $kpsewhich = findprog("kpsewhich");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 231)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 232) foreach my $prog(keys %texlive) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 233) my $package = $texlive{$prog};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 234) if (!$kpsewhich) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 235) add_package($package, $is_optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 236) next;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 237) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 238) my $file = qx($kpsewhich $prog);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 239) add_package($package, $is_optional) if ($file =~ /^\s*$/);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 240) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 241) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 242)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 243) sub get_sphinx_fname()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 244) {
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 245) my $fname = "sphinx-build";
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 246) return $fname if findprog($fname);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 247)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 248) $fname = "sphinx-build-3";
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 249) if (findprog($fname)) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 250) $need_symlink = 1;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 251) return $fname;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 252) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 253)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 254) return "";
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 255) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 256)
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 257) sub get_sphinx_version($)
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 258) {
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 259) my $cmd = shift;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 260) my $ver;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 261)
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 262) open IN, "$cmd --version 2>&1 |";
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 263) while (<IN>) {
e9dfeed251867 (Jonathan Corbet 2021-04-15 16:01:50 -0600 264) if (m/^\s*sphinx-build\s+([\d\.]+)((\+\/[\da-f]+)|(b\d+))?$/) {
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 265) $ver=$1;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 266) last;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 267) }
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 268) # Sphinx 1.2.x uses a different format
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 269) if (m/^\s*Sphinx.*\s+([\d\.]+)$/) {
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 270) $ver=$1;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 271) last;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 272) }
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 273) }
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 274) close IN;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 275) return $ver;
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 276) }
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 277)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 278) sub check_sphinx()
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 279) {
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 280) my $default_version;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 281)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 282) open IN, $conf or die "Can't open $conf";
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 283) while (<IN>) {
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 284) if (m/^\s*needs_sphinx\s*=\s*[\'\"]([\d\.]+)[\'\"]/) {
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 285) $min_version=$1;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 286) last;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 287) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 288) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 289) close IN;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 290)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 291) die "Can't get needs_sphinx version from $conf" if (!$min_version);
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 292)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 293) open IN, $requirement_file or die "Can't open $requirement_file";
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 294) while (<IN>) {
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 295) if (m/^\s*Sphinx\s*==\s*([\d\.]+)$/) {
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 296) $default_version=$1;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 297) last;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 298) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 299) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 300) close IN;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 301)
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 302) die "Can't get default sphinx version from $requirement_file" if (!$default_version);
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 303)
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 304) $virtenv_dir = $virtenv_prefix . $default_version;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 305)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 306) my $sphinx = get_sphinx_fname();
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 307) if ($sphinx eq "") {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 308) $need_sphinx = 1;
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 309) return;
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 310) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 311)
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 312) $cur_version = get_sphinx_version($sphinx);
a8b380c379efc (Mauro Carvalho Chehab 2020-04-21 16:31:05 +0200 313) die ("$sphinx returned an error") if (!$cur_version);
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 314)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 315) die "$sphinx didn't return its version" if (!$cur_version);
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 316)
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 317) if ($cur_version lt $min_version) {
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 318) printf "ERROR: Sphinx version is %s. It should be >= %s (recommended >= %s)\n",
1ef70ced55976 (Mauro Carvalho Chehab 2020-04-21 16:31:06 +0200 319) $cur_version, $min_version, $default_version;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 320) $need_sphinx = 1;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 321) return;
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 322) }
77d09ad9dc515 (Mauro Carvalho Chehab 2019-05-22 18:43:46 -0300 323)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 324) return if ($cur_version lt $rec_version);
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 325)
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 326) # On version check mode, just assume Sphinx has all mandatory deps
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 327) exit (0) if ($version_check);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 328) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 329)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 330) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 331) # Ancillary subroutines
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 332) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 333)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 334) sub catcheck($)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 335) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 336) my $res = "";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 337) $res = qx(cat $_[0]) if (-r $_[0]);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 338) return $res;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 339) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 340)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 341) sub which($)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 342) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 343) my $file = shift;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 344) my @path = split ":", $ENV{PATH};
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 345)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 346) foreach my $dir(@path) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 347) my $name = $dir.'/'.$file;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 348) return $name if (-x $name );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 349) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 350) return undef;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 351) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 352)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 353) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 354) # Subroutines that check distro-specific hints
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 355) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 356)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 357) sub give_debian_hints()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 358) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 359) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 360) "python-sphinx" => "python3-sphinx",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 361) "sphinx_rtd_theme" => "python3-sphinx-rtd-theme",
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 362) "ensurepip" => "python3-venv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 363) "virtualenv" => "virtualenv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 364) "dot" => "graphviz",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 365) "convert" => "imagemagick",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 366) "Pod::Usage" => "perl-modules",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 367) "xelatex" => "texlive-xetex",
8e7d5d15e73fd (Mauro Carvalho Chehab 2017-07-17 18:46:40 -0300 368) "rsvg-convert" => "librsvg2-bin",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 369) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 370)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 371) if ($pdf) {
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 372) check_missing_file(["/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"],
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 373) "fonts-dejavu", 2);
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 374)
9692f2fdb163a (Jeremy MAURO 2019-10-02 15:35:42 +0200 375) check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc",
bfc7f42810661 (Mauro Carvalho Chehab 2020-04-14 18:56:10 +0200 376) "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
bfc7f42810661 (Mauro Carvalho Chehab 2020-04-14 18:56:10 +0200 377) "/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc"],
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 378) "fonts-noto-cjk", 2);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 379) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 380)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 381) check_program("dvipng", 2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 382) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 383)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 384) return if (!$need && !$optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 385) printf("You should run:\n\n\tsudo apt-get install $install\n");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 386) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 387)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 388) sub give_redhat_hints()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 389) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 390) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 391) "python-sphinx" => "python3-sphinx",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 392) "sphinx_rtd_theme" => "python3-sphinx_rtd_theme",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 393) "virtualenv" => "python3-virtualenv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 394) "dot" => "graphviz",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 395) "convert" => "ImageMagick",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 396) "Pod::Usage" => "perl-Pod-Usage",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 397) "xelatex" => "texlive-xetex-bin",
8e7d5d15e73fd (Mauro Carvalho Chehab 2017-07-17 18:46:40 -0300 398) "rsvg-convert" => "librsvg2-tools",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 399) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 400)
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 401) my @fedora26_opt_pkgs = (
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 402) "graphviz-gd", # Fedora 26: needed for PDF support
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 403) );
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 404)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 405) my @fedora_tex_pkgs = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 406) "texlive-collection-fontsrecommended",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 407) "texlive-collection-latex",
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 408) "texlive-xecjk",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 409) "dejavu-sans-fonts",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 410) "dejavu-serif-fonts",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 411) "dejavu-sans-mono-fonts",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 412) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 413)
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 414) #
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 415) # Checks valid for RHEL/CentOS version 7.x.
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 416) #
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 417) my $old = 0;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 418) my $rel;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 419) $rel = $1 if ($system_release =~ /release\s+(\d+)/);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 420)
b308467c916aa (Mauro Carvalho Chehab 2019-07-13 08:50:24 -0300 421) if (!($system_release =~ /Fedora/)) {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 422) $map{"virtualenv"} = "python-virtualenv";
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 423)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 424) if ($rel && $rel < 8) {
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 425) $old = 1;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 426) $pdf = 0;
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 427)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 428) printf("Note: texlive packages on RHEL/CENTOS <= 7 are incomplete. Can't support PDF output\n");
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 429) printf("If you want to build PDF, please read:\n");
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 430) printf("\thttps://www.systutorials.com/241660/how-to-install-tex-live-on-centos-7-linux/\n");
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 431) }
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 432) } else {
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 433) if ($rel && $rel < 26) {
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 434) $old = 1;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 435) }
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 436) }
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 437) if (!$rel) {
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 438) printf("Couldn't identify release number\n");
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 439) $old = 1;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 440) $pdf = 0;
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 441) }
5d88953c32a64 (Mauro Carvalho Chehab 2017-07-17 18:46:39 -0300 442)
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 443) if ($pdf) {
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 444) check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc"],
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 445) "google-noto-sans-cjk-ttc-fonts", 2);
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 446) }
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 447)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 448) check_rpm_missing(\@fedora26_opt_pkgs, 2) if ($pdf && !$old);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 449) check_rpm_missing(\@fedora_tex_pkgs, 2) if ($pdf);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 450) check_missing_tex(2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 451) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 452)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 453) return if (!$need && !$optional);
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 454)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 455) if (!$old) {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 456) # dnf, for Fedora 18+
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 457) printf("You should run:\n\n\tsudo dnf install -y $install\n");
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 458) } else {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 459) # yum, for RHEL (and clones) or Fedora version < 18
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 460) printf("You should run:\n\n\tsudo yum install -y $install\n");
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 461) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 462) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 463)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 464) sub give_opensuse_hints()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 465) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 466) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 467) "python-sphinx" => "python3-sphinx",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 468) "sphinx_rtd_theme" => "python3-sphinx_rtd_theme",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 469) "virtualenv" => "python3-virtualenv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 470) "dot" => "graphviz",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 471) "convert" => "ImageMagick",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 472) "Pod::Usage" => "perl-Pod-Usage",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 473) "xelatex" => "texlive-xetex-bin",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 474) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 475)
b3df6223bdea7 (Mauro Carvalho Chehab 2020-04-14 18:56:09 +0200 476) # On Tumbleweed, this package is also named rsvg-convert
b3df6223bdea7 (Mauro Carvalho Chehab 2020-04-14 18:56:09 +0200 477) $map{"rsvg-convert"} = "rsvg-view" if (!($system_release =~ /Tumbleweed/));
b3df6223bdea7 (Mauro Carvalho Chehab 2020-04-14 18:56:09 +0200 478)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 479) my @suse_tex_pkgs = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 480) "texlive-babel-english",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 481) "texlive-caption",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 482) "texlive-colortbl",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 483) "texlive-courier",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 484) "texlive-dvips",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 485) "texlive-helvetic",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 486) "texlive-makeindex",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 487) "texlive-metafont",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 488) "texlive-metapost",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 489) "texlive-palatino",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 490) "texlive-preview",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 491) "texlive-times",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 492) "texlive-zapfchan",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 493) "texlive-zapfding",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 494) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 495)
353290a9eb536 (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 496) $map{"latexmk"} = "texlive-latexmk-bin";
353290a9eb536 (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 497)
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 498) # FIXME: add support for installing CJK fonts
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 499) #
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 500) # I tried hard, but was unable to find a way to install
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 501) # "Noto Sans CJK SC" on openSUSE
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 502)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 503) check_rpm_missing(\@suse_tex_pkgs, 2) if ($pdf);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 504) check_missing_tex(2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 505) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 506)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 507) return if (!$need && !$optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 508) printf("You should run:\n\n\tsudo zypper install --no-recommends $install\n");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 509) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 510)
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 511) sub give_mageia_hints()
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 512) {
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 513) my %map = (
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 514) "python-sphinx" => "python3-sphinx",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 515) "sphinx_rtd_theme" => "python3-sphinx_rtd_theme",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 516) "virtualenv" => "python3-virtualenv",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 517) "dot" => "graphviz",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 518) "convert" => "ImageMagick",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 519) "Pod::Usage" => "perl-Pod-Usage",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 520) "xelatex" => "texlive",
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 521) "rsvg-convert" => "librsvg2",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 522) );
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 523)
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 524) my @tex_pkgs = (
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 525) "texlive-fontsextra",
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 526) );
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 527)
353290a9eb536 (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 528) $map{"latexmk"} = "texlive-collection-basic";
353290a9eb536 (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 529)
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 530) my $packager_cmd;
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 531) my $noto_sans;
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 532) if ($system_release =~ /OpenMandriva/) {
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 533) $packager_cmd = "dnf install";
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 534) $noto_sans = "noto-sans-cjk-fonts";
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 535) @tex_pkgs = ( "texlive-collection-fontsextra" );
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 536) } else {
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 537) $packager_cmd = "urpmi";
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 538) $noto_sans = "google-noto-sans-cjk-ttc-fonts";
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 539) }
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 540)
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 541)
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 542) if ($pdf) {
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 543) check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc",
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 544) "/usr/share/fonts/TTF/NotoSans-Regular.ttf"],
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 545) $noto_sans, 2);
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 546) }
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 547)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 548) check_rpm_missing(\@tex_pkgs, 2) if ($pdf);
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 549) check_missing(\%map);
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 550)
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 551) return if (!$need && !$optional);
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 552) printf("You should run:\n\n\tsudo $packager_cmd $install\n");
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 553) }
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 554)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 555) sub give_arch_linux_hints()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 556) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 557) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 558) "sphinx_rtd_theme" => "python-sphinx_rtd_theme",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 559) "virtualenv" => "python-virtualenv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 560) "dot" => "graphviz",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 561) "convert" => "imagemagick",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 562) "xelatex" => "texlive-bin",
0d0da9aa03a17 (Louis Taylor 2019-11-02 18:45:11 +0000 563) "latexmk" => "texlive-core",
8e7d5d15e73fd (Mauro Carvalho Chehab 2017-07-17 18:46:40 -0300 564) "rsvg-convert" => "extra/librsvg",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 565) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 566)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 567) my @archlinux_tex_pkgs = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 568) "texlive-core",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 569) "texlive-latexextra",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 570) "ttf-dejavu",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 571) );
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 572) check_pacman_missing(\@archlinux_tex_pkgs, 2) if ($pdf);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 573)
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 574) if ($pdf) {
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 575) check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"],
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 576) "noto-fonts-cjk", 2);
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 577) }
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 578)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 579) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 580)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 581) return if (!$need && !$optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 582) printf("You should run:\n\n\tsudo pacman -S $install\n");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 583) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 584)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 585) sub give_gentoo_hints()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 586) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 587) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 588) "sphinx_rtd_theme" => "dev-python/sphinx_rtd_theme",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 589) "virtualenv" => "dev-python/virtualenv",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 590) "dot" => "media-gfx/graphviz",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 591) "convert" => "media-gfx/imagemagick",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 592) "xelatex" => "dev-texlive/texlive-xetex media-fonts/dejavu",
8e7d5d15e73fd (Mauro Carvalho Chehab 2017-07-17 18:46:40 -0300 593) "rsvg-convert" => "gnome-base/librsvg",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 594) );
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 595)
ff8fdb36ac35e (Jeremy MAURO 2019-10-02 15:33:39 +0200 596) check_missing_file(["/usr/share/fonts/dejavu/DejaVuSans.ttf"],
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 597) "media-fonts/dejavu", 2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 598)
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 599) if ($pdf) {
e45a631742fad (Mauro Carvalho Chehab 2020-04-14 18:56:11 +0200 600) check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf",
e45a631742fad (Mauro Carvalho Chehab 2020-04-14 18:56:11 +0200 601) "/usr/share/fonts/noto-cjk/NotoSerifCJK-Regular.ttc"],
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 602) "media-fonts/noto-cjk", 2);
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 603) }
27eed923f715f (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 604)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 605) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 606)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 607) return if (!$need && !$optional);
bba1e4cbdb5aa (Mauro Carvalho Chehab 2017-07-17 18:46:41 -0300 608)
bba1e4cbdb5aa (Mauro Carvalho Chehab 2017-07-17 18:46:41 -0300 609) printf("You should run:\n\n");
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 610)
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 611) my $imagemagick = "media-gfx/imagemagick svg png";
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 612) my $cairo = "media-gfx/graphviz cairo pdf";
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 613) my $portage_imagemagick = "/etc/portage/package.use/imagemagick";
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 614) my $portage_cairo = "/etc/portage/package.use/graphviz";
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 615)
e45a631742fad (Mauro Carvalho Chehab 2020-04-14 18:56:11 +0200 616) if (qx(grep imagemagick $portage_imagemagick 2>/dev/null) eq "") {
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 617) printf("\tsudo su -c 'echo \"$imagemagick\" > $portage_imagemagick'\n")
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 618) }
e45a631742fad (Mauro Carvalho Chehab 2020-04-14 18:56:11 +0200 619) if (qx(grep graphviz $portage_cairo 2>/dev/null) eq "") {
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 620) printf("\tsudo su -c 'echo \"$cairo\" > $portage_cairo'\n");
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 621) }
4ea96d57bbfda (Mauro Carvalho Chehab 2019-07-13 08:19:44 -0300 622)
bba1e4cbdb5aa (Mauro Carvalho Chehab 2017-07-17 18:46:41 -0300 623) printf("\tsudo emerge --ask $install\n");
bba1e4cbdb5aa (Mauro Carvalho Chehab 2017-07-17 18:46:41 -0300 624)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 625) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 626)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 627) sub check_distros()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 628) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 629) # Distro-specific hints
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 630) if ($system_release =~ /Red Hat Enterprise Linux/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 631) give_redhat_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 632) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 633) }
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 634) if ($system_release =~ /CentOS/) {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 635) give_redhat_hints;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 636) return;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 637) }
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 638) if ($system_release =~ /Scientific Linux/) {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 639) give_redhat_hints;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 640) return;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 641) }
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 642) if ($system_release =~ /Oracle Linux Server/) {
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 643) give_redhat_hints;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 644) return;
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 645) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 646) if ($system_release =~ /Fedora/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 647) give_redhat_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 648) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 649) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 650) if ($system_release =~ /Ubuntu/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 651) give_debian_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 652) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 653) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 654) if ($system_release =~ /Debian/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 655) give_debian_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 656) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 657) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 658) if ($system_release =~ /openSUSE/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 659) give_opensuse_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 660) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 661) }
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 662) if ($system_release =~ /Mageia/) {
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 663) give_mageia_hints;
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 664) return;
800d408a3427f (Mauro Carvalho Chehab 2017-07-21 13:20:41 -0300 665) }
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 666) if ($system_release =~ /OpenMandriva/) {
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 667) give_mageia_hints;
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 668) return;
d6ebf1890c8ba (Mauro Carvalho Chehab 2020-04-14 18:56:12 +0200 669) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 670) if ($system_release =~ /Arch Linux/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 671) give_arch_linux_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 672) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 673) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 674) if ($system_release =~ /Gentoo/) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 675) give_gentoo_hints;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 676) return;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 677) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 678)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 679) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 680) # Fall-back to generic hint code for other distros
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 681) # That's far from ideal, specially for LaTeX dependencies.
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 682) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 683) my %map = (
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 684) "sphinx-build" => "sphinx"
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 685) );
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 686) check_missing_tex(2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 687) check_missing(\%map);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 688) print "I don't know distro $system_release.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 689) print "So, I can't provide you a hint with the install procedure.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 690) print "There are likely missing dependencies.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 691) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 692)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 693) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 694) # Common dependencies
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 695) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 696)
2730ce017fa6d (Shuah Khan 2019-09-18 18:37:54 -0600 697) sub deactivate_help()
2730ce017fa6d (Shuah Khan 2019-09-18 18:37:54 -0600 698) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 699) printf "\nIf you want to exit the virtualenv, you can use:\n";
2730ce017fa6d (Shuah Khan 2019-09-18 18:37:54 -0600 700) printf "\tdeactivate\n";
2730ce017fa6d (Shuah Khan 2019-09-18 18:37:54 -0600 701) }
2730ce017fa6d (Shuah Khan 2019-09-18 18:37:54 -0600 702)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 703) sub get_virtenv()
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 704) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 705) my $ver;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 706) my $min_activate = "$ENV{'PWD'}/${virtenv_prefix}${min_version}/bin/activate";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 707) my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 708)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 709) @activates = sort {$b cmp $a} @activates;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 710)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 711) foreach my $f (@activates) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 712) next if ($f lt $min_activate);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 713)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 714) my $sphinx_cmd = $f;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 715) $sphinx_cmd =~ s/activate/sphinx-build/;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 716) next if (! -f $sphinx_cmd);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 717)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 718) my $ver = get_sphinx_version($sphinx_cmd);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 719) if ($need_sphinx && ($ver ge $min_version)) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 720) return ($f, $ver);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 721) } elsif ($ver gt $cur_version) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 722) return ($f, $ver);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 723) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 724) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 725) return ("", "");
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 726) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 727)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 728) sub recommend_sphinx_upgrade()
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 729) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 730) my $venv_ver;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 731)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 732) # Avoid running sphinx-builds from venv if $cur_version is good
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 733) if ($cur_version && ($cur_version ge $rec_version)) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 734) $latest_avail_ver = $cur_version;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 735) return;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 736) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 737)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 738) # Get the highest version from sphinx_*/bin/sphinx-build and the
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 739) # corresponding command to activate the venv/virtenv
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 740) $activate_cmd = get_virtenv();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 741)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 742) # Store the highest version from Sphinx existing virtualenvs
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 743) if (($activate_cmd ne "") && ($venv_ver gt $cur_version)) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 744) $latest_avail_ver = $venv_ver;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 745) } else {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 746) $latest_avail_ver = $cur_version if ($cur_version);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 747) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 748)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 749) # As we don't know package version of Sphinx, and there's no
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 750) # virtual environments, don't check if upgrades are needed
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 751) if (!$virtualenv) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 752) return if (!$latest_avail_ver);
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 753) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 754)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 755) # Either there are already a virtual env or a new one should be created
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 756) $need_pip = 1;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 757)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 758) # Return if the reason is due to an upgrade or not
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 759) if ($latest_avail_ver lt $rec_version) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 760) $rec_sphinx_upgrade = 1;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 761) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 762) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 763)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 764) #
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 765) # The logic here is complex, as it have to deal with different versions:
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 766) # - minimal supported version;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 767) # - minimal PDF version;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 768) # - recommended version.
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 769) # It also needs to work fine with both distro's package and venv/virtualenv
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 770) sub recommend_sphinx_version($)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 771) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 772) my $virtualenv_cmd = shift;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 773)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 774) if ($latest_avail_ver lt $min_pdf_version) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 775) print "note: If you want pdf, you need at least Sphinx $min_pdf_version.\n";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 776) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 777)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 778) # Version is OK. Nothing to do.
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 779) return if ($cur_version && ($cur_version ge $rec_version));
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 780)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 781) if (!$need_sphinx) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 782) # sphinx-build is present and its version is >= $min_version
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 783)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 784) #only recommend enabling a newer virtenv version if makes sense.
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 785) if ($latest_avail_ver gt $cur_version) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 786) printf "\nYou may also use the newer Sphinx version $latest_avail_ver with:\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 787) printf "\tdeactivate\n" if ($ENV{'PWD'} =~ /${virtenv_prefix}/);
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 788) printf "\t. $activate_cmd\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 789) deactivate_help();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 790)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 791) return;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 792) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 793) return if ($latest_avail_ver ge $rec_version);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 794) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 795)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 796) if (!$virtualenv) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 797) # No sphinx either via package or via virtenv. As we can't
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 798) # Compare the versions here, just return, recommending the
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 799) # user to install it from the package distro.
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 800) return if (!$latest_avail_ver);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 801)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 802) # User doesn't want a virtenv recommendation, but he already
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 803) # installed one via virtenv with a newer version.
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 804) # So, print commands to enable it
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 805) if ($latest_avail_ver gt $cur_version) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 806) printf "\nYou may also use the Sphinx virtualenv version $latest_avail_ver with:\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 807) printf "\tdeactivate\n" if ($ENV{'PWD'} =~ /${virtenv_prefix}/);
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 808) printf "\t. $activate_cmd\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 809) deactivate_help();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 810)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 811) return;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 812) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 813) print "\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 814) } else {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 815) $need++ if ($need_sphinx);
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 816) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 817)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 818) # Suggest newer versions if current ones are too old
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 819) if ($latest_avail_ver && $cur_version ge $min_version) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 820) # If there's a good enough version, ask the user to enable it
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 821) if ($latest_avail_ver ge $rec_version) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 822) printf "\nNeed to activate Sphinx (version $latest_avail_ver) on virtualenv with:\n";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 823) printf "\t. $activate_cmd\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 824) deactivate_help();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 825)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 826) return;
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 827) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 828)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 829) # Version is above the minimal required one, but may be
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 830) # below the recommended one. So, print warnings/notes
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 831)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 832) if ($latest_avail_ver lt $rec_version) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 833) print "Warning: It is recommended at least Sphinx version $rec_version.\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 834) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 835) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 836)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 837) # At this point, either it needs Sphinx or upgrade is recommended,
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 838) # both via pip
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 839)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 840) if ($rec_sphinx_upgrade) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 841) if (!$virtualenv) {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 842) print "Instead of install/upgrade Python Sphinx pkg, you could use pip/pypi with:\n\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 843) } else {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 844) print "To upgrade Sphinx, use:\n\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 845) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 846) } else {
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 847) print "Sphinx needs to be installed either as a package or via pip/pypi with:\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 848) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 849)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 850) $python_cmd = find_python_no_venv();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 851)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 852) printf "\t$virtualenv_cmd $virtenv_dir\n";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 853)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 854) printf "\t. $virtenv_dir/bin/activate\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 855) printf "\tpip install -r $requirement_file\n";
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 856) deactivate_help();
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 857) }
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 858)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 859) sub check_needs()
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 860) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 861) # Check if Sphinx is already accessible from current environment
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 862) check_sphinx();
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 863)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 864) if ($system_release) {
ec43a27fffd02 (Mauro Carvalho Chehab 2020-04-21 18:27:58 +0200 865) print "Detected OS: $system_release.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 866) } else {
ec43a27fffd02 (Mauro Carvalho Chehab 2020-04-21 18:27:58 +0200 867) print "Unknown OS\n";
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 868) }
ec43a27fffd02 (Mauro Carvalho Chehab 2020-04-21 18:27:58 +0200 869) printf "Sphinx version: %s\n\n", $cur_version if ($cur_version);
9b756a9d07fd3 (Mauro Carvalho Chehab 2017-07-24 09:09:24 -0300 870)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 871) # Check python command line, trying first python3
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 872) $python_cmd = findprog("python3");
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 873) $python_cmd = check_program("python", 0) if (!$python_cmd);
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 874)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 875) # Check the type of virtual env, depending on Python version
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 876) if ($python_cmd) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 877) if ($virtualenv) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 878) my $tmp = qx($python_cmd --version 2>&1);
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 879) if ($tmp =~ m/(\d+\.)(\d+\.)/) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 880) if ($1 < 3) {
4217e5074f33d (Jonathan Corbet 2021-02-01 17:17:14 -0700 881) # Fail if it finds python2 (or worse)
4217e5074f33d (Jonathan Corbet 2021-02-01 17:17:14 -0700 882) die "Python 3 is required to build the kernel docs\n";
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 883) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 884) if ($1 == 3 && $2 < 3) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 885) # Need Python 3.3 or upper for venv
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 886) $need_virtualenv = 1;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 887) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 888) } else {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 889) die "Warning: couldn't identify $python_cmd version!";
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 890) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 891) } else {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 892) add_package("python-sphinx", 0);
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 893) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 894) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 895)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 896) recommend_sphinx_upgrade();
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 897)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 898) my $virtualenv_cmd;
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 899)
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 900) if ($need_pip) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 901) # Set virtualenv command line, if python < 3.3
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 902) if ($need_virtualenv) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 903) $virtualenv_cmd = findprog("virtualenv-3");
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 904) $virtualenv_cmd = findprog("virtualenv-3.5") if (!$virtualenv_cmd);
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 905) if (!$virtualenv_cmd) {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 906) check_program("virtualenv", 0);
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 907) $virtualenv_cmd = "virtualenv";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 908) }
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 909) } else {
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 910) $virtualenv_cmd = "$python_cmd -m venv";
a5f785f102185 (Mauro Carvalho Chehab 2021-05-25 15:27:28 +0200 911) check_python_module("ensurepip", 0);
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 912) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 913) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 914)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 915) # Check for needed programs/tools
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 916) check_perl_module("Pod::Usage", 0);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 917) check_program("make", 0);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 918) check_program("gcc", 0);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 919) check_python_module("sphinx_rtd_theme", 1) if (!$virtualenv);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 920) check_program("dot", 1);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 921) check_program("convert", 1);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 922)
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 923) # Extra PDF files - should use 2 for is_optional
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 924) check_program("xelatex", 2) if ($pdf);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 925) check_program("rsvg-convert", 2) if ($pdf);
56e5a63392379 (Mauro Carvalho Chehab 2019-07-13 09:37:16 -0300 926) check_program("latexmk", 2) if ($pdf);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 927)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 928) # Do distro-specific checks and output distro-install commands
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 929) check_distros();
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 930)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 931) if (!$python_cmd) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 932) if ($need == 1) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 933) die "Can't build as $need mandatory dependency is missing";
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 934) } elsif ($need) {
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 935) die "Can't build as $need mandatory dependencies are missing";
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 936) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 937) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 938)
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 939) # Check if sphinx-build is called sphinx-build-3
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 940) if ($need_symlink) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 941) printf "\tsudo ln -sf %s /usr/bin/sphinx-build\n\n",
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 942) which("sphinx-build-3");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 943) }
2f9c502552cd3 (Mauro Carvalho Chehab 2020-04-14 18:56:13 +0200 944)
e50899122f320 (Mauro Carvalho Chehab 2021-05-25 15:27:27 +0200 945) recommend_sphinx_version($virtualenv_cmd);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 946) printf "\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 947)
54002b56b04bc (Bjorn Helgaas 2019-05-30 16:59:14 -0500 948) print "All optional dependencies are met.\n" if (!$optional);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 949)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 950) if ($need == 1) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 951) die "Can't build as $need mandatory dependency is missing";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 952) } elsif ($need) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 953) die "Can't build as $need mandatory dependencies are missing";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 954) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 955)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 956) print "Needed package dependencies are met.\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 957) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 958)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 959) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 960) # Main
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 961) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 962)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 963) while (@ARGV) {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 964) my $arg = shift(@ARGV);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 965)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 966) if ($arg eq "--no-virtualenv") {
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 967) $virtualenv = 0;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 968) } elsif ($arg eq "--no-pdf"){
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 969) $pdf = 0;
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 970) } elsif ($arg eq "--version-check"){
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 971) $version_check = 1;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 972) } else {
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 973) print "Usage:\n\t$0 <--no-virtualenv> <--no-pdf> <--version-check>\n\n";
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 974) print "Where:\n";
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 975) print "\t--no-virtualenv\t- Recommend installing Sphinx instead of using a virtualenv\n";
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 976) print "\t--version-check\t- if version is compatible, don't check for missing dependencies\n";
9b88ad5464af1 (Mauro Carvalho Chehab 2019-05-29 20:09:26 -0300 977) print "\t--no-pdf\t- don't check for dependencies required to build PDF docs\n\n";
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 978) exit -1;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 979) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 980) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 981)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 982) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 983) # Determine the system type. There's no standard unique way that would
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 984) # work with all distros with a minimal package install. So, several
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 985) # methods are used here.
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 986) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 987) # By default, it will use lsb_release function. If not available, it will
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 988) # fail back to reading the known different places where the distro name
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 989) # is stored
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 990) #
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 991)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 992) $system_release = qx(lsb_release -d) if which("lsb_release");
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 993) $system_release =~ s/Description:\s*// if ($system_release);
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 994) $system_release = catcheck("/etc/system-release") if !$system_release;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 995) $system_release = catcheck("/etc/redhat-release") if !$system_release;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 996) $system_release = catcheck("/etc/lsb-release") if !$system_release;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 997) $system_release = catcheck("/etc/gentoo-release") if !$system_release;
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 998)
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 999) # This seems more common than LSB these days
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1000) if (!$system_release) {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1001) my %os_var;
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1002) if (open IN, "cat /etc/os-release|") {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1003) while (<IN>) {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1004) if (m/^([\w\d\_]+)=\"?([^\"]*)\"?\n/) {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1005) $os_var{$1}=$2;
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1006) }
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1007) }
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1008) $system_release = $os_var{"NAME"};
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1009) if (defined($os_var{"VERSION_ID"})) {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1010) $system_release .= " " . $os_var{"VERSION_ID"} if (defined($os_var{"VERSION_ID"}));
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1011) } else {
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1012) $system_release .= " " . $os_var{"VERSION"};
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1013) }
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1014) }
d14d0c1aea8fe (Mauro Carvalho Chehab 2020-04-14 18:56:08 +0200 1015) }
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 1016) $system_release = catcheck("/etc/issue") if !$system_release;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 1017) $system_release =~ s/\s+$//;
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 1018)
24071ac1a6176 (Mauro Carvalho Chehab 2017-07-17 18:46:36 -0300 1019) check_needs;