From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / OSX / update-info-plist.pl
index c5233ae7a370afe3e3cee024a6b636f5f15a6c47..06624e9435bce831eb76da2a79ef8becde222b0f 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright © 2006-2013 Jamie Zawinski <jwz@jwz.org>
+# Copyright © 2006-2014 Jamie Zawinski <jwz@jwz.org>
 #
 # Permission to use, copy, modify, distribute, and sell this software and its
 # documentation for any purpose is hereby granted without fee, provided that
@@ -27,7 +27,7 @@ use IO::Compress::Gzip qw(gzip $GzipError);
 
 my ($exec_dir, $progname) = ($0 =~ m@^(.*?)/([^/]+)$@);
 
-my $version = q{ $Revision: 1.26 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/;
+my ($version) = ('$Revision: 1.35 $' =~ m/\s(\d[.\d]+)\s/s);
 
 $ENV{PATH} = "/usr/local/bin:$ENV{PATH}";   # for seticon
 
@@ -85,6 +85,7 @@ sub read_saver_xml($) {
 
   return () if ($name eq 'XScreenSaver');
   return () if ($name eq 'SaverTester');
+  return () if ($name eq 'XScreenSaverUpdater');
 
   my $file  = "$app_dir/Contents/Resources/" . lc($name) . ".xml";
   my $file2 = "$app_dir/" . lc($name) . ".xml";
@@ -178,7 +179,7 @@ sub update_saver_xml($$) {
                "\n" . 
                "From the XScreenSaver collection: " .
                "http://www.jwz.org/xscreensaver/\n" .
-               "Copyright \251 $year by $authors.\n");
+               "Copyright \302\251 $year by $authors.\n");
 
   my $desc2 = ("$name $vers,\n" .                      # Info.plist
                "\302\251 $year $authors.\n" .
@@ -197,6 +198,10 @@ sub update_saver_xml($$) {
 
   $body =~ s@(<_description>)(.*?)(</_description>)@$1$desc1$3@s;
 
+  # NSXMLParser doesn't seem to work properly on Latin1 XML documents,
+  # so we convert these to UTF8 when embedding them in the .saver bundle.
+  $body =~ s@encoding="ISO-8859-1"@encoding="UTF-8"@gsi;
+
   if ($obody eq $body && $was_compressed_p) {
     print STDERR "$progname: $filename: unchanged\n" if ($verbose > 1);
   } else {
@@ -309,6 +314,53 @@ sub set_thumb($) {
 }
 
 
+sub enable_gc($) {
+  my ($app_dir) = @_;
+
+  return unless ($app_dir =~ m@\.saver/?$@s);
+  my ($dir, $name) = ($app_dir =~ m@^(.*)/([^/]+)\.saver$@s);
+  error ("unparsable: $app_dir") unless $name;
+  my $exe = "$app_dir/Contents/MacOS/$name";
+  my @cmd = ("$dir/enable_gc", $exe);
+  print STDERR "$progname: exec: " . join(' ', @cmd) . "\n"
+    if ($verbose > 1);
+  system (@cmd);
+  my $exit  = $? >> 8;
+  exit ($exit) if $exit;
+}
+
+
+sub fix_coretext($) {
+  my ($app_dir) = @_;
+
+  # In MacOS 10.8, they moved CoreText.framework from
+  # /System/Library/Frameworks/ApplicationServices.framework/Frameworks/
+  # to /System/Library/Frameworks/ which means that executables compiled
+  # on 10.8 and newer won't run on 10.7 and older because they can't find
+  # the library. Fortunately, 10.8 and later leave a symlink behind, so
+  # the old location still works. So we need our executables to contain
+  # an LC_LOAD_DYLIB pointing at the old directory instead of the new
+  # one.
+  # 
+  return if ($app_dir =~ m@-iphone@s);
+  my ($dir, $name) = ($app_dir =~ m@^(.*)/([^/]+)\.(app|saver)$@s);
+  error ("unparsable: $app_dir") unless $name;
+  my $exe = "$app_dir/Contents/MacOS/$name";
+
+  my $new = ("/System/Library/Frameworks/CoreText.framework/" .
+             "Versions/A/CoreText");
+  my $old = ("/System/Library/Frameworks/ApplicationServices.framework/" .
+             "Frameworks/CoreText.framework/Versions/A/CoreText");
+  my @cmd = ("install_name_tool", "-change", $new, $old, $exe);
+
+  print STDERR "$progname: exec: " . join(' ', @cmd) . "\n"
+    if ($verbose > 1);
+  system (@cmd);
+  my $exit  = $? >> 8;
+  exit ($exit) if $exit;
+}
+
+
 sub update($) {
   my ($app_dir) = @_;
 
@@ -370,6 +422,8 @@ sub update($) {
 
   set_icon ($app_dir);
   set_thumb ($app_dir);
+# enable_gc ($app_dir);
+  fix_coretext ($app_dir)
 }