sphinx-pre-install (112d6212c80a1c560757520bd822a41c0ad15c2c) | sphinx-pre-install (0d0da9aa03a178d343f64f3bd7d545b0d3bf8b7e) |
---|---|
1#!/usr/bin/perl 2# SPDX-License-Identifier: GPL-2.0-or-later 3use strict; 4 5# Copyright (c) 2017-2019 Mauro Carvalho Chehab <mchehab@kernel.org> 6# 7 8my $prefix = "./"; --- 110 unchanged lines hidden (view full) --- 119 $optional++; 120 } else { 121 $need++; 122 } 123} 124 125sub check_missing_file($$$) 126{ | 1#!/usr/bin/perl 2# SPDX-License-Identifier: GPL-2.0-or-later 3use strict; 4 5# Copyright (c) 2017-2019 Mauro Carvalho Chehab <mchehab@kernel.org> 6# 7 8my $prefix = "./"; --- 110 unchanged lines hidden (view full) --- 119 $optional++; 120 } else { 121 $need++; 122 } 123} 124 125sub check_missing_file($$$) 126{ |
127 my $file = shift; | 127 my $files = shift; |
128 my $package = shift; 129 my $is_optional = shift; 130 | 128 my $package = shift; 129 my $is_optional = shift; 130 |
131 return if(-e $file); | 131 for (@$files) { 132 return if(-e $_); 133 } |
132 133 add_package($package, $is_optional); 134} 135 136sub findprog($) 137{ 138 foreach(split(/:/, $ENV{PATH})) { 139 return "$_/$_[0]" if(-x "$_/$_[0]"); --- 198 unchanged lines hidden (view full) --- 338 "dot" => "graphviz", 339 "convert" => "imagemagick", 340 "Pod::Usage" => "perl-modules", 341 "xelatex" => "texlive-xetex", 342 "rsvg-convert" => "librsvg2-bin", 343 ); 344 345 if ($pdf) { | 134 135 add_package($package, $is_optional); 136} 137 138sub findprog($) 139{ 140 foreach(split(/:/, $ENV{PATH})) { 141 return "$_/$_[0]" if(-x "$_/$_[0]"); --- 198 unchanged lines hidden (view full) --- 340 "dot" => "graphviz", 341 "convert" => "imagemagick", 342 "Pod::Usage" => "perl-modules", 343 "xelatex" => "texlive-xetex", 344 "rsvg-convert" => "librsvg2-bin", 345 ); 346 347 if ($pdf) { |
346 check_missing_file("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", | 348 check_missing_file(["/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"], |
347 "fonts-dejavu", 2); 348 | 349 "fonts-dejavu", 2); 350 |
349 check_missing_file("/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", | 351 check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", 352 "/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc"], |
350 "fonts-noto-cjk", 2); 351 } 352 353 check_program("dvipng", 2) if ($pdf); 354 check_missing(\%map); 355 356 return if (!$need && !$optional); 357 printf("You should run:\n\n\tsudo apt-get install $install\n"); --- 50 unchanged lines hidden (view full) --- 408 } 409 if (!$rel) { 410 printf("Couldn't identify release number\n"); 411 $old = 1; 412 $pdf = 0; 413 } 414 415 if ($pdf) { | 353 "fonts-noto-cjk", 2); 354 } 355 356 check_program("dvipng", 2) if ($pdf); 357 check_missing(\%map); 358 359 return if (!$need && !$optional); 360 printf("You should run:\n\n\tsudo apt-get install $install\n"); --- 50 unchanged lines hidden (view full) --- 411 } 412 if (!$rel) { 413 printf("Couldn't identify release number\n"); 414 $old = 1; 415 $pdf = 0; 416 } 417 418 if ($pdf) { |
416 check_missing_file("/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", | 419 check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc"], |
417 "google-noto-sans-cjk-ttc-fonts", 2); 418 } 419 420 check_rpm_missing(\@fedora26_opt_pkgs, 2) if ($pdf && !$old); 421 check_rpm_missing(\@fedora_tex_pkgs, 2) if ($pdf); 422 check_missing_tex(2) if ($pdf); 423 check_missing(\%map); 424 --- 68 unchanged lines hidden (view full) --- 493 494 my @tex_pkgs = ( 495 "texlive-fontsextra", 496 ); 497 498 $map{"latexmk"} = "texlive-collection-basic"; 499 500 if ($pdf) { | 420 "google-noto-sans-cjk-ttc-fonts", 2); 421 } 422 423 check_rpm_missing(\@fedora26_opt_pkgs, 2) if ($pdf && !$old); 424 check_rpm_missing(\@fedora_tex_pkgs, 2) if ($pdf); 425 check_missing_tex(2) if ($pdf); 426 check_missing(\%map); 427 --- 68 unchanged lines hidden (view full) --- 496 497 my @tex_pkgs = ( 498 "texlive-fontsextra", 499 ); 500 501 $map{"latexmk"} = "texlive-collection-basic"; 502 503 if ($pdf) { |
501 check_missing_file("/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", | 504 check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc"], |
502 "google-noto-sans-cjk-ttc-fonts", 2); 503 } 504 505 check_rpm_missing(\@tex_pkgs, 2) if ($pdf); 506 check_missing(\%map); 507 508 return if (!$need && !$optional); 509 printf("You should run:\n\n\tsudo urpmi $install\n"); 510} 511 512sub give_arch_linux_hints() 513{ 514 my %map = ( 515 "sphinx_rtd_theme" => "python-sphinx_rtd_theme", 516 "virtualenv" => "python-virtualenv", 517 "dot" => "graphviz", 518 "convert" => "imagemagick", 519 "xelatex" => "texlive-bin", | 505 "google-noto-sans-cjk-ttc-fonts", 2); 506 } 507 508 check_rpm_missing(\@tex_pkgs, 2) if ($pdf); 509 check_missing(\%map); 510 511 return if (!$need && !$optional); 512 printf("You should run:\n\n\tsudo urpmi $install\n"); 513} 514 515sub give_arch_linux_hints() 516{ 517 my %map = ( 518 "sphinx_rtd_theme" => "python-sphinx_rtd_theme", 519 "virtualenv" => "python-virtualenv", 520 "dot" => "graphviz", 521 "convert" => "imagemagick", 522 "xelatex" => "texlive-bin", |
523 "latexmk" => "texlive-core", |
|
520 "rsvg-convert" => "extra/librsvg", 521 ); 522 523 my @archlinux_tex_pkgs = ( 524 "texlive-core", 525 "texlive-latexextra", 526 "ttf-dejavu", 527 ); 528 check_pacman_missing(\@archlinux_tex_pkgs, 2) if ($pdf); 529 530 if ($pdf) { | 524 "rsvg-convert" => "extra/librsvg", 525 ); 526 527 my @archlinux_tex_pkgs = ( 528 "texlive-core", 529 "texlive-latexextra", 530 "ttf-dejavu", 531 ); 532 check_pacman_missing(\@archlinux_tex_pkgs, 2) if ($pdf); 533 534 if ($pdf) { |
531 check_missing_file("/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", | 535 check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], |
532 "noto-fonts-cjk", 2); 533 } 534 535 check_missing(\%map); 536 537 return if (!$need && !$optional); 538 printf("You should run:\n\n\tsudo pacman -S $install\n"); 539} --- 4 unchanged lines hidden (view full) --- 544 "sphinx_rtd_theme" => "dev-python/sphinx_rtd_theme", 545 "virtualenv" => "dev-python/virtualenv", 546 "dot" => "media-gfx/graphviz", 547 "convert" => "media-gfx/imagemagick", 548 "xelatex" => "dev-texlive/texlive-xetex media-fonts/dejavu", 549 "rsvg-convert" => "gnome-base/librsvg", 550 ); 551 | 536 "noto-fonts-cjk", 2); 537 } 538 539 check_missing(\%map); 540 541 return if (!$need && !$optional); 542 printf("You should run:\n\n\tsudo pacman -S $install\n"); 543} --- 4 unchanged lines hidden (view full) --- 548 "sphinx_rtd_theme" => "dev-python/sphinx_rtd_theme", 549 "virtualenv" => "dev-python/virtualenv", 550 "dot" => "media-gfx/graphviz", 551 "convert" => "media-gfx/imagemagick", 552 "xelatex" => "dev-texlive/texlive-xetex media-fonts/dejavu", 553 "rsvg-convert" => "gnome-base/librsvg", 554 ); 555 |
552 check_missing_file("/usr/share/fonts/dejavu/DejaVuSans.ttf", | 556 check_missing_file(["/usr/share/fonts/dejavu/DejaVuSans.ttf"], |
553 "media-fonts/dejavu", 2) if ($pdf); 554 555 if ($pdf) { | 557 "media-fonts/dejavu", 2) if ($pdf); 558 559 if ($pdf) { |
556 check_missing_file("/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf", | 560 check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf"], |
557 "media-fonts/noto-cjk", 2); 558 } 559 560 check_missing(\%map); 561 562 return if (!$need && !$optional); 563 564 printf("You should run:\n\n"); --- 75 unchanged lines hidden (view full) --- 640 print "So, I can't provide you a hint with the install procedure.\n"; 641 print "There are likely missing dependencies.\n"; 642} 643 644# 645# Common dependencies 646# 647 | 561 "media-fonts/noto-cjk", 2); 562 } 563 564 check_missing(\%map); 565 566 return if (!$need && !$optional); 567 568 printf("You should run:\n\n"); --- 75 unchanged lines hidden (view full) --- 644 print "So, I can't provide you a hint with the install procedure.\n"; 645 print "There are likely missing dependencies.\n"; 646} 647 648# 649# Common dependencies 650# 651 |
652sub deactivate_help() 653{ 654 printf "\tIf you want to exit the virtualenv, you can use:\n"; 655 printf "\tdeactivate\n"; 656} 657 |
|
648sub check_needs() 649{ 650 # Check for needed programs/tools 651 check_sphinx(); 652 653 if ($system_release) { 654 print "Detected OS: $system_release.\n\n"; 655 } else { --- 25 unchanged lines hidden (view full) --- 681 my $min_activate = "$ENV{'PWD'}/${virtenv_prefix}${min_version}/bin/activate"; 682 my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; 683 684 @activates = sort {$b cmp $a} @activates; 685 686 if ($need_sphinx && scalar @activates > 0 && $activates[0] ge $min_activate) { 687 printf "\nNeed to activate a compatible Sphinx version on virtualenv with:\n"; 688 printf "\t. $activates[0]\n"; | 658sub check_needs() 659{ 660 # Check for needed programs/tools 661 check_sphinx(); 662 663 if ($system_release) { 664 print "Detected OS: $system_release.\n\n"; 665 } else { --- 25 unchanged lines hidden (view full) --- 691 my $min_activate = "$ENV{'PWD'}/${virtenv_prefix}${min_version}/bin/activate"; 692 my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; 693 694 @activates = sort {$b cmp $a} @activates; 695 696 if ($need_sphinx && scalar @activates > 0 && $activates[0] ge $min_activate) { 697 printf "\nNeed to activate a compatible Sphinx version on virtualenv with:\n"; 698 printf "\t. $activates[0]\n"; |
699 deactivate_help(); |
|
689 exit (1); 690 } else { 691 my $rec_activate = "$virtenv_dir/bin/activate"; 692 my $virtualenv = findprog("virtualenv-3"); 693 $virtualenv = findprog("virtualenv-3.5") if (!$virtualenv); 694 $virtualenv = findprog("virtualenv") if (!$virtualenv); 695 $virtualenv = "virtualenv" if (!$virtualenv); 696 697 printf "\t$virtualenv $virtenv_dir\n"; 698 printf "\t. $rec_activate\n"; 699 printf "\tpip install -r $requirement_file\n"; | 700 exit (1); 701 } else { 702 my $rec_activate = "$virtenv_dir/bin/activate"; 703 my $virtualenv = findprog("virtualenv-3"); 704 $virtualenv = findprog("virtualenv-3.5") if (!$virtualenv); 705 $virtualenv = findprog("virtualenv") if (!$virtualenv); 706 $virtualenv = "virtualenv" if (!$virtualenv); 707 708 printf "\t$virtualenv $virtenv_dir\n"; 709 printf "\t. $rec_activate\n"; 710 printf "\tpip install -r $requirement_file\n"; |
711 deactivate_help(); |
|
700 701 $need++ if (!$rec_sphinx_upgrade); 702 } 703 } 704 printf "\n"; 705 706 print "All optional dependencies are met.\n" if (!$optional); 707 --- 52 unchanged lines hidden --- | 712 713 $need++ if (!$rec_sphinx_upgrade); 714 } 715 } 716 printf "\n"; 717 718 print "All optional dependencies are met.\n" if (!$optional); 719 --- 52 unchanged lines hidden --- |