pkg/generate_font_metadata.pl
author henryzh <henry.zhao@oracle.com>
Tue, 24 Feb 2015 18:57:01 -0800
changeset 1510 ef06e61b3a1f
parent 1479 4a76cf532c2c
permissions -rwxr-xr-x
20441798 Fix parfait errors for dsession
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     1
#! /usr/perl5/bin/perl -w
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     2
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     3
#
1479
4a76cf532c2c 19978574 Need an automated, repeatable way to generate X's FOSS required source releases
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1288
diff changeset
     4
# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     5
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     6
# Permission is hereby granted, free of charge, to any person obtaining a
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     7
# copy of this software and associated documentation files (the "Software"),
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     8
# to deal in the Software without restriction, including without limitation
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     9
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    10
# and/or sell copies of the Software, and to permit persons to whom the
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    11
# Software is furnished to do so, subject to the following conditions:
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    12
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    13
# The above copyright notice and this permission notice (including the next
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    14
# paragraph) shall be included in all copies or substantial portions of the
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    15
# Software.
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    16
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    18
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    19
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    20
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    21
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    22
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    23
# DEALINGS IN THE SOFTWARE.
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    24
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    25
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    26
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    27
require 5.005;				# minimal Perl version required
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    28
use strict;				#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    29
use diagnostics;			#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    30
use integer;				#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    31
use File::Spec;				# pathname manipulation routines
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    32
use English qw( -nomatchvars );
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    33
use Getopt::Long;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    34
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    35
# Required arguments:
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    36
# -p <proto_area>
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    37
# -m <manifest>
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    38
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    39
my $proto_dir;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    40
my $manifest;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    41
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    42
my $result = GetOptions('p|protodir=s' => \$proto_dir,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    43
                        'm|manifest=s' => \$manifest);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    44
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    45
if (!defined($proto_dir)) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    46
  print STDERR "Missing required protodir argument\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    47
  exit(1);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    48
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    49
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    50
if (!defined($manifest)) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    51
  print STDERR "Missing required manifest argument\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    52
  exit(1);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    53
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    54
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    55
# Directories containing font files
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    56
my %fontdirs = ();
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    57
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    58
open my $MANIFEST, '<', $manifest
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    59
  or die "Cannot open manifest $manifest: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    60
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    61
while (my $man = <$MANIFEST>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    62
  if ($man =~ m{path=(\S+)/fonts.dir}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    63
    $fontdirs{$1} = $1;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    64
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    65
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    66
close $MANIFEST;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    67
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    68
foreach my $fd (keys %fontdirs) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    69
  my $protofontpath = join('/', $proto_dir, $fd);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    70
  my $protometafile = join('/', $proto_dir, $fd, 'fonts.dir');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    71
  my %xlfds = ();
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    72
1288
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
    73
  if (! -f $protometafile) {
1479
4a76cf532c2c 19978574 Need an automated, repeatable way to generate X's FOSS required source releases
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1288
diff changeset
    74
      # mkfontscale -b -s -l is equivalent to mkfontdir
4a76cf532c2c 19978574 Need an automated, repeatable way to generate X's FOSS required source releases
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1288
diff changeset
    75
      run_cmd("$proto_dir/usr/bin/mkfontscale", "-b", "-s", "-l",
4a76cf532c2c 19978574 Need an automated, repeatable way to generate X's FOSS required source releases
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1288
diff changeset
    76
	      $protofontpath);
1288
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
    77
  }
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
    78
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    79
  open my $XFILE, '<', $protometafile
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    80
    or die "Cannot open $protometafile: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    81
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    82
  while (my $x = <$XFILE>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    83
    chomp($x);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    84
    if ($x =~ m{\s+}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    85
      my ($fontfile, $fontxlfd) = split(/\s+/, $x, 2);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    86
      $xlfds{$fontxlfd} = $fontfile;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    87
      printf
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    88
	qq(<transform file path="$fd/%s" -> add info.file.font.xlfd "%s">\n),
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    89
	$fontfile, $fontxlfd;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    90
    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    91
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    92
  close $XFILE;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    93
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    94
  $protometafile = join('/', $proto_dir, $fd, 'fonts.alias');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    95
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    96
  if (-f $protometafile) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    97
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    98
    open my $XFILE, '<', $protometafile
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    99
      or die "Cannot open $protometafile: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   100
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   101
    while (my $x = <$XFILE>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   102
      chomp($x);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   103
      if ($x =~ m{\s+}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   104
	my ($fontalias, $fontxlfd) = split(/\s+/, $x, 2);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   105
	$fontxlfd =~ s{^"(.*)"$}{$1};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   106
	if (exists $xlfds{$fontxlfd}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   107
	  my $fontfile = $xlfds{$fontxlfd};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   108
	  printf
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   109
	    qq(<transform file path="$fd/%s" -> add info.file.font.xlfd "%s">\n),
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   110
	      $fontfile, $fontalias;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   111
	} else {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   112
#	  print STDERR qq(No match found for "$fontxlfd" in $protometafile\n);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   113
	}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   114
      }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   115
    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   116
    close $XFILE;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   117
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   118
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   119
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   120
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   121
# Run fc-scan from the proto area, since it wasn't delivered until build 141
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   122
my $fc_scan = "$proto_dir/usr/bin/fc-scan";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   123
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   124
# See FcPatternFormat(3) for the full definition of the format syntax
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   125
#  %{file} => print the named value for this font
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   126
#  %{fullname|cescape} => print the named value with C-style string escapes
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   127
#			  (adds \ in front of \ or " characters)
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   128
#  %{?fullname{..A..}{..B..}} => if fullname is defined, then print A, else B
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   129
#  []fullname,fullnamelang{..A..} => for each pair of fullname & fullnamelang,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   130
#					print A with those values substituted
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   131
my $fc_scan_format = q(--format=%{?fullname{%{[]fullname,fullnamelang{<transform file path="%{file}" -> add info.file.font.name:%{fullnamelang} "%{fullname|cescape}">\n}}}{%{[]family,style{<transform file path="%{file}" -> add info.file.font.name "%{family|cescape} %{style|cescape} %{pixelsize}">\n}}}});
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   132
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   133
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   134
chdir($proto_dir);
1288
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   135
run_cmd($fc_scan, $fc_scan_format, keys %fontdirs);
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   136
exit(0);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   137
1288
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   138
sub run_cmd {
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   139
    my $cmd = $_[0];
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   140
    system(@_);
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   141
    if ($? == -1) {
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   142
	print STDERR "failed to execute $cmd: $!\n";
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   143
    }
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   144
    elsif ($? & 127) {
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   145
	printf STDERR "$cmd died with signal %d, %s coredump\n",
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   146
	($? & 127),  ($? & 128) ? 'with' : 'without';
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   147
    }
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   148
    elsif ($? != 0) {
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   149
	my $exit_code = $? >> 8;
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   150
	if ($exit_code != 1) {
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   151
	    printf STDERR "$cmd exited with value %d\n", $exit_code;
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   152
	    exit($exit_code);
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   153
	}
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   154
    }
cbb688257dda 7170130 X gate builds sometimes lose mkfontdir races
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   155
}