7170130 X gate builds sometimes lose mkfontdir races s11u1_17
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Fri, 18 May 2012 15:15:58 -0700
changeset 1288 cbb688257dda
parent 1287 23c6db466a10
child 1289 8005aaf41ee9
7170130 X gate builds sometimes lose mkfontdir races
open-src/font/Makefile.inc
open-src/font/sun-aliases/Makefile
pkg/generate_font_metadata.pl
--- a/open-src/font/Makefile.inc	Fri May 18 15:15:13 2012 -0700
+++ b/open-src/font/Makefile.inc	Fri May 18 15:15:58 2012 -0700
@@ -1,6 +1,6 @@
 # -*- Makefile -*- rules common to most X.Org font modules
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -59,6 +59,11 @@
 # Disable compression of pcf fonts
 MODTYPE_CONFIG_OPTS += --without-compression
 
+# Avoid races between modules that install to the same directory by not 
+# running mkfontdir at build time, but waiting for later (either in the
+# sun-aliases module or during packaging in generate_font_metadata.pl).
+MODTYPE_CONFIG_OPTS += MKFONTDIR=/usr/bin/true
+
 # Most font modules have nothing to build, for those that do, use lib flags
 MODTYPE_CFLAGS=$(LIB_CFLAGS)
 MODTYPE_LDFLAGS=$(LIB_LDFLAGS)
--- a/open-src/font/sun-aliases/Makefile	Fri May 18 15:15:13 2012 -0700
+++ b/open-src/font/sun-aliases/Makefile	Fri May 18 15:15:58 2012 -0700
@@ -1,6 +1,6 @@
 ###############################################################################
 #
-# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -68,14 +68,15 @@
 
 install_aliases: $(ALIAS_FILES)
 
-$(INSTDIR)/%-ISO8859-1/fonts.alias.all: $(INSTDIR)/%/fonts.alias.all
+$(ALIAS_DIRS:%=$(INSTDIR)/%):
+	mkdir -p $@
+
+$(INSTDIR)/%-ISO8859-1/fonts.alias.all: $(INSTDIR)/%/fonts.alias.all $(INSTDIR)/%-ISO8859-1
 	-rm -f $@
-	mkdir -p $(@D)
 	cp -pf $< $@
 
-$(INSTDIR)/%/fonts.alias.all: fonts.alias.%
+$(INSTDIR)/%/fonts.alias.all: fonts.alias.% $(INSTDIR)/%
 	-rm -f $@
-	mkdir -p $(@:fonts.alias.all=)
 	@if [[ -f $(@:.all=) ]] ; then \
 		$(START_CMD_ECHO) ; \
 		cat $(@:.all=) > $@ ; \
@@ -83,14 +84,11 @@
 	cat $< >> $@
 
 $(INSTDIR)/%/fonts.alias: $(INSTDIR)/%/fonts.alias.all $(INSTDIR)/%/fonts.dir
-	(cd $(@:fonts.alias=) ; \
+	(cd $(@D) ; \
 	 LD_LIBRARY_PATH="$(FONT_LIBS_PATH)" $(INSTALLALIAS) fonts.alias.all .)
 
-# Needed when installing to alternate protodir, such as when
-# generating pkg manifests
-$(INSTDIR)/%/fonts.dir:
-	print '0' > [email protected]
-	ln [email protected] $@ ; rm [email protected]
+$(INSTDIR)/%/fonts.dir: $(INSTDIR)/%
+	$(MKFONTDIR) $(@D)
 
 manifest_%: 
 	$(MAKE) $(MAKEFLAGS) manifest-per-type \
--- a/pkg/generate_font_metadata.pl	Fri May 18 15:15:13 2012 -0700
+++ b/pkg/generate_font_metadata.pl	Fri May 18 15:15:58 2012 -0700
@@ -1,7 +1,7 @@
 #! /usr/perl5/bin/perl -w
 
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -70,6 +70,10 @@
   my $protometafile = join('/', $proto_dir, $fd, 'fonts.dir');
   my %xlfds = ();
 
+  if (! -f $protometafile) {
+      run_cmd("$proto_dir/usr/bin/mkfontdir", $protofontpath);
+  }
+
   open my $XFILE, '<', $protometafile
     or die "Cannot open $protometafile: $!\n";
 
@@ -126,21 +130,24 @@
 
 
 chdir($proto_dir);
-system($fc_scan, $fc_scan_format, keys %fontdirs);
-if ($? == -1) {
-  print STDERR "failed to execute $fc_scan: $!\n";
-}
-elsif ($? & 127) {
-  printf STDERR "$fc_scan died with signal %d, %s coredump\n",
-    ($? & 127),  ($? & 128) ? 'with' : 'without';
-}
-elsif ($? != 0) {
-  my $exit_code = $? >> 8;
-  if ($exit_code != 1) {
-    printf STDERR "$fc_scan exited with value %d\n", $exit_code;
-    exit($exit_code);
-  }
-}
-
+run_cmd($fc_scan, $fc_scan_format, keys %fontdirs);
 exit(0);
 
+sub run_cmd {
+    my $cmd = $_[0];
+    system(@_);
+    if ($? == -1) {
+	print STDERR "failed to execute $cmd: $!\n";
+    }
+    elsif ($? & 127) {
+	printf STDERR "$cmd died with signal %d, %s coredump\n",
+	($? & 127),  ($? & 128) ? 'with' : 'without';
+    }
+    elsif ($? != 0) {
+	my $exit_code = $? >> 8;
+	if ($exit_code != 1) {
+	    printf STDERR "$cmd exited with value %d\n", $exit_code;
+	    exit($exit_code);
+	}
+    }
+}