~ubuntu-branches/ubuntu/raring/texlive-extra/raring

« back to all changes in this revision

Viewing changes to tlpkg/TeXLive/TLUtils.pm

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2012-05-16 08:22:07 UTC
  • mfrom: (1.1.12) (3.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20120516082207-41ox35jj1qsu46a7
Tags: 2012.20120516-1
* new upstream snapshot based on TL2012 tlpretest
* switch to xz compression for orig and deb (Closes: #672428)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: TLUtils.pm 26100 2012-04-23 04:20:08Z preining $
 
1
# $Id: TLUtils.pm 26320 2012-05-13 03:53:19Z preining $
2
2
# TeXLive::TLUtils.pm - the inevitable utilities for TeX Live.
3
3
# Copyright 2007, 2008, 2009, 2010, 2011 Norbert Preining, Reinhard Kotucha
4
4
# This file is licensed under the GNU General Public License version 2
6
6
 
7
7
package TeXLive::TLUtils;
8
8
 
9
 
my $svnrev = '$Revision: 26100 $';
 
9
my $svnrev = '$Revision: 26320 $';
10
10
my $_modulerevision;
11
11
if ($svnrev =~ m/: ([0-9]+) /) {
12
12
  $_modulerevision = $1;
163
163
    &conv_to_w32_path
164
164
    &native_slashify
165
165
    &forward_slashify
166
 
    &conv_to_w32_path
167
166
    &untar
168
167
    &unpack
169
168
    &merge_into
2682
2681
}
2683
2682
 
2684
2683
sub create_updmap {
2685
 
  my ($tlpdb,$dest,$localconf) = @_;
2686
 
  my @tlpdblines = $tlpdb->updmap_cfg_lines(
2687
 
                             get_disabled_local_configs($localconf, '#'));
2688
 
  # we do not use _create_config_files here because we want to
2689
 
  # parse the $localconf file for the five options in updmap.cfg
2690
 
  #_create_config_files($tlpdb, "texmf/web2c/updmap-hdr.cfg", $dest,
2691
 
  #                     $localconf, 0, '#', \@tlpdblines);
2692
 
  my $headfile = "texmf/web2c/updmap-hdr.cfg";
2693
 
  my $root = $tlpdb->root;
2694
 
  my @lines;
2695
 
  my @localconflines;
2696
 
  my %configs;
2697
 
  if (-r "$localconf") {
2698
 
    #
2699
 
    # this should be done more intelligently, but for now only add those
2700
 
    # lines without any duplication check ...
2701
 
    open FOO, "<$localconf"
2702
 
      or die "strange, -r ok but cannot open $localconf: $!";
2703
 
    my @bla = <FOO>;
2704
 
    close(FOO);
2705
 
    for my $l (@bla) {
2706
 
      my ($k, $v, @rest) = split(' ', $l);
2707
 
      if (check_updmap_config_value($k, $v, $localconf)) {
2708
 
        $configs{$k} = $v;
2709
 
      } else {
2710
 
        push @localconflines, $l;
2711
 
      }
2712
 
    }
2713
 
  }
2714
 
  #
2715
 
  # read the -hdr file and replace the options if given in the local
2716
 
  # config file
2717
 
  open(INFILE,"<$root/$headfile") or die("Cannot open $root/$headfile");
2718
 
  for my $l (<INFILE>) {
2719
 
    my ($k, $v, @rest) = split(' ', $l);
2720
 
    if (check_updmap_config_value($k, $v, "$root/$headfile")) {
2721
 
      if (defined($configs{$k})) {
2722
 
        push @lines, "$k $configs{$k}\n";
2723
 
      } else {
2724
 
        push @lines, $l;
2725
 
      }
2726
 
    } else {
2727
 
      push @lines, $l;
2728
 
    }
2729
 
  }
2730
 
  close (INFILE);
2731
 
 
2732
 
  # add the lines from the tlpdb
2733
 
  push @lines, @tlpdblines;
2734
 
 
2735
 
  # add additional local config lines
2736
 
  push @lines, @localconflines;
2737
 
 
2738
 
  if ($#lines >= 0) {
2739
 
    open(OUTFILE,">$dest")
2740
 
      or die("Cannot open $dest for writing: $!");
2741
 
 
2742
 
    printf OUTFILE "# Generated by %s on %s\n", "$0", scalar localtime;
2743
 
    print OUTFILE @lines;
2744
 
    close(OUTFILE) || warn "close(>$dest) failed: $!";
2745
 
  }
 
2684
  my ($tlpdb,$dest) = @_;
 
2685
  my @tlpdblines = $tlpdb->updmap_cfg_lines();
 
2686
  _create_config_files($tlpdb, "texmf/web2c/updmap-hdr.cfg", $dest,
 
2687
                       undef, 0, '#', \@tlpdblines);
2746
2688
}
2747
2689
 
2748
2690
sub check_updmap_config_value {
2810
2752
  my @lines = <INFILE>;
2811
2753
  push @lines, @$tlpdblinesref;
2812
2754
  close (INFILE);
2813
 
  if (-r "$localconf") {
 
2755
  if (defined($localconf) && -r $localconf) {
2814
2756
    #
2815
2757
    # this should be done more intelligently, but for now only add those
2816
2758
    # lines without any duplication check ...