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