# HG changeset patch # User Andrew John Hughes # Date 1275494341 -3600 # Node ID c3605faebe9260cdca309a3b8a2da70e53d831f1 # Parent 54c929c868e421e11fb9575d1e02dfb78f5e55ee Backport tzdata support from 1.8 (--with-tzdata-dir). 2009-12-22 Andrew John Hughes Backport --with-tzdata-dir option from IcedTea6. * Makefile.am: (icedtea.stamp): Copy tz.properties when TZDATA_DIR is specified. (icedtea-debug.stamp): Likewise. Add missing -debug suffix. * acinclude.m4: (CHECK_WITH_TZDATA_DIR): Allow a directory containing timezone data to be specified. Defaults to /usr/share/javazi. * configure.ac: Call CHECK_WITH_TZDATA_DIR. * patches/icedtea-use-system-tzdata.patch: New version which uses configurable datadir. As in IcedTea7. * patches/security/icedtea-6824265.patch: Revert to original version from Sun. * tz.properties.in: Input file for tzdata directory setting. diff -r 54c929c868e4 -r c3605faebe92 ChangeLog --- a/ChangeLog Wed Apr 28 23:04:32 2010 +0100 +++ b/ChangeLog Wed Jun 02 16:59:01 2010 +0100 @@ -1,3 +1,23 @@ +2009-12-22 Andrew John Hughes + + Backport --with-tzdata-dir option from IcedTea6. + * Makefile.am: + (icedtea.stamp): Copy tz.properties when TZDATA_DIR + is specified. + (icedtea-debug.stamp): Likewise. Add missing -debug + suffix. + * acinclude.m4: + (CHECK_WITH_TZDATA_DIR): Allow a directory containing timezone + data to be specified. Defaults to /usr/share/javazi. + * configure.ac: Call CHECK_WITH_TZDATA_DIR. + * patches/icedtea-use-system-tzdata.patch: + New version which uses configurable datadir. + As in IcedTea7. + * patches/security/icedtea-6824265.patch: + Revert to original version from Sun. + * tz.properties.in: + Input file for tzdata directory setting. + 2010-04-28 Andrew John Hughes PR icedtea/476 diff -r 54c929c868e4 -r c3605faebe92 Makefile.am --- a/Makefile.am Wed Apr 28 23:04:32 2010 +0100 +++ b/Makefile.am Wed Jun 02 16:59:01 2010 +0100 @@ -560,7 +560,6 @@ patches/icedtea-timezone.patch \ patches/icedtea-timezone-default-permission.patch \ patches/icedtea-simpletimezone-relax.patch \ - patches/icedtea-use-system-tzdata.patch \ patches/icedtea-headers.patch \ patches/hotspot/$(HSBUILD)/icedtea-headers.patch \ patches/icedtea-ant.patch \ @@ -668,7 +667,8 @@ patches/icedtea-format-warnings.patch \ patches/icedtea-fortify-source.patch \ patches/hotspot/$(HSBUILD)/icedtea-6791168.patch \ - patches/hotspot/$(HSBUILD)/icedtea-includedb.patch + patches/hotspot/$(HSBUILD)/icedtea-includedb.patch \ + patches/icedtea-use-system-tzdata.patch if WITH_ALT_HSBUILD ICEDTEA_PATCHES += \ @@ -1294,6 +1294,10 @@ cp $(abs_top_builddir)/nss.cfg \ $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/security; endif +if WITH_TZDATA_DIR + cp $(abs_top_builddir)/tz.properties \ + $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib; +endif @echo "IcedTea is served:" $(BUILD_OUTPUT_DIR) mkdir -p stamps touch stamps/icedtea.stamp @@ -1369,27 +1373,31 @@ printf -- '-cacao ALIASED_TO -server\n' >> $(BUILD_DEBUG_JRE_ARCH_DIR)/jvm.cfg endif if ENABLE_SYSTEMTAP - mkdir -p $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset ; \ + mkdir -p $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset ; \ grep "client IGNORE" $(BUILD_JRE_ARCH_DIR)/jvm.cfg; \ if test $$? -eq 0; then \ sed -e '/\/client\/libjvm.so/d' \ < $(abs_top_builddir)/tapset/hotspot.stp \ - > $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset/hotspot.stp; \ + > $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset/hotspot.stp; \ sed -e '/\/client\/libjvm.so/d' \ < $(abs_top_builddir)/tapset/hotspot_jni.stp \ - > $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset/hotspot_jni.stp; \ + > $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset/hotspot_jni.stp; \ else \ cp $(abs_top_builddir)/tapset/hotspot.stp \ - $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset/hotspot.stp; \ + $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset/hotspot.stp; \ cp $(abs_top_builddir)/tapset/hotspot_jni.stp \ - $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset/hotspot_jni.stp; \ + $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset/hotspot_jni.stp; \ fi; \ cp $(abs_top_builddir)/tapset/jstack.stp \ - $(BUILD_OUTPUT_DIR)/j2sdk-image/tapset/jstack.stp + $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/tapset/jstack.stp endif if ENABLE_NSS cp $(abs_top_builddir)/nss.cfg \ - $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/security; + $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/jre/lib/security; +endif +if WITH_TZDATA_DIR + cp $(abs_top_builddir)/tz.properties \ + $(BUILD_OUTPUT_DIR)-debug/j2sdk-image/jre/lib; endif @echo "IcedTea (debug build) is served:" \ $(BUILD_OUTPUT_DIR)-debug diff -r 54c929c868e4 -r c3605faebe92 acinclude.m4 --- a/acinclude.m4 Wed Apr 28 23:04:32 2010 +0100 +++ b/acinclude.m4 Wed Jun 02 16:59:01 2010 +0100 @@ -1039,3 +1039,33 @@ AC_SUBST(with_openjdk) ]) +AC_DEFUN([AC_CHECK_WITH_TZDATA_DIR], +[ + DEFAULT="/usr/share/javazi" + AC_MSG_CHECKING([which Java timezone data directory to use]) + AC_ARG_WITH([tzdata-dir], + [AS_HELP_STRING(--with-tzdata-dir,set the Java timezone data directory [[default=${DEFAULT}]])], + [ + if test "x${withval}" = x || test "x${withval}" = xyes; then + TZDATA_DIR_SET=yes + TZDATA_DIR="${DEFAULT}" + else + if test "x${withval}" = xno; then + TZDATA_DIR_SET=no + AC_MSG_RESULT([no]) + else + TZDATA_DIR_SET=yes + TZDATA_DIR="${withval}" + fi + fi + ], + [ + TZDATA_DIR="${DEFAULT}" + ]) + if test "x${TZDATA_DIR}" != "x"; then + AC_MSG_RESULT([${TZDATA_DIR}]) + fi + AC_SUBST([TZDATA_DIR]) + AM_CONDITIONAL(WITH_TZDATA_DIR, test "x${TZDATA_DIR}" != "x") + AC_CONFIG_FILES([tz.properties]) +]) diff -r 54c929c868e4 -r c3605faebe92 configure.ac --- a/configure.ac Wed Apr 28 23:04:32 2010 +0100 +++ b/configure.ac Wed Jun 02 16:59:01 2010 +0100 @@ -248,6 +248,7 @@ ENABLE_ZERO_BUILD ENABLE_HG AC_CHECK_WITH_HG_REVISION +AC_CHECK_WITH_TZDATA_DIR if test "x${enable_visualvm}" = "xyes" then diff -r 54c929c868e4 -r c3605faebe92 patches/icedtea-use-system-tzdata.patch --- a/patches/icedtea-use-system-tzdata.patch Wed Apr 28 23:04:32 2010 +0100 +++ b/patches/icedtea-use-system-tzdata.patch Wed Jun 02 16:59:01 2010 +0100 @@ -1,67 +1,99 @@ ---- openjdk6.orig/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Sat Mar 15 13:43:05 2008 -0400 -+++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Fri Aug 21 11:34:56 2009 +0200 -@@ -465,6 +465,27 @@ - */ - public static final byte TAG_TZDataVersion = 68; +# HG changeset patch +# User andrew +# Date 1257348405 0 +# Node ID d03acee39d3b283dbfe972ce9398ea1ce9cdd3fc +# Parent 922421b1938a44633d22fd2a5a1e376a99bb9090 +6593486: (tz) RFE: support user-defined directory path to time zone data files +Summary: Allow the timezone data directory to be changed by setting sun.timezone.dir + +diff -r 922421b1938a -r d03acee39d3b src/share/classes/sun/util/calendar/ZoneInfoFile.java +--- openjdk.orig/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Wed Nov 04 12:22:35 2009 +0000 ++++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Wed Nov 04 15:26:45 2009 +0000 +@@ -25,10 +25,12 @@ + + package sun.util.calendar; -+ // Cached location of the TZDATA files -+ private static final String JAVAZI_DIR = setup_JAVAZI_DIR(); ++import java.io.BufferedInputStream; + import java.io.File; + import java.io.FileInputStream; + import java.io.FileNotFoundException; + import java.io.IOException; ++import java.io.InputStream; + import java.lang.ref.SoftReference; + import java.security.AccessController; + import java.security.PrivilegedAction; +@@ -38,6 +40,7 @@ + import java.util.HashMap; + import java.util.List; + import java.util.Map; ++import java.util.Properties; + + /** + * ZoneInfoFile reads Zone information files in the +@@ -473,17 +476,52 @@ + private static Map zoneInfoObjects = null; + + private static final String ziDir; + -+ private static String setup_JAVAZI_DIR() { -+ try { -+ final String dir = AccessController.doPrivileged -+ (new sun.security.action.GetPropertyAction("user.zoneinfo.dir")); + static { +- String zi = (String) AccessController.doPrivileged( +- new sun.security.action.GetPropertyAction("java.home")) +- + File.separator + "lib" + File.separator + "zi"; ++ final String homeDir = ++ AccessController.doPrivileged( ++ new sun.security.action.GetPropertyAction("java.home")); ++ if (homeDir == null) { ++ throw new Error("java.home is not set"); ++ } ++ String zi = homeDir + File.separator + "lib" + ++ File.separator + "zi"; + try { ++ String otherDir = getZoneInfoDir(homeDir); ++ if (otherDir != null) ++ zi = otherDir; + zi = new File(zi).getCanonicalPath(); + } catch (Exception e) { + } + ziDir = zi; + } + ++ private static String getZoneInfoDir(final String homeDir) { ++ try { + return AccessController.doPrivileged -+ (new PrivilegedExceptionAction() { -+ public String run() { -+ File f = new File(dir, "ZoneInfoMappings"); -+ if (f.exists()) -+ return dir; -+ return null; -+ } -+ }); ++ (new PrivilegedExceptionAction() { ++ public String run() throws IOException { ++ File f = new File(homeDir + File.separator + "lib" + ++ File.separator + "tz.properties"); ++ InputStream in = new FileInputStream(f); ++ BufferedInputStream bin = new BufferedInputStream(in); ++ Properties props = new Properties(); ++ props.load(bin); ++ bin.close(); ++ String dir = props.getProperty("sun.zoneinfo.dir"); ++ if (dir == null) ++ return null; ++ File zim = new File(dir, "ZoneInfoMappings"); ++ if (zim.exists()) ++ return dir; ++ return null; ++ } ++ }); + } catch (PrivilegedActionException e) { -+ return null; ++ return null; + } + } + /** - * Excluded zones item tag. (Added in Mustang) - */ -@@ -1021,11 +1042,17 @@ + * Converts the given time zone ID to a platform dependent path + * name. For example, "America/Los_Angeles" is converted to +@@ -1032,8 +1070,8 @@ byte[] buffer = null; try { -- String homeDir = AccessController.doPrivileged( -- new sun.security.action.GetPropertyAction("java.home")); -- final String fname = homeDir + File.separator + "lib" + File.separator -- + "zi" + File.separator + fileName; - buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { -+ -+ String zi_dir = JAVAZI_DIR; -+ if (zi_dir == null) { -+ // Fall back to JDK-supplied tzdata -+ String homeDir = (String) AccessController.doPrivileged(new sun.security.action.GetPropertyAction("java.home")); -+ zi_dir = homeDir + File.separator + "lib" + File.separator -+ + "zi"; -+ } -+ -+ final String fname = zi_dir + File.separator + fileName; -+ buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { - File file = new File(fname); - if (!file.canRead()) { ---- oldopenjdk6/hotspot/src/os/linux/vm/os_linux.cpp 2008-03-26 05:07:22.000000000 -0400 -+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp 2008-05-08 11:03:17.000000000 -0400 -@@ -376,6 +381,11 @@ - } - } - -+ SystemProperty* sp = Arguments::system_properties(); -+ // Use the system zoneinfo files, if present -+ Arguments::PropertyList_add (&sp, -+ "user.zoneinfo.dir", "/usr/share/javazi"); -+ - #undef malloc - #undef getenv - #undef EXTENSIONS_DIR +- public Object run() throws IOException { ++ buffer = AccessController.doPrivileged(new PrivilegedExceptionAction() { ++ public byte[] run() throws IOException { + File file = new File(ziDir, fileName); + if (!file.exists() || !file.isFile()) { + return null; diff -r 54c929c868e4 -r c3605faebe92 patches/security/icedtea-6824265.patch --- a/patches/security/icedtea-6824265.patch Wed Apr 28 23:04:32 2010 +0100 +++ b/patches/security/icedtea-6824265.patch Wed Jun 02 16:59:01 2010 +0100 @@ -1,6 +1,6 @@ diff -Nru openjdk.orig/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java ---- openjdk.orig/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2009-11-08 23:11:42.000000000 +0000 -+++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2009-11-08 23:25:32.000000000 +0000 +--- openjdk.orig/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2009-04-24 08:34:26.000000000 +0100 ++++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2010-06-02 16:28:32.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. @@ -8,30 +8,15 @@ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it -@@ -465,10 +465,7 @@ - */ - public static final byte TAG_TZDataVersion = 68; - -- // Cached location of the TZDATA files -- private static final String JAVAZI_DIR = setup_JAVAZI_DIR(); -- -- private static String setup_JAVAZI_DIR() { -+ private static String setupJavaZIDir() { - try { - final String dir = AccessController.doPrivileged - (new sun.security.action.GetPropertyAction("user.zoneinfo.dir")); -@@ -493,6 +490,21 @@ +@@ -472,6 +472,18 @@ private static Map zoneInfoObjects = null; + private static final String ziDir; + static { -+ String zi = setupJavaZIDir(); -+ if (zi == null) { -+ zi = AccessController.doPrivileged( ++ String zi = (String) AccessController.doPrivileged( + new sun.security.action.GetPropertyAction("java.home")) -+ + File.separator + "lib" + File.separator + "zi"; -+ } ++ + File.separator + "lib" + File.separator + "zi"; + try { + zi = new File(zi).getCanonicalPath(); + } catch (Exception e) { @@ -42,7 +27,7 @@ /** * Converts the given time zone ID to a platform dependent path * name. For example, "America/Los_Angeles" is converted to -@@ -597,20 +609,7 @@ +@@ -576,20 +588,7 @@ return null; } @@ -64,7 +49,7 @@ int filesize = buf.length; int rawOffset = 0; int dstSavings = 0; -@@ -621,6 +620,18 @@ +@@ -600,6 +599,18 @@ int[] simpleTimeZoneParams = null; try { @@ -83,7 +68,7 @@ while (index < filesize) { byte tag = buf[index++]; int len = ((buf[index++] & 0xFF) << 8) + (buf[index++] & 0xFF); -@@ -1038,36 +1049,34 @@ +@@ -1017,30 +1028,33 @@ * Reads the specified file under <java.home>/lib/zi into a buffer. * @return the buffer, or null if any I/O error occurred. */ @@ -92,18 +77,11 @@ byte[] buffer = null; try { - -- String zi_dir = JAVAZI_DIR; -- if (zi_dir == null) { -- // Fall back to JDK-supplied tzdata -- String homeDir = (String) AccessController.doPrivileged(new sun.security.action.GetPropertyAction("java.home")); -- zi_dir = homeDir + File.separator + "lib" + File.separator -- + "zi"; -- } -- -- final String fname = zi_dir + File.separator + fileName; -- buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { -+ buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { +- String homeDir = AccessController.doPrivileged( +- new sun.security.action.GetPropertyAction("java.home")); +- final String fname = homeDir + File.separator + "lib" + File.separator +- + "zi" + File.separator + fileName; + buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { - File file = new File(fname); - if (!file.canRead()) { diff -r 54c929c868e4 -r c3605faebe92 tz.properties.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tz.properties.in Wed Jun 02 16:59:01 2010 +0100 @@ -0,0 +1,1 @@ +sun.zoneinfo.dir=@TZDATA_DIR@