"Fossies" - the Fresh Open Source Software Archive

Member "latex2html-2021.2/config/install.pl" (1 Jul 2021, 14539 Bytes) of package /linux/www/latex2html-2021.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "install.pl" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2021_vs_2021.2.

    1 #! /usr/bin/perl -w
    2 
    3 ###############################################################################
    4 # $Id: install.pl,v 1.12 2002/04/27 11:31:23 RRM Exp $
    5 #
    6 # install.pl
    7 #
    8 # This script is used to install LaTeX2HTML on the user's system
    9 #
   10 # Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
   11 #
   12 # This software is part of LaTeX2HTML, originally by Nikos Drakos
   13 # It is published under the GNU Public License and comes without any
   14 # warranty.
   15 #
   16 ###############################################################################
   17 # Changes History
   18 #
   19 # $Log: install.pl,v $
   20 # Revision 1.12  2002/04/27 11:31:23  RRM
   21 #      new release version:  2002-1
   22 #
   23 #  --  implements $LATEX2HTMLDIR (shared) and $LATEX2HTMLPLATDIR (unshared)
   24 #      puts unshared l2hconf.pm into $LATEX2HTMLPLATDIR (platform-specific)
   25 #      other modules into $LATEX2HTMLDIR (shareable across platforms)
   26 #
   27 #  --  checks for more graphics conversion utilities, for use with revised
   28 #       graphics.perl  and  graphicx.perl
   29 #
   30 # Revision 1.11  2002/03/07 01:56:19  RRM
   31 #  --  allow the environment variable DESTDIR to be recognise, as a means
   32 #      of giving the installation location; e.g.
   33 #
   34 #         make install DESTDIR=/usr/local/mypackages/
   35 #
   36 #      This is mainly for package-manager software, such as Debian and fink.
   37 #      Thanks to David R Morrison <drm@cgtp.duke.edu>
   38 #      and Daniel Steffen <steffen@maths.mq.edu.au>  for this feature.
   39 #
   40 # Revision 1.10  1999/11/16 00:07:21  MRO
   41 #
   42 # -- minimal change to make $TMP commentable, i.e. unavailable
   43 #
   44 # Revision 1.9  1999/11/09 00:43:42  MRO
   45 #
   46 #
   47 # -- added some changes suggested on the mail list recently: mainly cleanup
   48 #    of -dir option
   49 # -- added installation support for latex2html styles
   50 #
   51 # Revision 1.8  1999/10/26 22:32:57  MRO
   52 #
   53 # -- added a credit
   54 # -- reworked parts of the INSTALL documentation
   55 # -- installation now tries to install styles
   56 #
   57 # Revision 1.7  1999/10/25 21:18:22  MRO
   58 #
   59 # -- added more configure options (Jens' suggestions)
   60 # -- fixed bug in regexp range reported by Achim Haertel
   61 # -- fixed old references in documentation (related to mail list/archive)
   62 #
   63 # Revision 1.6  1999/10/03 18:40:42  MRO
   64 #
   65 # -- some cleanups for beta2
   66 # -- "make check" now checks all Perl code
   67 #
   68 # Revision 1.5  1999/08/30 22:45:09  MRO
   69 #
   70 # -- perl now reports line numbers respective to .pin file - eases
   71 #    code development!
   72 # -- l2hcfg.pm is installed, too for furtjer reference
   73 # -- some minor bugs (hopefully) fixed.
   74 #
   75 # Revision 1.4  1999/06/06 14:24:58  MRO
   76 #
   77 #
   78 # -- many cleanups wrt. to TeXlive
   79 # -- changed $* to /m as far as possible. $* is deprecated in perl5, all
   80 #    occurrences should be removed.
   81 #
   82 # Revision 1.3  1999/06/04 15:30:20  MRO
   83 #
   84 #
   85 # -- fixed errors introduced by cleaning up TMP*
   86 # -- made pstoimg -quiet really quiet
   87 # -- pstoimg -debug now saves intermediate result files
   88 # -- several fixes for OS/2
   89 #
   90 # Revision 1.2  1999/05/19 23:54:07  MRO
   91 #
   92 #
   93 # -- uniquified icons - some of them look a little bit strange, might
   94 #    need to be fixed.
   95 # -- got rid of unlink errors, cleaned up some cosmetics
   96 #
   97 # Revision 1.1  1999/05/11 06:10:03  MRO
   98 #
   99 #
  100 # - merged config stuff, did first tries on Linux. Simple document
  101 #   passes! More test required, have to ger rid of Warnings in texexpand
  102 #
  103 # Revision 1.12  1999/02/23 23:32:35  MRO
  104 #
  105 #
  106 # -- few changes for Win32
  107 #
  108 # Revision 1.11  1999/02/10 01:37:15  MRO
  109 #
  110 #
  111 # -- changed os-dependency structure again - now neat OO modules are
  112 #    used: portable, extensible, neat!
  113 # -- some minor cleanups and bugfixes
  114 #
  115 # Revision 1.10  1999/02/07 23:47:52  MRO
  116 #
  117 #
  118 # -- made install procedure work
  119 #
  120 # Revision 1.9  1998/12/14 22:55:07  MRO
  121 #
  122 #
  123 # -- commit test for MRO
  124 #
  125 # Revision 1.8  1998/12/12 16:39:17  MRO
  126 #
  127 #
  128 # -- cosmetic changes, reworked catching of STDERR in config.pl (Win32)
  129 # -- new configure opt --disable-paths
  130 # -- major cleanups
  131 #
  132 # Revision 1.7  1998/12/07 23:20:00  MRO
  133 #
  134 #
  135 # -- added POD documentation to pstoimg and did a general cleanup
  136 # -- some finetuning of config procedure and modules
  137 #
  138 # Revision 1.6  1998/10/31 14:13:09  MRO
  139 # -- changed OS-dependent module loading strategy: Modules are now located in
  140 #    different (OS-specific) directories nut have the same name: Easier to
  141 #    maintain and cleaner code
  142 # -- Cleaned up config procedure
  143 # -- Extended makefile functionality
  144 #
  145 # Revision 1.5  1998/05/06 22:31:24  latex2html
  146 # -- Enhancements to the config procedure: Added a "generic" target
  147 #    in the Makefile for the TeXlive CD (not perfect yet)
  148 # -- included test for kpsewhich / Web2C
  149 # -- included latest stuff from Override.pm into os_*.pm
  150 #
  151 # Revision 1.4  1998/04/28 22:22:40  latex2html
  152 # - The platform specific stuff is now kept in a separate perl module. This
  153 #   does not introduce significant overhead and enhances maintainability.
  154 #
  155 # Revision 1.3  1998/03/19 23:38:12  latex2html
  156 # -- made pstoimg plug-in compatible with old one (touchwood!)
  157 # -- cleaned up, added some comments
  158 # -- inserted version information output
  159 # -- incorporated patches to make OS/2 run better (thanks Uli)
  160 # -- updated Makefile: make, make test, make install should work now
  161 #
  162 # Revision 1.2  1998/03/17 23:26:47  latex2html
  163 # -- fixed some bugs in config.pl
  164 # -- first version of install.pl finished
  165 #
  166 # Revision 1.1  1998/03/16 23:32:01  latex2html
  167 # -- lots of cosmetic changes and bugfixes, thanks to Uli Wortmann
  168 #    for OS/2 testing
  169 # -- start of install procedure; checks for installation paths implemented
  170 #
  171 ###############################################################################
  172 
  173 require 5.003;
  174 use strict;
  175 # use diagnostics;
  176 use vars qw(%cfg);
  177 
  178 my ($VERSION) = q$Revision: 1.12 $ =~ /:\s*(\S*)/;
  179 
  180 # --------------------------------------------------------------------------
  181 # Initialize
  182 # --------------------------------------------------------------------------
  183 
  184 use FindBin;
  185 use lib "$FindBin::Bin/..";
  186 use cfgcache;
  187 use L2hos;
  188 
  189 my $dd = $cfg{'dd'};
  190 
  191 print "install.pl (Revision $VERSION)\n\n";
  192 
  193 my $FILECHMOD = 0644; # numbers staring with 0 are octal!
  194 my $DIRCHMOD  = 0755;
  195 my $BINCHMOD  = 0755;
  196 
  197 # --------------------------------------------------------------------------
  198 # The distribution's contents
  199 # --------------------------------------------------------------------------
  200 
  201 # legal values: bin|lib|plat  store in binary or library directory
  202 #               recurse       recurse for contents (directory only)
  203 #               from=<dir>    use other source directory
  204 #               to=<dir>      use other destination directory
  205 #      separate these flags with ','
  206 
  207 my %Install_items = (
  208   #'Changes'           => 'lib',
  209   #'FAQ'               => 'lib',
  210   #'INSTALL'           => 'lib',
  211   'IndicTeX-HTML'     => 'lib,recurse',
  212   'L2hos'             => 'lib,recurse',
  213   'L2hos.pm'          => 'lib',
  214   #'MANIFEST'          => 'lib',
  215   #'README'            => 'lib',
  216   #'README.dvips'      => 'lib',
  217   #'TODO'            => 'lib',
  218   'XyMTeX-HTML'       => 'lib,recurse',
  219   #'config'            => 'lib,recurse',
  220   #'config.bat'        => 'lib',
  221   #'configure'         => 'lib',
  222   #'configure.in'      => 'lib',
  223   'cweb2html'         => 'lib,recurse',
  224   'docs'              => 'lib,recurse',
  225   'dot.latex2html-init' => 'lib',
  226   'example'           => 'lib,recurse',
  227   'foilhtml'          => 'lib,recurse',
  228   # icons are teated specially below
  229   # the local config is also installed
  230   'cfgcache.pm'       => 'plat',
  231   #'latex2html.config' is now l2hconf.pm
  232   'l2hconf.pm'        => 'plat',
  233   'makemap'           => 'lib',
  234   'makeseg'           => 'lib,recurse',
  235   #'prefs.pm'          => 'lib',
  236   #'readme.hthtml'     => 'lib',
  237   'styles'            => 'lib,recurse',
  238   # MRO: Tests are for pre-installation testing
  239   #'tests'             => 'lib,recurse',
  240   'texinputs'         => 'lib,recurse',
  241   #'texlive.pm'        => 'lib',
  242   'versions'          => 'lib,recurse',
  243   #'wrapper'           => 'lib,recurse',
  244 );
  245 
  246 # --------------------------------------------------------------------------
  247 # Special case: OS dependencies
  248 # --------------------------------------------------------------------------
  249 
  250 my @scripts = qw(latex2html pstoimg texexpand);
  251 
  252 if($cfg{'texlive'}) {
  253   #$Install_items{'bin'} = 'lib,recurse';
  254   # where to install what be built
  255   my %plat_map = (
  256         win32 => 'win32:.bat',
  257         unix => 'i386-linux,rs6000-aix3.2.5,alpha-osf3.2,rs6000-aix4.1,alpha-osf4.0,mips-irix5.3,sparc-solaris2.5.1,hppa1.1-hpux10.10,mips-irix6.2,sparc-sunos4.1.4,powerpc-apple-darwin-current:'
  258         );
  259   my $script;
  260   foreach $script (@scripts) {
  261     my $plat;
  262     foreach $plat (qw(unix win32)) {
  263       my ($d,$ext) = split(/:/, $plat_map{$plat});
  264       my $ip;
  265       foreach $ip (split(',',$d)) {
  266         &install_file("./bin/$plat/$script$ext",
  267           "$cfg{'PREFIX'}/bin/$ip",$BINCHMOD);
  268         $Install_items{"bin/$plat/$script$ext"} =
  269           "to=$cfg{'PREFIX'}/bin/$ip";
  270       }
  271     }
  272     $Install_items{"$script.pl"} = 'lib';
  273   }
  274 } elsif($cfg{'wrapper'}) {
  275   foreach(@scripts) {
  276     $Install_items{"$_$cfg{'exec_extension'}"} = 'bin,from=bin';
  277     $Install_items{"$_.pl"} = 'lib';
  278   }
  279 } else {
  280   foreach(@scripts) {
  281     $Install_items{"$_$cfg{'exec_extension'}"} = 'bin';
  282   }
  283 }
  284 
  285 # --------------------------------------------------------------------------
  286 # Special case: icons
  287 # --------------------------------------------------------------------------
  288 
  289 # icons come in two flavors: GIF and PNG. They go into a icons directory
  290 # in SHLIBDIR (for the -local_icons option) and - if set - to ICONSTORAGE.
  291 # The icons are installed corresponding to the supported image formats.
  292 # If there is no image format supported, GIF icons are copied.
  293 
  294 my @icon_types = $cfg{'IMAGE_TYPES'} ? 
  295   split(/\s+/,$cfg{'IMAGE_TYPES'}) : qw(gif);
  296 my $iconrx = join('|', @icon_types);
  297 
  298 my $dest1 = "$cfg{'SHLIBDIR'}${dd}icons";
  299 if((-d $dest1 && !-w _) || (-d $cfg{'SHLIBDIR'} && !-w _)) {
  300   print STDERR "Error: Cannot install icons in '$dest1': No write permission.\n";
  301   $dest1 = '';
  302 }
  303 my $dest2 = $cfg{'ICONSTORAGE'} || '';
  304 if(-d $dest2 && !-w $dest2) {
  305   print STDERR "Error: Cannot install icons in '$dest2': No write permission.\n";
  306   $dest2 = '';
  307 }
  308 my $dir = "icons";
  309 unless(opendir(DIR,$dir)) {
  310   print STDERR qq{Error: Could not read directory "$dir": $!\n};
  311 } else {
  312   my $icon;
  313   while(defined($icon = readdir(DIR))) {
  314     next unless($icon =~ /\.($iconrx|html)$/oi);
  315     my $full = "$dir/$icon";
  316     next if($icon =~ /^\.{1,2}$/ || !-f $full || !-s _);
  317     &install_file($full,$dest1,$FILECHMOD,0) if($dest1);
  318     &install_file($full,$dest2,$FILECHMOD,0) if($dest2);
  319   }
  320   closedir(DIR);
  321 }
  322 
  323 # --------------------------------------------------------------------------
  324 # Go!
  325 # --------------------------------------------------------------------------
  326 
  327 my $item;
  328 foreach $item (sort keys %Install_items) {
  329 
  330   # Special case: pstoimg
  331   if($item =~ /pstoimg/ && !$cfg{'have_pstoimg'}) {
  332     print qq{Warning: pstoimg not installed, because build failed.\n};
  333     next;
  334   }
  335 
  336   my $from = '.';
  337   if($Install_items{$item} =~ /(?:^|,)from=([^,]+)(?:,|$)/) {
  338     $from = $1;
  339   }
  340 
  341   my $dest = '';
  342   my $chmod = $FILECHMOD;
  343   if($Install_items{$item} =~ /(^|,)bin(,|$)/) {
  344     $dest = $cfg{'BINDIR'};
  345     $chmod = $BINCHMOD;
  346   }
  347   elsif($Install_items{$item} =~ /(^|,)lib(,|$)/) {
  348     $dest = $cfg{'SHLIBDIR'};
  349   }
  350   elsif($Install_items{$item} =~ /(^|,)plat(,|$)/) {
  351     $dest = $cfg{'LIBDIR'};
  352   }
  353   if($Install_items{$item} =~ /(?:^|,)to=([^,]*)(?:,|$)/) {
  354     $dest = $1;
  355   }
  356   
  357   unless($dest) {
  358     die qq{Error: No destination for item "$item"\n};
  359   }
  360   if($Install_items{$item} =~ /(?:^|,)chmod=(\d+)(,|$)/) {
  361     $chmod = $1;
  362   }
  363   if($Install_items{$item} =~ /recurse/) {
  364     &install_recurse($item,$dest,$chmod);
  365   }
  366   else {
  367     &install_file("$from/$item",$dest,$chmod);
  368   }
  369 }
  370 
  371 #-----------------------------------------------------------------------------
  372 # try to install LaTeX2HTML style files
  373 #-----------------------------------------------------------------------------
  374 
  375 if($cfg{TEXPATH}) {
  376     print "\nNote: trying to install LaTeX2HTML style files in TeX directory tree\n     ($cfg{TEXPATH})\n";
  377     my $dir = 'texinputs';
  378     my $dest = $cfg{TEXPATH};
  379     unless(opendir(DIR,$dir)) {
  380       print STDERR qq{Error: Could not read directory "$dir": $!\n};
  381     } else {
  382       my $file;
  383       my $ok = 1;
  384       while(defined($file = readdir(DIR))) {
  385         my $full = "$dir/$file";
  386         next if($file =~ /^\.\.?$/ || !-f $full || !-s _);
  387         unless(&install_file($full,$cfg{TEXPATH},$FILECHMOD,0)) {
  388           $ok = 0;
  389           last;
  390         }
  391       }
  392       closedir(DIR);
  393       if($ok && $cfg{MKTEXLSR}) {
  394         print "Info: Running $cfg{MKTEXLSR} to rebuild ls-R database...\n";
  395         system($cfg{MKTEXLSR});
  396       }
  397     }
  398 }
  399 print "Done. Have a lot of fun with LaTeX2HTML!\n";
  400 exit 0;
  401 
  402 sub install_file {
  403   my ($src,$dest,$chmod) = @_;
  404 
  405   # prepend the value of DESTDIR, for package-managers
  406   $dest = $ENV{'DESTDIR'}.$dest if($ENV{'DESTDIR'});
  407   my $mkdir = $dest;
  408 
  409   my $file = $src;
  410   $file =~ s:^.*/::;
  411   my $full = "$dest$dd$file";
  412 
  413   $src  =~ s:/:$dd:g; # insert correct dir delimiter
  414 
  415   &mkpath($mkdir) || return 0;
  416   L2hos->Unlink($full); # avoid overwriting the target of symlinks
  417   unless(L2hos->Copy($src,$full)) {
  418     return 0;
  419   } elsif($chmod) {
  420     unless(chmod($chmod,$full)) {
  421       print STDERR qq{Warning: chmod of "$full" failed: $!\n};
  422       return 0;
  423     }
  424   }
  425   print "Info: Installed $full\n";
  426   1;
  427 }
  428 
  429 sub install_recurse {
  430   my ($dir,$dest,$chmod) = @_;
  431 
  432   my $reldir = $dir;
  433   $reldir =~ s:^.*/::;
  434 
  435   unless(opendir(DIR,$dir)) {
  436     print STDERR qq{Error: Could not read directory "$dir": $!\n};
  437     return 0;
  438   }
  439   my @subdirs = ();
  440   my $item;
  441   while(defined($item = readdir(DIR))) {
  442     next if($item =~ /^(\.{1,2}|CVS)$/);
  443     my $full = "$dir/$item";
  444     if(-d $full) {
  445       push(@subdirs,$full);
  446     } elsif(-s _) {
  447       &install_file($full,"$dest$dd$reldir",$chmod);
  448     } else {
  449       print "Warning: Skipping $full\n";
  450     }
  451   }
  452   closedir(DIR);
  453   foreach(@subdirs) {
  454     &install_recurse($_,"$dest$dd$reldir",$chmod);
  455   }
  456   1;
  457 }
  458 
  459 sub mkpath {
  460   my ($dir) = @_;
  461 
  462   unless(-d $dir) {
  463     if($dir =~ m#^(.*)[$dd$dd]([^$dd$dd]+)$#o) {
  464       my $parent = $1;
  465       $parent .= $dd unless($parent =~ /[$dd$dd]/o);
  466       &mkpath($parent) || return 0; # error
  467       unless(mkdir($dir,$DIRCHMOD)) {
  468         print STDERR qq{Error: Could not create directory "$dir": $!\n};
  469         return 0;
  470       }
  471     } else {
  472       print STDERR qq{Error: Cannot split directory "$dir"\n};
  473       return 0;
  474     }
  475   }
  476   1;
  477 }
  478