From 0bfcdf964147c3fd12cc6bbe88399babf777c2aa Mon Sep 17 00:00:00 2001 From: zhuhongbo Date: Mon, 2 Dec 2024 13:32:50 +0800 Subject: [PATCH] Fix Apr vs April-2024b and Improve style checks for months 2024b --- 0004-Fix-Apr-vs-April-2024b.patch | 17 ++++ ...mprove-style-checks-for-months-2024b.patch | 73 +++++++++++++++++ SimpleZoneTest.java | 26 ++++++ download | 4 +- javazic-harden-links.patch | 80 +++++++++++++++++++ tzdata.spec | 39 ++++++++- 6 files changed, 233 insertions(+), 6 deletions(-) create mode 100644 0004-Fix-Apr-vs-April-2024b.patch create mode 100644 0005-Improve-style-checks-for-months-2024b.patch create mode 100644 SimpleZoneTest.java create mode 100644 javazic-harden-links.patch diff --git a/0004-Fix-Apr-vs-April-2024b.patch b/0004-Fix-Apr-vs-April-2024b.patch new file mode 100644 index 0000000..892349e --- /dev/null +++ b/0004-Fix-Apr-vs-April-2024b.patch @@ -0,0 +1,17 @@ +commit 926b507fa5c3192b1b68fab5910cbd3ba9377c97 +From: zhuhongbo +Date: Tue, 19 Nov 2024 19:13:06 + +diff --git a/northamerica b/northamerica +index 01f392e0..1af874b6 100644 +--- a/northamerica ++++ b/northamerica +@@ -2631,7 +2631,7 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 + # http://puentelibre.mx/noticia/ciudad_juarez_cambio_horario_noviembre_2022/ + + # Rule NAME FROM TO - IN ON AT SAVE LETTER/S +-Rule Mexico 1931 only - April 30 0:00 1:00 D ++Rule Mexico 1931 only - Apr 30 0:00 1:00 D + Rule Mexico 1931 only - Oct 1 0:00 0 S + Rule Mexico 1939 only - Feb 5 0:00 1:00 D + Rule Mexico 1939 only - Jun 25 0:00 0 S diff --git a/0005-Improve-style-checks-for-months-2024b.patch b/0005-Improve-style-checks-for-months-2024b.patch new file mode 100644 index 0000000..b76274a --- /dev/null +++ b/0005-Improve-style-checks-for-months-2024b.patch @@ -0,0 +1,73 @@ +commit 7b6fb155cadd5e5ee70b55c2770e1bdd2f5d2a38 +From: zhuhongbo +Date: Tue, 19 Nov 2024 19:23:06 + +diff --git a/checktab.awk b/checktab.awk +index 9a26e465..15a3a697 100644 +--- a/checktab.awk ++++ b/checktab.awk +@@ -9,6 +9,19 @@ BEGIN { + if (!zone_table) zone_table = "zone1970.tab" + if (!want_warnings) want_warnings = -1 + ++ monthabbr["Jan"] = 1 ++ monthabbr["Feb"] = 1 ++ monthabbr["Mar"] = 1 ++ monthabbr["Apr"] = 1 ++ monthabbr["May"] = 1 ++ monthabbr["Jun"] = 1 ++ monthabbr["Jul"] = 1 ++ monthabbr["Aug"] = 1 ++ monthabbr["Sep"] = 1 ++ monthabbr["Oct"] = 1 ++ monthabbr["Nov"] = 1 ++ monthabbr["Dec"] = 1 ++ + while (getline >"/dev/stderr" ++ status = 1 ++ } + } else { ++ stdoff = $1 + ruleUsed[$2] = 1 + if ($3 ~ /%/) rulePercentUsed[$2] = 1 + } ++ ++ if (stdoff && stdoff !~ /^\-?1?[0-9](:[0-5][0-9](:[0-5][0-9])?)?$/) { ++ printf "%s:%d: unlikely STDOFF: %s\n", FILENAME, FNR, stdoff \ ++ >>"/dev/stderr" ++ status = 1 ++ } ++ + if (tz && tz ~ /\// && tz !~ /^Etc\//) { + if (!tztab[tz] && FILENAME != "backward" \ + && zone_table != "zonenow.tab") { diff --git a/SimpleZoneTest.java b/SimpleZoneTest.java new file mode 100644 index 0000000..7d6e8aa --- /dev/null +++ b/SimpleZoneTest.java @@ -0,0 +1,26 @@ +/* This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ + +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.Set; +import java.util.TimeZone; + +public class SimpleZoneTest { + public static void main(String[] args) { + // This is what failed in OpenJDK's build.tools.cldrconverter. + new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles"), + Locale.US).get(Calendar.YEAR); + } +} diff --git a/download b/download index b8eb984..1e643c9 100644 --- a/download +++ b/download @@ -1,4 +1,4 @@ cfc79fbbb17f21052d3dd7634ec70bea javazic-1.8-37392f2f5d59.tar.xz 6a3392cd5f1594d13c12c1a836ac8d91 javazic.tar.gz -2349edd8335245525cc082f2755d5bf4 tzdata2024a.tar.gz -1a9d670f0b418130503401b8b8f41769 tzcode2024a.tar.gz +e1d010b46844502f12dcff298c1b7154 tzdata2024b.tar.gz +aecb8ab771575b79183897cd591e2fd3 tzcode2024b.tar.gz diff --git a/javazic-harden-links.patch b/javazic-harden-links.patch new file mode 100644 index 0000000..7551488 --- /dev/null +++ b/javazic-harden-links.patch @@ -0,0 +1,80 @@ +commit 1bc13a1c10a580f84f1b7686c95344ec2633f611 +From: zhuhongbo +Date: Tue, 19 Nov 2024 20:33:56 + +diff -ur tzdata-2024b.orig/javazic-1.8/build/tools/tzdb/TzdbZoneRulesCompiler.java tzdata-2024b/javazic-1.8/build/tools/tzdb/TzdbZoneRulesCompiler.java +--- tzdata-2024b.orig/javazic-1.8/build/tools/tzdb/TzdbZoneRulesCompiler.java 2014-04-22 19:46:49.000000000 +0200 ++++ tzdata-2024b/javazic-1.8/build/tools/tzdb/TzdbZoneRulesCompiler.java 2024-09-20 21:10:12.748483767 +0200 +@@ -248,7 +248,7 @@ + // link version-region-rules + out.writeShort(builtZones.size()); + for (Map.Entry entry : builtZones.entrySet()) { +- int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); ++ int regionIndex = findRegionIndex(regionArray, entry.getKey()); + int rulesIndex = rulesList.indexOf(entry.getValue()); + out.writeShort(regionIndex); + out.writeShort(rulesIndex); +@@ -256,8 +256,8 @@ + // alias-region + out.writeShort(links.size()); + for (Map.Entry entry : links.entrySet()) { +- int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); +- int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); ++ int aliasIndex = findRegionIndex(regionArray, entry.getKey()); ++ int regionIndex = findRegionIndex(regionArray, entry.getValue()); + out.writeShort(aliasIndex); + out.writeShort(regionIndex); + } +@@ -269,6 +269,14 @@ + } + } + ++ private static int findRegionIndex(String[] regionArray, String region) { ++ int index = Arrays.binarySearch(regionArray, region); ++ if (index < 0) { ++ throw new IllegalArgumentException("Unknown region: " + region); ++ } ++ return index; ++ } ++ + private static final Pattern YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)"); + private static final Pattern MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)"); + private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); +@@ -607,22 +615,20 @@ + } + builtZones.put(aliasId, realRules); + } +- // remove UTC and GMT +- // builtZones.remove("UTC"); +- // builtZones.remove("GMT"); +- // builtZones.remove("GMT0"); +- builtZones.remove("GMT+0"); +- builtZones.remove("GMT-0"); +- links.remove("GMT+0"); +- links.remove("GMT-0"); +- // remove ROC, which is not supported in j.u.tz +- builtZones.remove("ROC"); +- links.remove("ROC"); +- // remove EST, HST and MST. They are supported via +- // the short-id mapping +- builtZones.remove("EST"); +- builtZones.remove("HST"); +- builtZones.remove("MST"); ++ ++ List zonesToRemove = Arrays.asList( ++ // remove UTC and GMT ++ "GMT+0", ++ "GMT-0", ++ // remove ROC, which is not supported in j.u.tz ++ "ROC", ++ // remove EST, HST and MST. They are supported via ++ // the short-id mapping ++ "EST", ++ "HST", ++ "MST"); ++ builtZones.keySet().removeAll(zonesToRemove); ++ links.keySet().removeAll(zonesToRemove); + } + + /** + diff --git a/tzdata.spec b/tzdata.spec index ad5c023..b492fcc 100644 --- a/tzdata.spec +++ b/tzdata.spec @@ -1,9 +1,9 @@ Summary: Timezone data Name: tzdata -Version: 2024a -%define tzdata_version 2024a -%define tzcode_version 2024a -Release: 1%{?dist} +Version: 2024b +%define tzdata_version 2024b +%define tzcode_version 2024b +Release: 2%{?dist} License: Public Domain Group: System Environment/Base URL: https://www.iana.org/time-zones @@ -12,10 +12,14 @@ Source1: ftp://ftp.iana.org/tz/releases/tzcode%{tzcode_version}.tar.gz Patch002: 0002-Fix-have-snprintf.patch Patch003: 0003-continue-to-ship-posixrules.patch +Patch004: 0004-Fix-Apr-vs-April-2024b.patch +Patch005: 0005-Improve-style-checks-for-months-2024b.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gawk, glibc, perl BuildRequires: glibc-common >= 2.5.90-7 +BuildRequires: gcc +BuildRequires: make BuildRequires: java-devel Conflicts: glibc-common <= 2.3.2-63 @@ -30,6 +34,7 @@ Summary: Timezone data for Java Group: System Environment/Base Source3: javazic.tar.gz Source4: http://omajid.fedorapeople.org/javazic-1.8-37392f2f5d59.tar.xz +Source5: SimpleZoneTest.java Patch100: javazic-fixup.patch Patch101: rebase-01.patch @@ -37,6 +42,7 @@ Patch102: rebase-02.patch Patch103: 7090844.patch Patch104: 7133138.patch Patch105: 8051641.patch +Patch106: javazic-harden-links.patch %description java This package contains timezone information for use by Java runtimes. @@ -46,6 +52,8 @@ This package contains timezone information for use by Java runtimes. %patch002 -p1 %patch003 -p1 +%patch004 -p1 +%patch005 -p1 # Currently tzdata is providing the "rearguard" data set for maximum # compatibility with existing Red Hat Enterprise Linux installs. Future releases of @@ -89,6 +97,7 @@ popd tar xf %{SOURCE4} %patch105 +%patch106 -p1 echo "%{name}%{tzdata_version}" >> VERSION @@ -133,6 +142,25 @@ cp -prd javazi $RPM_BUILD_ROOT%{_datadir}/javazi mkdir -p $RPM_BUILD_ROOT%{_datadir}/javazi-1.8 install -p -m 644 tzdb.dat $RPM_BUILD_ROOT%{_datadir}/javazi-1.8/ +%check +echo ============TESTING=============== +/usr/bin/env LANG=C make CC='gcc -std=gnu99' -k VALIDATE=':' check && true + +# Create a custom JAVA_HOME, where we can replace tzdb.dat with the +# one just built, for testing. +system_java_home=$(dirname $(readlink -f $(which java)))/.. +mkdir -p java_home +cp -Lr $system_java_home/* java_home/. +for tzdb in $(find java_home -name tzdb.dat) ; do + rm $tzdb + cp $RPM_BUILD_ROOT%{_datadir}/javazi-1.8/tzdb.dat $tzdb +done +# Compile the smoke test and run it. +cp %{SOURCE5} . +javac SimpleZoneTest.java +java_home/bin/java SimpleZoneTest +echo ============END TESTING=========== + %clean rm -rf $RPM_BUILD_ROOT @@ -150,6 +178,9 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/javazi-1.8 %changelog +* Tue Nov 19 2024 zhuhongbo - 2024b-2 +- Fix Apr vs April-2024b and Improve style checks for months 2024b + * Thu Feb 01 2024 Patsy Griffin - 2024a-1 - Rebase to tzdata-2024a - Kazakhstan will transition from UTC+6 to UTC+5 on 2024-03-01. -- Gitee