Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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